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

Commit 4b78fc42 authored by Christian Riesch's avatar Christian Riesch Committed by Brian Norris
Browse files

mtd: Add a retlen parameter to _get_{fact,user}_prot_info



Signed-off-by: default avatarChristian Riesch <christian.riesch@omicron.at>
Cc: Artem Bityutskiy <Artem.Bityutskiy@linux.intel.com>
Signed-off-by: default avatarBrian Norris <computersforpeace@gmail.com>
parent 41bf1a24
Loading
Loading
Loading
Loading
+13 −18
Original line number Original line Diff line number Diff line
@@ -68,10 +68,10 @@ static int cfi_intelext_read_fact_prot_reg (struct mtd_info *, loff_t, size_t, s
static int cfi_intelext_read_user_prot_reg (struct mtd_info *, loff_t, size_t, size_t *, u_char *);
static int cfi_intelext_read_user_prot_reg (struct mtd_info *, loff_t, size_t, size_t *, u_char *);
static int cfi_intelext_write_user_prot_reg (struct mtd_info *, loff_t, size_t, size_t *, u_char *);
static int cfi_intelext_write_user_prot_reg (struct mtd_info *, loff_t, size_t, size_t *, u_char *);
static int cfi_intelext_lock_user_prot_reg (struct mtd_info *, loff_t, size_t);
static int cfi_intelext_lock_user_prot_reg (struct mtd_info *, loff_t, size_t);
static int cfi_intelext_get_fact_prot_info (struct mtd_info *,
static int cfi_intelext_get_fact_prot_info(struct mtd_info *, size_t,
					    struct otp_info *, size_t);
					   size_t *, struct otp_info *);
static int cfi_intelext_get_user_prot_info (struct mtd_info *,
static int cfi_intelext_get_user_prot_info(struct mtd_info *, size_t,
					    struct otp_info *, size_t);
					   size_t *, struct otp_info *);
#endif
#endif
static int cfi_intelext_suspend (struct mtd_info *);
static int cfi_intelext_suspend (struct mtd_info *);
static void cfi_intelext_resume (struct mtd_info *);
static void cfi_intelext_resume (struct mtd_info *);
@@ -2394,24 +2394,19 @@ static int cfi_intelext_lock_user_prot_reg(struct mtd_info *mtd,
				     NULL, do_otp_lock, 1);
				     NULL, do_otp_lock, 1);
}
}


static int cfi_intelext_get_fact_prot_info(struct mtd_info *mtd,
static int cfi_intelext_get_fact_prot_info(struct mtd_info *mtd, size_t len,
					   struct otp_info *buf, size_t len)
					   size_t *retlen, struct otp_info *buf)
{
	size_t retlen;
	int ret;


	ret = cfi_intelext_otp_walk(mtd, 0, len, &retlen, (u_char *)buf, NULL, 0);
{
	return ret ? : retlen;
	return cfi_intelext_otp_walk(mtd, 0, len, retlen, (u_char *)buf,
				     NULL, 0);
}
}


static int cfi_intelext_get_user_prot_info(struct mtd_info *mtd,
static int cfi_intelext_get_user_prot_info(struct mtd_info *mtd, size_t len,
					   struct otp_info *buf, size_t len)
					   size_t *retlen, struct otp_info *buf)
{
{
	size_t retlen;
	return cfi_intelext_otp_walk(mtd, 0, len, retlen, (u_char *)buf,
	int ret;
				     NULL, 1);

	ret = cfi_intelext_otp_walk(mtd, 0, len, &retlen, (u_char *)buf, NULL, 1);
	return ret ? : retlen;
}
}


