diff options
-rw-r--r-- | drivers/mtd/chips/cfi_cmdset_0001.c | 31 | ||||
-rw-r--r-- | drivers/mtd/devices/mtd_dataflash.c | 7 | ||||
-rw-r--r-- | drivers/mtd/mtdchar.c | 11 | ||||
-rw-r--r-- | drivers/mtd/mtdcore.c | 12 | ||||
-rw-r--r-- | drivers/mtd/mtdpart.c | 14 | ||||
-rw-r--r-- | drivers/mtd/onenand/onenand_base.c | 30 | ||||
-rw-r--r-- | 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 5e74c860e532..e4ec355704a6 100644 --- a/drivers/mtd/chips/cfi_cmdset_0001.c +++ b/drivers/mtd/chips/cfi_cmdset_0001.c | |||
@@ -68,10 +68,10 @@ static int cfi_intelext_read_fact_prot_reg (struct mtd_info *, loff_t, size_t, s | |||
68 | static int cfi_intelext_read_user_prot_reg (struct mtd_info *, loff_t, size_t, size_t *, u_char *); | 68 | static int cfi_intelext_read_user_prot_reg (struct mtd_info *, loff_t, size_t, size_t *, u_char *); |
69 | static int cfi_intelext_write_user_prot_reg (struct mtd_info *, loff_t, size_t, size_t *, u_char *); | 69 | static int cfi_intelext_write_user_prot_reg (struct mtd_info *, loff_t, size_t, size_t *, u_char *); |
70 | static int cfi_intelext_lock_user_prot_reg (struct mtd_info *, loff_t, size_t); | 70 | static int cfi_intelext_lock_user_prot_reg (struct mtd_info *, loff_t, size_t); |
71 | static int cfi_intelext_get_fact_prot_info (struct mtd_info *, | 71 | static int cfi_intelext_get_fact_prot_info(struct mtd_info *, size_t, |
72 | struct otp_info *, size_t); | 72 | size_t *, struct otp_info *); |
73 | static int cfi_intelext_get_user_prot_info (struct mtd_info *, | 73 | static int cfi_intelext_get_user_prot_info(struct mtd_info *, size_t, |
74 | struct otp_info *, size_t); | 74 | size_t *, struct otp_info *); |
75 | #endif | 75 | #endif |
76 | static int cfi_intelext_suspend (struct mtd_info *); | 76 | static int cfi_intelext_suspend (struct mtd_info *); |
77 | static void cfi_intelext_resume (struct mtd_info *); | 77 | static void cfi_intelext_resume (struct mtd_info *); |
@@ -2394,24 +2394,19 @@ static int cfi_intelext_lock_user_prot_reg(struct mtd_info *mtd, | |||
2394 | NULL, do_otp_lock, 1); | 2394 | NULL, do_otp_lock, 1); |
2395 | } | 2395 | } |
2396 | 2396 | ||
2397 | static int cfi_intelext_get_fact_prot_info(struct mtd_info *mtd, | 2397 | static int cfi_intelext_get_fact_prot_info(struct mtd_info *mtd, size_t len, |
2398 | struct otp_info *buf, size_t len) | 2398 | size_t *retlen, struct otp_info *buf) |
2399 | { | ||
2400 | size_t retlen; | ||
2401 | int ret; | ||
2402 | 2399 | ||
2403 | ret = cfi_intelext_otp_walk(mtd, 0, len, &retlen, (u_char *)buf, NULL, 0); | 2400 | { |
2404 | return ret ? : retlen; | 2401 | return cfi_intelext_otp_walk(mtd, 0, len, retlen, (u_char *)buf, |
2402 | NULL, 0); | ||
2405 | } | 2403 | } |
2406 | 2404 | ||
2407 | static int cfi_intelext_get_user_prot_info(struct mtd_info *mtd, | 2405 | static int cfi_intelext_get_user_prot_info(struct mtd_info *mtd, size_t len, |
2408 | struct otp_info *buf, size_t len) | 2406 | size_t *retlen, struct otp_info *buf) |
2409 | { | 2407 | { |
2410 | size_t retlen; | 2408 | return cfi_intelext_otp_walk(mtd, 0, len, retlen, (u_char *)buf, |
2411 | int ret; | 2409 | NULL, 1); |
2412 | |||
2413 | ret = cfi_intelext_otp_walk(mtd, 0, len, &retlen, (u_char *)buf, NULL, 1); | ||
2414 | return ret ? : retlen; | ||
2415 | } | 2410 | } |
2416 | 2411 | ||
2417 | #endif | 2412 | #endif |
diff --git a/drivers/mtd/devices/mtd_dataflash.c b/drivers/mtd/devices/mtd_dataflash.c index 8b278d2b15bb..a6fdbe83bad6 100644 --- a/drivers/mtd/devices/mtd_dataflash.c +++ b/drivers/mtd/devices/mtd_dataflash.c | |||
@@ -439,8 +439,8 @@ static int dataflash_write(struct mtd_info *mtd, loff_t to, size_t len, | |||
439 | 439 | ||
440 | #ifdef CONFIG_MTD_DATAFLASH_OTP | 440 | #ifdef CONFIG_MTD_DATAFLASH_OTP |
441 | 441 | ||
442 | static int dataflash_get_otp_info(struct mtd_info *mtd, | 442 | static int dataflash_get_otp_info(struct mtd_info *mtd, size_t len, |
443 | struct otp_info *info, size_t len) | 443 | size_t *retlen, struct otp_info *info) |
444 | { | 444 | { |
445 | /* Report both blocks as identical: bytes 0..64, locked. | 445 | /* Report both blocks as identical: bytes 0..64, locked. |
446 | * Unless the user block changed from all-ones, we can't | 446 | * 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, | |||
449 | info->start = 0; | 449 | info->start = 0; |
450 | info->length = 64; | 450 | info->length = 64; |
451 | info->locked = 1; | 451 | info->locked = 1; |
452 | return sizeof(*info); | 452 | *retlen = sizeof(*info); |
453 | return 0; | ||
453 | } | 454 | } |
454 | 455 | ||
455 | static ssize_t otp_read(struct spi_device *spi, unsigned base, | 456 | static ssize_t otp_read(struct spi_device *spi, unsigned base, |
diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c index 2147e733533b..250798cf76aa 100644 --- a/drivers/mtd/mtdchar.c +++ b/drivers/mtd/mtdchar.c | |||
@@ -889,25 +889,26 @@ static int mtdchar_ioctl(struct file *file, u_int cmd, u_long arg) | |||
889 | case OTPGETREGIONINFO: | 889 | case OTPGETREGIONINFO: |
890 | { | 890 | { |
891 | struct otp_info *buf = kmalloc(4096, GFP_KERNEL); | 891 | struct otp_info *buf = kmalloc(4096, GFP_KERNEL); |
892 | size_t retlen; | ||
892 | if (!buf) | 893 | if (!buf) |
893 | return -ENOMEM; | 894 | return -ENOMEM; |
894 | switch (mfi->mode) { | 895 | switch (mfi->mode) { |
895 | case MTD_FILE_MODE_OTP_FACTORY: | 896 | case MTD_FILE_MODE_OTP_FACTORY: |
896 | ret = mtd_get_fact_prot_info(mtd, buf, 4096); | 897 | ret = mtd_get_fact_prot_info(mtd, 4096, &retlen, buf); |
897 | break; | 898 | break; |
898 | case MTD_FILE_MODE_OTP_USER: | 899 | case MTD_FILE_MODE_OTP_USER: |
899 | ret = mtd_get_user_prot_info(mtd, buf, 4096); | 900 | ret = mtd_get_user_prot_info(mtd, 4096, &retlen, buf); |
900 | break; | 901 | break; |
901 | default: | 902 | default: |
902 | ret = -EINVAL; | 903 | ret = -EINVAL; |
903 | break; | 904 | break; |
904 | } | 905 | } |
905 | if (ret >= 0) { | 906 | if (!ret) { |
906 | if (cmd == OTPGETREGIONCOUNT) { | 907 | if (cmd == OTPGETREGIONCOUNT) { |
907 | int nbr = ret / sizeof(struct otp_info); | 908 | int nbr = retlen / sizeof(struct otp_info); |
908 | ret = copy_to_user(argp, &nbr, sizeof(int)); | 909 | ret = copy_to_user(argp, &nbr, sizeof(int)); |
909 | } else | 910 | } else |
910 | ret = copy_to_user(argp, buf, ret); | 911 | ret = copy_to_user(argp, buf, retlen); |
911 | if (ret) | 912 | if (ret) |
912 | ret = -EFAULT; | 913 | ret = -EFAULT; |
913 | } | 914 | } |
diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c index 34c0b16aed5c..0a7d77e65335 100644 --- a/drivers/mtd/mtdcore.c +++ b/drivers/mtd/mtdcore.c | |||
@@ -883,14 +883,14 @@ EXPORT_SYMBOL_GPL(mtd_read_oob); | |||
883 | * devices. The user data is one time programmable but the factory data is read | 883 | * devices. The user data is one time programmable but the factory data is read |
884 | * only. | 884 | * only. |
885 | */ | 885 | */ |
886 | int mtd_get_fact_prot_info(struct mtd_info *mtd, struct otp_info *buf, | 886 | int mtd_get_fact_prot_info(struct mtd_info *mtd, size_t len, size_t *retlen, |
887 | size_t len) | 887 | struct otp_info *buf) |
888 | { | 888 | { |
889 | if (!mtd->_get_fact_prot_info) | 889 | if (!mtd->_get_fact_prot_info) |
890 | return -EOPNOTSUPP; | 890 | return -EOPNOTSUPP; |
891 | if (!len) | 891 | if (!len) |
892 | return 0; | 892 | return 0; |
893 | return mtd->_get_fact_prot_info(mtd, buf, len); | 893 | return mtd->_get_fact_prot_info(mtd, len, retlen, buf); |
894 | } | 894 | } |
895 | EXPORT_SYMBOL_GPL(mtd_get_fact_prot_info); | 895 | EXPORT_SYMBOL_GPL(mtd_get_fact_prot_info); |
896 | 896 | ||
@@ -906,14 +906,14 @@ int mtd_read_fact_prot_reg(struct mtd_info *mtd, loff_t from, size_t len, | |||
906 | } | 906 | } |
907 | EXPORT_SYMBOL_GPL(mtd_read_fact_prot_reg); | 907 | EXPORT_SYMBOL_GPL(mtd_read_fact_prot_reg); |
908 | 908 | ||
909 | int mtd_get_user_prot_info(struct mtd_info *mtd, struct otp_info *buf, | 909 | int mtd_get_user_prot_info(struct mtd_info *mtd, size_t len, size_t *retlen, |
910 | size_t len) | 910 | struct otp_info *buf) |
911 | { | 911 | { |
912 | if (!mtd->_get_user_prot_info) | 912 | if (!mtd->_get_user_prot_info) |
913 | return -EOPNOTSUPP; | 913 | return -EOPNOTSUPP; |
914 | if (!len) | 914 | if (!len) |
915 | return 0; | 915 | return 0; |
916 | return mtd->_get_user_prot_info(mtd, buf, len); | 916 | return mtd->_get_user_prot_info(mtd, len, retlen, buf); |
917 | } | 917 | } |
918 | EXPORT_SYMBOL_GPL(mtd_get_user_prot_info); | 918 | EXPORT_SYMBOL_GPL(mtd_get_user_prot_info); |
919 | 919 | ||
diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c index 3c7d6d7623c1..1ca9aec141ff 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 | ||
153 | static int part_get_user_prot_info(struct mtd_info *mtd, | 153 | static 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 | ||
160 | static int part_read_fact_prot_reg(struct mtd_info *mtd, loff_t from, | 161 | 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, | |||
165 | retlen, buf); | 166 | retlen, buf); |
166 | } | 167 | } |
167 | 168 | ||
168 | static int part_get_fact_prot_info(struct mtd_info *mtd, struct otp_info *buf, | 169 | static 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 | ||
175 | static int part_write(struct mtd_info *mtd, loff_t to, size_t len, | 177 | static 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 e886d7af868f..635ee0027691 100644 --- a/drivers/mtd/onenand/onenand_base.c +++ b/drivers/mtd/onenand/onenand_base.c | |||
@@ -3237,20 +3237,17 @@ static int onenand_otp_walk(struct mtd_info *mtd, loff_t from, size_t len, | |||
3237 | /** | 3237 | /** |
3238 | * onenand_get_fact_prot_info - [MTD Interface] Read factory OTP info | 3238 | * onenand_get_fact_prot_info - [MTD Interface] Read factory OTP info |
3239 | * @param mtd MTD device structure | 3239 | * @param mtd MTD device structure |
3240 | * @param buf the databuffer to put/get data | ||
3241 | * @param len number of bytes to read | 3240 | * @param len number of bytes to read |
3241 | * @param retlen pointer to variable to store the number of read bytes | ||
3242 | * @param buf the databuffer to put/get data | ||
3242 | * | 3243 | * |
3243 | * Read factory OTP info. | 3244 | * Read factory OTP info. |
3244 | */ | 3245 | */ |
3245 | static int onenand_get_fact_prot_info(struct mtd_info *mtd, | 3246 | static int onenand_get_fact_prot_info(struct mtd_info *mtd, size_t len, |
3246 | struct otp_info *buf, size_t len) | 3247 | size_t *retlen, struct otp_info *buf) |
3247 | { | 3248 | { |
3248 | size_t retlen; | 3249 | return onenand_otp_walk(mtd, 0, len, retlen, (u_char *) buf, NULL, |
3249 | int ret; | 3250 | MTD_OTP_FACTORY); |
3250 | |||
3251 | ret = onenand_otp_walk(mtd, 0, len, &retlen, (u_char *) buf, NULL, MTD_OTP_FACTORY); | ||
3252 | |||
3253 | return ret ? : retlen; | ||
3254 | } | 3251 | } |
3255 | 3252 | ||
3256 | /** | 3253 | /** |
@@ -3272,20 +3269,17 @@ static int onenand_read_fact_prot_reg(struct mtd_info *mtd, loff_t from, | |||
3272 | /** | 3269 | /** |
3273 | * onenand_get_user_prot_info - [MTD Interface] Read user OTP info | 3270 | * onenand_get_user_prot_info - [MTD Interface] Read user OTP info |
3274 | * @param mtd MTD device structure | 3271 | * @param mtd MTD device structure |
3275 | * @param buf the databuffer to put/get data | 3272 | * @param retlen pointer to variable to store the number of read bytes |
3276 | * @param len number of bytes to read | 3273 | * @param len number of bytes to read |
3274 | * @param buf the databuffer to put/get data | ||
3277 | * | 3275 | * |
3278 | * Read user OTP info. | 3276 | * Read user OTP info. |
3279 | */ | 3277 | */ |
3280 | static int onenand_get_user_prot_info(struct mtd_info *mtd, | 3278 | static int onenand_get_user_prot_info(struct mtd_info *mtd, size_t len, |
3281 | struct otp_info *buf, size_t len) | 3279 | size_t *retlen, struct otp_info *buf) |
3282 | { | 3280 | { |
3283 | size_t retlen; | 3281 | return onenand_otp_walk(mtd, 0, len, retlen, (u_char *) buf, NULL, |
3284 | int ret; | 3282 | MTD_OTP_USER); |
3285 | |||
3286 | ret = onenand_otp_walk(mtd, 0, len, &retlen, (u_char *) buf, NULL, MTD_OTP_USER); | ||
3287 | |||
3288 | return ret ? : retlen; | ||
3289 | } | 3283 | } |
3290 | 3284 | ||
3291 | /** | 3285 | /** |
diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h index 8cc0e2fb6894..a1b0b4c8fd79 100644 --- a/include/linux/mtd/mtd.h +++ b/include/linux/mtd/mtd.h | |||
@@ -204,12 +204,12 @@ struct mtd_info { | |||
204 | struct mtd_oob_ops *ops); | 204 | struct mtd_oob_ops *ops); |
205 | int (*_write_oob) (struct mtd_info *mtd, loff_t to, | 205 | int (*_write_oob) (struct mtd_info *mtd, loff_t to, |
206 | struct mtd_oob_ops *ops); | 206 | struct mtd_oob_ops *ops); |
207 | int (*_get_fact_prot_info) (struct mtd_info *mtd, struct otp_info *buf, | 207 | int (*_get_fact_prot_info) (struct mtd_info *mtd, size_t len, |
208 | size_t len); | 208 | size_t *retlen, struct otp_info *buf); |
209 | int (*_read_fact_prot_reg) (struct mtd_info *mtd, loff_t from, | 209 | int (*_read_fact_prot_reg) (struct mtd_info *mtd, loff_t from, |
210 | size_t len, size_t *retlen, u_char *buf); | 210 | size_t len, size_t *retlen, u_char *buf); |
211 | int (*_get_user_prot_info) (struct mtd_info *mtd, struct otp_info *buf, | 211 | int (*_get_user_prot_info) (struct mtd_info *mtd, size_t len, |
212 | size_t len); | 212 | size_t *retlen, struct otp_info *buf); |
213 | int (*_read_user_prot_reg) (struct mtd_info *mtd, loff_t from, | 213 | int (*_read_user_prot_reg) (struct mtd_info *mtd, loff_t from, |
214 | size_t len, size_t *retlen, u_char *buf); | 214 | size_t len, size_t *retlen, u_char *buf); |
215 | int (*_write_user_prot_reg) (struct mtd_info *mtd, loff_t to, | 215 | int (*_write_user_prot_reg) (struct mtd_info *mtd, loff_t to, |
@@ -278,12 +278,12 @@ static inline int mtd_write_oob(struct mtd_info *mtd, loff_t to, | |||
278 | return mtd->_write_oob(mtd, to, ops); | 278 | return mtd->_write_oob(mtd, to, ops); |
279 | } | 279 | } |
280 | 280 | ||
281 | int mtd_get_fact_prot_info(struct mtd_info *mtd, struct otp_info *buf, | 281 | int mtd_get_fact_prot_info(struct mtd_info *mtd, size_t len, size_t *retlen, |
282 | size_t len); | 282 | struct otp_info *buf); |
283 | int mtd_read_fact_prot_reg(struct mtd_info *mtd, loff_t from, size_t len, | 283 | int mtd_read_fact_prot_reg(struct mtd_info *mtd, loff_t from, size_t len, |
284 | size_t *retlen, u_char *buf); | 284 | size_t *retlen, u_char *buf); |
285 | int mtd_get_user_prot_info(struct mtd_info *mtd, struct otp_info *buf, | 285 | int mtd_get_user_prot_info(struct mtd_info *mtd, size_t len, size_t *retlen, |
286 | size_t len); | 286 | struct otp_info *buf); |
287 | int mtd_read_user_prot_reg(struct mtd_info *mtd, loff_t from, size_t len, | 287 | int mtd_read_user_prot_reg(struct mtd_info *mtd, loff_t from, size_t len, |
288 | size_t *retlen, u_char *buf); | 288 | size_t *retlen, u_char *buf); |
289 | int mtd_write_user_prot_reg(struct mtd_info *mtd, loff_t to, size_t len, | 289 | int mtd_write_user_prot_reg(struct mtd_info *mtd, loff_t to, size_t len, |