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/mtdconcat.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/mtdconcat.c')
-rw-r--r-- | drivers/mtd/mtdconcat.c | 27 |
1 files changed, 3 insertions, 24 deletions
diff --git a/drivers/mtd/mtdconcat.c b/drivers/mtd/mtdconcat.c index 1f2071803931..dd24232265e6 100644 --- a/drivers/mtd/mtdconcat.c +++ b/drivers/mtd/mtdconcat.c | |||
@@ -126,9 +126,6 @@ concat_write(struct mtd_info *mtd, loff_t to, size_t len, | |||
126 | int err = -EINVAL; | 126 | int err = -EINVAL; |
127 | int i; | 127 | int i; |
128 | 128 | ||
129 | if (!(mtd->flags & MTD_WRITEABLE)) | ||
130 | return -EROFS; | ||
131 | |||
132 | *retlen = 0; | 129 | *retlen = 0; |
133 | 130 | ||
134 | for (i = 0; i < concat->num_subdev; i++) { | 131 | for (i = 0; i < concat->num_subdev; i++) { |
@@ -145,11 +142,7 @@ concat_write(struct mtd_info *mtd, loff_t to, size_t len, | |||
145 | else | 142 | else |
146 | size = len; | 143 | size = len; |
147 | 144 | ||
148 | if (!(subdev->flags & MTD_WRITEABLE)) | 145 | err = mtd_write(subdev, to, size, &retsize, buf); |
149 | err = -EROFS; | ||
150 | else | ||
151 | err = mtd_write(subdev, to, size, &retsize, buf); | ||
152 | |||
153 | if (err) | 146 | if (err) |
154 | break; | 147 | break; |
155 | 148 | ||
@@ -176,9 +169,6 @@ concat_writev(struct mtd_info *mtd, const struct kvec *vecs, | |||
176 | int i; | 169 | int i; |
177 | int err = -EINVAL; | 170 | int err = -EINVAL; |
178 | 171 | ||
179 | if (!(mtd->flags & MTD_WRITEABLE)) | ||
180 | return -EROFS; | ||
181 | |||
182 | *retlen = 0; | 172 | *retlen = 0; |
183 | 173 | ||
184 | /* Calculate total length of data */ | 174 | /* Calculate total length of data */ |
@@ -220,12 +210,8 @@ concat_writev(struct mtd_info *mtd, const struct kvec *vecs, | |||
220 | old_iov_len = vecs_copy[entry_high].iov_len; | 210 | old_iov_len = vecs_copy[entry_high].iov_len; |
221 | vecs_copy[entry_high].iov_len = size; | 211 | vecs_copy[entry_high].iov_len = size; |
222 | 212 | ||
223 | if (!(subdev->flags & MTD_WRITEABLE)) | 213 | err = mtd_writev(subdev, &vecs_copy[entry_low], |
224 | err = -EROFS; | 214 | entry_high - entry_low + 1, to, &retsize); |
225 | else | ||
226 | err = mtd_writev(subdev, &vecs_copy[entry_low], | ||
227 | entry_high - entry_low + 1, to, | ||
228 | &retsize); | ||
229 | 215 | ||
230 | vecs_copy[entry_high].iov_len = old_iov_len - size; | 216 | vecs_copy[entry_high].iov_len = old_iov_len - size; |
231 | vecs_copy[entry_high].iov_base += size; | 217 | vecs_copy[entry_high].iov_base += size; |
@@ -399,9 +385,6 @@ static int concat_erase(struct mtd_info *mtd, struct erase_info *instr) | |||
399 | uint64_t length, offset = 0; | 385 | uint64_t length, offset = 0; |
400 | struct erase_info *erase; | 386 | struct erase_info *erase; |
401 | 387 | ||
402 | if (!(mtd->flags & MTD_WRITEABLE)) | ||
403 | return -EROFS; | ||
404 | |||
405 | /* | 388 | /* |
406 | * Check for proper erase block alignment of the to-be-erased area. | 389 | * Check for proper erase block alignment of the to-be-erased area. |
407 | * It is easier to do this based on the super device's erase | 390 | * It is easier to do this based on the super device's erase |
@@ -489,10 +472,6 @@ static int concat_erase(struct mtd_info *mtd, struct erase_info *instr) | |||
489 | else | 472 | else |
490 | erase->len = length; | 473 | erase->len = length; |
491 | 474 | ||
492 | if (!(subdev->flags & MTD_WRITEABLE)) { | ||
493 | err = -EROFS; | ||
494 | break; | ||
495 | } | ||
496 | length -= erase->len; | 475 | length -= erase->len; |
497 | if ((err = concat_dev_erase(subdev, erase))) { | 476 | if ((err = concat_dev_erase(subdev, erase))) { |
498 | /* sanity check: should never happen since | 477 | /* sanity check: should never happen since |