Commit 065f9716 authored by Dan Carpenter's avatar Dan Carpenter Committed by James Bottomley

[SCSI] target: Convert rd_build_device_space() to use errno

This patch converts rd_build_device_space() to return errno usage
for failures in rd_create_virtdevice().
Signed-off-by: default avatarDan Carpenter <error27@gmail.com>
Signed-off-by: default avatarNicholas A. Bellinger <nab@linux-iscsi.org>
Signed-off-by: default avatarJames Bottomley <James.Bottomley@suse.de>
parent 35ce9e26
...@@ -150,7 +150,7 @@ static int rd_build_device_space(struct rd_dev *rd_dev) ...@@ -150,7 +150,7 @@ static int rd_build_device_space(struct rd_dev *rd_dev)
if (rd_dev->rd_page_count <= 0) { if (rd_dev->rd_page_count <= 0) {
printk(KERN_ERR "Illegal page count: %u for Ramdisk device\n", printk(KERN_ERR "Illegal page count: %u for Ramdisk device\n",
rd_dev->rd_page_count); rd_dev->rd_page_count);
return -1; return -EINVAL;
} }
total_sg_needed = rd_dev->rd_page_count; total_sg_needed = rd_dev->rd_page_count;
...@@ -160,7 +160,7 @@ static int rd_build_device_space(struct rd_dev *rd_dev) ...@@ -160,7 +160,7 @@ static int rd_build_device_space(struct rd_dev *rd_dev)
if (!(sg_table)) { if (!(sg_table)) {
printk(KERN_ERR "Unable to allocate memory for Ramdisk" printk(KERN_ERR "Unable to allocate memory for Ramdisk"
" scatterlist tables\n"); " scatterlist tables\n");
return -1; return -ENOMEM;
} }
rd_dev->sg_table_array = sg_table; rd_dev->sg_table_array = sg_table;
...@@ -175,7 +175,7 @@ static int rd_build_device_space(struct rd_dev *rd_dev) ...@@ -175,7 +175,7 @@ static int rd_build_device_space(struct rd_dev *rd_dev)
if (!(sg)) { if (!(sg)) {
printk(KERN_ERR "Unable to allocate scatterlist array" printk(KERN_ERR "Unable to allocate scatterlist array"
" for struct rd_dev\n"); " for struct rd_dev\n");
return -1; return -ENOMEM;
} }
sg_init_table((struct scatterlist *)&sg[0], sg_per_table); sg_init_table((struct scatterlist *)&sg[0], sg_per_table);
...@@ -191,7 +191,7 @@ static int rd_build_device_space(struct rd_dev *rd_dev) ...@@ -191,7 +191,7 @@ static int rd_build_device_space(struct rd_dev *rd_dev)
if (!(pg)) { if (!(pg)) {
printk(KERN_ERR "Unable to allocate scatterlist" printk(KERN_ERR "Unable to allocate scatterlist"
" pages for struct rd_dev_sg_table\n"); " pages for struct rd_dev_sg_table\n");
return -1; return -ENOMEM;
} }
sg_assign_page(&sg[j], pg); sg_assign_page(&sg[j], pg);
sg[j].length = PAGE_SIZE; sg[j].length = PAGE_SIZE;
...@@ -253,15 +253,14 @@ static struct se_device *rd_create_virtdevice( ...@@ -253,15 +253,14 @@ static struct se_device *rd_create_virtdevice(
struct se_dev_limits dev_limits; struct se_dev_limits dev_limits;
struct rd_dev *rd_dev = p; struct rd_dev *rd_dev = p;
struct rd_host *rd_host = hba->hba_ptr; struct rd_host *rd_host = hba->hba_ptr;
int dev_flags = 0, ret = -EINVAL; int dev_flags = 0, ret;
char prod[16], rev[4]; char prod[16], rev[4];
memset(&dev_limits, 0, sizeof(struct se_dev_limits)); memset(&dev_limits, 0, sizeof(struct se_dev_limits));
if (rd_build_device_space(rd_dev) < 0) { ret = rd_build_device_space(rd_dev);
ret = -ENOMEM; if (ret < 0)
goto fail; goto fail;
}
snprintf(prod, 16, "RAMDISK-%s", (rd_dev->rd_direct) ? "DR" : "MCP"); snprintf(prod, 16, "RAMDISK-%s", (rd_dev->rd_direct) ? "DR" : "MCP");
snprintf(rev, 4, "%s", (rd_dev->rd_direct) ? RD_DR_VERSION : snprintf(rev, 4, "%s", (rd_dev->rd_direct) ? RD_DR_VERSION :
......
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