From 0894b32c5c1444d25f3e988cf03415ce8dfc5142 Mon Sep 17 00:00:00 2001 From: "Stephen M. Cameron" Date: Thu, 26 Aug 2010 13:56:20 -0500 Subject: [PATCH] cciss: factor out cciss_getluninfo Signed-off-by: Stephen M. Cameron Signed-off-by: Jens Axboe --- drivers/block/cciss.c | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c index 71018b98859..5abdce3ef70 100644 --- a/drivers/block/cciss.c +++ b/drivers/block/cciss.c @@ -1382,12 +1382,27 @@ static int cciss_getdrivver(ctlr_info_t *h, void __user *argp) return 0; } +static int cciss_getluninfo(ctlr_info_t *h, + struct gendisk *disk, void __user *argp) +{ + LogvolInfo_struct luninfo; + drive_info_struct *drv = get_drv(disk); + + if (!argp) + return -EINVAL; + memcpy(&luninfo.LunID, drv->LunID, sizeof(luninfo.LunID)); + luninfo.num_opens = drv->usage_count; + luninfo.num_parts = 0; + if (copy_to_user(argp, &luninfo, sizeof(LogvolInfo_struct))) + return -EFAULT; + return 0; +} + static int cciss_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, unsigned long arg) { struct gendisk *disk = bdev->bd_disk; ctlr_info_t *h = get_host(disk); - drive_info_struct *drv = get_drv(disk); void __user *argp = (void __user *)arg; dev_dbg(&h->pdev->dev, "cciss_ioctl: Called with cmd=%x %lx\n", @@ -1415,19 +1430,8 @@ static int cciss_ioctl(struct block_device *bdev, fmode_t mode, case CCISS_REGNEWD: case CCISS_REVALIDVOLS: return rebuild_lun_table(h, 0, 1); - - case CCISS_GETLUNINFO:{ - LogvolInfo_struct luninfo; - - memcpy(&luninfo.LunID, drv->LunID, - sizeof(luninfo.LunID)); - luninfo.num_opens = drv->usage_count; - luninfo.num_parts = 0; - if (copy_to_user(argp, &luninfo, - sizeof(LogvolInfo_struct))) - return -EFAULT; - return 0; - } + case CCISS_GETLUNINFO: + return cciss_getluninfo(h, disk, argp); case CCISS_PASSTHRU: { IOCTL_Command_struct iocommand; -- 2.11.4.GIT