diff options
author | Artem Bityutskiy <artem.bityutskiy@linux.intel.com> | 2012-02-03 11:13:23 -0500 |
---|---|---|
committer | David Woodhouse <David.Woodhouse@intel.com> | 2012-03-26 19:29:11 -0400 |
commit | 664addc248d2fed68d013d26ff2fc796d7134259 (patch) | |
tree | 197681f173c14068a8d634c9ab1c889fd02316cf /drivers/mtd/mtdpart.c | |
parent | 5def48982b778aaebe201f85af7170b7d0a6619f (diff) |
mtd: remove R/O checking duplication
Many drivers check whether the partition is R/O and return -EROFS if yes.
Let's stop having duplicated checks and move them to the API functions
instead.
And again a bit of noise - deleted few too sparse newlines, sorry.
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'drivers/mtd/mtdpart.c')
-rw-r--r-- | drivers/mtd/mtdpart.c | 14 |
1 files changed, 1 insertions, 13 deletions
diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c index fbe2c8a22e1c..33d32c6f4f58 100644 --- a/drivers/mtd/mtdpart.c +++ b/drivers/mtd/mtdpart.c | |||
@@ -172,8 +172,6 @@ static int part_write(struct mtd_info *mtd, loff_t to, size_t len, | |||
172 | size_t *retlen, const u_char *buf) | 172 | size_t *retlen, const u_char *buf) |
173 | { | 173 | { |
174 | struct mtd_part *part = PART(mtd); | 174 | struct mtd_part *part = PART(mtd); |
175 | if (!(mtd->flags & MTD_WRITEABLE)) | ||
176 | return -EROFS; | ||
177 | return mtd_write(part->master, to + part->offset, len, retlen, buf); | 175 | return mtd_write(part->master, to + part->offset, len, retlen, buf); |
178 | } | 176 | } |
179 | 177 | ||
@@ -181,8 +179,6 @@ static int part_panic_write(struct mtd_info *mtd, loff_t to, size_t len, | |||
181 | size_t *retlen, const u_char *buf) | 179 | size_t *retlen, const u_char *buf) |
182 | { | 180 | { |
183 | struct mtd_part *part = PART(mtd); | 181 | struct mtd_part *part = PART(mtd); |
184 | if (!(mtd->flags & MTD_WRITEABLE)) | ||
185 | return -EROFS; | ||
186 | return mtd_panic_write(part->master, to + part->offset, len, retlen, | 182 | return mtd_panic_write(part->master, to + part->offset, len, retlen, |
187 | buf); | 183 | buf); |
188 | } | 184 | } |
@@ -192,9 +188,6 @@ static int part_write_oob(struct mtd_info *mtd, loff_t to, | |||
192 | { | 188 | { |
193 | struct mtd_part *part = PART(mtd); | 189 | struct mtd_part *part = PART(mtd); |
194 | 190 | ||
195 | if (!(mtd->flags & MTD_WRITEABLE)) | ||
196 | return -EROFS; | ||
197 | |||
198 | if (to >= mtd->size) | 191 | if (to >= mtd->size) |
199 | return -EINVAL; | 192 | return -EINVAL; |
200 | if (ops->datbuf && to + ops->len > mtd->size) | 193 | if (ops->datbuf && to + ops->len > mtd->size) |
@@ -220,8 +213,6 @@ static int part_writev(struct mtd_info *mtd, const struct kvec *vecs, | |||
220 | unsigned long count, loff_t to, size_t *retlen) | 213 | unsigned long count, loff_t to, size_t *retlen) |
221 | { | 214 | { |
222 | struct mtd_part *part = PART(mtd); | 215 | struct mtd_part *part = PART(mtd); |
223 | if (!(mtd->flags & MTD_WRITEABLE)) | ||
224 | return -EROFS; | ||
225 | return mtd_writev(part->master, vecs, count, to + part->offset, | 216 | return mtd_writev(part->master, vecs, count, to + part->offset, |
226 | retlen); | 217 | retlen); |
227 | } | 218 | } |
@@ -230,8 +221,7 @@ static int part_erase(struct mtd_info *mtd, struct erase_info *instr) | |||
230 | { | 221 | { |
231 | struct mtd_part *part = PART(mtd); | 222 | struct mtd_part *part = PART(mtd); |
232 | int ret; | 223 | int ret; |
233 | if (!(mtd->flags & MTD_WRITEABLE)) | 224 | |
234 | return -EROFS; | ||
235 | instr->addr += part->offset; | 225 | instr->addr += part->offset; |
236 | ret = mtd_erase(part->master, instr); | 226 | ret = mtd_erase(part->master, instr); |
237 | if (ret) { | 227 | if (ret) { |
@@ -304,8 +294,6 @@ static int part_block_markbad(struct mtd_info *mtd, loff_t ofs) | |||
304 | struct mtd_part *part = PART(mtd); | 294 | struct mtd_part *part = PART(mtd); |
305 | int res; | 295 | int res; |
306 | 296 | ||
307 | if (!(mtd->flags & MTD_WRITEABLE)) | ||
308 | return -EROFS; | ||
309 | ofs += part->offset; | 297 | ofs += part->offset; |
310 | res = mtd_block_markbad(part->master, ofs); | 298 | res = mtd_block_markbad(part->master, ofs); |
311 | if (!res) | 299 | if (!res) |