Skip to content

Commit

Permalink
UBI: Extend UBI layer debug/messaging capabilities
Browse files Browse the repository at this point in the history
If there is more then one UBI device mounted, there is no way to
distinguish between messages from different UBI devices.
Add device number to all ubi layer message types.

The R/O block driver messages were replaced by pr_* since
ubi_device structure is not used by it.

Amended a bit by Artem.

Signed-off-by: Tanya Brokhman <tlinder@codeaurora.org>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
  • Loading branch information
Tanya Brokhman authored and Artem Bityutskiy committed Nov 7, 2014
1 parent 789c899 commit 3260870
Show file tree
Hide file tree
Showing 14 changed files with 441 additions and 407 deletions.
126 changes: 66 additions & 60 deletions drivers/mtd/ubi/attach.c

Large diffs are not rendered by default.

41 changes: 20 additions & 21 deletions drivers/mtd/ubi/block.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,13 @@ static int __init ubiblock_set_param(const char *val,

len = strnlen(val, UBIBLOCK_PARAM_LEN);
if (len == 0) {
ubi_warn("block: empty 'block=' parameter - ignored\n");
pr_warn("UBI: block: empty 'block=' parameter - ignored\n");
return 0;
}

if (len == UBIBLOCK_PARAM_LEN) {
ubi_err("block: parameter \"%s\" is too long, max. is %d\n",
val, UBIBLOCK_PARAM_LEN);
pr_err("UBI: block: parameter \"%s\" is too long, max. is %d\n",
val, UBIBLOCK_PARAM_LEN);
return -EINVAL;
}

Expand Down Expand Up @@ -188,9 +188,8 @@ static int ubiblock_read_to_buf(struct ubiblock *dev, char *buffer,

ret = ubi_read(dev->desc, leb, buffer, offset, len);
if (ret) {
ubi_err("%s: error %d while reading from LEB %d (offset %d, "
"length %d)", dev->gd->disk_name, ret, leb, offset,
len);
dev_err(disk_to_dev(dev->gd), "%d while reading from LEB %d (offset %d, length %d)",
ret, leb, offset, len);
return ret;
}
return 0;
Expand Down Expand Up @@ -328,8 +327,8 @@ static int ubiblock_open(struct block_device *bdev, fmode_t mode)

dev->desc = ubi_open_volume(dev->ubi_num, dev->vol_id, UBI_READONLY);
if (IS_ERR(dev->desc)) {
ubi_err("%s failed to open ubi volume %d_%d",
dev->gd->disk_name, dev->ubi_num, dev->vol_id);
dev_err(disk_to_dev(dev->gd), "failed to open ubi volume %d_%d",
dev->ubi_num, dev->vol_id);
ret = PTR_ERR(dev->desc);
dev->desc = NULL;
goto out_unlock;
Expand Down Expand Up @@ -405,7 +404,7 @@ int ubiblock_create(struct ubi_volume_info *vi)
/* Initialize the gendisk of this ubiblock device */
gd = alloc_disk(1);
if (!gd) {
ubi_err("block: alloc_disk failed");
pr_err("UBI: block: alloc_disk failed");
ret = -ENODEV;
goto out_free_dev;
}
Expand All @@ -421,7 +420,7 @@ int ubiblock_create(struct ubi_volume_info *vi)
spin_lock_init(&dev->queue_lock);
dev->rq = blk_init_queue(ubiblock_request, &dev->queue_lock);
if (!dev->rq) {
ubi_err("block: blk_init_queue failed");
dev_err(disk_to_dev(gd), "blk_init_queue failed");
ret = -ENODEV;
goto out_put_disk;
}
Expand All @@ -446,8 +445,8 @@ int ubiblock_create(struct ubi_volume_info *vi)

/* Must be the last step: anyone can call file ops from now on */
add_disk(dev->gd);
ubi_msg("%s created from ubi%d:%d(%s)",
dev->gd->disk_name, dev->ubi_num, dev->vol_id, vi->name);
dev_info(disk_to_dev(dev->gd), "created from ubi%d:%d(%s)",
dev->ubi_num, dev->vol_id, vi->name);
return 0;

out_free_queue:
Expand All @@ -464,7 +463,7 @@ static void ubiblock_cleanup(struct ubiblock *dev)
{
del_gendisk(dev->gd);
blk_cleanup_queue(dev->rq);
ubi_msg("%s released", dev->gd->disk_name);
dev_info(disk_to_dev(dev->gd), "released");
put_disk(dev->gd);
}

Expand Down Expand Up @@ -518,17 +517,17 @@ static int ubiblock_resize(struct ubi_volume_info *vi)
}
if ((sector_t)disk_capacity != disk_capacity) {
mutex_unlock(&devices_mutex);
ubi_warn("%s: the volume is too big (%d LEBs), cannot resize",
dev->gd->disk_name, vi->size);
dev_warn(disk_to_dev(dev->gd), "the volume is too big (%d LEBs), cannot resize",
vi->size);
return -EFBIG;
}

mutex_lock(&dev->dev_mutex);

if (get_capacity(dev->gd) != disk_capacity) {
set_capacity(dev->gd, disk_capacity);
ubi_msg("%s resized to %lld bytes", dev->gd->disk_name,
vi->used_bytes);
dev_info(disk_to_dev(dev->gd), "resized to %lld bytes",
vi->used_bytes);
}
mutex_unlock(&dev->dev_mutex);
mutex_unlock(&devices_mutex);
Expand Down Expand Up @@ -596,8 +595,8 @@ static int __init ubiblock_create_from_param(void)

desc = open_volume_desc(p->name, p->ubi_num, p->vol_id);
if (IS_ERR(desc)) {
ubi_err("block: can't open volume, err=%ld\n",
PTR_ERR(desc));
pr_err("UBI: block: can't open volume, err=%ld\n",
PTR_ERR(desc));
ret = PTR_ERR(desc);
break;
}
Expand All @@ -607,8 +606,8 @@ static int __init ubiblock_create_from_param(void)

ret = ubiblock_create(&vi);
if (ret) {
ubi_err("block: can't add '%s' volume, err=%d\n",
vi.name, ret);
pr_err("UBI: block: can't add '%s' volume, err=%d\n",
vi.name, ret);
break;
}
}
Expand Down
Loading

0 comments on commit 3260870

Please sign in to comment.