[PATCH v2 RESEND 1/2] mtd: Add a retlen parameter to _get_{fact,user}_prot_info

2014-01-28 Thread Christian Riesch
Signed-off-by: Christian Riesch 
Cc: Artem Bityutskiy 
Cc: Brian Norris 
---
 drivers/mtd/chips/cfi_cmdset_0001.c |   31 +--
 drivers/mtd/devices/mtd_dataflash.c |7 ---
 drivers/mtd/mtdchar.c   |   11 ++-
 drivers/mtd/mtdcore.c   |   12 ++--
 drivers/mtd/mtdpart.c   |   14 --
 drivers/mtd/onenand/onenand_base.c  |   30 --
 include/linux/mtd/mtd.h |   16 
 7 files changed, 57 insertions(+), 64 deletions(-)

diff --git a/drivers/mtd/chips/cfi_cmdset_0001.c 
b/drivers/mtd/chips/cfi_cmdset_0001.c
index 7751443..7aa581f 100644
--- a/drivers/mtd/chips/cfi_cmdset_0001.c
+++ b/drivers/mtd/chips/cfi_cmdset_0001.c
@@ -69,10 +69,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_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_get_fact_prot_info (struct mtd_info *,
-   struct otp_info *, size_t);
-static int cfi_intelext_get_user_prot_info (struct mtd_info *,
-   struct otp_info *, size_t);
+static int cfi_intelext_get_fact_prot_info(struct mtd_info *, size_t,
+  size_t *, struct otp_info *);
+static int cfi_intelext_get_user_prot_info(struct mtd_info *, size_t,
+  size_t *, struct otp_info *);
 #endif
 static int cfi_intelext_suspend (struct mtd_info *);
 static void cfi_intelext_resume (struct mtd_info *);
@@ -2399,24 +2399,19 @@ static int cfi_intelext_lock_user_prot_reg(struct 
mtd_info *mtd,
 NULL, do_otp_lock, 1);
 }
 
-static int cfi_intelext_get_fact_prot_info(struct mtd_info *mtd,
-  struct otp_info *buf, size_t len)
-{
-   size_t retlen;
-   int ret;
+static int cfi_intelext_get_fact_prot_info(struct mtd_info *mtd, size_t len,
+  size_t *retlen, struct otp_info *buf)
 
-   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,
-  struct otp_info *buf, size_t len)
+static int cfi_intelext_get_user_prot_info(struct mtd_info *mtd, 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, 
1);
-   return ret ? : retlen;
+   return cfi_intelext_otp_walk(mtd, 0, len, retlen, (u_char *)buf,
+NULL, 1);
 }
 
 #endif
diff --git a/drivers/mtd/devices/mtd_dataflash.c 
b/drivers/mtd/devices/mtd_dataflash.c
index 28779b6..09c69ce 100644
--- a/drivers/mtd/devices/mtd_dataflash.c
+++ b/drivers/mtd/devices/mtd_dataflash.c
@@ -442,8 +442,8 @@ static int dataflash_write(struct mtd_info *mtd, loff_t to, 
size_t len,
 
 #ifdef CONFIG_MTD_DATAFLASH_OTP
 
-static int dataflash_get_otp_info(struct mtd_info *mtd,
-   struct otp_info *info, size_t len)
+static int dataflash_get_otp_info(struct mtd_info *mtd, size_t len,
+ size_t *retlen, struct otp_info *info)
 {
/* Report both blocks as identical:  bytes 0..64, locked.
 * Unless the user block changed from all-ones, we can't
@@ -452,7 +452,8 @@ static int dataflash_get_otp_info(struct mtd_info *mtd,
info->start = 0;
info->length = 64;
info->locked = 1;
-   return sizeof(*info);
+   *retlen = sizeof(*info);
+   return 0;
 }
 
 static ssize_t otp_read(struct spi_device *spi, unsigned base,
diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c
index 684bfa3..0edb0ca 100644
--- a/drivers/mtd/mtdchar.c
+++ b/drivers/mtd/mtdchar.c
@@ -888,25 +888,26 @@ static int mtdchar_ioctl(struct file *file, u_int cmd, 
u_long arg)
case OTPGETREGIONINFO:
{
struct otp_info *buf = kmalloc(4096, GFP_KERNEL);
+   size_t retlen;
if (!buf)
return -ENOMEM;
switch (mfi->mode) {
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;
case MTD_FILE_MODE_OTP_USER:
-   ret = mtd_get_user_prot_info(mtd, 

Re: [PATCH v2 RESEND 1/2] mtd: Add a retlen parameter to _get_{fact,user}_prot_info

2014-03-04 Thread Brian Norris
On Tue, Jan 28, 2014 at 09:29:44AM +0100, Christian Riesch wrote:
> Signed-off-by: Christian Riesch 
> Cc: Artem Bityutskiy 
> Cc: Brian Norris 
> ---
>  drivers/mtd/chips/cfi_cmdset_0001.c |   31 +--
>  drivers/mtd/devices/mtd_dataflash.c |7 ---
>  drivers/mtd/mtdchar.c   |   11 ++-
>  drivers/mtd/mtdcore.c   |   12 ++--
>  drivers/mtd/mtdpart.c   |   14 --
>  drivers/mtd/onenand/onenand_base.c  |   30 --
>  include/linux/mtd/mtd.h |   16 
>  7 files changed, 57 insertions(+), 64 deletions(-)

Pushed patch 1 to l2-mtd.git. I may not push patch 2 yet; let me know if
you see a problem with that.

Thanks,
Brian
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/