diff options
Diffstat (limited to 'drivers/mtd/ubi/cdev.c')
-rw-r--r-- | drivers/mtd/ubi/cdev.c | 36 |
1 files changed, 19 insertions, 17 deletions
diff --git a/drivers/mtd/ubi/cdev.c b/drivers/mtd/ubi/cdev.c index 59de69a24e40..3410ea8109f8 100644 --- a/drivers/mtd/ubi/cdev.c +++ b/drivers/mtd/ubi/cdev.c | |||
@@ -48,13 +48,14 @@ | |||
48 | 48 | ||
49 | /** | 49 | /** |
50 | * get_exclusive - get exclusive access to an UBI volume. | 50 | * get_exclusive - get exclusive access to an UBI volume. |
51 | * @ubi: UBI device description object | ||
51 | * @desc: volume descriptor | 52 | * @desc: volume descriptor |
52 | * | 53 | * |
53 | * This function changes UBI volume open mode to "exclusive". Returns previous | 54 | * This function changes UBI volume open mode to "exclusive". Returns previous |
54 | * mode value (positive integer) in case of success and a negative error code | 55 | * mode value (positive integer) in case of success and a negative error code |
55 | * in case of failure. | 56 | * in case of failure. |
56 | */ | 57 | */ |
57 | static int get_exclusive(struct ubi_volume_desc *desc) | 58 | static int get_exclusive(struct ubi_device *ubi, struct ubi_volume_desc *desc) |
58 | { | 59 | { |
59 | int users, err; | 60 | int users, err; |
60 | struct ubi_volume *vol = desc->vol; | 61 | struct ubi_volume *vol = desc->vol; |
@@ -63,7 +64,7 @@ static int get_exclusive(struct ubi_volume_desc *desc) | |||
63 | users = vol->readers + vol->writers + vol->exclusive; | 64 | users = vol->readers + vol->writers + vol->exclusive; |
64 | ubi_assert(users > 0); | 65 | ubi_assert(users > 0); |
65 | if (users > 1) { | 66 | if (users > 1) { |
66 | ubi_err("%d users for volume %d", users, vol->vol_id); | 67 | ubi_err(ubi, "%d users for volume %d", users, vol->vol_id); |
67 | err = -EBUSY; | 68 | err = -EBUSY; |
68 | } else { | 69 | } else { |
69 | vol->readers = vol->writers = 0; | 70 | vol->readers = vol->writers = 0; |
@@ -134,7 +135,7 @@ static int vol_cdev_release(struct inode *inode, struct file *file) | |||
134 | vol->ubi->ubi_num, vol->vol_id, desc->mode); | 135 | vol->ubi->ubi_num, vol->vol_id, desc->mode); |
135 | 136 | ||
136 | if (vol->updating) { | 137 | if (vol->updating) { |
137 | ubi_warn("update of volume %d not finished, volume is damaged", | 138 | ubi_warn(vol->ubi, "update of volume %d not finished, volume is damaged", |
138 | vol->vol_id); | 139 | vol->vol_id); |
139 | ubi_assert(!vol->changing_leb); | 140 | ubi_assert(!vol->changing_leb); |
140 | vol->updating = 0; | 141 | vol->updating = 0; |
@@ -158,7 +159,7 @@ static loff_t vol_cdev_llseek(struct file *file, loff_t offset, int origin) | |||
158 | 159 | ||
159 | if (vol->updating) { | 160 | if (vol->updating) { |
160 | /* Update is in progress, seeking is prohibited */ | 161 | /* Update is in progress, seeking is prohibited */ |
161 | ubi_err("updating"); | 162 | ubi_err(vol->ubi, "updating"); |
162 | return -EBUSY; | 163 | return -EBUSY; |
163 | } | 164 | } |
164 | 165 | ||
@@ -193,11 +194,11 @@ static ssize_t vol_cdev_read(struct file *file, __user char *buf, size_t count, | |||
193 | count, *offp, vol->vol_id); | 194 | count, *offp, vol->vol_id); |
194 | 195 | ||
195 | if (vol->updating) { | 196 | if (vol->updating) { |
196 | ubi_err("updating"); | 197 | ubi_err(vol->ubi, "updating"); |
197 | return -EBUSY; | 198 | return -EBUSY; |
198 | } | 199 | } |
199 | if (vol->upd_marker) { | 200 | if (vol->upd_marker) { |
200 | ubi_err("damaged volume, update marker is set"); | 201 | ubi_err(vol->ubi, "damaged volume, update marker is set"); |
201 | return -EBADF; | 202 | return -EBADF; |
202 | } | 203 | } |
203 | if (*offp == vol->used_bytes || count == 0) | 204 | if (*offp == vol->used_bytes || count == 0) |
@@ -277,7 +278,7 @@ static ssize_t vol_cdev_direct_write(struct file *file, const char __user *buf, | |||
277 | 278 | ||
278 | lnum = div_u64_rem(*offp, vol->usable_leb_size, &off); | 279 | lnum = div_u64_rem(*offp, vol->usable_leb_size, &off); |
279 | if (off & (ubi->min_io_size - 1)) { | 280 | if (off & (ubi->min_io_size - 1)) { |
280 | ubi_err("unaligned position"); | 281 | ubi_err(ubi, "unaligned position"); |
281 | return -EINVAL; | 282 | return -EINVAL; |
282 | } | 283 | } |
283 | 284 | ||
@@ -286,7 +287,7 @@ static ssize_t vol_cdev_direct_write(struct file *file, const char __user *buf, | |||
286 | 287 | ||
287 | /* We can write only in fractions of the minimum I/O unit */ | 288 | /* We can write only in fractions of the minimum I/O unit */ |
288 | if (count & (ubi->min_io_size - 1)) { | 289 | if (count & (ubi->min_io_size - 1)) { |
289 | ubi_err("unaligned write length"); | 290 | ubi_err(ubi, "unaligned write length"); |
290 | return -EINVAL; | 291 | return -EINVAL; |
291 | } | 292 | } |
292 | 293 | ||
@@ -348,7 +349,7 @@ static ssize_t vol_cdev_write(struct file *file, const char __user *buf, | |||
348 | err = ubi_more_leb_change_data(ubi, vol, buf, count); | 349 | err = ubi_more_leb_change_data(ubi, vol, buf, count); |
349 | 350 | ||
350 | if (err < 0) { | 351 | if (err < 0) { |
351 | ubi_err("cannot accept more %zd bytes of data, error %d", | 352 | ubi_err(ubi, "cannot accept more %zd bytes of data, error %d", |
352 | count, err); | 353 | count, err); |
353 | return err; | 354 | return err; |
354 | } | 355 | } |
@@ -370,7 +371,7 @@ static ssize_t vol_cdev_write(struct file *file, const char __user *buf, | |||
370 | return err; | 371 | return err; |
371 | 372 | ||
372 | if (err) { | 373 | if (err) { |
373 | ubi_warn("volume %d on UBI device %d is corrupted", | 374 | ubi_warn(ubi, "volume %d on UBI device %d is corrupted", |
374 | vol->vol_id, ubi->ubi_num); | 375 | vol->vol_id, ubi->ubi_num); |
375 | vol->corrupted = 1; | 376 | vol->corrupted = 1; |
376 | } | 377 | } |
@@ -420,7 +421,7 @@ static long vol_cdev_ioctl(struct file *file, unsigned int cmd, | |||
420 | break; | 421 | break; |
421 | } | 422 | } |
422 | 423 | ||
423 | err = get_exclusive(desc); | 424 | err = get_exclusive(ubi, desc); |
424 | if (err < 0) | 425 | if (err < 0) |
425 | break; | 426 | break; |
426 | 427 | ||
@@ -456,7 +457,7 @@ static long vol_cdev_ioctl(struct file *file, unsigned int cmd, | |||
456 | req.bytes < 0 || req.lnum >= vol->usable_leb_size) | 457 | req.bytes < 0 || req.lnum >= vol->usable_leb_size) |
457 | break; | 458 | break; |
458 | 459 | ||
459 | err = get_exclusive(desc); | 460 | err = get_exclusive(ubi, desc); |
460 | if (err < 0) | 461 | if (err < 0) |
461 | break; | 462 | break; |
462 | 463 | ||
@@ -642,7 +643,7 @@ static int verify_mkvol_req(const struct ubi_device *ubi, | |||
642 | return 0; | 643 | return 0; |
643 | 644 | ||
644 | bad: | 645 | bad: |
645 | ubi_err("bad volume creation request"); | 646 | ubi_err(ubi, "bad volume creation request"); |
646 | ubi_dump_mkvol_req(req); | 647 | ubi_dump_mkvol_req(req); |
647 | return err; | 648 | return err; |
648 | } | 649 | } |
@@ -708,12 +709,12 @@ static int rename_volumes(struct ubi_device *ubi, | |||
708 | for (i = 0; i < req->count - 1; i++) { | 709 | for (i = 0; i < req->count - 1; i++) { |
709 | for (n = i + 1; n < req->count; n++) { | 710 | for (n = i + 1; n < req->count; n++) { |
710 | if (req->ents[i].vol_id == req->ents[n].vol_id) { | 711 | if (req->ents[i].vol_id == req->ents[n].vol_id) { |
711 | ubi_err("duplicated volume id %d", | 712 | ubi_err(ubi, "duplicated volume id %d", |
712 | req->ents[i].vol_id); | 713 | req->ents[i].vol_id); |
713 | return -EINVAL; | 714 | return -EINVAL; |
714 | } | 715 | } |
715 | if (!strcmp(req->ents[i].name, req->ents[n].name)) { | 716 | if (!strcmp(req->ents[i].name, req->ents[n].name)) { |
716 | ubi_err("duplicated volume name \"%s\"", | 717 | ubi_err(ubi, "duplicated volume name \"%s\"", |
717 | req->ents[i].name); | 718 | req->ents[i].name); |
718 | return -EINVAL; | 719 | return -EINVAL; |
719 | } | 720 | } |
@@ -736,7 +737,8 @@ static int rename_volumes(struct ubi_device *ubi, | |||
736 | re->desc = ubi_open_volume(ubi->ubi_num, vol_id, UBI_READWRITE); | 737 | re->desc = ubi_open_volume(ubi->ubi_num, vol_id, UBI_READWRITE); |
737 | if (IS_ERR(re->desc)) { | 738 | if (IS_ERR(re->desc)) { |
738 | err = PTR_ERR(re->desc); | 739 | err = PTR_ERR(re->desc); |
739 | ubi_err("cannot open volume %d, error %d", vol_id, err); | 740 | ubi_err(ubi, "cannot open volume %d, error %d", |
741 | vol_id, err); | ||
740 | kfree(re); | 742 | kfree(re); |
741 | goto out_free; | 743 | goto out_free; |
742 | } | 744 | } |
@@ -795,7 +797,7 @@ static int rename_volumes(struct ubi_device *ubi, | |||
795 | continue; | 797 | continue; |
796 | 798 | ||
797 | /* The volume exists but busy, or an error occurred */ | 799 | /* The volume exists but busy, or an error occurred */ |
798 | ubi_err("cannot open volume \"%s\", error %d", | 800 | ubi_err(ubi, "cannot open volume \"%s\", error %d", |
799 | re->new_name, err); | 801 | re->new_name, err); |
800 | goto out_free; | 802 | goto out_free; |
801 | } | 803 | } |