aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
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
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')
-rw-r--r--drivers/mtd/chips/cfi_cmdset_0001.c16
-rw-r--r--drivers/mtd/devices/mtdram.c3
-rw-r--r--drivers/mtd/devices/phram.c3
-rw-r--r--drivers/mtd/devices/pmc551.c3
-rw-r--r--drivers/mtd/devices/slram.c5
-rw-r--r--drivers/mtd/lpddr/lpddr_cmds.c12
-rw-r--r--drivers/mtd/mtdpart.c4
7 files changed, 29 insertions, 17 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)
diff --git a/drivers/mtd/devices/mtdram.c b/drivers/mtd/devices/mtdram.c
index 91030cfb03b..e1f017bf077 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
63static void ram_unpoint(struct mtd_info *mtd, loff_t from, size_t len) 63static 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 eff2b69864f..38035551a7d 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
73static void phram_unpoint(struct mtd_info *mtd, loff_t from, size_t len) 73static int phram_unpoint(struct mtd_info *mtd, loff_t from, size_t len)
74{ 74{
75 return 0;
75} 76}
76 77
77static int phram_read(struct mtd_info *mtd, loff_t from, size_t len, 78static 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 67d22e1cbc0..933127ecebe 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
209static void pmc551_unpoint(struct mtd_info *mtd, loff_t from, size_t len) 209static 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
216static int pmc551_read(struct mtd_info *mtd, loff_t from, size_t len, 217static 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 cbeb19522bb..9431ffc761c 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;
76static int slram_erase(struct mtd_info *, struct erase_info *); 76static int slram_erase(struct mtd_info *, struct erase_info *);
77static int slram_point(struct mtd_info *, loff_t, size_t, size_t *, void **, 77static int slram_point(struct mtd_info *, loff_t, size_t, size_t *, void **,
78 resource_size_t *); 78 resource_size_t *);
79static void slram_unpoint(struct mtd_info *, loff_t, size_t); 79static int slram_unpoint(struct mtd_info *, loff_t, size_t);
80static int slram_read(struct mtd_info *, loff_t, size_t, size_t *, u_char *); 80static int slram_read(struct mtd_info *, loff_t, size_t, size_t *, u_char *);
81static int slram_write(struct mtd_info *, loff_t, size_t, size_t *, const u_char *); 81static 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
122static void slram_unpoint(struct mtd_info *mtd, loff_t from, size_t len) 122static int slram_unpoint(struct mtd_info *mtd, loff_t from, size_t len)
123{ 123{
124 return 0;
124} 125}
125 126
126static int slram_read(struct mtd_info *mtd, loff_t from, size_t len, 127static 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 fd19d3b1ee9..de960b1d395 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);
40static int lpddr_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len); 40static int lpddr_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len);
41static int lpddr_point(struct mtd_info *mtd, loff_t adr, size_t len, 41static 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);
43static void lpddr_unpoint(struct mtd_info *mtd, loff_t adr, size_t len); 43static int lpddr_unpoint(struct mtd_info *mtd, loff_t adr, size_t len);
44static int get_chip(struct map_info *map, struct flchip *chip, int mode); 44static int get_chip(struct map_info *map, struct flchip *chip, int mode);
45static int chip_ready(struct map_info *map, struct flchip *chip, int mode); 45static int chip_ready(struct map_info *map, struct flchip *chip, int mode);
46static void put_chip(struct map_info *map, struct flchip *chip); 46static 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
578static void lpddr_unpoint (struct mtd_info *mtd, loff_t adr, size_t len) 578static 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;
581 struct lpddr_private *lpddr = map->fldrv_priv; 581 struct lpddr_private *lpddr = map->fldrv_priv;
582 int chipnum = adr >> lpddr->chipshift; 582 int chipnum = adr >> lpddr->chipshift, err = 0;
583 unsigned long ofs; 583 unsigned long ofs;
584 584
585 /* ofs: offset within the first chip that the first read should start */ 585 /* ofs: offset within the first chip that the first read should start */
@@ -603,9 +603,11 @@ static void lpddr_unpoint (struct mtd_info *mtd, loff_t adr, size_t len)
603 chip->ref_point_counter--; 603 chip->ref_point_counter--;
604 if (chip->ref_point_counter == 0) 604 if (chip->ref_point_counter == 0)
605 chip->state = FL_READY; 605 chip->state = FL_READY;
606 } else 606 } else {
607 printk(KERN_WARNING "%s: Warning: unpoint called on non" 607 printk(KERN_WARNING "%s: Warning: unpoint called on non"
608 "pointed region\n", map->name); 608 "pointed region\n", map->name);
609 err = -EINVAL;
610 }
609 611
610 put_chip(map, chip); 612 put_chip(map, chip);
611 mutex_unlock(&chip->mutex); 613 mutex_unlock(&chip->mutex);
@@ -614,6 +616,8 @@ static void lpddr_unpoint (struct mtd_info *mtd, loff_t adr, size_t len)
614 ofs = 0; 616 ofs = 0;
615 chipnum++; 617 chipnum++;
616 } 618 }
619
620 return err;
617} 621}
618 622
619static int lpddr_write_buffers(struct mtd_info *mtd, loff_t to, size_t len, 623static int lpddr_write_buffers(struct mtd_info *mtd, loff_t to, size_t len,
diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c
index 4f01079e357..da8a0b28316 100644
--- a/drivers/mtd/mtdpart.c
+++ b/drivers/mtd/mtdpart.c
@@ -92,11 +92,11 @@ static int part_point(struct mtd_info *mtd, loff_t from, size_t len,
92 virt, phys); 92 virt, phys);
93} 93}
94 94
95static void part_unpoint(struct mtd_info *mtd, loff_t from, size_t len) 95static int part_unpoint(struct mtd_info *mtd, loff_t from, size_t len)
96{ 96{
97 struct mtd_part *part = PART(mtd); 97 struct mtd_part *part = PART(mtd);
98 98
99 mtd_unpoint(part->master, from + part->offset, len); 99 return mtd_unpoint(part->master, from + part->offset, len);
100} 100}
101 101
102static unsigned long part_get_unmapped_area(struct mtd_info *mtd, 102static unsigned long part_get_unmapped_area(struct mtd_info *mtd,