diff options
| author | Artem Bityutskiy <artem.bityutskiy@linux.intel.com> | 2012-02-03 06:20:43 -0500 |
|---|---|---|
| committer | David Woodhouse <David.Woodhouse@intel.com> | 2012-03-26 19:27:19 -0400 |
| commit | 5e4e6e3fdf48c1b012e2b6e80ed1d7e99d4fa6d1 (patch) | |
| tree | dade127061f6c466f4146152572cc17c05d44761 | |
| parent | e2414f4c20bd4dc62186fbfd7bdec50bce6d2ead (diff) | |
mtd: return error code from mtd_unpoint
The 'mtd_unpoint()' API function should be able to return an error code because
it may fail if you specify incorrect offset. This patch changes this MTD API
function and amends all the drivers correspondingly.
Also return '-EOPNOTSUPP' from 'mtd_unpoint()' when the '->unpoint()' method is
undefined. We do not really need this currently, but this just makes
sense to be consistent with 'mtd_point()'.
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
| -rw-r--r-- | drivers/mtd/chips/cfi_cmdset_0001.c | 16 | ||||
| -rw-r--r-- | drivers/mtd/devices/mtdram.c | 3 | ||||
| -rw-r--r-- | drivers/mtd/devices/phram.c | 3 | ||||
| -rw-r--r-- | drivers/mtd/devices/pmc551.c | 3 | ||||
| -rw-r--r-- | drivers/mtd/devices/slram.c | 5 | ||||
| -rw-r--r-- | drivers/mtd/lpddr/lpddr_cmds.c | 12 | ||||
| -rw-r--r-- | drivers/mtd/mtdpart.c | 4 | ||||
| -rw-r--r-- | include/linux/mtd/mtd.h | 6 | ||||
| -rw-r--r-- | include/linux/mtd/pmc551.h | 1 |
9 files changed, 33 insertions, 20 deletions
diff --git a/drivers/mtd/chips/cfi_cmdset_0001.c b/drivers/mtd/chips/cfi_cmdset_0001.c index 152accf4bf85..4d04551cffd7 100644 --- a/drivers/mtd/chips/cfi_cmdset_0001.c +++ b/drivers/mtd/chips/cfi_cmdset_0001.c | |||
| @@ -87,7 +87,7 @@ static int cfi_intelext_partition_fixup(struct mtd_info *, struct cfi_private ** | |||
| 87 | 87 | ||
| 88 | static int cfi_intelext_point (struct mtd_info *mtd, loff_t from, size_t len, | 88 | static int cfi_intelext_point (struct mtd_info *mtd, loff_t from, size_t len, |
| 89 | size_t *retlen, void **virt, resource_size_t *phys); | 89 | size_t *retlen, void **virt, resource_size_t *phys); |
| 90 | static void cfi_intelext_unpoint(struct mtd_info *mtd, loff_t from, size_t len); | 90 | static int cfi_intelext_unpoint(struct mtd_info *mtd, loff_t from, size_t len); |
| 91 | 91 | ||
| 92 | static int chip_ready (struct map_info *map, struct flchip *chip, unsigned long adr, int mode); | 92 | static int chip_ready (struct map_info *map, struct flchip *chip, unsigned long adr, int mode); |
| 93 | static int get_chip(struct map_info *map, struct flchip *chip, unsigned long adr, int mode); | 93 | static int get_chip(struct map_info *map, struct flchip *chip, unsigned long adr, int mode); |
| @@ -1369,12 +1369,12 @@ static int cfi_intelext_point(struct mtd_info *mtd, loff_t from, size_t len, | |||
| 1369 | return 0; | 1369 | return 0; |
| 1370 | } | 1370 | } |
| 1371 | 1371 | ||
| 1372 | static void cfi_intelext_unpoint(struct mtd_info *mtd, loff_t from, size_t len) | 1372 | static int cfi_intelext_unpoint(struct mtd_info *mtd, loff_t from, size_t len) |
| 1373 | { | 1373 | { |
| 1374 | struct map_info *map = mtd->priv; | 1374 | struct map_info *map = mtd->priv; |
| 1375 | struct cfi_private *cfi = map->fldrv_priv; | 1375 | struct cfi_private *cfi = map->fldrv_priv; |
| 1376 | unsigned long ofs; | 1376 | unsigned long ofs; |
| 1377 | int chipnum; | 1377 | int chipnum, err = 0; |
| 1378 | 1378 | ||
| 1379 | /* Now unlock the chip(s) POINT state */ | 1379 | /* Now unlock the chip(s) POINT state */ |
| 1380 | 1380 | ||
| @@ -1382,7 +1382,7 @@ static void cfi_intelext_unpoint(struct mtd_info *mtd, loff_t from, size_t len) | |||
| 1382 | chipnum = (from >> cfi->chipshift); | 1382 | chipnum = (from >> cfi->chipshift); |
| 1383 | ofs = from - (chipnum << cfi->chipshift); | 1383 | ofs = from - (chipnum << cfi->chipshift); |
| 1384 | 1384 | ||
| 1385 | while (len) { | 1385 | while (len && !err) { |
| 1386 | unsigned long thislen; | 1386 | unsigned long thislen; |
| 1387 | struct flchip *chip; | 1387 | struct flchip *chip; |
| 1388 | 1388 | ||
| @@ -1400,8 +1400,10 @@ static void cfi_intelext_unpoint(struct mtd_info *mtd, loff_t from, size_t len) | |||
| 1400 | chip->ref_point_counter--; | 1400 | chip->ref_point_counter--; |
| 1401 | if(chip->ref_point_counter == 0) | 1401 | if(chip->ref_point_counter == 0) |
| 1402 | chip->state = FL_READY; | 1402 | chip->state = FL_READY; |
| 1403 | } else | 1403 | } else { |
| 1404 | printk(KERN_ERR "%s: Warning: unpoint called on non pointed region\n", map->name); /* Should this give an error? */ | 1404 | printk(KERN_ERR "%s: Error: unpoint called on non pointed region\n", map->name); |
| 1405 | err = -EINVAL; | ||
| 1406 | } | ||
| 1405 | 1407 | ||
| 1406 | put_chip(map, chip, chip->start); | 1408 | put_chip(map, chip, chip->start); |
| 1407 | mutex_unlock(&chip->mutex); | 1409 | mutex_unlock(&chip->mutex); |
| @@ -1410,6 +1412,8 @@ static void cfi_intelext_unpoint(struct mtd_info *mtd, loff_t from, size_t len) | |||
| 1410 | ofs = 0; | 1412 | ofs = 0; |
| 1411 | chipnum++; | 1413 | chipnum++; |
| 1412 | } | 1414 | } |
| 1415 | |||
| 1416 | return err; | ||
| 1413 | } | 1417 | } |
| 1414 | 1418 | ||
| 1415 | static inline int do_read_onechip(struct map_info *map, struct flchip *chip, loff_t adr, size_t len, u_char *buf) | 1419 | static inline int do_read_onechip(struct map_info *map, struct flchip *chip, loff_t adr, size_t len, u_char *buf) |
diff --git a/drivers/mtd/devices/mtdram.c b/drivers/mtd/devices/mtdram.c index 91030cfb03b3..e1f017bf0777 100644 --- a/drivers/mtd/devices/mtdram.c +++ b/drivers/mtd/devices/mtdram.c | |||
| @@ -60,8 +60,9 @@ static int ram_point(struct mtd_info *mtd, loff_t from, size_t len, | |||
| 60 | return 0; | 60 | return 0; |
| 61 | } | 61 | } |
| 62 | 62 | ||
| 63 | static void ram_unpoint(struct mtd_info *mtd, loff_t from, size_t len) | 63 | static int ram_unpoint(struct mtd_info *mtd, loff_t from, size_t len) |
| 64 | { | 64 | { |
| 65 | return 0; | ||
| 65 | } | 66 | } |
| 66 | 67 | ||
| 67 | /* | 68 | /* |
diff --git a/drivers/mtd/devices/phram.c b/drivers/mtd/devices/phram.c index eff2b69864f5..38035551a7d2 100644 --- a/drivers/mtd/devices/phram.c +++ b/drivers/mtd/devices/phram.c | |||
| @@ -70,8 +70,9 @@ static int phram_point(struct mtd_info *mtd, loff_t from, size_t len, | |||
| 70 | return 0; | 70 | return 0; |
| 71 | } | 71 | } |
| 72 | 72 | ||
| 73 | static void phram_unpoint(struct mtd_info *mtd, loff_t from, size_t len) | 73 | static int phram_unpoint(struct mtd_info *mtd, loff_t from, size_t len) |
| 74 | { | 74 | { |
| 75 | return 0; | ||
| 75 | } | 76 | } |
| 76 | 77 | ||
| 77 | static int phram_read(struct mtd_info *mtd, loff_t from, size_t len, | 78 | static int phram_read(struct mtd_info *mtd, loff_t from, size_t len, |
diff --git a/drivers/mtd/devices/pmc551.c b/drivers/mtd/devices/pmc551.c index 67d22e1cbc0e..933127ecebe5 100644 --- a/drivers/mtd/devices/pmc551.c +++ b/drivers/mtd/devices/pmc551.c | |||
| @@ -206,11 +206,12 @@ static int pmc551_point(struct mtd_info *mtd, loff_t from, size_t len, | |||
| 206 | return 0; | 206 | return 0; |
| 207 | } | 207 | } |
| 208 | 208 | ||
| 209 | static void pmc551_unpoint(struct mtd_info *mtd, loff_t from, size_t len) | 209 | static int pmc551_unpoint(struct mtd_info *mtd, loff_t from, size_t len) |
| 210 | { | 210 | { |
| 211 | #ifdef CONFIG_MTD_PMC551_DEBUG | 211 | #ifdef CONFIG_MTD_PMC551_DEBUG |
| 212 | printk(KERN_DEBUG "pmc551_unpoint()\n"); | 212 | printk(KERN_DEBUG "pmc551_unpoint()\n"); |
| 213 | #endif | 213 | #endif |
| 214 | return 0; | ||
| 214 | } | 215 | } |
| 215 | 216 | ||
| 216 | static int pmc551_read(struct mtd_info *mtd, loff_t from, size_t len, | 217 | static int pmc551_read(struct mtd_info *mtd, loff_t from, size_t len, |
diff --git a/drivers/mtd/devices/slram.c b/drivers/mtd/devices/slram.c index cbeb19522bbc..9431ffc761c2 100644 --- a/drivers/mtd/devices/slram.c +++ b/drivers/mtd/devices/slram.c | |||
| @@ -76,7 +76,7 @@ static slram_mtd_list_t *slram_mtdlist = NULL; | |||
| 76 | static int slram_erase(struct mtd_info *, struct erase_info *); | 76 | static int slram_erase(struct mtd_info *, struct erase_info *); |
| 77 | static int slram_point(struct mtd_info *, loff_t, size_t, size_t *, void **, | 77 | static int slram_point(struct mtd_info *, loff_t, size_t, size_t *, void **, |
| 78 | resource_size_t *); | 78 | resource_size_t *); |
| 79 | static void slram_unpoint(struct mtd_info *, loff_t, size_t); | 79 | static int slram_unpoint(struct mtd_info *, loff_t, size_t); |
| 80 | static int slram_read(struct mtd_info *, loff_t, size_t, size_t *, u_char *); | 80 | static int slram_read(struct mtd_info *, loff_t, size_t, size_t *, u_char *); |
| 81 | static int slram_write(struct mtd_info *, loff_t, size_t, size_t *, const u_char *); | 81 | static int slram_write(struct mtd_info *, loff_t, size_t, size_t *, const u_char *); |
| 82 | 82 | ||
| @@ -119,8 +119,9 @@ static int slram_point(struct mtd_info *mtd, loff_t from, size_t len, | |||
| 119 | return(0); | 119 | return(0); |
| 120 | } | 120 | } |
| 121 | 121 | ||
| 122 | static void slram_unpoint(struct mtd_info *mtd, loff_t from, size_t len) | 122 | static int slram_unpoint(struct mtd_info *mtd, loff_t from, size_t len) |
| 123 | { | 123 | { |
| 124 | return 0; | ||
| 124 | } | 125 | } |
| 125 | 126 | ||
| 126 | static int slram_read(struct mtd_info *mtd, loff_t from, size_t len, | 127 | static int slram_read(struct mtd_info *mtd, loff_t from, size_t len, |
diff --git a/drivers/mtd/lpddr/lpddr_cmds.c b/drivers/mtd/lpddr/lpddr_cmds.c index fd19d3b1ee90..de960b1d395a 100644 --- a/drivers/mtd/lpddr/lpddr_cmds.c +++ b/drivers/mtd/lpddr/lpddr_cmds.c | |||
| @@ -40,7 +40,7 @@ static int lpddr_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len); | |||
| 40 | static int lpddr_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len); | 40 | static int lpddr_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len); |
| 41 | static int lpddr_point(struct mtd_info *mtd, loff_t adr, size_t len, | 41 | static int lpddr_point(struct mtd_info *mtd, loff_t adr, size_t len, |
| 42 | size_t *retlen, void **mtdbuf, resource_size_t *phys); | 42 | size_t *retlen, void **mtdbuf, resource_size_t *phys); |
| 43 | static void lpddr_unpoint(struct mtd_info *mtd, loff_t adr, size_t len); | 43 | static int lpddr_unpoint(struct mtd_info *mtd, loff_t adr, size_t len); |
| 44 | static int get_chip(struct map_info *map, struct flchip *chip, int mode); | 44 | static int get_chip(struct map_info *map, struct flchip *chip, int mode); |
| 45 | static int chip_ready(struct map_info *map, struct flchip *chip, int mode); | 45 | static int chip_ready(struct map_info *map, struct flchip *chip, int mode); |
| 46 | static void put_chip(struct map_info *map, struct flchip *chip); | 46 | static void put_chip(struct map_info *map, struct flchip *chip); |
| @@ -575,11 +575,11 @@ static int lpddr_point(struct mtd_info *mtd, loff_t adr, size_t len, | |||
| 575 | return 0; | 575 | return 0; |
| 576 | } | 576 | } |
| 577 | 577 | ||
| 578 | static void lpddr_unpoint (struct mtd_info *mtd, loff_t adr, size_t len) | 578 | static int lpddr_unpoint (struct mtd_info *mtd, loff_t adr, size_t len) |
| 579 | { | 579 | { |
| 580 | struct map_info *map = mtd->priv; | 580 | struct map_info *map = mtd->priv; |
