diff options
author | Stephen M. Cameron <scameron@beardog.cce.hp.com> | 2010-07-19 14:46:38 -0400 |
---|---|---|
committer | Jens Axboe <jaxboe@fusionio.com> | 2010-08-07 12:52:30 -0400 |
commit | f70dba83669bf718c2f1731f0f58b8149e883593 (patch) | |
tree | cb0c2a5cff4678a860e230d33bea580b9e73aba0 /drivers/block/cciss.c | |
parent | 058a0f9f31283d5eb9d8686d3b4f69e55d1589f1 (diff) |
cciss: use consistent variable names
cciss: use consistent variable names
"h", for the hba structure and "c" for the command structures.
and get rid of trivial CCISS_LOCK macro.
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 | 611 |
1 files changed, 304 insertions, 307 deletions
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c index 2abe6df9445e..70ad24f3604f 100644 --- a/drivers/block/cciss.c +++ b/drivers/block/cciss.c | |||
@@ -191,17 +191,17 @@ static int rebuild_lun_table(ctlr_info_t *h, int first_time, int via_ioctl); | |||
191 | static int deregister_disk(ctlr_info_t *h, int drv_index, | 191 | static int deregister_disk(ctlr_info_t *h, int drv_index, |
192 | int clear_all, int via_ioctl); | 192 | int clear_all, int via_ioctl); |
193 | 193 | ||
194 | static void cciss_read_capacity(int ctlr, int logvol, | 194 | static void cciss_read_capacity(ctlr_info_t *h, int logvol, |
195 | sector_t *total_size, unsigned int *block_size); | 195 | sector_t *total_size, unsigned int *block_size); |
196 | static void cciss_read_capacity_16(int ctlr, int logvol, | 196 | static void cciss_read_capacity_16(ctlr_info_t *h, int logvol, |
197 | sector_t *total_size, unsigned int *block_size); | 197 | sector_t *total_size, unsigned int *block_size); |
198 | static void cciss_geometry_inquiry(int ctlr, int logvol, | 198 | static void cciss_geometry_inquiry(ctlr_info_t *h, int logvol, |
199 | sector_t total_size, | 199 | sector_t total_size, |
200 | unsigned int block_size, InquiryData_struct *inq_buff, | 200 | unsigned int block_size, InquiryData_struct *inq_buff, |
201 | drive_info_struct *drv); | 201 | drive_info_struct *drv); |
202 | static void __devinit cciss_interrupt_mode(ctlr_info_t *); | 202 | static void __devinit cciss_interrupt_mode(ctlr_info_t *); |
203 | static void start_io(ctlr_info_t *h); | 203 | static void start_io(ctlr_info_t *h); |
204 | static int sendcmd_withirq(__u8 cmd, int ctlr, void *buff, size_t size, | 204 | static int sendcmd_withirq(ctlr_info_t *h, __u8 cmd, void *buff, size_t size, |
205 | __u8 page_code, unsigned char scsi3addr[], | 205 | __u8 page_code, unsigned char scsi3addr[], |
206 | int cmd_type); | 206 | int cmd_type); |
207 | static int sendcmd_withirq_core(ctlr_info_t *h, CommandList_struct *c, | 207 | static int sendcmd_withirq_core(ctlr_info_t *h, CommandList_struct *c, |
@@ -229,9 +229,9 @@ static void calc_bucket_map(int *bucket, int num_buckets, int nsgs, | |||
229 | static void cciss_put_controller_into_performant_mode(ctlr_info_t *h); | 229 | static void cciss_put_controller_into_performant_mode(ctlr_info_t *h); |
230 | 230 | ||
231 | #ifdef CONFIG_PROC_FS | 231 | #ifdef CONFIG_PROC_FS |
232 | static void cciss_procinit(int i); | 232 | static void cciss_procinit(ctlr_info_t *h); |
233 | #else | 233 | #else |
234 | static void cciss_procinit(int i) | 234 | static void cciss_procinit(ctlr_info_t *h) |
235 | { | 235 | { |
236 | } | 236 | } |
237 | #endif /* CONFIG_PROC_FS */ | 237 | #endif /* CONFIG_PROC_FS */ |
@@ -416,26 +416,25 @@ static void cciss_seq_show_header(struct seq_file *seq) | |||
416 | h->maxQsinceinit, h->max_outstanding, h->maxSG); | 416 | h->maxQsinceinit, h->max_outstanding, h->maxSG); |
417 | 417 | ||
418 | #ifdef CONFIG_CISS_SCSI_TAPE | 418 | #ifdef CONFIG_CISS_SCSI_TAPE |
419 | cciss_seq_tape_report(seq, h->ctlr); | 419 | cciss_seq_tape_report(seq, h); |
420 | #endif /* CONFIG_CISS_SCSI_TAPE */ | 420 | #endif /* CONFIG_CISS_SCSI_TAPE */ |
421 | } | 421 | } |
422 | 422 | ||
423 | static void *cciss_seq_start(struct seq_file *seq, loff_t *pos) | 423 | static void *cciss_seq_start(struct seq_file *seq, loff_t *pos) |
424 | { | 424 | { |
425 | ctlr_info_t *h = seq->private; | 425 | ctlr_info_t *h = seq->private; |
426 | unsigned ctlr = h->ctlr; | ||
427 | unsigned long flags; | 426 | unsigned long flags; |
428 | 427 | ||
429 | /* prevent displaying bogus info during configuration | 428 | /* prevent displaying bogus info during configuration |
430 | * or deconfiguration of a logical volume | 429 | * or deconfiguration of a logical volume |
431 | */ | 430 | */ |
432 | spin_lock_irqsave(CCISS_LOCK(ctlr), flags); | 431 | spin_lock_irqsave(&h->lock, flags); |
433 | if (h->busy_configuring) { | 432 | if (h->busy_configuring) { |
434 | spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags); | 433 | spin_unlock_irqrestore(&h->lock, flags); |
435 | return ERR_PTR(-EBUSY); | 434 | return ERR_PTR(-EBUSY); |
436 | } | 435 | } |
437 | h->busy_configuring = 1; | 436 | h->busy_configuring = 1; |
438 | spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags); | 437 | spin_unlock_irqrestore(&h->lock, flags); |
439 | 438 | ||
440 | if (*pos == 0) | 439 | if (*pos == 0) |
441 | cciss_seq_show_header(seq); | 440 | cciss_seq_show_header(seq); |
@@ -543,7 +542,7 @@ cciss_proc_write(struct file *file, const char __user *buf, | |||
543 | struct seq_file *seq = file->private_data; | 542 | struct seq_file *seq = file->private_data; |
544 | ctlr_info_t *h = seq->private; | 543 | ctlr_info_t *h = seq->private; |
545 | 544 | ||
546 | err = cciss_engage_scsi(h->ctlr); | 545 | err = cciss_engage_scsi(h); |
547 | if (err == 0) | 546 | if (err == 0) |
548 | err = length; | 547 | err = length; |
549 | } else | 548 | } else |
@@ -566,7 +565,7 @@ static const struct file_operations cciss_proc_fops = { | |||
566 | .write = cciss_proc_write, | 565 | .write = cciss_proc_write, |
567 | }; | 566 | }; |
568 | 567 | ||
569 | static void __devinit cciss_procinit(int i) | 568 | static void __devinit cciss_procinit(ctlr_info_t *h) |
570 | { | 569 | { |
571 | struct proc_dir_entry *pde; | 570 | struct proc_dir_entry *pde; |
572 | 571 | ||
@@ -574,9 +573,9 @@ static void __devinit cciss_procinit(int i) | |||
574 | proc_cciss = proc_mkdir("driver/cciss", NULL); | 573 | proc_cciss = proc_mkdir("driver/cciss", NULL); |
575 | if (!proc_cciss) | 574 | if (!proc_cciss) |
576 | return; | 575 | return; |
577 | pde = proc_create_data(hba[i]->devname, S_IWUSR | S_IRUSR | S_IRGRP | | 576 | pde = proc_create_data(h->devname, S_IWUSR | S_IRUSR | S_IRGRP | |
578 | S_IROTH, proc_cciss, | 577 | S_IROTH, proc_cciss, |
579 | &cciss_proc_fops, hba[i]); | 578 | &cciss_proc_fops, h); |
580 | } | 579 | } |
581 | #endif /* CONFIG_PROC_FS */ | 580 | #endif /* CONFIG_PROC_FS */ |
582 | 581 | ||
@@ -609,12 +608,12 @@ static ssize_t dev_show_unique_id(struct device *dev, | |||
609 | unsigned long flags; | 608 | unsigned long flags; |
610 | int ret = 0; | 609 | int ret = 0; |
611 | 610 | ||
612 | spin_lock_irqsave(CCISS_LOCK(h->ctlr), flags); | 611 | spin_lock_irqsave(&h->lock, flags); |
613 | if (h->busy_configuring) | 612 | if (h->busy_configuring) |
614 | ret = -EBUSY; | 613 | ret = -EBUSY; |
615 | else | 614 | else |
616 | memcpy(sn, drv->serial_no, sizeof(sn)); | 615 | memcpy(sn, drv->serial_no, sizeof(sn)); |
617 | spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags); | 616 | spin_unlock_irqrestore(&h->lock, flags); |
618 | 617 | ||
619 | if (ret) | 618 | if (ret) |
620 | return ret; | 619 | return ret; |
@@ -639,12 +638,12 @@ static ssize_t dev_show_vendor(struct device *dev, | |||
639 | unsigned long flags; | 638 | unsigned long flags; |
640 | int ret = 0; | 639 | int ret = 0; |
641 | 640 | ||
642 | spin_lock_irqsave(CCISS_LOCK(h->ctlr), flags); | 641 | spin_lock_irqsave(&h->lock, flags); |
643 | if (h->busy_configuring) | 642 | if (h->busy_configuring) |
644 | ret = -EBUSY; | 643 | ret = -EBUSY; |
645 | else | 644 | else |
646 | memcpy(vendor, drv->vendor, VENDOR_LEN + 1); | 645 | memcpy(vendor, drv->vendor, VENDOR_LEN + 1); |
647 | spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags); | 646 | spin_unlock_irqrestore(&h->lock, flags); |
648 | 647 | ||
649 | if (ret) | 648 | if (ret) |
650 | return ret; | 649 | return ret; |
@@ -663,12 +662,12 @@ static ssize_t dev_show_model(struct device *dev, | |||
663 | unsigned long flags; | 662 | unsigned long flags; |
664 | int ret = 0; | 663 | int ret = 0; |
665 | 664 | ||
666 | spin_lock_irqsave(CCISS_LOCK(h->ctlr), flags); | 665 | spin_lock_irqsave(&h->lock, flags); |
667 | if (h->busy_configuring) | 666 | if (h->busy_configuring) |
668 | ret = -EBUSY; | 667 | ret = -EBUSY; |
669 | else | 668 | else |
670 | memcpy(model, drv->model, MODEL_LEN + 1); | 669 | memcpy(model, drv->model, MODEL_LEN + 1); |
671 | spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags); | 670 | spin_unlock_irqrestore(&h->lock, flags); |
672 | 671 | ||
673 | if (ret) | 672 | if (ret) |
674 | return ret; | 673 | return ret; |
@@ -687,12 +686,12 @@ static ssize_t dev_show_rev(struct device *dev, | |||
687 | unsigned long flags; | 686 | unsigned long flags; |
688 | int ret = 0; | 687 | int ret = 0; |
689 | 688 | ||
690 | spin_lock_irqsave(CCISS_LOCK(h->ctlr), flags); | 689 | spin_lock_irqsave(&h->lock, flags); |
691 | if (h->busy_configuring) | 690 | if (h->busy_configuring) |
692 | ret = -EBUSY; | 691 | ret = -EBUSY; |
693 | else | 692 | else |
694 | memcpy(rev, drv->rev, REV_LEN + 1); | 693 | memcpy(rev, drv->rev, REV_LEN + 1); |
695 | spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags); | 694 | spin_unlock_irqrestore(&h->lock, flags); |
696 | 695 | ||
697 | if (ret) | 696 | if (ret) |
698 | return ret; | 697 | return ret; |
@@ -709,17 +708,17 @@ static ssize_t cciss_show_lunid(struct device *dev, | |||
709 | unsigned long flags; | 708 | unsigned long flags; |
710 | unsigned char lunid[8]; | 709 | unsigned char lunid[8]; |
711 | 710 | ||
712 | spin_lock_irqsave(CCISS_LOCK(h->ctlr), flags); | 711 | spin_lock_irqsave(&h->lock, flags); |
713 | if (h->busy_configuring) { | 712 | if (h->busy_configuring) { |
714 | spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags); | 713 | spin_unlock_irqrestore(&h->lock, flags); |
715 | return -EBUSY; | 714 | return -EBUSY; |
716 | } | 715 | } |
717 | if (!drv->heads) { | 716 | if (!drv->heads) { |
718 | spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags); | 717 | spin_unlock_irqrestore(&h->lock, flags); |
719 | return -ENOTTY; | 718 | return -ENOTTY; |
720 | } | 719 | } |
721 | memcpy(lunid, drv->LunID, sizeof(lunid)); | 720 | memcpy(lunid, drv->LunID, sizeof(lunid)); |
722 | spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags); | 721 | spin_unlock_irqrestore(&h->lock, flags); |
723 | return snprintf(buf, 20, "0x%02x%02x%02x%02x%02x%02x%02x%02x\n", | 722 | return snprintf(buf, 20, "0x%02x%02x%02x%02x%02x%02x%02x%02x\n", |
724 | lunid[0], lunid[1], lunid[2], lunid[3], | 723 | lunid[0], lunid[1], lunid[2], lunid[3], |
725 | lunid[4], lunid[5], lunid[6], lunid[7]); | 724 | lunid[4], lunid[5], lunid[6], lunid[7]); |
@@ -734,13 +733,13 @@ static ssize_t cciss_show_raid_level(struct device *dev, | |||
734 | int raid; | 733 | int raid; |
735 | unsigned long flags; | 734 | unsigned long flags; |
736 | 735 | ||
737 | spin_lock_irqsave(CCISS_LOCK(h->ctlr), flags); | 736 | spin_lock_irqsave(&h->lock, flags); |
738 | if (h->busy_configuring) { | 737 | if (h->busy_configuring) { |
739 | spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags); | 738 | spin_unlock_irqrestore(&h->lock, flags); |
740 | return -EBUSY; | 739 | return -EBUSY; |
741 | } | 740 | } |
742 | raid = drv->raid_level; | 741 | raid = drv->raid_level; |
743 | spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags); | 742 | spin_unlock_irqrestore(&h->lock, flags); |
744 | if (raid < 0 || raid > RAID_UNKNOWN) | 743 | if (raid < 0 || raid > RAID_UNKNOWN) |
745 | raid = RAID_UNKNOWN; | 744 | raid = RAID_UNKNOWN; |
746 | 745 | ||
@@ -757,13 +756,13 @@ static ssize_t cciss_show_usage_count(struct device *dev, | |||
757 | unsigned long flags; | 756 | unsigned long flags; |
758 | int count; | 757 | int count; |
759 | 758 | ||
760 | spin_lock_irqsave(CCISS_LOCK(h->ctlr), flags); | 759 | spin_lock_irqsave(&h->lock, flags); |
761 | if (h->busy_configuring) { | 760 | if (h->busy_configuring) { |
762 | spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags); | 761 | spin_unlock_irqrestore(&h->lock, flags); |
763 | return -EBUSY; | 762 | return -EBUSY; |
764 | } | 763 | } |
765 | count = drv->usage_count; | 764 | count = drv->usage_count; |
766 | spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags); | 765 | spin_unlock_irqrestore(&h->lock, flags); |
767 | return snprintf(buf, 20, "%d\n", count); | 766 | return snprintf(buf, 20, "%d\n", count); |
768 | } | 767 | } |
769 | static DEVICE_ATTR(usage_count, S_IRUGO, cciss_show_usage_count, NULL); | 768 | static DEVICE_ATTR(usage_count, S_IRUGO, cciss_show_usage_count, NULL); |
@@ -1012,7 +1011,7 @@ static inline drive_info_struct *get_drv(struct gendisk *disk) | |||
1012 | */ | 1011 | */ |
1013 | static int cciss_open(struct block_device *bdev, fmode_t mode) | 1012 | static int cciss_open(struct block_device *bdev, fmode_t mode) |
1014 | { | 1013 | { |
1015 | ctlr_info_t *host = get_host(bdev->bd_disk); | 1014 | ctlr_info_t *h = get_host(bdev->bd_disk); |
1016 | drive_info_struct *drv = get_drv(bdev->bd_disk); | 1015 | drive_info_struct *drv = get_drv(bdev->bd_disk); |
1017 | 1016 | ||
1018 | #ifdef CCISS_DEBUG | 1017 | #ifdef CCISS_DEBUG |
@@ -1044,7 +1043,7 @@ static int cciss_open(struct block_device *bdev, fmode_t mode) | |||
1044 | return -EPERM; | 1043 | return -EPERM; |
1045 | } | 1044 | } |
1046 | drv->usage_count++; | 1045 | drv->usage_count++; |
1047 | host->usage_count++; | 1046 | h->usage_count++; |
1048 | return 0; | 1047 | return 0; |
1049 | } | 1048 | } |
1050 | 1049 | ||
@@ -1064,11 +1063,11 @@ static int cciss_unlocked_open(struct block_device *bdev, fmode_t mode) | |||
1064 | */ | 1063 | */ |
1065 | static int cciss_release(struct gendisk *disk, fmode_t mode) | 1064 | static int cciss_release(struct gendisk *disk, fmode_t mode) |
1066 | { | 1065 | { |
1067 | ctlr_info_t *host; | 1066 | ctlr_info_t *h; |
1068 | drive_info_struct *drv; | 1067 | drive_info_struct *drv; |
1069 | 1068 | ||
1070 | lock_kernel(); | 1069 | lock_kernel(); |
1071 | host = get_host(disk); | 1070 | h = get_host(disk); |
1072 | drv = get_drv(disk); | 1071 | drv = get_drv(disk); |
1073 | 1072 | ||
1074 | #ifdef CCISS_DEBUG | 1073 | #ifdef CCISS_DEBUG |
@@ -1076,7 +1075,7 @@ static int cciss_release(struct gendisk *disk, fmode_t mode) | |||
1076 | #endif /* CCISS_DEBUG */ | 1075 | #endif /* CCISS_DEBUG */ |
1077 | 1076 | ||
1078 | drv->usage_count--; | 1077 | drv->usage_count--; |
1079 | host->usage_count--; | 1078 | h->usage_count--; |
1080 | unlock_kernel(); | 1079 | unlock_kernel(); |
1081 | return 0; | 1080 | return 0; |
1082 | } | 1081 | } |
@@ -1223,11 +1222,11 @@ static int cciss_getgeo(struct block_device *bdev, struct hd_geometry *geo) | |||
1223 | return 0; | 1222 | return 0; |
1224 | } | 1223 | } |
1225 | 1224 | ||
1226 | static void check_ioctl_unit_attention(ctlr_info_t *host, CommandList_struct *c) | 1225 | static void check_ioctl_unit_attention(ctlr_info_t *h, CommandList_struct *c) |
1227 | { | 1226 | { |
1228 | if (c->err_info->CommandStatus == CMD_TARGET_STATUS && | 1227 | if (c->err_info->CommandStatus == CMD_TARGET_STATUS && |
1229 | c->err_info->ScsiStatus != SAM_STAT_CHECK_CONDITION) | 1228 | c->err_info->ScsiStatus != SAM_STAT_CHECK_CONDITION) |
1230 | (void)check_for_unit_attention(host, c); | 1229 | (void)check_for_unit_attention(h, c); |
1231 | } | 1230 | } |
1232 | /* | 1231 | /* |
1233 | * ioctl | 1232 | * ioctl |
@@ -1236,9 +1235,8 @@ static int cciss_ioctl(struct block_device *bdev, fmode_t mode, | |||
1236 | unsigned int cmd, unsigned long arg) | 1235 | unsigned int cmd, unsigned long arg) |
1237 | { | 1236 | { |
1238 | struct gendisk *disk = bdev->bd_disk; | 1237 | struct gendisk *disk = bdev->bd_disk; |
1239 | ctlr_info_t *host = get_host(disk); | 1238 | ctlr_info_t *h = get_host(disk); |
1240 | drive_info_struct *drv = get_drv(disk); | 1239 | drive_info_struct *drv = get_drv(disk); |
1241 | int ctlr = host->ctlr; | ||
1242 | void __user *argp = (void __user *)arg; | 1240 | void __user *argp = (void __user *)arg; |
1243 | 1241 | ||
1244 | #ifdef CCISS_DEBUG | 1242 | #ifdef CCISS_DEBUG |
@@ -1252,10 +1250,10 @@ static int cciss_ioctl(struct block_device *bdev, fmode_t mode, | |||
1252 | 1250 | ||
1253 | if (!arg) | 1251 | if (!arg) |
1254 | return -EINVAL; | 1252 | return -EINVAL; |
1255 | pciinfo.domain = pci_domain_nr(host->pdev->bus); | 1253 | pciinfo.domain = pci_domain_nr(h->pdev->bus); |
1256 | pciinfo.bus = host->pdev->bus->number; | 1254 | pciinfo.bus = h->pdev->bus->number; |
1257 | pciinfo.dev_fn = host->pdev->devfn; | 1255 | pciinfo.dev_fn = h->pdev->devfn; |
1258 | pciinfo.board_id = host->board_id; | 1256 | pciinfo.board_id = h->board_id; |
1259 | if (copy_to_user | 1257 | if (copy_to_user |
1260 | (argp, &pciinfo, sizeof(cciss_pci_info_struct))) | 1258 | (argp, &pciinfo, sizeof(cciss_pci_info_struct))) |
1261 | return -EFAULT; | 1259 | return -EFAULT; |
@@ -1267,9 +1265,9 @@ static int cciss_ioctl(struct block_device *bdev, fmode_t mode, | |||
1267 | if (!arg) | 1265 | if (!arg) |
1268 | return -EINVAL; | 1266 | return -EINVAL; |
1269 | intinfo.delay = | 1267 | intinfo.delay = |
1270 | readl(&host->cfgtable->HostWrite.CoalIntDelay); | 1268 | readl(&h->cfgtable->HostWrite.CoalIntDelay); |
1271 | intinfo.count = | 1269 | intinfo.count = |
1272 | readl(&host->cfgtable->HostWrite.CoalIntCount); | 1270 | readl(&h->cfgtable->HostWrite.CoalIntCount); |
1273 | if (copy_to_user | 1271 | if (copy_to_user |
1274 | (argp, &intinfo, sizeof(cciss_coalint_struct))) | 1272 | (argp, &intinfo, sizeof(cciss_coalint_struct))) |
1275 | return -EFAULT; | 1273 | return -EFAULT; |
@@ -1293,22 +1291,22 @@ static int cciss_ioctl(struct block_device *bdev, fmode_t mode, | |||
1293 | // printk("cciss_ioctl: delay and count cannot be 0\n"); | 1291 | // printk("cciss_ioctl: delay and count cannot be 0\n"); |
1294 | return -EINVAL; | 1292 | return -EINVAL; |
1295 | } | 1293 | } |
1296 | spin_lock_irqsave(CCISS_LOCK(ctlr), flags); | 1294 | spin_lock_irqsave(&h->lock, flags); |
1297 | /* Update the field, and then ring the doorbell */ | 1295 | /* Update the field, and then ring the doorbell */ |
1298 | writel(intinfo.delay, | 1296 | writel(intinfo.delay, |
1299 | &(host->cfgtable->HostWrite.CoalIntDelay)); | 1297 | &(h->cfgtable->HostWrite.CoalIntDelay)); |
1300 | writel(intinfo.count, | 1298 | writel(intinfo.count, |
1301 | &(host->cfgtable->HostWrite.CoalIntCount)); | 1299 | &(h->cfgtable->HostWrite.CoalIntCount)); |
1302 | writel(CFGTBL_ChangeReq, host->vaddr + SA5_DOORBELL); | 1300 | writel(CFGTBL_ChangeReq, h->vaddr + SA5_DOORBELL); |
1303 | 1301 | ||
1304 | for (i = 0; i < MAX_IOCTL_CONFIG_WAIT; i++) { | 1302 | for (i = 0; i < MAX_IOCTL_CONFIG_WAIT; i++) { |
1305 | if (!(readl(host->vaddr + SA5_DOORBELL) | 1303 | if (!(readl(h->vaddr + SA5_DOORBELL) |
1306 | & CFGTBL_ChangeReq)) | 1304 | & CFGTBL_ChangeReq)) |
1307 | break; | 1305 | break; |
1308 | /* delay and try again */ | 1306 | /* delay and try again */ |
1309 | udelay(1000); | 1307 | udelay(1000); |
1310 | } | 1308 | } |
1311 | spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags); | 1309 | spin_unlock_irqrestore(&h->lock, flags); |
1312 | if (i >= MAX_IOCTL_CONFIG_WAIT) | 1310 | if (i >= MAX_IOCTL_CONFIG_WAIT) |
1313 | return -EAGAIN; | 1311 | return -EAGAIN; |
1314 | return 0; | 1312 | return 0; |
@@ -1322,7 +1320,7 @@ static int cciss_ioctl(struct block_device *bdev, fmode_t mode, | |||
1322 | return -EINVAL; | 1320 | return -EINVAL; |
1323 | for (i = 0; i < 16; i++) | 1321 | for (i = 0; i < 16; i++) |
1324 | NodeName[i] = | 1322 | NodeName[i] = |
1325 | readb(&host->cfgtable->ServerName[i]); | 1323 | readb(&h->cfgtable->ServerName[i]); |
1326 | if (copy_to_user(argp, NodeName, sizeof(NodeName_type))) | 1324 | if (copy_to_user(argp, NodeName, sizeof(NodeName_type))) |
1327 | return -EFAULT; | 1325 | return -EFAULT; |
1328 | return 0; | 1326 | return 0; |
@@ -1342,23 +1340,23 @@ static int cciss_ioctl(struct block_device *bdev, fmode_t mode, | |||
1342 | (NodeName, argp, sizeof(NodeName_type))) | 1340 | (NodeName, argp, sizeof(NodeName_type))) |
1343 | return -EFAULT; | 1341 | return -EFAULT; |
1344 | 1342 | ||
1345 | spin_lock_irqsave(CCISS_LOCK(ctlr), flags); | 1343 | spin_lock_irqsave(&h->lock, flags); |
1346 | 1344 | ||
1347 | /* Update the field, and then ring the doorbell */ | 1345 | /* Update the field, and then ring the doorbell */ |
1348 | for (i = 0; i < 16; i++) | 1346 | for (i = 0; i < 16; i++) |
1349 | writeb(NodeName[i], | 1347 | writeb(NodeName[i], |
1350 | &host->cfgtable->ServerName[i]); | 1348 | &h->cfgtable->ServerName[i]); |
1351 | 1349 | ||
1352 | writel(CFGTBL_ChangeReq, host->vaddr + SA5_DOORBELL); | 1350 | writel(CFGTBL_ChangeReq, h->vaddr + SA5_DOORBELL); |
1353 | 1351 | ||
1354 | for (i = 0; i < MAX_IOCTL_CONFIG_WAIT; i++) { | 1352 | for (i = 0; i < MAX_IOCTL_CONFIG_WAIT; i++) { |
1355 | if (!(readl(host->vaddr + SA5_DOORBELL) | 1353 | if (!(readl(h->vaddr + SA5_DOORBELL) |
1356 | & CFGTBL_ChangeReq)) | 1354 | & CFGTBL_ChangeReq)) |
1357 | break; | 1355 | break; |
1358 | /* delay and try again */ | 1356 | /* delay and try again */ |
1359 | udelay(1000); | 1357 | udelay(1000); |
1360 | } | 1358 | } |
1361 | spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags); | 1359 | spin_unlock_irqrestore(&h->lock, flags); |
1362 | if (i >= MAX_IOCTL_CONFIG_WAIT) | 1360 | if (i >= MAX_IOCTL_CONFIG_WAIT) |
1363 | return -EAGAIN; | 1361 | return -EAGAIN; |
1364 | return 0; | 1362 | return 0; |
@@ -1370,7 +1368,7 @@ static int cciss_ioctl(struct block_device *bdev, fmode_t mode, | |||
1370 | 1368 | ||
1371 | if (!arg) | 1369 | if (!arg) |
1372 | return -EINVAL; | 1370 | return -EINVAL; |
1373 | heartbeat = readl(&host->cfgtable->HeartBeat); | 1371 | heartbeat = readl(&h->cfgtable->HeartBeat); |
1374 | if (copy_to_user | 1372 | if (copy_to_user |
1375 | (argp, &heartbeat, sizeof(Heartbeat_type))) | 1373 | (argp, &heartbeat, sizeof(Heartbeat_type))) |
1376 | return -EFAULT; | 1374 | return -EFAULT; |
@@ -1382,7 +1380,7 @@ static int cciss_ioctl(struct block_device *bdev, fmode_t mode, | |||
1382 | 1380 | ||
1383 | if (!arg) | 1381 | if (!arg) |
1384 | return -EINVAL; | 1382 | return -EINVAL; |
1385 | BusTypes = readl(&host->cfgtable->BusTypes); | 1383 | BusTypes = readl(&h->cfgtable->BusTypes); |
1386 | if (copy_to_user | 1384 | if (copy_to_user |
1387 | (argp, &BusTypes, sizeof(BusTypes_type))) | 1385 | (argp, &BusTypes, sizeof(BusTypes_type))) |
1388 | return -EFAULT; | 1386 | return -EFAULT; |
@@ -1394,7 +1392,7 @@ static int cciss_ioctl(struct block_device *bdev, fmode_t mode, | |||
1394 | 1392 | ||
1395 | if (!arg) | 1393 | if (!arg) |
1396 | return -EINVAL; | 1394 | return -EINVAL; |
1397 | memcpy(firmware, host->firm_ver, 4); | 1395 | memcpy(firmware, h->firm_ver, 4); |
1398 | 1396 | ||
1399 | if (copy_to_user | 1397 | if (copy_to_user |
1400 | (argp, firmware, sizeof(FirmwareVer_type))) | 1398 | (argp, firmware, sizeof(FirmwareVer_type))) |
@@ -1417,7 +1415,7 @@ static int cciss_ioctl(struct block_device *bdev, fmode_t mode, | |||
1417 | case CCISS_DEREGDISK: | 1415 | case CCISS_DEREGDISK: |
1418 | case CCISS_REGNEWD: | 1416 | case CCISS_REGNEWD: |
1419 | case CCISS_REVALIDVOLS: | 1417 | case CCISS_REVALIDVOLS: |
1420 | return rebuild_lun_table(host, 0, 1); | 1418 | return rebuild_lun_table(h, 0, 1); |
1421 | 1419 | ||
1422 | case CCISS_GETLUNINFO:{ | 1420 | case CCISS_GETLUNINFO:{ |
1423 | LogvolInfo_struct luninfo; | 1421 | LogvolInfo_struct luninfo; |
@@ -1472,7 +1470,8 @@ static int cciss_ioctl(struct block_device *bdev, fmode_t mode, | |||
1472 | } else { | 1470 | } else { |
1473 | memset(buff, 0, iocommand.buf_size); | 1471 | memset(buff, 0, iocommand.buf_size); |
1474 | } | 1472 | } |
1475 | if ((c = cmd_alloc(host, 0)) == NULL) { | 1473 | c = cmd_alloc(h, 0); |
1474 | if (!c) { | ||
1476 | kfree(buff); | 1475 | kfree(buff); |
1477 | return -ENOMEM; | 1476 | return -ENOMEM; |
1478 | } | 1477 | } |
@@ -1498,7 +1497,7 @@ static int cciss_ioctl(struct block_device *bdev, fmode_t mode, | |||
1498 | 1497 | ||
1499 | /* Fill in the scatter gather information */ | 1498 | /* Fill in the scatter gather information */ |
1500 | if (iocommand.buf_size > 0) { | 1499 | if (iocommand.buf_size > 0) { |
1501 | temp64.val = pci_map_single(host->pdev, buff, | 1500 | temp64.val = pci_map_single(h->pdev, buff, |
1502 | iocommand.buf_size, | 1501 | iocommand.buf_size, |
1503 | PCI_DMA_BIDIRECTIONAL); | 1502 | PCI_DMA_BIDIRECTIONAL); |
1504 | c->SG[0].Addr.lower = temp64.val32.lower; | 1503 | c->SG[0].Addr.lower = temp64.val32.lower; |
@@ -1508,24 +1507,24 @@ static int cciss_ioctl(struct block_device *bdev, fmode_t mode, | |||
1508 | } | 1507 | } |
1509 | c->waiting = &wait; | 1508 | c->waiting = &wait; |
1510 | 1509 | ||
1511 | enqueue_cmd_and_start_io(host, c); | 1510 | enqueue_cmd_and_start_io(h, c); |
1512 | wait_for_completion(&wait); | 1511 | wait_for_completion(&wait); |
1513 | 1512 | ||
1514 | /* unlock the buffers from DMA */ | 1513 | /* unlock the buffers from DMA */ |
1515 | temp64.val32.lower = c->SG[0].Addr.lower; | 1514 | temp64.val32.lower = c->SG[0].Addr.lower; |
1516 | temp64.val32.upper = c->SG[0].Addr.upper; | 1515 | temp64.val32.upper = c->SG[0].Addr.upper; |
1517 | pci_unmap_single(host->pdev, (dma_addr_t) temp64.val, | 1516 | pci_unmap_single(h->pdev, (dma_addr_t) temp64.val, |
1518 | iocommand.buf_size, | 1517 | iocommand.buf_size, |
1519 | PCI_DMA_BIDIRECTIONAL); | 1518 | PCI_DMA_BIDIRECTIONAL); |
1520 | 1519 | ||
1521 | check_ioctl_unit_attention(host, c); | 1520 | check_ioctl_unit_attention(h, c); |
1522 | 1521 | ||
1523 | /* Copy the error information out */ | 1522 | /* Copy the error information out */ |
1524 | iocommand.error_info = *(c->err_info); | 1523 | iocommand.error_info = *(c->err_info); |
1525 | if (copy_to_user | 1524 | if (copy_to_user |
1526 | (argp, &iocommand, sizeof(IOCTL_Command_struct))) { | 1525 | (argp, &iocommand, sizeof(IOCTL_Command_struct))) { |
1527 | kfree(buff); | 1526 | kfree(buff); |
1528 | cmd_free(host, c, 0); | 1527 | cmd_free(h, c, 0); |
1529 | return -EFAULT; | 1528 | return -EFAULT; |
1530 | } | 1529 | } |
1531 | 1530 | ||
@@ -1534,12 +1533,12 @@ static int cciss_ioctl(struct block_device *bdev, fmode_t mode, | |||
1534 | if (copy_to_user | 1533 | if (copy_to_user |
1535 | (iocommand.buf, buff, iocommand.buf_size)) { | 1534 | (iocommand.buf, buff, iocommand.buf_size)) { |
1536 | kfree(buff); | 1535 | kfree(buff); |
1537 | cmd_free(host, c, 0); | 1536 | cmd_free(h, c, 0); |
1538 | return -EFAULT; | 1537 | return -EFAULT; |
1539 | } | 1538 | } |
1540 | } | 1539 | } |
1541 | kfree(buff); | 1540 | kfree(buff); |
1542 | cmd_free(host, c, 0); | 1541 | cmd_free(h, c, 0); |
1543 | return 0; | 1542 | return 0; |
1544 | } | 1543 | } |
1545 | case CCISS_BIG_PASSTHRU:{ | 1544 | case CCISS_BIG_PASSTHRU:{ |
@@ -1621,7 +1620,8 @@ static int cciss_ioctl(struct block_device *bdev, fmode_t mode, | |||
1621 | data_ptr += sz; | 1620 | data_ptr += sz; |
1622 | sg_used++; | 1621 | sg_used++; |
1623 | } | 1622 | } |
1624 | if ((c = cmd_alloc(host, 0)) == NULL) { | 1623 | c = cmd_alloc(h, 0); |
1624 | if (!c) { | ||
1625 | status = -ENOMEM; | 1625 | status = -ENOMEM; |
1626 | goto cleanup1; | 1626 | goto cleanup1; |
1627 | } | 1627 | } |
@@ -1642,7 +1642,7 @@ static int cciss_ioctl(struct block_device *bdev, fmode_t mode, | |||
1642 | if (ioc->buf_size > 0) { | 1642 | if (ioc->buf_size > 0) { |
1643 | for (i = 0; i < sg_used; i++) { | 1643 | for (i = 0; i < sg_used; i++) { |
1644 | temp64.val = | 1644 | temp64.val = |
1645 | pci_map_single(host->pdev, buff[i], | 1645 | pci_map_single(h->pdev, buff[i], |
1646 | buff_size[i], | 1646 | buff_size[i], |
1647 | PCI_DMA_BIDIRECTIONAL); | 1647 | PCI_DMA_BIDIRECTIONAL); |
1648 | c->SG[i].Addr.lower = | 1648 | c->SG[i].Addr.lower = |
@@ -1654,21 +1654,21 @@ static int cciss_ioctl(struct block_device *bdev, fmode_t mode, | |||
1654 | } | 1654 | } |
1655 | } | 1655 | } |
1656 | c->waiting = &wait; | 1656 | c->waiting = &wait; |
1657 | enqueue_cmd_and_start_io(host, c); | 1657 | enqueue_cmd_and_start_io(h, c); |
1658 | wait_for_completion(&wait); | 1658 | wait_for_completion(&wait); |
1659 | /* unlock the buffers from DMA */ | 1659 | /* unlock the buffers from DMA */ |
1660 | for (i = 0; i < sg_used; i++) { | 1660 | for (i = 0; i < sg_used; i++) { |
1661 | temp64.val32.lower = c->SG[i].Addr.lower; | 1661 | temp64.val32.lower = c->SG[i].Addr.lower; |
1662 | temp64.val32.upper = c->SG[i].Addr.upper; | 1662 | temp64.val32.upper = c->SG[i].Addr.upper; |
1663 | pci_unmap_single(host->pdev, | 1663 | pci_unmap_single(h->pdev, |
1664 | (dma_addr_t) temp64.val, buff_size[i], | 1664 | (dma_addr_t) temp64.val, buff_size[i], |
1665 | PCI_DMA_BIDIRECTIONAL); | 1665 | PCI_DMA_BIDIRECTIONAL); |
1666 | } | 1666 | } |
1667 | check_ioctl_unit_attention(host, c); | 1667 | check_ioctl_unit_attention(h, c); |
1668 | /* Copy the error information out */ | 1668 | /* Copy the error information out */ |
1669 | ioc->error_info = *(c->err_info); | 1669 | ioc->error_info = *(c->err_info); |
1670 | if (copy_to_user(argp, ioc, sizeof(*ioc))) { | 1670 | if (copy_to_user(argp, ioc, sizeof(*ioc))) { |
1671 | cmd_free(host, c, 0); | 1671 | cmd_free(h, c, 0); |
1672 | status = -EFAULT; | 1672 | status = -EFAULT; |
1673 | goto cleanup1; | 1673 | goto cleanup1; |
1674 | } | 1674 | } |
@@ -1678,14 +1678,14 @@ static int cciss_ioctl(struct block_device *bdev, fmode_t mode, | |||
1678 | for (i = 0; i < sg_used; i++) { | 1678 | for (i = 0; i < sg_used; i++) { |
1679 | if (copy_to_user | 1679 | if (copy_to_user |
1680 | (ptr, buff[i], buff_size[i])) { | 1680 | (ptr, buff[i], buff_size[i])) { |
1681 | cmd_free(host, c, 0); | 1681 | cmd_free(h, c, 0); |
1682 | status = -EFAULT; | 1682 | status = -EFAULT; |
1683 | goto cleanup1; | 1683 | goto cleanup1; |
1684 | } | 1684 | } |
1685 | ptr += buff_size[i]; | 1685 | ptr += buff_size[i]; |
1686 | } | 1686 | } |
1687 | } | 1687 | } |
1688 | cmd_free(host, c, 0); | 1688 | cmd_free(h, c, 0); |
1689 | status = 0; | 1689 | status = 0; |
1690 | cleanup1: | 1690 | cleanup1: |
1691 | if (buff) { | 1691 | if (buff) { |
@@ -1773,26 +1773,26 @@ static void cciss_check_queues(ctlr_info_t *h) | |||
1773 | 1773 | ||
1774 | static void cciss_softirq_done(struct request *rq) | 1774 | static void cciss_softirq_done(struct request *rq) |
1775 | { | 1775 | { |
1776 | CommandList_struct *cmd = rq->completion_data; | 1776 | CommandList_struct *c = rq->completion_data; |
1777 | ctlr_info_t *h = hba[cmd->ctlr]; | 1777 | ctlr_info_t *h = hba[c->ctlr]; |
1778 | SGDescriptor_struct *curr_sg = cmd->SG; | 1778 | SGDescriptor_struct *curr_sg = c->SG; |
1779 | u64bit temp64; | 1779 | u64bit temp64; |
1780 | unsigned long flags; | 1780 | unsigned long flags; |
1781 | int i, ddir; | 1781 | int i, ddir; |
1782 | int sg_index = 0; | 1782 | int sg_index = 0; |
1783 | 1783 | ||
1784 | if (cmd->Request.Type.Direction == XFER_READ) | 1784 | if (c->Request.Type.Direction == XFER_READ) |
1785 | ddir = PCI_DMA_FROMDEVICE; | 1785 | ddir = PCI_DMA_FROMDEVICE; |
1786 | else | 1786 | else |
1787 | ddir = PCI_DMA_TODEVICE; | 1787 | ddir = PCI_DMA_TODEVICE; |
1788 | 1788 | ||
1789 | /* command did not need to be retried */ | 1789 | /* command did not need to be retried */ |
1790 | /* unmap the DMA mapping for all the scatter gather elements */ | 1790 | /* unmap the DMA mapping for all the scatter gather elements */ |
1791 | for (i = 0; i < cmd->Header.SGList; i++) { | 1791 | for (i = 0; i < c->Header.SGList; i++) { |
1792 | if (curr_sg[sg_index].Ext == CCISS_SG_CHAIN) { | 1792 | if (curr_sg[sg_index].Ext == CCISS_SG_CHAIN) { |
1793 | cciss_unmap_sg_chain_block(h, cmd); | 1793 | cciss_unmap_sg_chain_block(h, c); |
1794 | /* Point to the next block */ | 1794 | /* Point to the next block */ |
1795 | curr_sg = h->cmd_sg_list[cmd->cmdindex]; | 1795 | curr_sg = h->cmd_sg_list[c->cmdindex]; |
1796 | sg_index = 0; | 1796 | sg_index = 0; |
1797 | } | 1797 | } |
1798 | temp64.val32.lower = curr_sg[sg_index].Addr.lower; | 1798 | temp64.val32.lower = curr_sg[sg_index].Addr.lower; |
@@ -1808,12 +1808,12 @@ static void cciss_softirq_done(struct request *rq) | |||
1808 | 1808 | ||
1809 | /* set the residual count for pc requests */ | 1809 | /* set the residual count for pc requests */ |
1810 | if (rq->cmd_type == REQ_TYPE_BLOCK_PC) | 1810 | if (rq->cmd_type == REQ_TYPE_BLOCK_PC) |
1811 | rq->resid_len = cmd->err_info->ResidualCnt; | 1811 | rq->resid_len = c->err_info->ResidualCnt; |
1812 | 1812 | ||
1813 | blk_end_request_all(rq, (rq->errors == 0) ? 0 : -EIO); | 1813 | blk_end_request_all(rq, (rq->errors == 0) ? 0 : -EIO); |
1814 | 1814 | ||
1815 | spin_lock_irqsave(&h->lock, flags); | 1815 | spin_lock_irqsave(&h->lock, flags); |
1816 | cmd_free(h, cmd, 1); | 1816 | cmd_free(h, c, 1); |
1817 | cciss_check_queues(h); | 1817 | cciss_check_queues(h); |
1818 | spin_unlock_irqrestore(&h->lock, flags); | 1818 | spin_unlock_irqrestore(&h->lock, flags); |
1819 | } | 1819 | } |
@@ -1829,7 +1829,7 @@ static inline void log_unit_to_scsi3addr(ctlr_info_t *h, | |||
1829 | * via the inquiry page 0. Model, vendor, and rev are set to empty strings if | 1829 | * via the inquiry page 0. Model, vendor, and rev are set to empty strings if |
1830 | * they cannot be read. | 1830 | * they cannot be read. |
1831 | */ | 1831 | */ |
1832 | static void cciss_get_device_descr(int ctlr, int logvol, | 1832 | static void cciss_get_device_descr(ctlr_info_t *h, int logvol, |
1833 | char *vendor, char *model, char *rev) | 1833 | char *vendor, char *model, char *rev) |
1834 | { | 1834 | { |
1835 | int rc; | 1835 | int rc; |
@@ -1844,8 +1844,8 @@ static void cciss_get_device_descr(int ctlr, int logvol, | |||
1844 | if (!inq_buf) | 1844 | if (!inq_buf) |
1845 | return; | 1845 | return; |
1846 | 1846 | ||
1847 | log_unit_to_scsi3addr(hba[ctlr], scsi3addr, logvol); | 1847 | log_unit_to_scsi3addr(h, scsi3addr, logvol); |
1848 | rc = sendcmd_withirq(CISS_INQUIRY, ctlr, inq_buf, sizeof(*inq_buf), 0, | 1848 | rc = sendcmd_withirq(h, CISS_INQUIRY, inq_buf, sizeof(*inq_buf), 0, |
1849 | scsi3addr, TYPE_CMD); | 1849 | scsi3addr, TYPE_CMD); |
1850 | if (rc == IO_OK) { | 1850 | if (rc == IO_OK) { |
1851 | memcpy(vendor, &inq_buf->data_byte[8], VENDOR_LEN); | 1851 | memcpy(vendor, &inq_buf->data_byte[8], VENDOR_LEN); |
@@ -1865,7 +1865,7 @@ static void cciss_get_device_descr(int ctlr, int logvol, | |||
1865 | * number cannot be had, for whatever reason, 16 bytes of 0xff | 1865 | * number cannot be had, for whatever reason, 16 bytes of 0xff |
1866 | * are returned instead. | 1866 | * are returned instead. |
1867 | */ | 1867 | */ |
1868 | static void cciss_get_serial_no(int ctlr, int logvol, | 1868 | static void cciss_get_serial_no(ctlr_info_t *h, int logvol, |
1869 | unsigned char *serial_no, int buflen) | 1869 | unsigned char *serial_no, int buflen) |
1870 | { | 1870 | { |
1871 | #define PAGE_83_INQ_BYTES 64 | 1871 | #define PAGE_83_INQ_BYTES 64 |
@@ -1880,8 +1880,8 @@ static void cciss_get_serial_no(int ctlr, int logvol, | |||
1880 | if (!buf) | 1880 | if (!buf) |
1881 | return; | 1881 | return; |
1882 | memset(serial_no, 0, buflen); | 1882 | memset(serial_no, 0, buflen); |
1883 | log_unit_to_scsi3addr(hba[ctlr], scsi3addr, logvol); | 1883 | log_unit_to_scsi3addr(h, scsi3addr, logvol); |
1884 | rc = sendcmd_withirq(CISS_INQUIRY, ctlr, buf, | 1884 | rc = sendcmd_withirq(h, CISS_INQUIRY, buf, |
1885 | PAGE_83_INQ_BYTES, 0x83, scsi3addr, TYPE_CMD); | 1885 | PAGE_83_INQ_BYTES, 0x83, scsi3addr, TYPE_CMD); |
1886 | if (rc == IO_OK) | 1886 | if (rc == IO_OK) |
1887 | memcpy(serial_no, &buf[8], buflen); | 1887 | memcpy(serial_no, &buf[8], buflen); |
@@ -1947,10 +1947,9 @@ init_queue_failure: | |||
1947 | * is also the controller node. Any changes to disk 0 will show up on | 1947 | * is also the controller node. Any changes to disk 0 will show up on |
1948 | * the next reboot. | 1948 | * the next reboot. |
1949 | */ | 1949 | */ |
1950 | static void cciss_update_drive_info(int ctlr, int drv_index, int first_time, | 1950 | static void cciss_update_drive_info(ctlr_info_t *h, int drv_index, |
1951 | int via_ioctl) | 1951 | int first_time, int via_ioctl) |
1952 | { | 1952 | { |
1953 | ctlr_info_t *h = hba[ctlr]; | ||
1954 | struct gendisk *disk; | 1953 | struct gendisk *disk; |
1955 | InquiryData_struct *inq_buff = NULL; | 1954 | InquiryData_struct *inq_buff = NULL; |
1956 | unsigned int block_size; | 1955 | unsigned int block_size; |
@@ -1967,16 +1966,16 @@ static void cciss_update_drive_info(int ctlr, int drv_index, int first_time, | |||
1967 | 1966 | ||
1968 | /* testing to see if 16-byte CDBs are already being used */ | 1967 | /* testing to see if 16-byte CDBs are already being used */ |
1969 | if (h->cciss_read == CCISS_READ_16) { | 1968 | if (h->cciss_read == CCISS_READ_16) { |
1970 | cciss_read_capacity_16(h->ctlr, drv_index, | 1969 | cciss_read_capacity_16(h, drv_index, |
1971 | &total_size, &block_size); | 1970 | &total_size, &block_size); |
1972 | 1971 | ||
1973 | } else { | 1972 | } else { |
1974 | cciss_read_capacity(ctlr, drv_index, &total_size, &block_size); | 1973 | cciss_read_capacity(h, drv_index, &total_size, &block_size); |
1975 | /* if read_capacity returns all F's this volume is >2TB */ | 1974 | /* if read_capacity returns all F's this volume is >2TB */ |
1976 | /* in size so we switch to 16-byte CDB's for all */ | 1975 | /* in size so we switch to 16-byte CDB's for all */ |
1977 | /* read/write ops */ | 1976 | /* read/write ops */ |
1978 | if (total_size == 0xFFFFFFFFULL) { | 1977 | if (total_size == 0xFFFFFFFFULL) { |
1979 | cciss_read_capacity_16(ctlr, drv_index, | 1978 | cciss_read_capacity_16(h, drv_index, |
1980 | &total_size, &block_size); | 1979 | &total_size, &block_size); |
1981 | h->cciss_read = CCISS_READ_16; | 1980 | h->cciss_read = CCISS_READ_16; |
1982 | h->cciss_write = CCISS_WRITE_16; | 1981 | h->cciss_write = CCISS_WRITE_16; |
@@ -1986,14 +1985,14 @@ static void cciss_update_drive_info(int ctlr, int drv_index, int first_time, | |||
1986 | } | 1985 | } |
1987 | } | 1986 | } |
1988 | 1987 | ||
1989 | cciss_geometry_inquiry(ctlr, drv_index, total_size, block_size, | 1988 | cciss_geometry_inquiry(h, drv_index, total_size, block_size, |
1990 | inq_buff, drvinfo); | 1989 | inq_buff, drvinfo); |
1991 | drvinfo->block_size = block_size; | 1990 | drvinfo->block_size = block_size; |
1992 | drvinfo->nr_blocks = total_size + 1; | 1991 | drvinfo->nr_blocks = total_size + 1; |
1993 | 1992 | ||
1994 | cciss_get_device_descr(ctlr, drv_index, drvinfo->vendor, | 1993 | cciss_get_device_descr(h, drv_index, drvinfo->vendor, |
1995 | drvinfo->model, drvinfo->rev); | 1994 | drvinfo->model, drvinfo->rev); |
1996 | cciss_get_serial_no(ctlr, drv_index, drvinfo->serial_no, | 1995 | cciss_get_serial_no(h, drv_index, drvinfo->serial_no, |
1997 | sizeof(drvinfo->serial_no)); | 1996 | sizeof(drvinfo->serial_no)); |
1998 | /* Save the lunid in case we deregister the disk, below. */ | 1997 | /* Save the lunid in case we deregister the disk, below. */ |
1999 | memcpy(drvinfo->LunID, h->drv[drv_index]->LunID, | 1998 | memcpy(drvinfo->LunID, h->drv[drv_index]->LunID, |
@@ -2019,9 +2018,9 @@ static void cciss_update_drive_info(int ctlr, int drv_index, int first_time, | |||
2019 | */ | 2018 | */ |
2020 | if (h->drv[drv_index]->raid_level != -1 && drv_index != 0) { | 2019 | if (h->drv[drv_index]->raid_level != -1 && drv_index != 0) { |
2021 | printk(KERN_WARNING "disk %d has changed.\n", drv_index); | 2020 | printk(KERN_WARNING "disk %d has changed.\n", drv_index); |
2022 | spin_lock_irqsave(CCISS_LOCK(h->ctlr), flags); | 2021 | spin_lock_irqsave(&h->lock, flags); |
2023 | h->drv[drv_index]->busy_configuring = 1; | 2022 | h->drv[drv_index]->busy_configuring = 1; |
2024 | spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags); | 2023 | spin_unlock_irqrestore(&h->lock, flags); |
2025 | 2024 | ||
2026 | /* deregister_disk sets h->drv[drv_index]->queue = NULL | 2025 | /* deregister_disk sets h->drv[drv_index]->queue = NULL |
2027 | * which keeps the interrupt handler from starting | 2026 | * which keeps the interrupt handler from starting |
@@ -2243,7 +2242,6 @@ error: | |||
2243 | static int rebuild_lun_table(ctlr_info_t *h, int first_time, | 2242 | static int rebuild_lun_table(ctlr_info_t *h, int first_time, |
2244 | int via_ioctl) | 2243 | int via_ioctl) |
2245 | { | 2244 | { |
2246 | int ctlr = h->ctlr; | ||
2247 | int num_luns; | 2245 | int num_luns; |
2248 | ReportLunData_struct *ld_buff = NULL; | 2246 | ReportLunData_struct *ld_buff = NULL; |
2249 | int return_code; | 2247 | int return_code; |
@@ -2258,19 +2256,19 @@ static int rebuild_lun_table(ctlr_info_t *h, int first_time, | |||
2258 | return -EPERM; | 2256 | return -EPERM; |
2259 | 2257 | ||
2260 | /* Set busy_configuring flag for this operation */ | 2258 | /* Set busy_configuring flag for this operation */ |
2261 | spin_lock_irqsave(CCISS_LOCK(h->ctlr), flags); | 2259 | spin_lock_irqsave(&h->lock, flags); |
2262 | if (h->busy_configuring) { | 2260 | if (h->busy_configuring) { |
2263 | spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags); | 2261 | spin_unlock_irqrestore(&h->lock, flags); |
2264 | return -EBUSY; | 2262 | return -EBUSY; |
2265 | } | 2263 | } |
2266 | h->busy_configuring = 1; | 2264 | h->busy_configuring = 1; |
2267 | spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags); | 2265 | spin_unlock_irqrestore(&h->lock, flags); |
2268 | 2266 | ||
2269 | ld_buff = kzalloc(sizeof(ReportLunData_struct), GFP_KERNEL); | 2267 | ld_buff = kzalloc(sizeof(ReportLunData_struct), GFP_KERNEL); |
2270 | if (ld_buff == NULL) | 2268 | if (ld_buff == NULL) |
2271 | goto mem_msg; | 2269 | goto mem_msg; |
2272 | 2270 | ||
2273 | return_code = sendcmd_withirq(CISS_REPORT_LOG, ctlr, ld_buff, | 2271 | return_code = sendcmd_withirq(h, CISS_REPORT_LOG, ld_buff, |
2274 | sizeof(ReportLunData_struct), | 2272 | sizeof(ReportLunData_struct), |
2275 | 0, CTLR_LUNID, TYPE_CMD); | 2273 | 0, CTLR_LUNID, TYPE_CMD); |
2276 | 2274 | ||
@@ -2317,9 +2315,9 @@ static int rebuild_lun_table(ctlr_info_t *h, int first_time, | |||
2317 | } | 2315 | } |
2318 | if (!drv_found) { | 2316 | if (!drv_found) { |
2319 | /* Deregister it from the OS, it's gone. */ | 2317 | /* Deregister it from the OS, it's gone. */ |
2320 | spin_lock_irqsave(CCISS_LOCK(h->ctlr), flags); | 2318 | spin_lock_irqsave(&h->lock, flags); |
2321 | h->drv[i]->busy_configuring = 1; | 2319 | h->drv[i]->busy_configuring = 1; |
2322 | spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags); | 2320 | spin_unlock_irqrestore(&h->lock, flags); |
2323 | return_code = deregister_disk(h, i, 1, via_ioctl); | 2321 | return_code = deregister_disk(h, i, 1, via_ioctl); |
2324 | if (h->drv[i] != NULL) | 2322 | if (h->drv[i] != NULL) |
2325 | h->drv[i]->busy_configuring = 0; | 2323 | h->drv[i]->busy_configuring = 0; |
@@ -2358,8 +2356,7 @@ static int rebuild_lun_table(ctlr_info_t *h, int first_time, | |||
2358 | if (drv_index == -1) | 2356 | if (drv_index == -1) |
2359 | goto freeret; | 2357 | goto freeret; |
2360 | } | 2358 | } |
2361 | cciss_update_drive_info(ctlr, drv_index, first_time, | 2359 | cciss_update_drive_info(h, drv_index, first_time, via_ioctl); |
2362 | via_ioctl); | ||
2363 | } /* end for */ | 2360 | } /* end for */ |
2364 | 2361 | ||
2365 | freeret: | 2362 | freeret: |
@@ -2491,11 +2488,10 @@ static int deregister_disk(ctlr_info_t *h, int drv_index, | |||
2491 | return 0; | 2488 | return 0; |
2492 | } | 2489 | } |
2493 | 2490 | ||
2494 | static int fill_cmd(CommandList_struct *c, __u8 cmd, int ctlr, void *buff, | 2491 | static int fill_cmd(ctlr_info_t *h, CommandList_struct *c, __u8 cmd, void *buff, |
2495 | size_t size, __u8 page_code, unsigned char *scsi3addr, | 2492 | size_t size, __u8 page_code, unsigned char *scsi3addr, |
2496 | int cmd_type) | 2493 | int cmd_type) |
2497 | { | 2494 | { |
2498 | ctlr_info_t *h = hba[ctlr]; | ||
2499 | u64bit buff_dma_handle; | 2495 | u64bit buff_dma_handle; |
2500 | int status = IO_OK; | 2496 | int status = IO_OK; |
2501 | 2497 | ||
@@ -2580,7 +2576,8 @@ static int fill_cmd(CommandList_struct *c, __u8 cmd, int ctlr, void *buff, | |||
2580 | break; | 2576 | break; |
2581 | default: | 2577 | default: |
2582 | printk(KERN_WARNING | 2578 | printk(KERN_WARNING |
2583 | "cciss%d: Unknown Command 0x%c\n", ctlr, cmd); | 2579 | "cciss%d: Unknown Command 0x%c\n", |
2580 | h->ctlr, cmd); | ||
2584 | return IO_ERROR; | 2581 | return IO_ERROR; |
2585 | } | 2582 | } |
2586 | } else if (cmd_type == TYPE_MSG) { | 2583 | } else if (cmd_type == TYPE_MSG) { |
@@ -2613,12 +2610,13 @@ static int fill_cmd(CommandList_struct *c, __u8 cmd, int ctlr, void *buff, | |||
2613 | break; | 2610 | break; |
2614 | default: | 2611 | default: |
2615 | printk(KERN_WARNING | 2612 | printk(KERN_WARNING |
2616 | "cciss%d: unknown message type %d\n", ctlr, cmd); | 2613 | "cciss%d: unknown message type %d\n", |
2614 | h->ctlr, cmd); | ||
2617 | return IO_ERROR; | 2615 | return IO_ERROR; |
2618 | } | 2616 | } |
2619 | } else { | 2617 | } else { |
2620 | printk(KERN_WARNING | 2618 | printk(KERN_WARNING |
2621 | "cciss%d: unknown command type %d\n", ctlr, cmd_type); | 2619 | "cciss%d: unknown command type %d\n", h->ctlr, cmd_type); |
2622 | return IO_ERROR; | 2620 | return IO_ERROR; |
2623 | } | 2621 | } |
2624 | /* Fill in the scatter gather information */ | 2622 | /* Fill in the scatter gather information */ |
@@ -2760,18 +2758,17 @@ command_done: | |||
2760 | return return_status; | 2758 | return return_status; |
2761 | } | 2759 | } |
2762 | 2760 | ||
2763 | static int sendcmd_withirq(__u8 cmd, int ctlr, void *buff, size_t size, | 2761 | static int sendcmd_withirq(ctlr_info_t *h, __u8 cmd, void *buff, size_t size, |
2764 | __u8 page_code, unsigned char scsi3addr[], | 2762 | __u8 page_code, unsigned char scsi3addr[], |
2765 | int cmd_type) | 2763 | int cmd_type) |
2766 | { | 2764 | { |
2767 | ctlr_info_t *h = hba[ctlr]; | ||
2768 | CommandList_struct *c; | 2765 | CommandList_struct *c; |
2769 | int return_status; | 2766 | int return_status; |
2770 | 2767 | ||
2771 | c = cmd_alloc(h, 0); | 2768 | c = cmd_alloc(h, 0); |
2772 | if (!c) | 2769 | if (!c) |
2773 | return -ENOMEM; | 2770 | return -ENOMEM; |
2774 | return_status = fill_cmd(c, cmd, ctlr, buff, size, page_code, | 2771 | return_status = fill_cmd(h, c, cmd, buff, size, page_code, |
2775 | scsi3addr, cmd_type); | 2772 | scsi3addr, cmd_type); |
2776 | if (return_status == IO_OK) | 2773 | if (return_status == IO_OK) |
2777 | return_status = sendcmd_withirq_core(h, c, 1); | 2774 | return_status = sendcmd_withirq_core(h, c, 1); |
@@ -2780,7 +2777,7 @@ static int sendcmd_withirq(__u8 cmd, int ctlr, void *buff, size_t size, | |||
2780 | return return_status; | 2777 | return return_status; |
2781 | } | 2778 | } |
2782 | 2779 | ||
2783 | static void cciss_geometry_inquiry(int ctlr, int logvol, | 2780 | static void cciss_geometry_inquiry(ctlr_info_t *h, int logvol, |
2784 | sector_t total_size, | 2781 | sector_t total_size, |
2785 | unsigned int block_size, | 2782 | unsigned int block_size, |
2786 | InquiryData_struct *inq_buff, | 2783 | InquiryData_struct *inq_buff, |
@@ -2791,8 +2788,8 @@ static void cciss_geometry_inquiry(int ctlr, int logvol, | |||
2791 | unsigned char scsi3addr[8]; | 2788 | unsigned char scsi3addr[8]; |
2792 | 2789 | ||
2793 | memset(inq_buff, 0, sizeof(InquiryData_struct)); | 2790 | memset(inq_buff, 0, sizeof(InquiryData_struct)); |
2794 | log_unit_to_scsi3addr(hba[ctlr], scsi3addr, logvol); | 2791 | log_unit_to_scsi3addr(h, scsi3addr, logvol); |
2795 | return_code = sendcmd_withirq(CISS_INQUIRY, ctlr, inq_buff, | 2792 | return_code = sendcmd_withirq(h, CISS_INQUIRY, inq_buff, |
2796 | sizeof(*inq_buff), 0xC1, scsi3addr, TYPE_CMD); | 2793 | sizeof(*inq_buff), 0xC1, scsi3addr, TYPE_CMD); |
2797 | if (return_code == IO_OK) { | 2794 | if (return_code == IO_OK) { |
2798 | if (inq_buff->data_byte[8] == 0xFF) { | 2795 | if (inq_buff->data_byte[8] == 0xFF) { |
@@ -2826,7 +2823,7 @@ static void cciss_geometry_inquiry(int ctlr, int logvol, | |||
2826 | } | 2823 | } |
2827 | 2824 | ||
2828 | static void | 2825 | static void |
2829 | cciss_read_capacity(int ctlr, int logvol, sector_t *total_size, | 2826 | cciss_read_capacity(ctlr_info_t *h, int logvol, sector_t *total_size, |
2830 | unsigned int *block_size) | 2827 | unsigned int *block_size) |
2831 | { | 2828 | { |
2832 | ReadCapdata_struct *buf; | 2829 | ReadCapdata_struct *buf; |
@@ -2839,8 +2836,8 @@ cciss_read_capacity(int ctlr, int logvol, sector_t *total_size, | |||
2839 | return; | 2836 | return; |
2840 | } | 2837 | } |
2841 | 2838 | ||
2842 | log_unit_to_scsi3addr(hba[ctlr], scsi3addr, logvol); | 2839 | log_unit_to_scsi3addr(h, scsi3addr, logvol); |
2843 | return_code = sendcmd_withirq(CCISS_READ_CAPACITY, ctlr, buf, | 2840 | return_code = sendcmd_withirq(h, CCISS_READ_CAPACITY, buf, |
2844 | sizeof(ReadCapdata_struct), 0, scsi3addr, TYPE_CMD); | 2841 | sizeof(ReadCapdata_struct), 0, scsi3addr, TYPE_CMD); |
2845 | if (return_code == IO_OK) { | 2842 | if (return_code == IO_OK) { |
2846 | *total_size = be32_to_cpu(*(__be32 *) buf->total_size); | 2843 | *total_size = be32_to_cpu(*(__be32 *) buf->total_size); |
@@ -2853,7 +2850,7 @@ cciss_read_capacity(int ctlr, int logvol, sector_t *total_size, | |||
2853 | kfree(buf); | 2850 | kfree(buf); |
2854 | } | 2851 | } |
2855 | 2852 | ||
2856 | static void cciss_read_capacity_16(int ctlr, int logvol, | 2853 | static void cciss_read_capacity_16(ctlr_info_t *h, int logvol, |
2857 | sector_t *total_size, unsigned int *block_size) | 2854 | sector_t *total_size, unsigned int *block_size) |
2858 | { | 2855 | { |
2859 | ReadCapdata_struct_16 *buf; | 2856 | ReadCapdata_struct_16 *buf; |
@@ -2866,9 +2863,9 @@ static void cciss_read_capacity_16(int ctlr, int logvol, | |||
2866 | return; | 2863 | return; |
2867 | } | 2864 | } |
2868 | 2865 | ||
2869 | log_unit_to_scsi3addr(hba[ctlr], scsi3addr, logvol); | 2866 | log_unit_to_scsi3addr(h, scsi3addr, logvol); |
2870 | return_code = sendcmd_withirq(CCISS_READ_CAPACITY_16, | 2867 | return_code = sendcmd_withirq(h, CCISS_READ_CAPACITY_16, |
2871 | ctlr, buf, sizeof(ReadCapdata_struct_16), | 2868 | buf, sizeof(ReadCapdata_struct_16), |
2872 | 0, scsi3addr, TYPE_CMD); | 2869 | 0, scsi3addr, TYPE_CMD); |
2873 | if (return_code == IO_OK) { | 2870 | if (return_code == IO_OK) { |
2874 | *total_size = be64_to_cpu(*(__be64 *) buf->total_size); | 2871 | *total_size = be64_to_cpu(*(__be64 *) buf->total_size); |
@@ -2910,13 +2907,13 @@ static int cciss_revalidate(struct gendisk *disk) | |||
2910 | return 1; | 2907 | return 1; |
2911 | } | 2908 | } |
2912 | if (h->cciss_read == CCISS_READ_10) { | 2909 | if (h->cciss_read == CCISS_READ_10) { |
2913 | cciss_read_capacity(h->ctlr, logvol, | 2910 | cciss_read_capacity(h, logvol, |
2914 | &total_size, &block_size); | 2911 | &total_size, &block_size); |
2915 | } else { | 2912 | } else { |
2916 | cciss_read_capacity_16(h->ctlr, logvol, | 2913 | cciss_read_capacity_16(h, logvol, |
2917 | &total_size, &block_size); | 2914 | &total_size, &block_size); |
2918 | } | 2915 | } |
2919 | cciss_geometry_inquiry(h->ctlr, logvol, total_size, block_size, | 2916 | cciss_geometry_inquiry(h, logvol, total_size, block_size, |
2920 | inq_buff, drv); | 2917 | inq_buff, drv); |
2921 | 2918 | ||
2922 | blk_queue_logical_block_size(drv->queue, drv->block_size); | 2919 | blk_queue_logical_block_size(drv->queue, drv->block_size); |
@@ -2966,7 +2963,7 @@ static void start_io(ctlr_info_t *h) | |||
2966 | } | 2963 | } |
2967 | } | 2964 | } |
2968 | 2965 | ||
2969 | /* Assumes that CCISS_LOCK(h->ctlr) is held. */ | 2966 | /* Assumes that h->lock is held. */ |
2970 | /* Zeros out the error record and then resends the command back */ | 2967 | /* Zeros out the error record and then resends the command back */ |
2971 | /* to the controller */ | 2968 | /* to the controller */ |
2972 | static inline void resend_cciss_cmd(ctlr_info_t *h, CommandList_struct *c) | 2969 | static inline void resend_cciss_cmd(ctlr_info_t *h, CommandList_struct *c) |
@@ -3494,7 +3491,7 @@ static irqreturn_t do_cciss_intx(int irq, void *dev_id) | |||
3494 | * If there are completed commands in the completion queue, | 3491 | * If there are completed commands in the completion queue, |
3495 | * we had better do something about it. | 3492 | * we had better do something about it. |
3496 | */ | 3493 | */ |
3497 | spin_lock_irqsave(CCISS_LOCK(h->ctlr), flags); | 3494 | spin_lock_irqsave(&h->lock, flags); |
3498 | while (interrupt_pending(h)) { | 3495 | while (interrupt_pending(h)) { |
3499 | raw_tag = get_next_completion(h); | 3496 | raw_tag = get_next_completion(h); |
3500 | while (raw_tag != FIFO_EMPTY) { | 3497 | while (raw_tag != FIFO_EMPTY) { |
@@ -3505,7 +3502,7 @@ static irqreturn_t do_cciss_intx(int irq, void *dev_id) | |||
3505 | } | 3502 | } |
3506 | } | 3503 | } |
3507 | 3504 | ||
3508 | spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags); | 3505 | spin_unlock_irqrestore(&h->lock, flags); |
3509 | return IRQ_HANDLED; | 3506 | return IRQ_HANDLED; |
3510 | } | 3507 | } |
3511 | 3508 | ||
@@ -3524,7 +3521,7 @@ static irqreturn_t do_cciss_msix_intr(int irq, void *dev_id) | |||
3524 | * If there are completed commands in the completion queue, | 3521 | * If there are completed commands in the completion queue, |
3525 | * we had better do something about it. | 3522 | * we had better do something about it. |
3526 | */ | 3523 | */ |
3527 | spin_lock_irqsave(CCISS_LOCK(h->ctlr), flags); | 3524 | spin_lock_irqsave(&h->lock, flags); |
3528 | raw_tag = get_next_completion(h); | 3525 | raw_tag = get_next_completion(h); |
3529 | while (raw_tag != FIFO_EMPTY) { | 3526 | while (raw_tag != FIFO_EMPTY) { |
3530 | if (cciss_tag_contains_index(raw_tag)) | 3527 | if (cciss_tag_contains_index(raw_tag)) |
@@ -3533,7 +3530,7 @@ static irqreturn_t do_cciss_msix_intr(int irq, void *dev_id) | |||
3533 | raw_tag = process_nonindexed_cmd(h, raw_tag); | 3530 | raw_tag = process_nonindexed_cmd(h, raw_tag); |
3534 | } | 3531 | } |
3535 | 3532 | ||
3536 | spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags); | 3533 | spin_unlock_irqrestore(&h->lock, flags); |
3537 | return IRQ_HANDLED; | 3534 | return IRQ_HANDLED; |
3538 | } | 3535 | } |
3539 | 3536 | ||
@@ -3961,7 +3958,7 @@ clean_up: | |||
3961 | * controllers that are capable. If not, we use IO-APIC mode. | 3958 | * controllers that are capable. If not, we use IO-APIC mode. |
3962 | */ | 3959 | */ |
3963 | 3960 | ||
3964 | static void __devinit cciss_interrupt_mode(ctlr_info_t *c) | 3961 | static void __devinit cciss_interrupt_mode(ctlr_info_t *h) |
3965 | { | 3962 | { |
3966 | #ifdef CONFIG_PCI_MSI | 3963 | #ifdef CONFIG_PCI_MSI |
3967 | int err; | 3964 | int err; |
@@ -3970,18 +3967,18 @@ static void __devinit cciss_interrupt_mode(ctlr_info_t *c) | |||
3970 | }; | 3967 | }; |
3971 | 3968 | ||
3972 | /* Some boards advertise MSI but don't really support it */ | 3969 | /* Some boards advertise MSI but don't really support it */ |
3973 | if ((c->board_id == 0x40700E11) || (c->board_id == 0x40800E11) || | 3970 | if ((h->board_id == 0x40700E11) || (h->board_id == 0x40800E11) || |
3974 | (c->board_id == 0x40820E11) || (c->board_id == 0x40830E11)) | 3971 | (h->board_id == 0x40820E11) || (h->board_id == 0x40830E11)) |
3975 | goto default_int_mode; | 3972 | goto default_int_mode; |
3976 | 3973 | ||
3977 | if (pci_find_capability(c->pdev, PCI_CAP_ID_MSIX)) { | 3974 | if (pci_find_capability(h->pdev, PCI_CAP_ID_MSIX)) { |
3978 | err = pci_enable_msix(c->pdev, cciss_msix_entries, 4); | 3975 | err = pci_enable_msix(h->pdev, cciss_msix_entries, 4); |
3979 | if (!err) { | 3976 | if (!err) { |
3980 | c->intr[0] = cciss_msix_entries[0].vector; | 3977 | h->intr[0] = cciss_msix_entries[0].vector; |
3981 | c->intr[1] = cciss_msix_entries[1].vector; | 3978 | h->intr[1] = cciss_msix_entries[1].vector; |
3982 | c->intr[2] = cciss_msix_entries[2].vector; | 3979 | h->intr[2] = cciss_msix_entries[2].vector; |
3983 | c->intr[3] = cciss_msix_entries[3].vector; | 3980 | h->intr[3] = cciss_msix_entries[3].vector; |
3984 | c->msix_vector = 1; | 3981 | h->msix_vector = 1; |
3985 | return; | 3982 | return; |
3986 | } | 3983 | } |
3987 | if (err > 0) { | 3984 | if (err > 0) { |
@@ -3994,17 +3991,16 @@ static void __devinit cciss_interrupt_mode(ctlr_info_t *c) | |||
3994 | goto default_int_mode; | 3991 | goto default_int_mode; |
3995 | } | 3992 | } |
3996 | } | 3993 | } |
3997 | if (pci_find_capability(c->pdev, PCI_CAP_ID_MSI)) { | 3994 | if (pci_find_capability(h->pdev, PCI_CAP_ID_MSI)) { |
3998 | if (!pci_enable_msi(c->pdev)) { | 3995 | if (!pci_enable_msi(h->pdev)) |
3999 | c->msi_vector = 1; | 3996 | h->msi_vector = 1; |
4000 | } else { | 3997 | else |
4001 | printk(KERN_WARNING "cciss: MSI init failed\n"); | 3998 | printk(KERN_WARNING "cciss: MSI init failed\n"); |
4002 | } | ||
4003 | } | 3999 | } |
4004 | default_int_mode: | 4000 | default_int_mode: |
4005 | #endif /* CONFIG_PCI_MSI */ | 4001 | #endif /* CONFIG_PCI_MSI */ |
4006 | /* if we get here we're going to use the default interrupt mode */ | 4002 | /* if we get here we're going to use the default interrupt mode */ |
4007 | c->intr[PERF_MODE_INT] = c->pdev->irq; | 4003 | h->intr[PERF_MODE_INT] = h->pdev->irq; |
4008 | return; | 4004 | return; |
4009 | } | 4005 | } |
4010 | 4006 | ||
@@ -4190,28 +4186,28 @@ static inline void cciss_p600_dma_prefetch_quirk(ctlr_info_t *h) | |||
4190 | pci_write_config_dword(h->pdev, PCI_COMMAND_PARITY, dma_refetch); | 4186 | pci_write_config_dword(h->pdev, PCI_COMMAND_PARITY, dma_refetch); |
4191 | } | 4187 | } |
4192 | 4188 | ||
4193 | static int __devinit cciss_pci_init(ctlr_info_t *c) | 4189 | static int __devinit cciss_pci_init(ctlr_info_t *h) |
4194 | { | 4190 | { |
4195 | int prod_index, err; | 4191 | int prod_index, err; |
4196 | 4192 | ||
4197 | prod_index = cciss_lookup_board_id(c->pdev, &c->board_id); | 4193 | prod_index = cciss_lookup_board_id(h->pdev, &h->board_id); |
4198 | if (prod_index < 0) | 4194 | if (prod_index < 0) |
4199 | return -ENODEV; | 4195 | return -ENODEV; |
4200 | c->product_name = products[prod_index].product_name; | 4196 | h->product_name = products[prod_index].product_name; |
4201 | c->access = *(products[prod_index].access); | 4197 | h->access = *(products[prod_index].access); |
4202 | 4198 | ||
4203 | if (cciss_board_disabled(c)) { | 4199 | if (cciss_board_disabled(h)) { |
4204 | printk(KERN_WARNING | 4200 | printk(KERN_WARNING |
4205 | "cciss: controller appears to be disabled\n"); | 4201 | "cciss: controller appears to be disabled\n"); |
4206 | return -ENODEV; | 4202 | return -ENODEV; |
4207 | } | 4203 | } |
4208 | err = pci_enable_device(c->pdev); | 4204 | err = pci_enable_device(h->pdev); |
4209 | if (err) { | 4205 | if (err) { |
4210 | printk(KERN_ERR "cciss: Unable to Enable PCI device\n"); | 4206 | printk(KERN_ERR "cciss: Unable to Enable PCI device\n"); |
4211 | return err; | 4207 | return err; |
4212 | } | 4208 | } |
4213 | 4209 | ||
4214 | err = pci_request_regions(c->pdev, "cciss"); | 4210 | err = pci_request_regions(h->pdev, "cciss"); |
4215 | if (err) { | 4211 | if (err) { |
4216 | printk(KERN_ERR "cciss: Cannot obtain PCI resources, " | 4212 | printk(KERN_ERR "cciss: Cannot obtain PCI resources, " |
4217 | "aborting\n"); | 4213 | "aborting\n"); |
@@ -4220,38 +4216,38 @@ static int __devinit cciss_pci_init(ctlr_info_t *c) | |||
4220 | 4216 | ||
4221 | #ifdef CCISS_DEBUG | 4217 | #ifdef CCISS_DEBUG |
4222 | printk(KERN_INFO "command = %x\n", command); | 4218 | printk(KERN_INFO "command = %x\n", command); |
4223 | printk(KERN_INFO "irq = %x\n", c->pdev->irq); | 4219 | printk(KERN_INFO "irq = %x\n", h->pdev->irq); |
4224 | printk(KERN_INFO "board_id = %x\n", c->board_id); | 4220 | printk(KERN_INFO "board_id = %x\n", h->board_id); |
4225 | #endif /* CCISS_DEBUG */ | 4221 | #endif /* CCISS_DEBUG */ |
4226 | 4222 | ||
4227 | /* If the kernel supports MSI/MSI-X we will try to enable that functionality, | 4223 | /* If the kernel supports MSI/MSI-X we will try to enable that functionality, |
4228 | * else we use the IO-APIC interrupt assigned to us by system ROM. | 4224 | * else we use the IO-APIC interrupt assigned to us by system ROM. |
4229 | */ | 4225 | */ |
4230 | cciss_interrupt_mode(c); | 4226 | cciss_interrupt_mode(h); |
4231 | err = cciss_pci_find_memory_BAR(c->pdev, &c->paddr); | 4227 | err = cciss_pci_find_memory_BAR(h->pdev, &h->paddr); |
4232 | if (err) | 4228 | if (err) |
4233 | goto err_out_free_res; | 4229 | goto err_out_free_res; |
4234 | c->vaddr = remap_pci_mem(c->paddr, 0x250); | 4230 | h->vaddr = remap_pci_mem(h->paddr, 0x250); |
4235 | if (!c->vaddr) { | 4231 | if (!h->vaddr) { |
4236 | err = -ENOMEM; | 4232 | err = -ENOMEM; |
4237 | goto err_out_free_res; | 4233 | goto err_out_free_res; |
4238 | } | 4234 | } |
4239 | err = cciss_wait_for_board_ready(c); | 4235 | err = cciss_wait_for_board_ready(h); |
4240 | if (err) | 4236 | if (err) |
4241 | goto err_out_free_res; | 4237 | goto err_out_free_res; |
4242 | err = cciss_find_cfgtables(c); | 4238 | err = cciss_find_cfgtables(h); |
4243 | if (err) | 4239 | if (err) |
4244 | goto err_out_free_res; | 4240 | goto err_out_free_res; |
4245 | print_cfg_table(c->cfgtable); | 4241 | print_cfg_table(h->cfgtable); |
4246 | cciss_find_board_params(c); | 4242 | cciss_find_board_params(h); |
4247 | 4243 | ||
4248 | if (!CISS_signature_present(c)) { | 4244 | if (!CISS_signature_present(h)) { |
4249 | err = -ENODEV; | 4245 | err = -ENODEV; |
4250 | goto err_out_free_res; | 4246 | goto err_out_free_res; |
4251 | } | 4247 | } |
4252 | cciss_enable_scsi_prefetch(c); | 4248 | cciss_enable_scsi_prefetch(h); |
4253 | cciss_p600_dma_prefetch_quirk(c); | 4249 | cciss_p600_dma_prefetch_quirk(h); |
4254 | cciss_put_controller_into_performant_mode(c); | 4250 | cciss_put_controller_into_performant_mode(h); |
4255 | return 0; | 4251 | return 0; |
4256 | 4252 | ||
4257 | err_out_free_res: | 4253 | err_out_free_res: |
@@ -4259,13 +4255,13 @@ err_out_free_res: | |||
4259 | * Deliberately omit pci_disable_device(): it does something nasty to | 4255 | * Deliberately omit pci_disable_device(): it does something nasty to |
4260 | * Smart Array controllers that pci_enable_device does not undo | 4256 | * Smart Array controllers that pci_enable_device does not undo |
4261 | */ | 4257 | */ |
4262 | if (c->transtable) | 4258 | if (h->transtable) |
4263 | iounmap(c->transtable); | 4259 | iounmap(h->transtable); |
4264 | if (c->cfgtable) | 4260 | if (h->cfgtable) |
4265 | iounmap(c->cfgtable); | 4261 | iounmap(h->cfgtable); |
4266 | if (c->vaddr) | 4262 | if (h->vaddr) |
4267 | iounmap(c->vaddr); | 4263 | iounmap(h->vaddr); |
4268 | pci_release_regions(c->pdev); | 4264 | pci_release_regions(h->pdev); |
4269 | return err; | 4265 | return err; |
4270 | } | 4266 | } |
4271 | 4267 | ||
@@ -4278,12 +4274,12 @@ static int alloc_cciss_hba(void) | |||
4278 | 4274 | ||
4279 | for (i = 0; i < MAX_CTLR; i++) { | 4275 | for (i = 0; i < MAX_CTLR; i++) { |
4280 | if (!hba[i]) { | 4276 | if (!hba[i]) { |
4281 | ctlr_info_t *p; | 4277 | ctlr_info_t *h; |
4282 | 4278 | ||
4283 | p = kzalloc(sizeof(ctlr_info_t), GFP_KERNEL); | 4279 | h = kzalloc(sizeof(ctlr_info_t), GFP_KERNEL); |
4284 | if (!p) | 4280 | if (!h) |
4285 | goto Enomem; | 4281 | goto Enomem; |
4286 | hba[i] = p; | 4282 | hba[i] = h; |
4287 | return i; | 4283 | return i; |
4288 | } | 4284 | } |
4289 | } | 4285 | } |
@@ -4295,12 +4291,11 @@ Enomem: | |||
4295 | return -1; | 4291 | return -1; |
4296 | } | 4292 | } |
4297 | 4293 | ||
4298 | static void free_hba(int n) | 4294 | static void free_hba(ctlr_info_t *h) |
4299 | { | 4295 | { |
4300 | ctlr_info_t *h = hba[n]; | ||
4301 | int i; | 4296 | int i; |
4302 | 4297 | ||
4303 | hba[n] = NULL; | 4298 | hba[h->ctlr] = NULL; |
4304 | for (i = 0; i < h->highest_lun + 1; i++) | 4299 | for (i = 0; i < h->highest_lun + 1; i++) |
4305 | if (h->gendisk[i] != NULL) | 4300 | if (h->gendisk[i] != NULL) |
4306 | put_disk(h->gendisk[i]); | 4301 | put_disk(h->gendisk[i]); |
@@ -4651,6 +4646,7 @@ static int __devinit cciss_init_one(struct pci_dev *pdev, | |||
4651 | int rc; | 4646 | int rc; |
4652 | int dac, return_code; | 4647 | int dac, return_code; |
4653 | InquiryData_struct *inq_buff; | 4648 | InquiryData_struct *inq_buff; |
4649 | ctlr_info_t *h; | ||
4654 | 4650 | ||
4655 | rc = cciss_init_reset_devices(pdev); | 4651 | rc = cciss_init_reset_devices(pdev); |
4656 | if (rc) | 4652 | if (rc) |
@@ -4659,21 +4655,22 @@ static int __devinit cciss_init_one(struct pci_dev *pdev, | |||
4659 | if (i < 0) | 4655 | if (i < 0) |
4660 | return -1; | 4656 | return -1; |
4661 | 4657 | ||
4662 | hba[i]->pdev = pdev; | 4658 | h = hba[i]; |
4663 | hba[i]->busy_initializing = 1; | 4659 | h->pdev = pdev; |
4664 | INIT_HLIST_HEAD(&hba[i]->cmpQ); | 4660 | h->busy_initializing = 1; |
4665 | INIT_HLIST_HEAD(&hba[i]->reqQ); | 4661 | INIT_HLIST_HEAD(&h->cmpQ); |
4666 | mutex_init(&hba[i]->busy_shutting_down); | 4662 | INIT_HLIST_HEAD(&h->reqQ); |
4663 | mutex_init(&h->busy_shutting_down); | ||
4667 | 4664 | ||
4668 | if (cciss_pci_init(hba[i]) != 0) | 4665 | if (cciss_pci_init(h) != 0) |
4669 | goto clean_no_release_regions; | 4666 | goto clean_no_release_regions; |
4670 | 4667 | ||
4671 | sprintf(hba[i]->devname, "cciss%d", i); | 4668 | sprintf(h->devname, "cciss%d", i); |
4672 | hba[i]->ctlr = i; | 4669 | h->ctlr = i; |
4673 | 4670 | ||
4674 | init_completion(&hba[i]->scan_wait); | 4671 | init_completion(&h->scan_wait); |
4675 | 4672 | ||
4676 | if (cciss_create_hba_sysfs_entry(hba[i])) | 4673 | if (cciss_create_hba_sysfs_entry(h)) |
4677 | goto clean0; | 4674 | goto clean0; |
4678 | 4675 | ||
4679 | /* configure PCI DMA stuff */ | 4676 | /* configure PCI DMA stuff */ |
@@ -4692,100 +4689,100 @@ static int __devinit cciss_init_one(struct pci_dev *pdev, | |||
4692 | * 8 controller support. | 4689 | * 8 controller support. |
4693 | */ | 4690 | */ |
4694 | if (i < MAX_CTLR_ORIG) | 4691 | if (i < MAX_CTLR_ORIG) |
4695 | hba[i]->major = COMPAQ_CISS_MAJOR + i; | 4692 | h->major = COMPAQ_CISS_MAJOR + i; |
4696 | rc = register_blkdev(hba[i]->major, hba[i]->devname); | 4693 | rc = register_blkdev(h->major, h->devname); |
4697 | if (rc == -EBUSY || rc == -EINVAL) { | 4694 | if (rc == -EBUSY || rc == -EINVAL) { |
4698 | printk(KERN_ERR | 4695 | printk(KERN_ERR |
4699 | "cciss: Unable to get major number %d for %s " | 4696 | "cciss: Unable to get major number %d for %s " |
4700 | "on hba %d\n", hba[i]->major, hba[i]->devname, i); | 4697 | "on hba %d\n", h->major, h->devname, i); |
4701 | goto clean1; | 4698 | goto clean1; |
4702 | } else { | 4699 | } else { |
4703 | if (i >= MAX_CTLR_ORIG) | 4700 | if (i >= MAX_CTLR_ORIG) |
4704 | hba[i]->major = rc; | 4701 | h->major = rc; |
4705 | } | 4702 | } |
4706 | 4703 | ||
4707 | /* make sure the board interrupts are off */ | 4704 | /* make sure the board interrupts are off */ |
4708 | hba[i]->access.set_intr_mask(hba[i], CCISS_INTR_OFF); | 4705 | h->access.set_intr_mask(h, CCISS_INTR_OFF); |
4709 | if (hba[i]->msi_vector || hba[i]->msix_vector) { | 4706 | if (h->msi_vector || h->msix_vector) { |
4710 | if (request_irq(hba[i]->intr[PERF_MODE_INT], | 4707 | if (request_irq(h->intr[PERF_MODE_INT], |
4711 | do_cciss_msix_intr, | 4708 | do_cciss_msix_intr, |
4712 | IRQF_DISABLED, hba[i]->devname, hba[i])) { | 4709 | IRQF_DISABLED, h->devname, h)) { |
4713 | printk(KERN_ERR "cciss: Unable to get irq %d for %s\n", | 4710 | printk(KERN_ERR "cciss: Unable to get irq %d for %s\n", |
4714 | hba[i]->intr[PERF_MODE_INT], hba[i]->devname); | 4711 | h->intr[PERF_MODE_INT], h->devname); |
4715 | goto clean2; | 4712 | goto clean2; |
4716 | } | 4713 | } |
4717 | } else { | 4714 | } else { |
4718 | if (request_irq(hba[i]->intr[PERF_MODE_INT], do_cciss_intx, | 4715 | if (request_irq(h->intr[PERF_MODE_INT], do_cciss_intx, |
4719 | IRQF_DISABLED, hba[i]->devname, hba[i])) { | 4716 | IRQF_DISABLED, h->devname, h)) { |
4720 | printk(KERN_ERR "cciss: Unable to get irq %d for %s\n", | 4717 | printk(KERN_ERR "cciss: Unable to get irq %d for %s\n", |
4721 | hba[i]->intr[PERF_MODE_INT], hba[i]->devname); | 4718 | h->intr[PERF_MODE_INT], h->devname); |
4722 | goto clean2; | 4719 | goto clean2; |
4723 | } | 4720 | } |
4724 | } | 4721 | } |
4725 | 4722 | ||
4726 | printk(KERN_INFO "%s: <0x%x> at PCI %s IRQ %d%s using DAC\n", | 4723 | printk(KERN_INFO "%s: <0x%x> at PCI %s IRQ %d%s using DAC\n", |
4727 | hba[i]->devname, pdev->device, pci_name(pdev), | 4724 | h->devname, pdev->device, pci_name(pdev), |
4728 | hba[i]->intr[PERF_MODE_INT], dac ? "" : " not"); | 4725 | h->intr[PERF_MODE_INT], dac ? "" : " not"); |
4729 | 4726 | ||
4730 | hba[i]->cmd_pool_bits = | 4727 | h->cmd_pool_bits = |
4731 | kmalloc(DIV_ROUND_UP(hba[i]->nr_cmds, BITS_PER_LONG) | 4728 | kmalloc(DIV_ROUND_UP(h->nr_cmds, BITS_PER_LONG) |
4732 | * sizeof(unsigned long), GFP_KERNEL); | 4729 | * sizeof(unsigned long), GFP_KERNEL); |
4733 | hba[i]->cmd_pool = (CommandList_struct *) | 4730 | h->cmd_pool = (CommandList_struct *) |
4734 | pci_alloc_consistent(hba[i]->pdev, | 4731 | pci_alloc_consistent(h->pdev, |
4735 | hba[i]->nr_cmds * sizeof(CommandList_struct), | 4732 | h->nr_cmds * sizeof(CommandList_struct), |
4736 | &(hba[i]->cmd_pool_dhandle)); | 4733 | &(h->cmd_pool_dhandle)); |
4737 | hba[i]->errinfo_pool = (ErrorInfo_struct *) | 4734 | h->errinfo_pool = (ErrorInfo_struct *) |
4738 | pci_alloc_consistent(hba[i]->pdev, | 4735 | pci_alloc_consistent(h->pdev, |
4739 | hba[i]->nr_cmds * sizeof(ErrorInfo_struct), | 4736 | h->nr_cmds * sizeof(ErrorInfo_struct), |
4740 | &(hba[i]->errinfo_pool_dhandle)); | 4737 | &(h->errinfo_pool_dhandle)); |
4741 | if ((hba[i]->cmd_pool_bits == NULL) | 4738 | if ((h->cmd_pool_bits == NULL) |
4742 | || (hba[i]->cmd_pool == NULL) | 4739 | || (h->cmd_pool == NULL) |
4743 | || (hba[i]->errinfo_pool == NULL)) { | 4740 | || (h->errinfo_pool == NULL)) { |
4744 | printk(KERN_ERR "cciss: out of memory"); | 4741 | printk(KERN_ERR "cciss: out of memory"); |
4745 | goto clean4; | 4742 | goto clean4; |
4746 | } | 4743 | } |
4747 | 4744 | ||
4748 | /* Need space for temp scatter list */ | 4745 | /* Need space for temp scatter list */ |
4749 | hba[i]->scatter_list = kmalloc(hba[i]->max_commands * | 4746 | h->scatter_list = kmalloc(h->max_commands * |
4750 | sizeof(struct scatterlist *), | 4747 | sizeof(struct scatterlist *), |
4751 | GFP_KERNEL); | 4748 | GFP_KERNEL); |
4752 | for (k = 0; k < hba[i]->nr_cmds; k++) { | 4749 | for (k = 0; k < h->nr_cmds; k++) { |
4753 | hba[i]->scatter_list[k] = kmalloc(sizeof(struct scatterlist) * | 4750 | h->scatter_list[k] = kmalloc(sizeof(struct scatterlist) * |
4754 | hba[i]->maxsgentries, | 4751 | h->maxsgentries, |
4755 | GFP_KERNEL); | 4752 | GFP_KERNEL); |
4756 | if (hba[i]->scatter_list[k] == NULL) { | 4753 | if (h->scatter_list[k] == NULL) { |
4757 | printk(KERN_ERR "cciss%d: could not allocate " | 4754 | printk(KERN_ERR "cciss%d: could not allocate " |
4758 | "s/g lists\n", i); | 4755 | "s/g lists\n", i); |
4759 | goto clean4; | 4756 | goto clean4; |
4760 | } | 4757 | } |
4761 | } | 4758 | } |
4762 | hba[i]->cmd_sg_list = cciss_allocate_sg_chain_blocks(hba[i], | 4759 | h->cmd_sg_list = cciss_allocate_sg_chain_blocks(h, |
4763 | hba[i]->chainsize, hba[i]->nr_cmds); | 4760 | h->chainsize, h->nr_cmds); |
4764 | if (!hba[i]->cmd_sg_list && hba[i]->chainsize > 0) | 4761 | if (!h->cmd_sg_list && h->chainsize > 0) |
4765 | goto clean4; | 4762 | goto clean4; |
4766 | 4763 | ||
4767 | spin_lock_init(&hba[i]->lock); | 4764 | spin_lock_init(&h->lock); |
4768 | 4765 | ||
4769 | /* Initialize the pdev driver private data. | 4766 | /* Initialize the pdev driver private data. |
4770 | have it point to hba[i]. */ | 4767 | have it point to h. */ |
4771 | pci_set_drvdata(pdev, hba[i]); | 4768 | pci_set_drvdata(pdev, h); |
4772 | /* command and error info recs zeroed out before | 4769 | /* command and error info recs zeroed out before |
4773 | they are used */ | 4770 | they are used */ |
4774 | memset(hba[i]->cmd_pool_bits, 0, | 4771 | memset(h->cmd_pool_bits, 0, |
4775 | DIV_ROUND_UP(hba[i]->nr_cmds, BITS_PER_LONG) | 4772 | DIV_ROUND_UP(h->nr_cmds, BITS_PER_LONG) |
4776 | * sizeof(unsigned long)); | 4773 | * sizeof(unsigned long)); |
4777 | 4774 | ||
4778 | hba[i]->num_luns = 0; | 4775 | h->num_luns = 0; |
4779 | hba[i]->highest_lun = -1; | 4776 | h->highest_lun = -1; |
4780 | for (j = 0; j < CISS_MAX_LUN; j++) { | 4777 | for (j = 0; j < CISS_MAX_LUN; j++) { |
4781 | hba[i]->drv[j] = NULL; | 4778 | h->drv[j] = NULL; |
4782 | hba[i]->gendisk[j] = NULL; | 4779 | h->gendisk[j] = NULL; |
4783 | } | 4780 | } |
4784 | 4781 | ||
4785 | cciss_scsi_setup(i); | 4782 | cciss_scsi_setup(h); |
4786 | 4783 | ||
4787 | /* Turn the interrupts on so we can service requests */ | 4784 | /* Turn the interrupts on so we can service requests */ |
4788 | hba[i]->access.set_intr_mask(hba[i], CCISS_INTR_ON); | 4785 | h->access.set_intr_mask(h, CCISS_INTR_ON); |
4789 | 4786 | ||
4790 | /* Get the firmware version */ | 4787 | /* Get the firmware version */ |
4791 | inq_buff = kzalloc(sizeof(InquiryData_struct), GFP_KERNEL); | 4788 | inq_buff = kzalloc(sizeof(InquiryData_struct), GFP_KERNEL); |
@@ -4794,59 +4791,59 @@ static int __devinit cciss_init_one(struct pci_dev *pdev, | |||
4794 | goto clean4; | 4791 | goto clean4; |
4795 | } | 4792 | } |
4796 | 4793 | ||
4797 | return_code = sendcmd_withirq(CISS_INQUIRY, i, inq_buff, | 4794 | return_code = sendcmd_withirq(h, CISS_INQUIRY, inq_buff, |
4798 | sizeof(InquiryData_struct), 0, CTLR_LUNID, TYPE_CMD); | 4795 | sizeof(InquiryData_struct), 0, CTLR_LUNID, TYPE_CMD); |
4799 | if (return_code == IO_OK) { | 4796 | if (return_code == IO_OK) { |
4800 | hba[i]->firm_ver[0] = inq_buff->data_byte[32]; | 4797 | h->firm_ver[0] = inq_buff->data_byte[32]; |
4801 | hba[i]->firm_ver[1] = inq_buff->data_byte[33]; | 4798 | h->firm_ver[1] = inq_buff->data_byte[33]; |
4802 | hba[i]->firm_ver[2] = inq_buff->data_byte[34]; | 4799 | h->firm_ver[2] = inq_buff->data_byte[34]; |
4803 | hba[i]->firm_ver[3] = inq_buff->data_byte[35]; | 4800 | h->firm_ver[3] = inq_buff->data_byte[35]; |
4804 | } else { /* send command failed */ | 4801 | } else { /* send command failed */ |
4805 | printk(KERN_WARNING "cciss: unable to determine firmware" | 4802 | printk(KERN_WARNING "cciss: unable to determine firmware" |
4806 | " version of controller\n"); | 4803 | " version of controller\n"); |
4807 | } | 4804 | } |
4808 | kfree(inq_buff); | 4805 | kfree(inq_buff); |
4809 | 4806 | ||
4810 | cciss_procinit(i); | 4807 | cciss_procinit(h); |
4811 | 4808 | ||
4812 | hba[i]->cciss_max_sectors = 8192; | 4809 | h->cciss_max_sectors = 8192; |
4813 | 4810 | ||
4814 | rebuild_lun_table(hba[i], 1, 0); | 4811 | rebuild_lun_table(h, 1, 0); |
4815 | hba[i]->busy_initializing = 0; | 4812 | h->busy_initializing = 0; |
4816 | return 1; | 4813 | return 1; |
4817 | 4814 | ||
4818 | clean4: | 4815 | clean4: |
4819 | kfree(hba[i]->cmd_pool_bits); | 4816 | kfree(h->cmd_pool_bits); |
4820 | /* Free up sg elements */ | 4817 | /* Free up sg elements */ |
4821 | for (k = 0; k < hba[i]->nr_cmds; k++) | 4818 | for (k = 0; k < h->nr_cmds; k++) |
4822 | kfree(hba[i]->scatter_list[k]); | 4819 | kfree(h->scatter_list[k]); |
4823 | kfree(hba[i]->scatter_list); | 4820 | kfree(h->scatter_list); |
4824 | cciss_free_sg_chain_blocks(hba[i]->cmd_sg_list, hba[i]->nr_cmds); | 4821 | cciss_free_sg_chain_blocks(h->cmd_sg_list, h->nr_cmds); |
4825 | if (hba[i]->cmd_pool) | 4822 | if (h->cmd_pool) |
4826 | pci_free_consistent(hba[i]->pdev, | 4823 | pci_free_consistent(h->pdev, |
4827 | hba[i]->nr_cmds * sizeof(CommandList_struct), | 4824 | h->nr_cmds * sizeof(CommandList_struct), |
4828 | hba[i]->cmd_pool, hba[i]->cmd_pool_dhandle); | 4825 | h->cmd_pool, h->cmd_pool_dhandle); |
4829 | if (hba[i]->errinfo_pool) | 4826 | if (h->errinfo_pool) |
4830 | pci_free_consistent(hba[i]->pdev, | 4827 | pci_free_consistent(h->pdev, |
4831 | hba[i]->nr_cmds * sizeof(ErrorInfo_struct), | 4828 | h->nr_cmds * sizeof(ErrorInfo_struct), |
4832 | hba[i]->errinfo_pool, | 4829 | h->errinfo_pool, |
4833 | hba[i]->errinfo_pool_dhandle); | 4830 | h->errinfo_pool_dhandle); |
4834 | free_irq(hba[i]->intr[PERF_MODE_INT], hba[i]); | 4831 | free_irq(h->intr[PERF_MODE_INT], h); |
4835 | clean2: | 4832 | clean2: |
4836 | unregister_blkdev(hba[i]->major, hba[i]->devname); | 4833 | unregister_blkdev(h->major, h->devname); |
4837 | clean1: | 4834 | clean1: |
4838 | cciss_destroy_hba_sysfs_entry(hba[i]); | 4835 | cciss_destroy_hba_sysfs_entry(h); |
4839 | clean0: | 4836 | clean0: |
4840 | pci_release_regions(pdev); | 4837 | pci_release_regions(pdev); |
4841 | clean_no_release_regions: | 4838 | clean_no_release_regions: |
4842 | hba[i]->busy_initializing = 0; | 4839 | h->busy_initializing = 0; |
4843 | 4840 | ||
4844 | /* | 4841 | /* |
4845 | * Deliberately omit pci_disable_device(): it does something nasty to | 4842 | * Deliberately omit pci_disable_device(): it does something nasty to |
4846 | * Smart Array controllers that pci_enable_device does not undo | 4843 | * Smart Array controllers that pci_enable_device does not undo |
4847 | */ | 4844 | */ |
4848 | pci_set_drvdata(pdev, NULL); | 4845 | pci_set_drvdata(pdev, NULL); |
4849 | free_hba(i); | 4846 | free_hba(h); |
4850 | return -1; | 4847 | return -1; |
4851 | } | 4848 | } |
4852 | 4849 | ||
@@ -4866,7 +4863,7 @@ static void cciss_shutdown(struct pci_dev *pdev) | |||
4866 | } | 4863 | } |
4867 | /* write all data in the battery backed cache to disk */ | 4864 | /* write all data in the battery backed cache to disk */ |
4868 | memset(flush_buf, 0, 4); | 4865 | memset(flush_buf, 0, 4); |
4869 | return_code = sendcmd_withirq(CCISS_CACHE_FLUSH, h->ctlr, flush_buf, | 4866 | return_code = sendcmd_withirq(h, CCISS_CACHE_FLUSH, flush_buf, |
4870 | 4, 0, CTLR_LUNID, TYPE_CMD); | 4867 | 4, 0, CTLR_LUNID, TYPE_CMD); |
4871 | kfree(flush_buf); | 4868 | kfree(flush_buf); |
4872 | if (return_code != IO_OK) | 4869 | if (return_code != IO_OK) |
@@ -4878,7 +4875,7 @@ static void cciss_shutdown(struct pci_dev *pdev) | |||
4878 | 4875 | ||
4879 | static void __devexit cciss_remove_one(struct pci_dev *pdev) | 4876 | static void __devexit cciss_remove_one(struct pci_dev *pdev) |
4880 | { | 4877 | { |
4881 | ctlr_info_t *tmp_ptr; | 4878 | ctlr_info_t *h; |
4882 | int i, j; | 4879 | int i, j; |
4883 | 4880 | ||
4884 | if (pci_get_drvdata(pdev) == NULL) { | 4881 | if (pci_get_drvdata(pdev) == NULL) { |
@@ -4886,28 +4883,28 @@ static void __devexit cciss_remove_one(struct pci_dev *pdev) | |||
4886 | return; | 4883 | return; |
4887 | } | 4884 | } |
4888 | 4885 | ||
4889 | tmp_ptr = pci_get_drvdata(pdev); | 4886 | h = pci_get_drvdata(pdev); |
4890 | i = tmp_ptr->ctlr; | 4887 | i = h->ctlr; |
4891 | if (hba[i] == NULL) { | 4888 | if (hba[i] == NULL) { |
4892 | printk(KERN_ERR "cciss: device appears to " | 4889 | printk(KERN_ERR "cciss: device appears to " |
4893 | "already be removed \n"); | 4890 | "already be removed\n"); |
4894 | return; | 4891 | return; |
4895 | } | 4892 | } |
4896 | 4893 | ||
4897 | mutex_lock(&hba[i]->busy_shutting_down); | 4894 | mutex_lock(&h->busy_shutting_down); |
4898 | 4895 | ||
4899 | remove_from_scan_list(hba[i]); | 4896 | remove_from_scan_list(h); |
4900 | remove_proc_entry(hba[i]->devname, proc_cciss); | 4897 | remove_proc_entry(h->devname, proc_cciss); |
4901 | unregister_blkdev(hba[i]->major, hba[i]->devname); | 4898 | unregister_blkdev(h->major, h->devname); |
4902 | 4899 | ||
4903 | /* remove it from the disk list */ | 4900 | /* remove it from the disk list */ |
4904 | for (j = 0; j < CISS_MAX_LUN; j++) { | 4901 | for (j = 0; j < CISS_MAX_LUN; j++) { |
4905 | struct gendisk *disk = hba[i]->gendisk[j]; | 4902 | struct gendisk *disk = h->gendisk[j]; |
4906 | if (disk) { | 4903 | if (disk) { |
4907 | struct request_queue *q = disk->queue; | 4904 | struct request_queue *q = disk->queue; |
4908 | 4905 | ||
4909 | if (disk->flags & GENHD_FL_UP) { | 4906 | if (disk->flags & GENHD_FL_UP) { |
4910 | cciss_destroy_ld_sysfs_entry(hba[i], j, 1); | 4907 | cciss_destroy_ld_sysfs_entry(h, j, 1); |
4911 | del_gendisk(disk); | 4908 | del_gendisk(disk); |
4912 | } | 4909 | } |
4913 | if (q) | 4910 | if (q) |
@@ -4916,41 +4913,41 @@ static void __devexit cciss_remove_one(struct pci_dev *pdev) | |||
4916 | } | 4913 | } |
4917 | 4914 | ||
4918 | #ifdef CONFIG_CISS_SCSI_TAPE | 4915 | #ifdef CONFIG_CISS_SCSI_TAPE |
4919 | cciss_unregister_scsi(i); /* unhook from SCSI subsystem */ | 4916 | cciss_unregister_scsi(h); /* unhook from SCSI subsystem */ |
4920 | #endif | 4917 | #endif |
4921 | 4918 | ||
4922 | cciss_shutdown(pdev); | 4919 | cciss_shutdown(pdev); |
4923 | 4920 | ||
4924 | #ifdef CONFIG_PCI_MSI | 4921 | #ifdef CONFIG_PCI_MSI |
4925 | if (hba[i]->msix_vector) | 4922 | if (h->msix_vector) |
4926 | pci_disable_msix(hba[i]->pdev); | 4923 | pci_disable_msix(h->pdev); |
4927 | else if (hba[i]->msi_vector) | 4924 | else if (h->msi_vector) |
4928 | pci_disable_msi(hba[i]->pdev); | 4925 | pci_disable_msi(h->pdev); |
4929 | #endif /* CONFIG_PCI_MSI */ | 4926 | #endif /* CONFIG_PCI_MSI */ |
4930 | 4927 | ||
4931 | iounmap(hba[i]->transtable); | 4928 | iounmap(h->transtable); |
4932 | iounmap(hba[i]->cfgtable); | 4929 | iounmap(h->cfgtable); |
4933 | iounmap(hba[i]->vaddr); | 4930 | iounmap(h->vaddr); |
4934 | 4931 | ||
4935 | pci_free_consistent(hba[i]->pdev, hba[i]->nr_cmds * sizeof(CommandList_struct), | 4932 | pci_free_consistent(h->pdev, h->nr_cmds * sizeof(CommandList_struct), |
4936 | hba[i]->cmd_pool, hba[i]->cmd_pool_dhandle); | 4933 | h->cmd_pool, h->cmd_pool_dhandle); |
4937 | pci_free_consistent(hba[i]->pdev, hba[i]->nr_cmds * sizeof(ErrorInfo_struct), | 4934 | pci_free_consistent(h->pdev, h->nr_cmds * sizeof(ErrorInfo_struct), |
4938 | hba[i]->errinfo_pool, hba[i]->errinfo_pool_dhandle); | 4935 | h->errinfo_pool, h->errinfo_pool_dhandle); |
4939 | kfree(hba[i]->cmd_pool_bits); | 4936 | kfree(h->cmd_pool_bits); |
4940 | /* Free up sg elements */ | 4937 | /* Free up sg elements */ |
4941 | for (j = 0; j < hba[i]->nr_cmds; j++) | 4938 | for (j = 0; j < h->nr_cmds; j++) |
4942 | kfree(hba[i]->scatter_list[j]); | 4939 | kfree(h->scatter_list[j]); |
4943 | kfree(hba[i]->scatter_list); | 4940 | kfree(h->scatter_list); |
4944 | cciss_free_sg_chain_blocks(hba[i]->cmd_sg_list, hba[i]->nr_cmds); | 4941 | cciss_free_sg_chain_blocks(h->cmd_sg_list, h->nr_cmds); |
4945 | /* | 4942 | /* |
4946 | * Deliberately omit pci_disable_device(): it does something nasty to | 4943 | * Deliberately omit pci_disable_device(): it does something nasty to |
4947 | * Smart Array controllers that pci_enable_device does not undo | 4944 | * Smart Array controllers that pci_enable_device does not undo |
4948 | */ | 4945 | */ |
4949 | pci_release_regions(pdev); | 4946 | pci_release_regions(pdev); |
4950 | pci_set_drvdata(pdev, NULL); | 4947 | pci_set_drvdata(pdev, NULL); |
4951 | cciss_destroy_hba_sysfs_entry(hba[i]); | 4948 | cciss_destroy_hba_sysfs_entry(h); |
4952 | mutex_unlock(&hba[i]->busy_shutting_down); | 4949 | mutex_unlock(&h->busy_shutting_down); |
4953 | free_hba(i); | 4950 | free_hba(h); |
4954 | } | 4951 | } |
4955 | 4952 | ||
4956 | static struct pci_driver cciss_pci_driver = { | 4953 | static struct pci_driver cciss_pci_driver = { |