Commit 9353848c authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jens Axboe

dasd: refactor dasd_ioctl_information

Prepare for in-kernel callers of this functionality.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
[sth@de.ibm.com: remove leftover kfree]
Signed-off-by: default avatarStefan Haberland <sth@linux.ibm.com>
Reviewed-by: default avatarPeter Oberparleiter <oberpar@linux.ibm.com>
Reviewed-by: default avatarJan Hoeppner <hoeppner@linux.ibm.com>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 3448914e
...@@ -457,10 +457,9 @@ static int dasd_ioctl_read_profile(struct dasd_block *block, void __user *argp) ...@@ -457,10 +457,9 @@ static int dasd_ioctl_read_profile(struct dasd_block *block, void __user *argp)
/* /*
* Return dasd information. Used for BIODASDINFO and BIODASDINFO2. * Return dasd information. Used for BIODASDINFO and BIODASDINFO2.
*/ */
static int dasd_ioctl_information(struct dasd_block *block, static int __dasd_ioctl_information(struct dasd_block *block,
unsigned int cmd, void __user *argp) struct dasd_information2_t *dasd_info)
{ {
struct dasd_information2_t *dasd_info;
struct subchannel_id sch_id; struct subchannel_id sch_id;
struct ccw_dev_id dev_id; struct ccw_dev_id dev_id;
struct dasd_device *base; struct dasd_device *base;
...@@ -473,15 +472,9 @@ static int dasd_ioctl_information(struct dasd_block *block, ...@@ -473,15 +472,9 @@ static int dasd_ioctl_information(struct dasd_block *block,
if (!base->discipline || !base->discipline->fill_info) if (!base->discipline || !base->discipline->fill_info)
return -EINVAL; return -EINVAL;
dasd_info = kzalloc(sizeof(struct dasd_information2_t), GFP_KERNEL);
if (dasd_info == NULL)
return -ENOMEM;
rc = base->discipline->fill_info(base, dasd_info); rc = base->discipline->fill_info(base, dasd_info);
if (rc) { if (rc)
kfree(dasd_info);
return rc; return rc;
}
cdev = base->cdev; cdev = base->cdev;
ccw_device_get_id(cdev, &dev_id); ccw_device_get_id(cdev, &dev_id);
...@@ -520,15 +513,24 @@ static int dasd_ioctl_information(struct dasd_block *block, ...@@ -520,15 +513,24 @@ static int dasd_ioctl_information(struct dasd_block *block,
list_for_each(l, &base->ccw_queue) list_for_each(l, &base->ccw_queue)
dasd_info->chanq_len++; dasd_info->chanq_len++;
spin_unlock_irqrestore(&block->queue_lock, flags); spin_unlock_irqrestore(&block->queue_lock, flags);
return 0;
}
rc = 0; static int dasd_ioctl_information(struct dasd_block *block, void __user *argp,
if (copy_to_user(argp, dasd_info, size_t copy_size)
((cmd == (unsigned int) BIODASDINFO2) ? {
sizeof(struct dasd_information2_t) : struct dasd_information2_t *dasd_info;
sizeof(struct dasd_information_t)))) int error;
rc = -EFAULT;
dasd_info = kzalloc(sizeof(*dasd_info), GFP_KERNEL);
if (!dasd_info)
return -ENOMEM;
error = __dasd_ioctl_information(block, dasd_info);
if (!error && copy_to_user(argp, dasd_info, copy_size))
error = -EFAULT;
kfree(dasd_info); kfree(dasd_info);
return rc; return error;
} }
/* /*
...@@ -622,10 +624,12 @@ int dasd_ioctl(struct block_device *bdev, fmode_t mode, ...@@ -622,10 +624,12 @@ int dasd_ioctl(struct block_device *bdev, fmode_t mode,
rc = dasd_ioctl_check_format(bdev, argp); rc = dasd_ioctl_check_format(bdev, argp);
break; break;
case BIODASDINFO: case BIODASDINFO:
rc = dasd_ioctl_information(block, cmd, argp); rc = dasd_ioctl_information(block, argp,
sizeof(struct dasd_information_t));
break; break;
case BIODASDINFO2: case BIODASDINFO2:
rc = dasd_ioctl_information(block, cmd, argp); rc = dasd_ioctl_information(block, argp,
sizeof(struct dasd_information2_t));
break; break;
case BIODASDPRRD: case BIODASDPRRD:
rc = dasd_ioctl_read_profile(block, argp); rc = dasd_ioctl_read_profile(block, argp);
......
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