diff options
author | Stephen M. Cameron <scameron@beardog.cce.hp.com> | 2010-08-26 14:55:44 -0400 |
---|---|---|
committer | Jens Axboe <jaxboe@fusionio.com> | 2010-09-10 06:12:30 -0400 |
commit | 4c800eed9a46f7b6a469d24e7e6051b23e62bb69 (patch) | |
tree | 2dd28321454adc0c0d3b0af63347e25243b0d645 /drivers/block/cciss.c | |
parent | 576e661c658ab7d2a15cc12d5b8a1600db81ec0a (diff) |
cciss: factor out cciss_setintinfo
Signed-off-by: Stephen M. Cameron <scameron@beardog.cce.hp.com>
Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
Diffstat (limited to 'drivers/block/cciss.c')
-rw-r--r-- | drivers/block/cciss.c | 66 |
1 files changed, 32 insertions, 34 deletions
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c index fc761404cef7..5119c8837cf5 100644 --- a/drivers/block/cciss.c +++ b/drivers/block/cciss.c | |||
@@ -1260,6 +1260,37 @@ static int cciss_getintinfo(ctlr_info_t *h, void __user *argp) | |||
1260 | return 0; | 1260 | return 0; |
1261 | } | 1261 | } |
1262 | 1262 | ||
1263 | static int cciss_setintinfo(ctlr_info_t *h, void __user *argp) | ||
1264 | { | ||
1265 | cciss_coalint_struct intinfo; | ||
1266 | unsigned long flags; | ||
1267 | int i; | ||
1268 | |||
1269 | if (!argp) | ||
1270 | return -EINVAL; | ||
1271 | if (!capable(CAP_SYS_ADMIN)) | ||
1272 | return -EPERM; | ||
1273 | if (copy_from_user(&intinfo, argp, sizeof(intinfo))) | ||
1274 | return -EFAULT; | ||
1275 | if ((intinfo.delay == 0) && (intinfo.count == 0)) | ||
1276 | return -EINVAL; | ||
1277 | spin_lock_irqsave(&h->lock, flags); | ||
1278 | /* Update the field, and then ring the doorbell */ | ||
1279 | writel(intinfo.delay, &(h->cfgtable->HostWrite.CoalIntDelay)); | ||
1280 | writel(intinfo.count, &(h->cfgtable->HostWrite.CoalIntCount)); | ||
1281 | writel(CFGTBL_ChangeReq, h->vaddr + SA5_DOORBELL); | ||
1282 | |||
1283 | for (i = 0; i < MAX_IOCTL_CONFIG_WAIT; i++) { | ||
1284 | if (!(readl(h->vaddr + SA5_DOORBELL) & CFGTBL_ChangeReq)) | ||
1285 | break; | ||
1286 | udelay(1000); /* delay and try again */ | ||
1287 | } | ||
1288 | spin_unlock_irqrestore(&h->lock, flags); | ||
1289 | if (i >= MAX_IOCTL_CONFIG_WAIT) | ||
1290 | return -EAGAIN; | ||
1291 | return 0; | ||
1292 | } | ||
1293 | |||
1263 | static int cciss_ioctl(struct block_device *bdev, fmode_t mode, | 1294 | static int cciss_ioctl(struct block_device *bdev, fmode_t mode, |
1264 | unsigned int cmd, unsigned long arg) | 1295 | unsigned int cmd, unsigned long arg) |
1265 | { | 1296 | { |
@@ -1276,40 +1307,7 @@ static int cciss_ioctl(struct block_device *bdev, fmode_t mode, | |||
1276 | case CCISS_GETINTINFO: | 1307 | case CCISS_GETINTINFO: |
1277 | return cciss_getintinfo(h, argp); | 1308 | return cciss_getintinfo(h, argp); |
1278 | case CCISS_SETINTINFO: | 1309 | case CCISS_SETINTINFO: |
1279 | { | 1310 | return cciss_setintinfo(h, argp); |
1280 | cciss_coalint_struct intinfo; | ||
1281 | unsigned long flags; | ||
1282 | int i; | ||
1283 | |||
1284 | if (!arg) | ||
1285 | return -EINVAL; | ||
1286 | if (!capable(CAP_SYS_ADMIN)) | ||
1287 | return -EPERM; | ||
1288 | if (copy_from_user | ||
1289 | (&intinfo, argp, sizeof(cciss_coalint_struct))) | ||
1290 | return -EFAULT; | ||
1291 | if ((intinfo.delay == 0) && (intinfo.count == 0)) | ||
1292 | return -EINVAL; | ||
1293 | spin_lock_irqsave(&h->lock, flags); | ||
1294 | /* Update the field, and then ring the doorbell */ | ||
1295 | writel(intinfo.delay, | ||
1296 | &(h->cfgtable->HostWrite.CoalIntDelay)); | ||
1297 | writel(intinfo.count, | ||
1298 | &(h->cfgtable->HostWrite.CoalIntCount)); | ||
1299 | writel(CFGTBL_ChangeReq, h->vaddr + SA5_DOORBELL); | ||
1300 | |||
1301 | for (i = 0; i < MAX_IOCTL_CONFIG_WAIT; i++) { | ||
1302 | if (!(readl(h->vaddr + SA5_DOORBELL) | ||
1303 | & CFGTBL_ChangeReq)) | ||
1304 | break; | ||
1305 | /* delay and try again */ | ||
1306 | udelay(1000); | ||
1307 | } | ||
1308 | spin_unlock_irqrestore(&h->lock, flags); | ||
1309 | if (i >= MAX_IOCTL_CONFIG_WAIT) | ||
1310 | return -EAGAIN; | ||
1311 | return 0; | ||
1312 | } | ||
1313 | case CCISS_GETNODENAME: | 1311 | case CCISS_GETNODENAME: |
1314 | { | 1312 | { |
1315 | NodeName_type NodeName; | 1313 | NodeName_type NodeName; |