Skip to content

Commit 7ae79d7

Browse files
dedekindDavid Woodhouse
authored andcommitted
mtd: introduce mtd_panic_write interface
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
1 parent eda95cb commit 7ae79d7

3 files changed

Lines changed: 19 additions & 14 deletions

File tree

‎drivers/mtd/mtdoops.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,8 @@ static void mtdoops_write(struct mtdoops_context *cxt, int panic)
222222
hdr[1] = MTDOOPS_KERNMSG_MAGIC;
223223

224224
if (panic)
225-
ret = mtd->panic_write(mtd, cxt->nextpage * record_size,
226-
record_size, &retlen, cxt->oops_buf);
225+
ret = mtd_panic_write(mtd, cxt->nextpage * record_size,
226+
record_size, &retlen, cxt->oops_buf);
227227
else
228228
ret = mtd_write(mtd, cxt->nextpage * record_size,
229229
record_size, &retlen, cxt->oops_buf);

‎drivers/mtd/mtdpart.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,8 @@ static int part_panic_write(struct mtd_info *mtd, loff_t to, size_t len,
201201
len = 0;
202202
else if (to + len > mtd->size)
203203
len = mtd->size - to;
204-
return part->master->panic_write(part->master, to + part->offset,
205-
len, retlen, buf);
204+
return mtd_panic_write(part->master, to + part->offset, len, retlen,
205+
buf);
206206
}
207207

208208
static int part_write_oob(struct mtd_info *mtd, loff_t to,

‎include/linux/mtd/mtd.h‎

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -186,23 +186,15 @@ struct mtd_info {
186186
size_t *retlen, u_char *buf);
187187
int (*write) (struct mtd_info *mtd, loff_t to, size_t len,
188188
size_t *retlen, const u_char *buf);
189+
int (*panic_write) (struct mtd_info *mtd, loff_t to, size_t len,
190+
size_t *retlen, const u_char *buf);
189191

190192
/* Backing device capabilities for this device
191193
* - provides mmap capabilities
192194
*/
193195
struct backing_dev_info *backing_dev_info;
194196

195197

196-
197-
/* In blackbox flight recorder like scenarios we want to make successful
198-
writes in interrupt context. panic_write() is only intended to be
199-
called when its known the kernel is about to panic and we need the
200-
write to succeed. Since the kernel is not going to be running for much
201-
longer, this function can break locks and delay to ensure the write
202-
succeeds (but not sleep). */
203-
204-
int (*panic_write) (struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf);
205-
206198
int (*read_oob) (struct mtd_info *mtd, loff_t from,
207199
struct mtd_oob_ops *ops);
208200
int (*write_oob) (struct mtd_info *mtd, loff_t to,
@@ -315,6 +307,19 @@ static inline int mtd_write(struct mtd_info *mtd, loff_t to, size_t len,
315307
return mtd->write(mtd, to, len, retlen, buf);
316308
}
317309

310+
/*
311+
* In blackbox flight recorder like scenarios we want to make successful writes
312+
* in interrupt context. panic_write() is only intended to be called when its
313+
* known the kernel is about to panic and we need the write to succeed. Since
314+
* the kernel is not going to be running for much longer, this function can
315+
* break locks and delay to ensure the write succeeds (but not sleep).
316+
*/
317+
static inline int mtd_panic_write(struct mtd_info *mtd, loff_t to, size_t len,
318+
size_t *retlen, const u_char *buf)
319+
{
320+
return mtd->panic_write(mtd, to, len, retlen, buf);
321+
}
322+
318323
static inline struct mtd_info *dev_to_mtd(struct device *dev)
319324
{
320325
return dev ? dev_get_drvdata(dev) : NULL;

0 commit comments

Comments
 (0)