* [PATCH] mtd: mtdconcat: map through panic write handler
@ 2020-06-02 14:34 Matt Weber
2020-09-07 7:34 ` Miquel Raynal
0 siblings, 1 reply; 2+ messages in thread
From: Matt Weber @ 2020-06-02 14:34 UTC (permalink / raw)
To: linux-mtd; +Cc: Matt Weber
Allows a mtdconcat's subdevice->_panic_write to be used for
capturing a mtdoops dump.
Note: The ->_panic_write is mapped through from the first chip
that is part of the concat virtual device.
Signed-off-by: Matthew Weber <matthew.weber@rockwellcollins.com>
---
drivers/mtd/mtdconcat.c | 44 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 44 insertions(+)
diff --git a/drivers/mtd/mtdconcat.c b/drivers/mtd/mtdconcat.c
index cbc5925e6440..af99a5af601e 100644
--- a/drivers/mtd/mtdconcat.c
+++ b/drivers/mtd/mtdconcat.c
@@ -116,6 +116,48 @@ concat_read(struct mtd_info *mtd, loff_t from, size_t len,
return -EINVAL;
}
+static int
+concat_panic_write(struct mtd_info *mtd, loff_t to, size_t len,
+ size_t * retlen, const u_char * buf)
+{
+ struct mtd_concat *concat = CONCAT(mtd);
+ int err = -EINVAL;
+ int i;
+ for (i = 0; i < concat->num_subdev; i++) {
+ struct mtd_info *subdev = concat->subdev[i];
+ size_t size, retsize;
+
+ if (to >= subdev->size) {
+ size = 0;
+ to -= subdev->size;
+ continue;
+ }
+ if (to + len > subdev->size)
+ size = subdev->size - to;
+ else
+ size = len;
+
+ err = mtd_panic_write(subdev, to, size, &retsize, buf);
+ if (err == -EOPNOTSUPP) {
+ printk(KERN_ERR "mtdconcat: Cannot write from panic without panic_write\n");
+ return;
+ }
+ if (err)
+ break;
+
+ *retlen += retsize;
+ len -= size;
+ if (len == 0)
+ break;
+
+ err = -EINVAL;
+ buf += size;
+ to = 0;
+ }
+ return err;
+}
+
+
static int
concat_write(struct mtd_info *mtd, loff_t to, size_t len,
size_t * retlen, const u_char * buf)
@@ -660,6 +702,8 @@ struct mtd_info *mtd_concat_create(struct mtd_info *subdev[], /* subdevices to c
concat->mtd._block_isbad = concat_block_isbad;
if (subdev[0]->_block_markbad)
concat->mtd._block_markbad = concat_block_markbad;
+ if (subdev[0]->_panic_write)
+ concat->mtd._panic_write = concat_panic_write;
concat->mtd.ecc_stats.badblocks = subdev[0]->ecc_stats.badblocks;
--
2.17.1
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] mtd: mtdconcat: map through panic write handler
2020-06-02 14:34 [PATCH] mtd: mtdconcat: map through panic write handler Matt Weber
@ 2020-09-07 7:34 ` Miquel Raynal
0 siblings, 0 replies; 2+ messages in thread
From: Miquel Raynal @ 2020-09-07 7:34 UTC (permalink / raw)
To: Matt Weber, linux-mtd; +Cc: Miquel Raynal
On Tue, 2020-06-02 at 14:34:03 UTC, Matt Weber wrote:
> Allows a mtdconcat's subdevice->_panic_write to be used for
> capturing a mtdoops dump.
>
> Note: The ->_panic_write is mapped through from the first chip
> that is part of the concat virtual device.
>
> Signed-off-by: Matthew Weber <matthew.weber@rockwellcollins.com>
Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/next, thanks.
Miquel
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-09-07 7:35 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-02 14:34 [PATCH] mtd: mtdconcat: map through panic write handler Matt Weber
2020-09-07 7:34 ` Miquel Raynal
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).