#endif
#endif
+4 −3
Original line number Original line Diff line number Diff line
@@ -439,8 +439,8 @@ static int dataflash_write(struct mtd_info *mtd, loff_t to, size_t len,


#ifdef CONFIG_MTD_DATAFLASH_OTP
#ifdef CONFIG_MTD_DATAFLASH_OTP


static int dataflash_get_otp_info(struct mtd_info *mtd,
static int dataflash_get_otp_info(struct mtd_info *mtd, size_t len,
		struct otp_info *info, size_t len)
				  size_t *retlen, struct otp_info *info)
{
{
	/* Report both blocks as identical:  bytes 0..64, locked.
	/* Report both blocks as identical:  bytes 0..64, locked.
	 * Unless the user block changed from all-ones, we can't
	 * Unless the user block changed from all-ones, we can't
@@ -449,7 +449,8 @@ static int dataflash_get_otp_info(struct mtd_info *mtd,
	info->start = 0;
	info->start = 0;
	info->length = 64;
	info->length = 64;
	info->locked = 1;
	info->locked = 1;
	return sizeof(*info);
	*retlen = sizeof(*info);
	return 0;
}
}


static ssize_t otp_read(struct spi_device *spi, unsigned base,
static ssize_t otp_read(struct spi_device *spi, unsigned base,
+6 −5
Original line number Original line Diff line number Diff line
@@ -889,25 +889,26 @@ static int mtdchar_ioctl(struct file *file, u_int cmd, u_long arg)
	case OTPGETREGIONINFO:
	case OTPGETREGIONINFO:
	{
	{
		struct otp_info *buf = kmalloc(4096, GFP_KERNEL);
		struct otp_info *buf = kmalloc(4096, GFP_KERNEL);
		size_t retlen;
		if (!buf)
		if (!buf)
			return -ENOMEM;
			return -ENOMEM;
		switch (mfi->mode) {
		switch (mfi->mode) {
		case MTD_FILE_MODE_OTP_FACTORY:
		case MTD_FILE_MODE_OTP_FACTORY:
			ret = mtd_get_fact_prot_info(mtd, buf, 4096);
			ret = mtd_get_fact_prot_info(mtd, 4096, &retlen, buf);
			break;
			break;
		case MTD_FILE_MODE_OTP_USER:
		case MTD_FILE_MODE_OTP_USER:
			ret = mtd_get_user_prot_info(mtd, buf, 4096);
			ret = mtd_get_user_prot_info(mtd, 4096, &retlen, buf);
			break;
			break;
		default:
		default:
			ret = -EINVAL;
			ret = -EINVAL;
			break;
			break;
		}
		}
		if (ret >= 0) {
		if (!ret) {
			if (cmd == OTPGETREGIONCOUNT) {
			if (cmd == OTPGETREGIONCOUNT) {
				int nbr = ret / sizeof(struct otp_info);
				int nbr = retlen / sizeof(struct otp_info);
				ret = copy_to_user(argp, &nbr, sizeof(int));
				ret = copy_to_user(argp, &nbr, sizeof(int));
			} else
			} else
				ret = copy_to_user(argp, buf, ret);
				ret = copy_to_user(argp, buf, retlen);
			if (ret)
			if (ret)
				ret = -EFAULT;
				ret = -EFAULT;
		}
		}
+6 −6
Original line number Original line Diff line number Diff line
@@ -883,14 +883,14 @@ EXPORT_SYMBOL_GPL(mtd_read_oob);
 * devices. The user data is one time programmable but the factory data is read
 * devices. The user data is one time programmable but the factory data is read
 * only.
 * only.
 */
 */
int mtd_get_fact_prot_info(struct mtd_info *mtd, struct otp_info *buf,
int mtd_get_fact_prot_info(struct mtd_info *mtd, size_t len, size_t *retlen,
			   size_t len)
			   struct otp_info *buf)
{
{
	if (!mtd->_get_fact_prot_info)
	if (!mtd->_get_fact_prot_info)
		return -EOPNOTSUPP;
		return -EOPNOTSUPP;
	if (!len)
	if (!len)
		return 0;
		return 0;
	return mtd->_get_fact_prot_info(mtd, buf, len);
	return mtd->_get_fact_prot_info(mtd, len, retlen, buf);
}
}
EXPORT_SYMBOL_GPL(mtd_get_fact_prot_info);
EXPORT_SYMBOL_GPL(mtd_get_fact_prot_info);


@@ -906,14 +906,14 @@ int mtd_read_fact_prot_reg(struct mtd_info *mtd, loff_t from, size_t len,
}
}
EXPORT_SYMBOL_GPL(mtd_read_fact_prot_reg);
EXPORT_SYMBOL_GPL(mtd_read_fact_prot_reg);


int mtd_get_user_prot_info(struct mtd_info *mtd, struct otp_info *buf,
int mtd_get_user_prot_info(struct mtd_info *mtd, size_t len, size_t *retlen,
			   size_t len)
			   struct otp_info *buf)
{
{
	if (!mtd->_get_user_prot_info)
	if (!mtd->_get_user_prot_info)
		return -EOPNOTSUPP;
		return -EOPNOTSUPP;
	if (!len)
	if (!len)
		return 0;
		return 0;
	return mtd->_get_user_prot_info(mtd, buf, len);
	return mtd->_get_user_prot_info(mtd, len, retlen, buf);
}
}
EXPORT_SYMBOL_GPL(mtd_get_user_prot_info);
EXPORT_SYMBOL_GPL(mtd_get_user_prot_info);


+8 −6
Original line number Original line Diff line number Diff line
@@ -150,11 +150,12 @@ static int part_read_user_prot_reg(struct mtd_info *mtd, loff_t from,
						 retlen, buf);
						 retlen, buf);
}
}


static int part_get_user_prot_info(struct mtd_info *mtd,
static int part_get_user_prot_info(struct mtd_info *mtd, size_t len,
		struct otp_info *buf, size_t len)
				   size_t *retlen, struct otp_info *buf)
{
{
	struct mtd_part *part = PART(mtd);
	struct mtd_part *part = PART(mtd);
	return part->master->_get_user_prot_info(part->master, buf, len);
	return part->master->_get_user_prot_info(part->master, len, retlen,
						 buf);
}
}


static int part_read_fact_prot_reg(struct mtd_info *mtd, loff_t from,
static int part_read_fact_prot_reg(struct mtd_info *mtd, loff_t from,
@@ -165,11 +166,12 @@ static int part_read_fact_prot_reg(struct mtd_info *mtd, loff_t from,
						 retlen, buf);
						 retlen, buf);
}
}


static int part_get_fact_prot_info(struct mtd_info *mtd, struct otp_info *buf,
static int part_get_fact_prot_info(struct mtd_info *mtd, size_t len,
		size_t len)
				   size_t *retlen, struct otp_info *buf)
{
{
	struct mtd_part *part = PART(mtd);
	struct mtd_part *part = PART(mtd);
	return part->master->_get_fact_prot_info(part->master, buf, len);
	return part->master->_get_fact_prot_info(part->master, len, retlen,
						 buf);
}
}


static int part_write(struct mtd_info *mtd, loff_t to, size_t len,
static int part_write(struct mtd_info *mtd, loff_t to, size_t len,
Loading