[PATCH] MTD: otp support for mtd-concat devices

Christian Hohnstaedt
2006-06-12T16:16:39Z

Uses the otp region of the first sub-device as otp region
of the concat device.

Signed-off-by: Christian Hohnstaedt <chohnstaedt@innominate.com>

---

drivers/mtd/mtdconcat.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 59 insertions(+), 0 deletions(-)

e50d51beab818e66b62f602c2990d27770a04d13
diff --git a/drivers/mtd/mtdconcat.c b/drivers/mtd/mtdconcat.c
index 1fea631..4468039 100644
--- a/drivers/mtd/mtdconcat.c
+++ b/drivers/mtd/mtdconcat.c
@@ -676,6 +676,50 @@ static int concat_block_markbad(struct m
return err;
}

+#ifdef CONFIG_MTD_OTP
+static int concat_read_user_prot_reg (struct mtd_info *mtd, loff_t from,
+ size_t len, size_t *retlen, u_char *buf)
+{
+ mtd = CONCAT(mtd)->subdev[0];
+ return mtd->read_user_prot_reg (mtd, from, len, retlen, buf);
+}
+
+static int concat_get_user_prot_info (struct mtd_info *mtd,
+ struct otp_info *buf, size_t len)
+{
+ mtd = CONCAT(mtd)->subdev[0];
+ return mtd->get_user_prot_info (mtd, buf, len);
+}
+
+static int concat_read_fact_prot_reg (struct mtd_info *mtd, loff_t from,
+ size_t len, size_t *retlen, u_char *buf)
+{
+ mtd = CONCAT(mtd)->subdev[0];
+ return mtd->read_fact_prot_reg (mtd, from, len, retlen, buf);
+}
+
+static int concat_get_fact_prot_info (struct mtd_info *mtd,
+ struct otp_info *buf, size_t len)
+{
+ mtd = CONCAT(mtd)->subdev[0];
+ return mtd->get_fact_prot_info (mtd, buf, len);
+}
+
+static int concat_write_user_prot_reg (struct mtd_info *mtd, loff_t from,
+ size_t len, size_t *retlen, u_char *buf)
+{
+ mtd = CONCAT(mtd)->subdev[0];
+ return mtd->write_user_prot_reg (mtd, from, len, retlen, buf);
+}
+
+static int concat_lock_user_prot_reg (struct mtd_info *mtd, loff_t from,
+ size_t len)
+{
+ mtd = CONCAT(mtd)->subdev[0];
+ return mtd->lock_user_prot_reg (mtd, from, len);
+}
+#endif
+
/*
* This function constructs a virtual MTD device by concatenating
* num_devs MTD devices. A pointer to the new device object is
@@ -734,6 +778,21 @@ struct mtd_info *mtd_concat_create(struc

concat->mtd.ecc_stats.badblocks = subdev[0]->ecc_stats.badblocks;

+#ifdef CONFIG_MTD_OTP
+ if (subdev[0]->read_user_prot_reg)
+ concat->mtd.read_user_prot_reg = concat_read_user_prot_reg;
+ if (subdev[0]->read_fact_prot_reg)
+ concat->mtd.read_fact_prot_reg = concat_read_fact_prot_reg;
+ if (subdev[0]->write_user_prot_reg)
+ concat->mtd.write_user_prot_reg = concat_write_user_prot_reg;
+ if (subdev[0]->lock_user_prot_reg)
+ concat->mtd.lock_user_prot_reg = concat_lock_user_prot_reg;
+ if (subdev[0]->get_user_prot_info)
+ concat->mtd.get_user_prot_info = concat_get_user_prot_info;
+ if (subdev[0]->get_fact_prot_info)
+ concat->mtd.get_fact_prot_info = concat_get_fact_prot_info;
+#endif
+
concat->subdev[0] = subdev[0];

for (i = 1; i < num_devs; i++) {
--
Christian Hohnstaedt
Software Engineer

Innominate Security Technologies AG /device attached security/
tel: +49.30.6392-3285
fax: +49.30.6392-3307
Albert-Einstein-Str. 14
D-12489 Berlin, Germany