Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a750b5ce authored by Artem Bityutskiy's avatar Artem Bityutskiy Committed by David Woodhouse
Browse files

mtd: introduce mtd_get_fact_prot_info interface

parent a2cc5ba0
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -925,7 +925,7 @@ static int mtdchar_ioctl(struct file *file, u_int cmd, u_long arg)
		switch (mfi->mode) {
		case MTD_FILE_MODE_OTP_FACTORY:
			if (mtd->get_fact_prot_info)
				ret = mtd->get_fact_prot_info(mtd, buf, 4096);
				ret = mtd_get_fact_prot_info(mtd, buf, 4096);
			break;
		case MTD_FILE_MODE_OTP_USER:
			if (mtd->get_user_prot_info)
+1 −1
Original line number Diff line number Diff line
@@ -175,7 +175,7 @@ static int part_get_fact_prot_info(struct mtd_info *mtd, struct otp_info *buf,
		size_t len)
{
	struct mtd_part *part = PART(mtd);
	return part->master->get_fact_prot_info(part->master, buf, len);
	return mtd_get_fact_prot_info(part->master, buf, len);
}

static int part_write(struct mtd_info *mtd, loff_t to, size_t len,
+13 −6
Original line number Diff line number Diff line
@@ -192,18 +192,14 @@ struct mtd_info {
			 struct mtd_oob_ops *ops);
	int (*write_oob) (struct mtd_info *mtd, loff_t to,
			  struct mtd_oob_ops *ops);
	int (*get_fact_prot_info) (struct mtd_info *mtd, struct otp_info *buf,
				   size_t len);

	/* Backing device capabilities for this device
	 * - provides mmap capabilities
	 */
	struct backing_dev_info *backing_dev_info;

	/*
	 * Methods to access the protection register area, present in some
	 * flash devices. The user data is one time programmable but the
	 * factory data is read only.
	 */
	int (*get_fact_prot_info) (struct mtd_info *mtd, struct otp_info *buf, size_t len);
	int (*read_fact_prot_reg) (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf);
	int (*get_user_prot_info) (struct mtd_info *mtd, struct otp_info *buf, size_t len);
	int (*read_user_prot_reg) (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf);
@@ -330,6 +326,17 @@ static inline int mtd_write_oob(struct mtd_info *mtd, loff_t to,
	return mtd->write_oob(mtd, to, ops);
}

/*
 * Method to access the protection register area, present in some flash
 * devices. The user data is one time programmable but the factory data is read
 * only.
 */
static inline int mtd_get_fact_prot_info(struct mtd_info *mtd,
					 struct otp_info *buf, size_t len)
{
	return mtd->get_fact_prot_info(mtd, buf, len);
}

static inline struct mtd_info *dev_to_mtd(struct device *dev)
{
	return dev ? dev_get_drvdata(dev) : NULL;