aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/chips
diff options
context:
space:
mode:
authorArtem Bityutskiy <artem.bityutskiy@linux.intel.com>2012-02-03 06:20:43 -0500
committerDavid Woodhouse <David.Woodhouse@intel.com>2012-03-26 19:27:19 -0400
commit5e4e6e3fdf48c1b012e2b6e80ed1d7e99d4fa6d1 (patch)
treedade127061f6c466f4146152572cc17c05d44761 /drivers/mtd/chips
parente2414f4c20bd4dc62186fbfd7bdec50bce6d2ead (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>
Diffstat (limited to 'drivers/mtd/chips')
-rw-r--r--drivers/mtd/chips/cfi_cmdset_0001.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/drivers/mtd/chips/cfi_cmdset_0001.c b/drivers/mtd/chips/cfi_cmdset_0001.c
index 152accf4bf8..4d04551cffd 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
88static int cfi_intelext_point (struct mtd_info *mtd, loff_t from, size_t len, 88static 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);
90static void cfi_intelext_unpoint(struct mtd_info *mtd, loff_t from, size_t len); 90static int cfi_intelext_unpoint(struct mtd_info *mtd, loff_t from, size_t len);
91 91
92static int chip_ready (struct map_info *map, struct flchip *chip, unsigned long adr, int mode); 92static int chip_ready (struct map_info *map, struct flchip *chip, unsigned long adr, int mode);
93static int get_chip(struct map_info *map, struct flchip *chip, unsigned long adr, int mode); 93static 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
1372static void cfi_intelext_unpoint(struct mtd_info *mtd, loff_t from, size_t len) 1372static 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
1415static inline int do_read_onechip(struct map_info *map, struct flchip *chip, loff_t adr, size_t len, u_char *buf) 1419static inline int do_read_onechip(struct map_info *map, struct flchip *chip, loff_t adr, size_t len, u_char *buf)