aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/devices/slram.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mtd/devices/slram.c')
-rw-r--r--drivers/mtd/devices/slram.c23
1 files changed, 0 insertions, 23 deletions
diff --git a/drivers/mtd/devices/slram.c b/drivers/mtd/devices/slram.c
index 9431ffc761c2..842e4890d771 100644
--- a/drivers/mtd/devices/slram.c
+++ b/drivers/mtd/devices/slram.c
@@ -84,21 +84,13 @@ static int slram_erase(struct mtd_info *mtd, struct erase_info *instr)
84{ 84{
85 slram_priv_t *priv = mtd->priv; 85 slram_priv_t *priv = mtd->priv;
86 86
87 if (instr->addr + instr->len > mtd->size) {
88 return(-EINVAL);
89 }
90
91 memset(priv->start + instr->addr, 0xff, instr->len); 87 memset(priv->start + instr->addr, 0xff, instr->len);
92
93 /* This'll catch a few races. Free the thing before returning :) 88 /* This'll catch a few races. Free the thing before returning :)
94 * I don't feel at all ashamed. This kind of thing is possible anyway 89 * I don't feel at all ashamed. This kind of thing is possible anyway
95 * with flash, but unlikely. 90 * with flash, but unlikely.
96 */ 91 */
97
98 instr->state = MTD_ERASE_DONE; 92 instr->state = MTD_ERASE_DONE;
99
100 mtd_erase_callback(instr); 93 mtd_erase_callback(instr);
101
102 return(0); 94 return(0);
103} 95}
104 96
@@ -110,10 +102,6 @@ static int slram_point(struct mtd_info *mtd, loff_t from, size_t len,
110 /* can we return a physical address with this driver? */ 102 /* can we return a physical address with this driver? */
111 if (phys) 103 if (phys)
112 return -EINVAL; 104 return -EINVAL;
113
114 if (from + len > mtd->size)
115 return -EINVAL;
116
117 *virt = priv->start + from; 105 *virt = priv->start + from;
118 *retlen = len; 106 *retlen = len;
119 return(0); 107 return(0);
@@ -129,14 +117,7 @@ static int slram_read(struct mtd_info *mtd, loff_t from, size_t len,
129{ 117{
130 slram_priv_t *priv = mtd->priv; 118 slram_priv_t *priv = mtd->priv;
131 119
132 if (from > mtd->size)
133 return -EINVAL;
134
135 if (from + len > mtd->size)
136 len = mtd->size - from;
137
138 memcpy(buf, priv->start + from, len); 120 memcpy(buf, priv->start + from, len);
139
140 *retlen = len; 121 *retlen = len;
141 return(0); 122 return(0);
142} 123}
@@ -146,11 +127,7 @@ static int slram_write(struct mtd_info *mtd, loff_t to, size_t len,
146{ 127{
147 slram_priv_t *priv = mtd->priv; 128 slram_priv_t *priv = mtd->priv;
148 129
149 if (to + len > mtd->size)
150 return -EINVAL;
151
152 memcpy(priv->start + to, buf, len); 130 memcpy(priv->start + to, buf, len);
153
154 *retlen = len; 131 *retlen = len;
155 return(0); 132 return(0);
156} 133}