aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/devices/phram.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mtd/devices/phram.c')
-rw-r--r--drivers/mtd/devices/phram.c23
1 files changed, 0 insertions, 23 deletions
diff --git a/drivers/mtd/devices/phram.c b/drivers/mtd/devices/phram.c
index 38035551a7d2..36add7ce4632 100644
--- a/drivers/mtd/devices/phram.c
+++ b/drivers/mtd/devices/phram.c
@@ -38,29 +38,20 @@ static int phram_erase(struct mtd_info *mtd, struct erase_info *instr)
38{ 38{
39 u_char *start = mtd->priv; 39 u_char *start = mtd->priv;
40 40
41 if (instr->addr + instr->len > mtd->size)
42 return -EINVAL;
43
44 memset(start + instr->addr, 0xff, instr->len); 41 memset(start + instr->addr, 0xff, instr->len);
45 42
46 /* This'll catch a few races. Free the thing before returning :) 43 /* This'll catch a few races. Free the thing before returning :)
47 * I don't feel at all ashamed. This kind of thing is possible anyway 44 * I don't feel at all ashamed. This kind of thing is possible anyway
48 * with flash, but unlikely. 45 * with flash, but unlikely.
49 */ 46 */
50
51 instr->state = MTD_ERASE_DONE; 47 instr->state = MTD_ERASE_DONE;
52
53 mtd_erase_callback(instr); 48 mtd_erase_callback(instr);
54
55 return 0; 49 return 0;
56} 50}
57 51
58static int phram_point(struct mtd_info *mtd, loff_t from, size_t len, 52static int phram_point(struct mtd_info *mtd, loff_t from, size_t len,
59 size_t *retlen, void **virt, resource_size_t *phys) 53 size_t *retlen, void **virt, resource_size_t *phys)
60{ 54{
61 if (from + len > mtd->size)
62 return -EINVAL;
63
64 /* can we return a physical address with this driver? */ 55 /* can we return a physical address with this driver? */
65 if (phys) 56 if (phys)
66 return -EINVAL; 57 return -EINVAL;
@@ -80,14 +71,7 @@ static int phram_read(struct mtd_info *mtd, loff_t from, size_t len,
80{ 71{
81 u_char *start = mtd->priv; 72 u_char *start = mtd->priv;
82 73
83 if (from >= mtd->size)
84 return -EINVAL;
85
86 if (len > mtd->size - from)
87 len = mtd->size - from;
88
89 memcpy(buf, start + from, len); 74 memcpy(buf, start + from, len);
90
91 *retlen = len; 75 *retlen = len;
92 return 0; 76 return 0;
93} 77}
@@ -97,14 +81,7 @@ static int phram_write(struct mtd_info *mtd, loff_t to, size_t len,
97{ 81{
98 u_char *start = mtd->priv; 82 u_char *start = mtd->priv;
99 83
100 if (to >= mtd->size)
101 return -EINVAL;
102
103 if (len > mtd->size - to)
104 len = mtd->size - to;
105
106 memcpy(start + to, buf, len); 84 memcpy(start + to, buf, len);
107
108 *retlen = len; 85 *retlen = len;
109 return 0; 86 return 0;
110} 87}