aboutsummaryrefslogtreecommitdiffstats
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
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>
-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
-rw-r--r--include/linux/mtd/mtd.h6
-rw-r--r--include/linux/mtd/pmc551.h1
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
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 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
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 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
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 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
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 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;
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 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);
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 4f01079e357f..da8a0b28316c 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,
diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
index e2e545616b2a..8c243117c087 100644
--- a/include/linux/mtd/mtd.h
+++ b/include/linux/mtd/mtd.h
@@ -177,7 +177,7 @@ struct mtd_info {
177 int (*_erase) (struct mtd_info *mtd, struct erase_info *instr); 177 int (*_erase) (struct mtd_info *mtd, struct erase_info *instr);
178 int (*_point) (struct mtd_info *mtd, loff_t from, size_t len, 178 int (*_point) (struct mtd_info *mtd, loff_t from, size_t len,
179 size_t *retlen, void **virt, resource_size_t *phys); 179 size_t *retlen, void **virt, resource_size_t *phys);
180 void (*_unpoint) (struct mtd_info *mtd, loff_t from, size_t len); 180 int (*_unpoint) (struct mtd_info *mtd, loff_t from, size_t len);
181 unsigned long (*_get_unmapped_area) (struct mtd_info *mtd, 181 unsigned long (*_get_unmapped_area) (struct mtd_info *mtd,
182 unsigned long len, 182 unsigned long len,
183 unsigned long offset, 183 unsigned long offset,
@@ -265,8 +265,10 @@ static inline int mtd_point(struct mtd_info *mtd, loff_t from, size_t len,
265} 265}
266 266
267/* We probably shouldn't allow XIP if the unpoint isn't a NULL */ 267/* We probably shouldn't allow XIP if the unpoint isn't a NULL */
268static inline void mtd_unpoint(struct mtd_info *mtd, loff_t from, size_t len) 268static inline int mtd_unpoint(struct mtd_info *mtd, loff_t from, size_t len)
269{ 269{
270 if (!mtd->_point)
271 return -EOPNOTSUPP;
270 return mtd->_unpoint(mtd, from, len); 272 return mtd->_unpoint(mtd, from, len);
271} 273}
272 274
diff --git a/include/linux/mtd/pmc551.h b/include/linux/mtd/pmc551.h
index 27ad40aed19f..da8b98d1b330 100644
--- a/include/linux/mtd/pmc551.h
+++ b/include/linux/mtd/pmc551.h
@@ -34,7 +34,6 @@ struct mypriv {
34 * Function Prototypes 34 * Function Prototypes
35 */ 35 */
36static int pmc551_erase(struct mtd_info *, struct erase_info *); 36static int pmc551_erase(struct mtd_info *, struct erase_info *);
37static void pmc551_unpoint(struct mtd_info *, loff_t, size_t);
38static int pmc551_point(struct mtd_info *mtd, loff_t from, size_t len, 37static int pmc551_point(struct mtd_info *mtd, loff_t from, size_t len,
39 size_t *retlen, void **virt, resource_size_t *phys); 38 size_t *retlen, void **virt, resource_size_t *phys);
40static int pmc551_read(struct mtd_info *, loff_t, size_t, size_t *, u_char *); 39static int pmc551_read(struct mtd_info *, loff_t, size_t, size_t *, u_char *);