Commit 01f7b309 authored by Artem Bityutskiy's avatar Artem Bityutskiy

UBI: improve error messages

Always print error code with error messages, sometimes it is
extremely helpful info.
Signed-off-by: default avatarArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
parent 49dfc299
...@@ -211,7 +211,8 @@ out_eraseblock_size: ...@@ -211,7 +211,8 @@ out_eraseblock_size:
out_unregister: out_unregister:
device_unregister(&ubi->dev); device_unregister(&ubi->dev);
out: out:
ubi_err("failed to initialize sysfs for %s", ubi->ubi_name); ubi_err("failed to initialize sysfs for %s, error %d",
ubi->ubi_name, err);
return err; return err;
} }
...@@ -285,7 +286,7 @@ static int uif_init(struct ubi_device *ubi) ...@@ -285,7 +286,7 @@ static int uif_init(struct ubi_device *ubi)
err = cdev_add(&ubi->cdev, dev, 1); err = cdev_add(&ubi->cdev, dev, 1);
if (err) { if (err) {
ubi_err("cannot add character device %s", ubi->ubi_name); ubi_err("cannot add character device");
goto out_unreg; goto out_unreg;
} }
...@@ -296,9 +297,11 @@ static int uif_init(struct ubi_device *ubi) ...@@ -296,9 +297,11 @@ static int uif_init(struct ubi_device *ubi)
for (i = 0; i < ubi->vtbl_slots; i++) for (i = 0; i < ubi->vtbl_slots; i++)
if (ubi->volumes[i]) { if (ubi->volumes[i]) {
err = ubi_add_volume(ubi, i); err = ubi_add_volume(ubi, i);
if (err) if (err) {
ubi_err("cannot add volume %d", i);
goto out_volumes; goto out_volumes;
} }
}
return 0; return 0;
...@@ -309,6 +312,7 @@ out_cdev: ...@@ -309,6 +312,7 @@ out_cdev:
cdev_del(&ubi->cdev); cdev_del(&ubi->cdev);
out_unreg: out_unreg:
unregister_chrdev_region(ubi->cdev.dev, ubi->vtbl_slots + 1); unregister_chrdev_region(ubi->cdev.dev, ubi->vtbl_slots + 1);
ubi_err("cannot initialize UBI %s, error %d", ubi->ubi_name, err);
return err; return err;
} }
...@@ -422,7 +426,8 @@ static int io_init(struct ubi_device *ubi) ...@@ -422,7 +426,8 @@ static int io_init(struct ubi_device *ubi)
/* Make sure minimal I/O unit is power of 2 */ /* Make sure minimal I/O unit is power of 2 */
if (!is_power_of_2(ubi->min_io_size)) { if (!is_power_of_2(ubi->min_io_size)) {
ubi_err("bad min. I/O unit"); ubi_err("min. I/O unit (%d) is not power of 2",
ubi->min_io_size);
return -EINVAL; return -EINVAL;
} }
......
...@@ -377,7 +377,8 @@ static ssize_t vol_cdev_write(struct file *file, const char __user *buf, ...@@ -377,7 +377,8 @@ static ssize_t vol_cdev_write(struct file *file, const char __user *buf,
err = ubi_more_update_data(ubi, vol->vol_id, buf, count); err = ubi_more_update_data(ubi, vol->vol_id, buf, count);
if (err < 0) { if (err < 0) {
ubi_err("cannot write %zd bytes of update data", count); ubi_err("cannot write %zd bytes of update data, error %d",
count, err);
return err; return err;
} }
......
...@@ -305,7 +305,7 @@ int ubi_create_volume(struct ubi_device *ubi, struct ubi_mkvol_req *req) ...@@ -305,7 +305,7 @@ int ubi_create_volume(struct ubi_device *ubi, struct ubi_mkvol_req *req)
dev = MKDEV(MAJOR(ubi->cdev.dev), vol_id + 1); dev = MKDEV(MAJOR(ubi->cdev.dev), vol_id + 1);
err = cdev_add(&vol->cdev, dev, 1); err = cdev_add(&vol->cdev, dev, 1);
if (err) { if (err) {
ubi_err("cannot add character device for volume %d", vol_id); ubi_err("cannot add character device");
goto out_mapping; goto out_mapping;
} }
...@@ -319,8 +319,10 @@ int ubi_create_volume(struct ubi_device *ubi, struct ubi_mkvol_req *req) ...@@ -319,8 +319,10 @@ int ubi_create_volume(struct ubi_device *ubi, struct ubi_mkvol_req *req)
vol->dev.class = ubi_class; vol->dev.class = ubi_class;
sprintf(&vol->dev.bus_id[0], "%s_%d", ubi->ubi_name, vol->vol_id); sprintf(&vol->dev.bus_id[0], "%s_%d", ubi->ubi_name, vol->vol_id);
err = device_register(&vol->dev); err = device_register(&vol->dev);
if (err) if (err) {
ubi_err("cannot register device");
goto out_gluebi; goto out_gluebi;
}
err = volume_sysfs_init(ubi, vol); err = volume_sysfs_init(ubi, vol);
if (err) if (err)
...@@ -364,6 +366,7 @@ out_acc: ...@@ -364,6 +366,7 @@ out_acc:
out_unlock: out_unlock:
spin_unlock(&ubi->volumes_lock); spin_unlock(&ubi->volumes_lock);
kfree(vol); kfree(vol);
ubi_err("cannot create volume %d, error %d", vol_id, err);
return err; return err;
/* /*
...@@ -380,6 +383,7 @@ out_sysfs: ...@@ -380,6 +383,7 @@ out_sysfs:
ubi->volumes[vol_id] = NULL; ubi->volumes[vol_id] = NULL;
spin_unlock(&ubi->volumes_lock); spin_unlock(&ubi->volumes_lock);
volume_sysfs_close(vol); volume_sysfs_close(vol);
ubi_err("cannot create volume %d, error %d", vol_id, err);
return err; return err;
} }
...@@ -591,7 +595,8 @@ int ubi_add_volume(struct ubi_device *ubi, int vol_id) ...@@ -591,7 +595,8 @@ int ubi_add_volume(struct ubi_device *ubi, int vol_id)
dev = MKDEV(MAJOR(ubi->cdev.dev), vol->vol_id + 1); dev = MKDEV(MAJOR(ubi->cdev.dev), vol->vol_id + 1);
err = cdev_add(&vol->cdev, dev, 1); err = cdev_add(&vol->cdev, dev, 1);
if (err) { if (err) {
ubi_err("cannot add character device for volume %d", vol_id); ubi_err("cannot add character device for volume %d, error %d",
vol_id, err);
return err; return err;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment