aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd
diff options
context:
space:
mode:
authorChristian Riesch <christian.riesch@omicron.at>2014-01-28 03:29:44 -0500
committerNitin Garg <nitin.garg@freescale.com>2014-04-16 09:57:49 -0400
commitfbdf78d53275cf017b263945abfe00ce06881b4b (patch)
treefe416885dd7814271e834cc8a68460ebfa5c7fad /drivers/mtd
parentedbab95c43e3a5acfa735d74076b2d6b51132a9b (diff)
mtd: Add a retlen parameter to _get_{fact,user}_prot_info
Signed-off-by: Christian Riesch <christian.riesch@omicron.at> Cc: Artem Bityutskiy <Artem.Bityutskiy@linux.intel.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com> Signed-off-by: Huang Shijie <b32955@freescale.com>
Diffstat (limited to 'drivers/mtd')
-rw-r--r--drivers/mtd/chips/cfi_cmdset_0001.c31
-rw-r--r--drivers/mtd/devices/mtd_dataflash.c7
-rw-r--r--drivers/mtd/mtdchar.c11
-rw-r--r--drivers/mtd/mtdcore.c12
-rw-r--r--drivers/mtd/mtdpart.c14
-rw-r--r--drivers/mtd/onenand/onenand_base.c30
6 files changed, 49 insertions, 56 deletions
diff --git a/drivers/mtd/chips/cfi_cmdset_0001.c b/drivers/mtd/chips/cfi_cmdset_0001.c
index 77514430f1fe..7aa581f0ea4d 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
69static int cfi_intelext_read_user_prot_reg (struct mtd_info *, loff_t, size_t, size_t *, u_char *); 69static int cfi_intelext_read_user_prot_reg (struct mtd_info *, loff_t, size_t, size_t *, u_char *);
70static int cfi_intelext_write_user_prot_reg (struct mtd_info *, loff_t, size_t, size_t *, u_char *); 70static int cfi_intelext_write_user_prot_reg (struct mtd_info *, loff_t, size_t, size_t *, u_char *);
71static int cfi_intelext_lock_user_prot_reg (struct mtd_info *, loff_t, size_t); 71static int cfi_intelext_lock_user_prot_reg (struct mtd_info *, loff_t, size_t);
72static int cfi_intelext_get_fact_prot_info (struct mtd_info *, 72static int cfi_intelext_get_fact_prot_info(struct mtd_info *, size_t,
73 struct otp_info *, size_t); 73 size_t *, struct otp_info *);
74static int cfi_intelext_get_user_prot_info (struct mtd_info *, 74static int cfi_intelext_get_user_prot_info(struct mtd_info *, size_t,
75 struct otp_info *, size_t); 75 size_t *, struct otp_info *);
76#endif 76#endif
77static int cfi_intelext_suspend (struct mtd_info *); 77static int cfi_intelext_suspend (struct mtd_info *);
78static void cfi_intelext_resume (struct mtd_info *); 78static void cfi_intelext_resume (struct mtd_info *);
@@ -2399,24 +2399,19 @@ static int cfi_intelext_lock_user_prot_reg(struct mtd_info *mtd,
2399 NULL, do_otp_lock, 1); 2399 NULL, do_otp_lock, 1);
2400} 2400}
2401 2401
2402static int cfi_intelext_get_fact_prot_info(struct mtd_info *mtd, 2402static int cfi_intelext_get_fact_prot_info(struct mtd_info *mtd, size_t len,
2403 struct otp_info *buf, size_t len) 2403 size_t *retlen, struct otp_info *buf)
2404{
2405 size_t retlen;
2406 int ret;
2407 2404
2408 ret = cfi_intelext_otp_walk(mtd, 0, len, &retlen, (u_char *)buf, NULL, 0); 2405{
2409 return ret ? : retlen; 2406 return cfi_intelext_otp_walk(mtd, 0, len, retlen, (u_char *)buf,
2407 NULL, 0);
2410} 2408}
2411 2409
2412static int cfi_intelext_get_user_prot_info(struct mtd_info *mtd, 2410static int cfi_intelext_get_user_prot_info(struct mtd_info *mtd, size_t len,
2413 struct otp_info *buf, size_t len) 2411 size_t *retlen, struct otp_info *buf)
2414{ 2412{
2415 size_t retlen; 2413 return cfi_intelext_otp_walk(mtd, 0, len, retlen, (u_char *)buf,
2416 int ret; 2414 NULL, 1);
2417
2418 ret = cfi_intelext_otp_walk(mtd, 0, len, &retlen, (u_char *)buf, NULL, 1);
2419 return ret ? : retlen;
2420} 2415}
2421 2416
2422#endif 2417#endif
diff --git a/drivers/mtd/devices/mtd_dataflash.c b/drivers/mtd/devices/mtd_dataflash.c
index 28779b6dfcd9..09c69cedc5b2 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,
442 442
443#ifdef CONFIG_MTD_DATAFLASH_OTP 443#ifdef CONFIG_MTD_DATAFLASH_OTP
444 444
445static int dataflash_get_otp_info(struct mtd_info *mtd, 445static int dataflash_get_otp_info(struct mtd_info *mtd, size_t len,
446 struct otp_info *info, size_t len) 446 size_t *retlen, struct otp_info *info)
447{ 447{
448 /* Report both blocks as identical: bytes 0..64, locked. 448 /* Report both blocks as identical: bytes 0..64, locked.
449 * Unless the user block changed from all-ones, we can't 449 * 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,
452 info->start = 0; 452 info->start = 0;
453 info->length = 64; 453 info->length = 64;
454 info->locked = 1; 454 info->locked = 1;
455 return sizeof(*info); 455 *retlen = sizeof(*info);
456 return 0;
456} 457}
457 458
458static ssize_t otp_read(struct spi_device *spi, unsigned base, 459static ssize_t otp_read(struct spi_device *spi, unsigned base,
diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c
index c719879284bd..c2b5c4d98ba0 100644
--- a/drivers/mtd/mtdchar.c
+++ b/drivers/mtd/mtdchar.c
@@ -906,25 +906,26 @@ static int mtdchar_ioctl(struct file *file, u_int cmd, u_long arg)
906 case OTPGETREGIONINFO: 906 case OTPGETREGIONINFO:
907 { 907 {
908 struct otp_info *buf = kmalloc(4096, GFP_KERNEL); 908 struct otp_info *buf = kmalloc(4096, GFP_KERNEL);
909 size_t retlen;
909 if (!buf) 910 if (!buf)
910 return -ENOMEM; 911 return -ENOMEM;
911 switch (mfi->mode) { 912 switch (mfi->mode) {
912 case MTD_FILE_MODE_OTP_FACTORY: 913 case MTD_FILE_MODE_OTP_FACTORY:
913 ret = mtd_get_fact_prot_info(mtd, buf, 4096); 914 ret = mtd_get_fact_prot_info(mtd, 4096, &retlen, buf);
914 break; 915 break;
915 case MTD_FILE_MODE_OTP_USER: 916 case MTD_FILE_MODE_OTP_USER:
916 ret = mtd_get_user_prot_info(mtd, buf, 4096); 917 ret = mtd_get_user_prot_info(mtd, 4096, &retlen, buf);
917 break; 918 break;
918 default: 919 default:
919 ret = -EINVAL; 920 ret = -EINVAL;
920 break; 921 break;
921 } 922 }
922 if (ret >= 0) { 923 if (!ret) {
923 if (cmd == OTPGETREGIONCOUNT) { 924 if (cmd == OTPGETREGIONCOUNT) {
924 int nbr = ret / sizeof(struct otp_info); 925 int nbr = retlen / sizeof(struct otp_info);
925 ret = copy_to_user(argp, &nbr, sizeof(int)); 926 ret = copy_to_user(argp, &nbr, sizeof(int));
926 } else 927 } else
927 ret = copy_to_user(argp, buf, ret); 928 ret = copy_to_user(argp, buf, retlen);
928 if (ret) 929 if (ret)
929 ret = -EFAULT; 930 ret = -EFAULT;
930 } 931 }
diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index e5f17b3e0ed5..9cdc1542d2ee 100644
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -891,14 +891,14 @@ EXPORT_SYMBOL_GPL(mtd_read_oob);
891 * devices. The user data is one time programmable but the factory data is read 891 * devices. The user data is one time programmable but the factory data is read
892 * only. 892 * only.
893 */ 893 */
894int mtd_get_fact_prot_info(struct mtd_info *mtd, struct otp_info *buf, 894int mtd_get_fact_prot_info(struct mtd_info *mtd, size_t len, size_t *retlen,
895 size_t len) 895 struct otp_info *buf)
896{ 896{
897 if (!mtd->_get_fact_prot_info) 897 if (!mtd->_get_fact_prot_info)
898 return -EOPNOTSUPP; 898 return -EOPNOTSUPP;
899 if (!len) 899 if (!len)
900 return 0; 900 return 0;
901 return mtd->_get_fact_prot_info(mtd, buf, len); 901 return mtd->_get_fact_prot_info(mtd, len, retlen, buf);
902} 902}
903EXPORT_SYMBOL_GPL(mtd_get_fact_prot_info); 903EXPORT_SYMBOL_GPL(mtd_get_fact_prot_info);
904 904
@@ -914,14 +914,14 @@ int mtd_read_fact_prot_reg(struct mtd_info *mtd, loff_t from, size_t len,
914} 914}
915EXPORT_SYMBOL_GPL(mtd_read_fact_prot_reg); 915EXPORT_SYMBOL_GPL(mtd_read_fact_prot_reg);
916 916
917int mtd_get_user_prot_info(struct mtd_info *mtd, struct otp_info *buf, 917int mtd_get_user_prot_info(struct mtd_info *mtd, size_t len, size_t *retlen,
918 size_t len) 918 struct otp_info *buf)
919{ 919{
920 if (!mtd->_get_user_prot_info) 920 if (!mtd->_get_user_prot_info)
921 return -EOPNOTSUPP; 921 return -EOPNOTSUPP;
922 if (!len) 922 if (!len)
923 return 0; 923 return 0;
924 return mtd->_get_user_prot_info(mtd, buf, len); 924 return mtd->_get_user_prot_info(mtd, len, retlen, buf);
925} 925}
926EXPORT_SYMBOL_GPL(mtd_get_user_prot_info); 926EXPORT_SYMBOL_GPL(mtd_get_user_prot_info);
927 927
diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c
index 6e732c3820c1..84f5866ae385 100644
--- a/drivers/mtd/mtdpart.c
+++ b/drivers/mtd/mtdpart.c
@@ -150,11 +150,12 @@ static int part_read_user_prot_reg(struct mtd_info *mtd, loff_t from,
150 retlen, buf); 150 retlen, buf);
151} 151}
152 152
153static int part_get_user_prot_info(struct mtd_info *mtd, 153static int part_get_user_prot_info(struct mtd_info *mtd, size_t len,
154 struct otp_info *buf, size_t len) 154 size_t *retlen, struct otp_info *buf)
155{ 155{
156 struct mtd_part *part = PART(mtd); 156 struct mtd_part *part = PART(mtd);
157 return part->master->_get_user_prot_info(part->master, buf, len); 157 return part->master->_get_user_prot_info(part->master, len, retlen,
158 buf);
158} 159}
159 160
160static int part_read_fact_prot_reg(struct mtd_info *mtd, loff_t from, 161static 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,
165 retlen, buf); 166 retlen, buf);
166} 167}
167 168
168static int part_get_fact_prot_info(struct mtd_info *mtd, struct otp_info *buf, 169static int part_get_fact_prot_info(struct mtd_info *mtd, size_t len,
169 size_t len) 170 size_t *retlen, struct otp_info *buf)
170{ 171{
171 struct mtd_part *part = PART(mtd); 172 struct mtd_part *part = PART(mtd);
172 return part->master->_get_fact_prot_info(part->master, buf, len); 173 return part->master->_get_fact_prot_info(part->master, len, retlen,
174 buf);
173} 175}
174 176
175static int part_write(struct mtd_info *mtd, loff_t to, size_t len, 177static int part_write(struct mtd_info *mtd, loff_t to, size_t len,
diff --git a/drivers/mtd/onenand/onenand_base.c b/drivers/mtd/onenand/onenand_base.c
index b3f41f200622..419c538eb3ac 100644
--- a/drivers/mtd/onenand/onenand_base.c
+++ b/drivers/mtd/onenand/onenand_base.c
@@ -3242,20 +3242,17 @@ static int onenand_otp_walk(struct mtd_info *mtd, loff_t from, size_t len,
3242/** 3242/**
3243 * onenand_get_fact_prot_info - [MTD Interface] Read factory OTP info 3243 * onenand_get_fact_prot_info - [MTD Interface] Read factory OTP info
3244 * @param mtd MTD device structure 3244 * @param mtd MTD device structure
3245 * @param buf the databuffer to put/get data
3246 * @param len number of bytes to read 3245 * @param len number of bytes to read
3246 * @param retlen pointer to variable to store the number of read bytes
3247 * @param buf the databuffer to put/get data
3247 * 3248 *
3248 * Read factory OTP info. 3249 * Read factory OTP info.
3249 */ 3250 */
3250static int onenand_get_fact_prot_info(struct mtd_info *mtd, 3251static int onenand_get_fact_prot_info(struct mtd_info *mtd, size_t len,
3251 struct otp_info *buf, size_t len) 3252 size_t *retlen, struct otp_info *buf)
3252{ 3253{
3253 size_t retlen; 3254 return onenand_otp_walk(mtd, 0, len, retlen, (u_char *) buf, NULL,
3254 int ret; 3255 MTD_OTP_FACTORY);
3255
3256 ret = onenand_otp_walk(mtd, 0, len, &retlen, (u_char *) buf, NULL, MTD_OTP_FACTORY);
3257
3258 return ret ? : retlen;
3259} 3256}
3260 3257
3261/** 3258/**
@@ -3277,20 +3274,17 @@ static int onenand_read_fact_prot_reg(struct mtd_info *mtd, loff_t from,
3277/** 3274/**
3278 * onenand_get_user_prot_info - [MTD Interface] Read user OTP info 3275 * onenand_get_user_prot_info - [MTD Interface] Read user OTP info
3279 * @param mtd MTD device structure 3276 * @param mtd MTD device structure
3280 * @param buf the databuffer to put/get data 3277 * @param retlen pointer to variable to store the number of read bytes
3281 * @param len number of bytes to read 3278 * @param len number of bytes to read
3279 * @param buf the databuffer to put/get data
3282 * 3280 *
3283 * Read user OTP info. 3281 * Read user OTP info.
3284 */ 3282 */
3285static int onenand_get_user_prot_info(struct mtd_info *mtd, 3283static int onenand_get_user_prot_info(struct mtd_info *mtd, size_t len,
3286 struct otp_info *buf, size_t len) 3284 size_t *retlen, struct otp_info *buf)
3287{ 3285{
3288 size_t retlen; 3286 return onenand_otp_walk(mtd, 0, len, retlen, (u_char *) buf, NULL,
3289 int ret; 3287 MTD_OTP_USER);
3290
3291 ret = onenand_otp_walk(mtd, 0, len, &retlen, (u_char *) buf, NULL, MTD_OTP_USER);
3292
3293 return ret ? : retlen;
3294} 3288}
3295 3289
3296/** 3290/**