aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi
diff options
context:
space:
mode:
authorMatthew Wilcox <matthew@wil.cx>2007-10-05 15:55:13 -0400
committerJames Bottomley <jejb@mulgrave.localdomain>2007-10-23 15:26:34 -0400
commit5111eefa17615bdf17ca00ec2cdca16302c7697e (patch)
tree99fe4783b42b7b3a35f7962705e8002643651b16 /drivers/scsi
parent99c9e0a1d6cfe1ba1169a7a81435ee85bc00e4a1 (diff)
[SCSI] sym53c8xx: Remove pci_dev pointer from sym_shcb
This structure is accessed by the device; the fewer Linux things in it, the better. Using the pci_dev pointer from the hostdata requires a lot of changes: - Pass Scsi_Host to a lot of routines which currently take a sym_hcb. - Set the Scsi_Host as the pci drvdata (instead of the sym_hcb) Signed-off-by: Matthew Wilcox <willy@linux.intel.com> Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'drivers/scsi')
-rw-r--r--drivers/scsi/sym53c8xx_2/sym_fw.c16
-rw-r--r--drivers/scsi/sym53c8xx_2/sym_fw.h2
-rw-r--r--drivers/scsi/sym53c8xx_2/sym_glue.c97
-rw-r--r--drivers/scsi/sym53c8xx_2/sym_glue.h5
-rw-r--r--drivers/scsi/sym53c8xx_2/sym_hipd.c60
-rw-r--r--drivers/scsi/sym53c8xx_2/sym_hipd.h4
6 files changed, 99 insertions, 85 deletions
diff --git a/drivers/scsi/sym53c8xx_2/sym_fw.c b/drivers/scsi/sym53c8xx_2/sym_fw.c
index aa230d23eda4..190770bdc194 100644
--- a/drivers/scsi/sym53c8xx_2/sym_fw.c
+++ b/drivers/scsi/sym53c8xx_2/sym_fw.c
@@ -104,8 +104,9 @@ static struct sym_fwz_ofs sym_fw2z_ofs = {
104 * Patch routine for firmware #1. 104 * Patch routine for firmware #1.
105 */ 105 */
106static void 106static void
107sym_fw1_patch(struct sym_hcb *np) 107sym_fw1_patch(struct Scsi_Host *shost)
108{ 108{
109 struct sym_hcb *np = sym_get_hcb(shost);
109 struct sym_fw1a_scr *scripta0; 110 struct sym_fw1a_scr *scripta0;
110 struct sym_fw1b_scr *scriptb0; 111 struct sym_fw1b_scr *scriptb0;
111 112
@@ -145,8 +146,11 @@ sym_fw1_patch(struct sym_hcb *np)
145 * Patch routine for firmware #2. 146 * Patch routine for firmware #2.
146 */ 147 */
147static void 148static void
148sym_fw2_patch(struct sym_hcb *np) 149sym_fw2_patch(struct Scsi_Host *shost)
149{ 150{
151 struct sym_data *sym_data = shost_priv(shost);
152 struct pci_dev *pdev = sym_data->pdev;
153 struct sym_hcb *np = sym_data->ncb;
150 struct sym_fw2a_scr *scripta0; 154 struct sym_fw2a_scr *scripta0;
151 struct sym_fw2b_scr *scriptb0; 155 struct sym_fw2b_scr *scriptb0;
152 156
@@ -205,14 +209,14 @@ sym_fw2_patch(struct sym_hcb *np)
205 * Remove a couple of work-arounds specific to C1010 if 209 * Remove a couple of work-arounds specific to C1010 if
206 * they are not desirable. See `sym_fw2.h' for more details. 210 * they are not desirable. See `sym_fw2.h' for more details.
207 */ 211 */
208 if (!(np->s.device->device == PCI_DEVICE_ID_LSI_53C1010_66 && 212 if (!(pdev->device == PCI_DEVICE_ID_LSI_53C1010_66 &&
209 np->s.device->revision < 0x1 && 213 pdev->revision < 0x1 &&
210 np->pciclk_khz < 60000)) { 214 np->pciclk_khz < 60000)) {
211 scripta0->datao_phase[0] = cpu_to_scr(SCR_NO_OP); 215 scripta0->datao_phase[0] = cpu_to_scr(SCR_NO_OP);
212 scripta0->datao_phase[1] = cpu_to_scr(0); 216 scripta0->datao_phase[1] = cpu_to_scr(0);
213 } 217 }
214 if (!(np->s.device->device == PCI_DEVICE_ID_LSI_53C1010_33 /* && 218 if (!(pdev->device == PCI_DEVICE_ID_LSI_53C1010_33 /* &&
215 np->s.device->revision < 0xff */)) { 219 pdev->revision < 0xff */)) {
216 scripta0->sel_done[0] = cpu_to_scr(SCR_NO_OP); 220 scripta0->sel_done[0] = cpu_to_scr(SCR_NO_OP);
217 scripta0->sel_done[1] = cpu_to_scr(0); 221 scripta0->sel_done[1] = cpu_to_scr(0);
218 } 222 }
diff --git a/drivers/scsi/sym53c8xx_2/sym_fw.h b/drivers/scsi/sym53c8xx_2/sym_fw.h
index 66ec35beab5b..ae7e0f9e93fc 100644
--- a/drivers/scsi/sym53c8xx_2/sym_fw.h
+++ b/drivers/scsi/sym53c8xx_2/sym_fw.h
@@ -143,7 +143,7 @@ struct sym_fw {
143 *z_ofs; /* Useful offsets in script Z */ 143 *z_ofs; /* Useful offsets in script Z */
144 /* Setup and patch methods for this firmware */ 144 /* Setup and patch methods for this firmware */
145 void (*setup)(struct sym_hcb *, struct sym_fw *); 145 void (*setup)(struct sym_hcb *, struct sym_fw *);
146 void (*patch)(struct sym_hcb *); 146 void (*patch)(struct Scsi_Host *);
147}; 147};
148 148
149/* 149/*
diff --git a/drivers/scsi/sym53c8xx_2/sym_glue.c b/drivers/scsi/sym53c8xx_2/sym_glue.c
index 1c18b3b9aa15..df0547afe526 100644
--- a/drivers/scsi/sym53c8xx_2/sym_glue.c
+++ b/drivers/scsi/sym53c8xx_2/sym_glue.c
@@ -497,14 +497,16 @@ static void sym_timer(struct sym_hcb *np)
497/* 497/*
498 * PCI BUS error handler. 498 * PCI BUS error handler.
499 */ 499 */
500void sym_log_bus_error(struct sym_hcb *np) 500void sym_log_bus_error(struct Scsi_Host *shost)
501{ 501{
502 u_short pci_sts; 502 struct sym_data *sym_data = shost_priv(shost);
503 pci_read_config_word(np->s.device, PCI_STATUS, &pci_sts); 503 struct pci_dev *pdev = sym_data->pdev;
504 unsigned short pci_sts;
505 pci_read_config_word(pdev, PCI_STATUS, &pci_sts);
504 if (pci_sts & 0xf900) { 506 if (pci_sts & 0xf900) {
505 pci_write_config_word(np->s.device, PCI_STATUS, pci_sts); 507 pci_write_config_word(pdev, PCI_STATUS, pci_sts);
506 printf("%s: PCI STATUS = 0x%04x\n", 508 shost_printk(KERN_WARNING, shost,
507 sym_name(np), pci_sts & 0xf900); 509 "PCI bus error: status = 0x%04x\n", pci_sts & 0xf900);
508 } 510 }
509} 511}
510 512
@@ -595,16 +597,17 @@ static void sym53c8xx_timer(unsigned long npref)
595 */ 597 */
596static int sym_eh_handler(int op, char *opname, struct scsi_cmnd *cmd) 598static int sym_eh_handler(int op, char *opname, struct scsi_cmnd *cmd)
597{ 599{
598 struct sym_hcb *np = SYM_SOFTC_PTR(cmd);
599 struct sym_ucmd *ucmd = SYM_UCMD_PTR(cmd); 600 struct sym_ucmd *ucmd = SYM_UCMD_PTR(cmd);
600 struct Scsi_Host *host = cmd->device->host; 601 struct Scsi_Host *shost = cmd->device->host;
601 struct pci_dev *pdev = np->s.device; 602 struct sym_data *sym_data = shost_priv(shost);
603 struct pci_dev *pdev = sym_data->pdev;
604 struct sym_hcb *np = sym_data->ncb;
602 SYM_QUEHEAD *qp; 605 SYM_QUEHEAD *qp;
603 int cmd_queued = 0; 606 int cmd_queued = 0;
604 int sts = -1; 607 int sts = -1;
605 struct completion eh_done; 608 struct completion eh_done;
606 609
607 scmd_printk(KERN_WARNING, cmd, "%s operation started.\n", opname); 610 scmd_printk(KERN_WARNING, cmd, "%s operation started\n", opname);
608 611
609 /* We may be in an error condition because the PCI bus 612 /* We may be in an error condition because the PCI bus
610 * went down. In this case, we need to wait until the 613 * went down. In this case, we need to wait until the
@@ -614,11 +617,10 @@ static int sym_eh_handler(int op, char *opname, struct scsi_cmnd *cmd)
614 */ 617 */
615#define WAIT_FOR_PCI_RECOVERY 35 618#define WAIT_FOR_PCI_RECOVERY 35
616 if (pci_channel_offline(pdev)) { 619 if (pci_channel_offline(pdev)) {
617 struct sym_data *sym_data = shost_priv(host);
618 struct completion *io_reset; 620 struct completion *io_reset;
619 int finished_reset = 0; 621 int finished_reset = 0;
620 init_completion(&eh_done); 622 init_completion(&eh_done);
621 spin_lock_irq(host->host_lock); 623 spin_lock_irq(shost->host_lock);
622 /* Make sure we didn't race */ 624 /* Make sure we didn't race */
623 if (pci_channel_offline(pdev)) { 625 if (pci_channel_offline(pdev)) {
624 if (!sym_data->io_reset) 626 if (!sym_data->io_reset)
@@ -627,7 +629,7 @@ static int sym_eh_handler(int op, char *opname, struct scsi_cmnd *cmd)
627 } else { 629 } else {
628 finished_reset = 1; 630 finished_reset = 1;
629 } 631 }
630 spin_unlock_irq(host->host_lock); 632 spin_unlock_irq(shost->host_lock);
631 if (!finished_reset) 633 if (!finished_reset)
632 finished_reset = wait_for_completion_timeout(io_reset, 634 finished_reset = wait_for_completion_timeout(io_reset,
633 WAIT_FOR_PCI_RECOVERY*HZ); 635 WAIT_FOR_PCI_RECOVERY*HZ);
@@ -635,7 +637,7 @@ static int sym_eh_handler(int op, char *opname, struct scsi_cmnd *cmd)
635 return SCSI_FAILED; 637 return SCSI_FAILED;
636 } 638 }
637 639
638 spin_lock_irq(host->host_lock); 640 spin_lock_irq(shost->host_lock);
639 /* This one is queued in some place -> to wait for completion */ 641 /* This one is queued in some place -> to wait for completion */
640 FOR_EACH_QUEUED_ELEMENT(&np->busy_ccbq, qp) { 642 FOR_EACH_QUEUED_ELEMENT(&np->busy_ccbq, qp) {
641 struct sym_ccb *cp = sym_que_entry(qp, struct sym_ccb, link_ccbq); 643 struct sym_ccb *cp = sym_que_entry(qp, struct sym_ccb, link_ccbq);
@@ -660,7 +662,7 @@ static int sym_eh_handler(int op, char *opname, struct scsi_cmnd *cmd)
660 break; 662 break;
661 case SYM_EH_HOST_RESET: 663 case SYM_EH_HOST_RESET:
662 sym_reset_scsi_bus(np, 0); 664 sym_reset_scsi_bus(np, 0);
663 sym_start_up(np, 1); 665 sym_start_up(shost, 1);
664 sts = 0; 666 sts = 0;
665 break; 667 break;
666 default: 668 default:
@@ -674,13 +676,13 @@ static int sym_eh_handler(int op, char *opname, struct scsi_cmnd *cmd)
674 if (cmd_queued) { 676 if (cmd_queued) {
675 init_completion(&eh_done); 677 init_completion(&eh_done);
676 ucmd->eh_done = &eh_done; 678 ucmd->eh_done = &eh_done;
677 spin_unlock_irq(host->host_lock); 679 spin_unlock_irq(shost->host_lock);
678 if (!wait_for_completion_timeout(&eh_done, 5*HZ)) { 680 if (!wait_for_completion_timeout(&eh_done, 5*HZ)) {
679 ucmd->eh_done = NULL; 681 ucmd->eh_done = NULL;
680 sts = -2; 682 sts = -2;
681 } 683 }
682 } else { 684 } else {
683 spin_unlock_irq(host->host_lock); 685 spin_unlock_irq(shost->host_lock);
684 } 686 }
685 687
686 dev_warn(&cmd->device->sdev_gendev, "%s operation %s.\n", opname, 688 dev_warn(&cmd->device->sdev_gendev, "%s operation %s.\n", opname,
@@ -993,8 +995,9 @@ static int is_keyword(char *ptr, int len, char *verb)
993 * Parse a control command 995 * Parse a control command
994 */ 996 */
995 997
996static int sym_user_command(struct sym_hcb *np, char *buffer, int length) 998static int sym_user_command(struct Scsi_Host *shost, char *buffer, int length)
997{ 999{
1000 struct sym_hcb *np = sym_get_hcb(shost);
998 char *ptr = buffer; 1001 char *ptr = buffer;
999 int len = length; 1002 int len = length;
1000 struct sym_usrcmd cmd, *uc = &cmd; 1003 struct sym_usrcmd cmd, *uc = &cmd;
@@ -1121,9 +1124,9 @@ printk("sym_user_command: data=%ld\n", uc->data);
1121 else { 1124 else {
1122 unsigned long flags; 1125 unsigned long flags;
1123 1126
1124 spin_lock_irqsave(np->s.host->host_lock, flags); 1127 spin_lock_irqsave(shost->host_lock, flags);
1125 sym_exec_user_command (np, uc); 1128 sym_exec_user_command(np, uc);
1126 spin_unlock_irqrestore(np->s.host->host_lock, flags); 1129 spin_unlock_irqrestore(shost->host_lock, flags);
1127 } 1130 }
1128 return length; 1131 return length;
1129} 1132}
@@ -1179,8 +1182,11 @@ static int copy_info(struct info_str *info, char *fmt, ...)
1179/* 1182/*
1180 * Copy formatted information into the input buffer. 1183 * Copy formatted information into the input buffer.
1181 */ 1184 */
1182static int sym_host_info(struct sym_hcb *np, char *ptr, off_t offset, int len) 1185static int sym_host_info(struct Scsi_Host *shost, char *ptr, off_t offset, int len)
1183{ 1186{
1187 struct sym_data *sym_data = shost_priv(shost);
1188 struct pci_dev *pdev = sym_data->pdev;
1189 struct sym_hcb *np = sym_data->ncb;
1184 struct info_str info; 1190 struct info_str info;
1185 1191
1186 info.buffer = ptr; 1192 info.buffer = ptr;
@@ -1190,9 +1196,9 @@ static int sym_host_info(struct sym_hcb *np, char *ptr, off_t offset, int len)
1190 1196
1191 copy_info(&info, "Chip " NAME53C "%s, device id 0x%x, " 1197 copy_info(&info, "Chip " NAME53C "%s, device id 0x%x, "
1192 "revision id 0x%x\n", np->s.chip_name, 1198 "revision id 0x%x\n", np->s.chip_name,
1193 np->s.device->device, np->s.device->revision); 1199 pdev->device, pdev->revision);
1194 copy_info(&info, "At PCI address %s, IRQ %u\n", 1200 copy_info(&info, "At PCI address %s, IRQ %u\n",
1195 pci_name(np->s.device), np->s.device->irq); 1201 pci_name(pdev), pdev->irq);
1196 copy_info(&info, "Min. period factor %d, %s SCSI BUS%s\n", 1202 copy_info(&info, "Min. period factor %d, %s SCSI BUS%s\n",
1197 (int) (np->minsync_dt ? np->minsync_dt : np->minsync), 1203 (int) (np->minsync_dt ? np->minsync_dt : np->minsync),
1198 np->maxwide ? "Wide" : "Narrow", 1204 np->maxwide ? "Wide" : "Narrow",
@@ -1211,15 +1217,14 @@ static int sym_host_info(struct sym_hcb *np, char *ptr, off_t offset, int len)
1211 * - func = 0 means read (returns adapter infos) 1217 * - func = 0 means read (returns adapter infos)
1212 * - func = 1 means write (not yet merget from sym53c8xx) 1218 * - func = 1 means write (not yet merget from sym53c8xx)
1213 */ 1219 */
1214static int sym53c8xx_proc_info(struct Scsi_Host *host, char *buffer, 1220static int sym53c8xx_proc_info(struct Scsi_Host *shost, char *buffer,
1215 char **start, off_t offset, int length, int func) 1221 char **start, off_t offset, int length, int func)
1216{ 1222{
1217 struct sym_hcb *np = sym_get_hcb(host);
1218 int retv; 1223 int retv;
1219 1224
1220 if (func) { 1225 if (func) {
1221#ifdef SYM_LINUX_USER_COMMAND_SUPPORT 1226#ifdef SYM_LINUX_USER_COMMAND_SUPPORT
1222 retv = sym_user_command(np, buffer, length); 1227 retv = sym_user_command(shost, buffer, length);
1223#else 1228#else
1224 retv = -EINVAL; 1229 retv = -EINVAL;
1225#endif 1230#endif
@@ -1227,7 +1232,7 @@ static int sym53c8xx_proc_info(struct Scsi_Host *host, char *buffer,
1227 if (start) 1232 if (start)
1228 *start = buffer; 1233 *start = buffer;
1229#ifdef SYM_LINUX_USER_INFO_SUPPORT 1234#ifdef SYM_LINUX_USER_INFO_SUPPORT
1230 retv = sym_host_info(np, buffer, offset, length); 1235 retv = sym_host_info(shost, buffer, offset, length);
1231#else 1236#else
1232 retv = -EINVAL; 1237 retv = -EINVAL;
1233#endif 1238#endif
@@ -1303,20 +1308,18 @@ static struct Scsi_Host * __devinit sym_attach(struct scsi_host_template *tpnt,
1303 np = __sym_calloc_dma(&pdev->dev, sizeof(*np), "HCB"); 1308 np = __sym_calloc_dma(&pdev->dev, sizeof(*np), "HCB");
1304 if (!np) 1309 if (!np)
1305 goto attach_failed; 1310 goto attach_failed;
1306 np->s.device = pdev;
1307 np->bus_dmat = &pdev->dev; /* Result in 1 DMA pool per HBA */ 1311 np->bus_dmat = &pdev->dev; /* Result in 1 DMA pool per HBA */
1308 sym_data->ncb = np; 1312 sym_data->ncb = np;
1309 sym_data->pdev = pdev; 1313 sym_data->pdev = pdev;
1310 np->s.host = shost; 1314 np->s.host = shost;
1311 1315
1312 pci_set_drvdata(pdev, np); 1316 pci_set_drvdata(pdev, shost);
1313 1317
1314 /* 1318 /*
1315 * Copy some useful infos to the HCB. 1319 * Copy some useful infos to the HCB.
1316 */ 1320 */
1317 np->hcb_ba = vtobus(np); 1321 np->hcb_ba = vtobus(np);
1318 np->verbose = sym_driver_setup.verbose; 1322 np->verbose = sym_driver_setup.verbose;
1319 np->s.device = pdev;
1320 np->s.unit = unit; 1323 np->s.unit = unit;
1321 np->features = dev->chip.features; 1324 np->features = dev->chip.features;
1322 np->clock_divn = dev->chip.nr_divisor; 1325 np->clock_divn = dev->chip.nr_divisor;
@@ -1331,9 +1334,9 @@ static struct Scsi_Host * __devinit sym_attach(struct scsi_host_template *tpnt,
1331 sprintf(np->s.inst_name, "sym%d", np->s.unit); 1334 sprintf(np->s.inst_name, "sym%d", np->s.unit);
1332 1335
1333 if ((SYM_CONF_DMA_ADDRESSING_MODE > 0) && (np->features & FE_DAC) && 1336 if ((SYM_CONF_DMA_ADDRESSING_MODE > 0) && (np->features & FE_DAC) &&
1334 !pci_set_dma_mask(np->s.device, DMA_DAC_MASK)) { 1337 !pci_set_dma_mask(pdev, DMA_DAC_MASK)) {
1335 set_dac(np); 1338 set_dac(np);
1336 } else if (pci_set_dma_mask(np->s.device, DMA_32BIT_MASK)) { 1339 } else if (pci_set_dma_mask(pdev, DMA_32BIT_MASK)) {
1337 printf_warning("%s: No suitable DMA available\n", sym_name(np)); 1340 printf_warning("%s: No suitable DMA available\n", sym_name(np));
1338 goto attach_failed; 1341 goto attach_failed;
1339 } 1342 }
@@ -1380,7 +1383,7 @@ static struct Scsi_Host * __devinit sym_attach(struct scsi_host_template *tpnt,
1380 /* 1383 /*
1381 * Start the SCRIPTS. 1384 * Start the SCRIPTS.
1382 */ 1385 */
1383 sym_start_up(np, 1); 1386 sym_start_up(shost, 1);
1384 1387
1385 /* 1388 /*
1386 * Start the timer daemon 1389 * Start the timer daemon
@@ -1645,8 +1648,9 @@ static void sym_config_pqs(struct pci_dev *pdev, struct sym_device *sym_dev)
1645 * Detach the host. 1648 * Detach the host.
1646 * We have to free resources and halt the NCR chip. 1649 * We have to free resources and halt the NCR chip.
1647 */ 1650 */
1648static int sym_detach(struct sym_hcb *np, struct pci_dev *pdev) 1651static int sym_detach(struct Scsi_Host *shost, struct pci_dev *pdev)
1649{ 1652{
1653 struct sym_hcb *np = sym_get_hcb(shost);
1650 printk("%s: detaching ...\n", sym_name(np)); 1654 printk("%s: detaching ...\n", sym_name(np));
1651 1655
1652 del_timer_sync(&np->s.timer); 1656 del_timer_sync(&np->s.timer);
@@ -1750,14 +1754,11 @@ static int __devinit sym2_probe(struct pci_dev *pdev,
1750 1754
1751static void __devexit sym2_remove(struct pci_dev *pdev) 1755static void __devexit sym2_remove(struct pci_dev *pdev)
1752{ 1756{
1753 struct sym_hcb *np = pci_get_drvdata(pdev); 1757 struct Scsi_Host *shost = pci_get_drvdata(pdev);
1754 struct Scsi_Host *host = np->s.host;
1755
1756 scsi_remove_host(host);
1757 scsi_host_put(host);
1758
1759 sym_detach(np, pdev);
1760 1758
1759 scsi_remove_host(shost);
1760 scsi_host_put(shost);
1761 sym_detach(shost, pdev);
1761 pci_release_regions(pdev); 1762 pci_release_regions(pdev);
1762 pci_disable_device(pdev); 1763 pci_disable_device(pdev);
1763 1764
@@ -1791,9 +1792,9 @@ static pci_ers_result_t sym2_io_error_detected(struct pci_dev *pdev,
1791 */ 1792 */
1792static pci_ers_result_t sym2_io_slot_dump(struct pci_dev *pdev) 1793static pci_ers_result_t sym2_io_slot_dump(struct pci_dev *pdev)
1793{ 1794{
1794 struct sym_hcb *np = pci_get_drvdata(pdev); 1795 struct Scsi_Host *shost = pci_get_drvdata(pdev);
1795 1796
1796 sym_dump_registers(np); 1797 sym_dump_registers(shost);
1797 1798
1798 /* Request a slot reset. */ 1799 /* Request a slot reset. */
1799 return PCI_ERS_RESULT_NEED_RESET; 1800 return PCI_ERS_RESULT_NEED_RESET;
@@ -1833,7 +1834,8 @@ static void sym2_reset_workarounds(struct pci_dev *pdev)
1833 */ 1834 */
1834static pci_ers_result_t sym2_io_slot_reset(struct pci_dev *pdev) 1835static pci_ers_result_t sym2_io_slot_reset(struct pci_dev *pdev)
1835{ 1836{
1836 struct sym_hcb *np = pci_get_drvdata(pdev); 1837 struct Scsi_Host *shost = pci_get_drvdata(pdev);
1838 struct sym_hcb *np = sym_get_hcb(shost);
1837 1839
1838 printk(KERN_INFO "%s: recovering from a PCI slot reset\n", 1840 printk(KERN_INFO "%s: recovering from a PCI slot reset\n",
1839 sym_name(np)); 1841 sym_name(np));
@@ -1863,7 +1865,7 @@ static pci_ers_result_t sym2_io_slot_reset(struct pci_dev *pdev)
1863 sym_name(np)); 1865 sym_name(np));
1864 return PCI_ERS_RESULT_DISCONNECT; 1866 return PCI_ERS_RESULT_DISCONNECT;
1865 } 1867 }
1866 sym_start_up(np, 1); 1868 sym_start_up(shost, 1);
1867 } 1869 }
1868 1870
1869 return PCI_ERS_RESULT_RECOVERED; 1871 return PCI_ERS_RESULT_RECOVERED;
@@ -1879,8 +1881,7 @@ static pci_ers_result_t sym2_io_slot_reset(struct pci_dev *pdev)
1879 */ 1881 */
1880static void sym2_io_resume(struct pci_dev *pdev) 1882static void sym2_io_resume(struct pci_dev *pdev)
1881{ 1883{
1882 struct sym_hcb *np = pci_get_drvdata(pdev); 1884 struct Scsi_Host *shost = pci_get_drvdata(pdev);
1883 struct Scsi_Host *shost = np->s.host;
1884 struct sym_data *sym_data = shost_priv(shost); 1885 struct sym_data *sym_data = shost_priv(shost);
1885 1886
1886 spin_lock_irq(shost->host_lock); 1887 spin_lock_irq(shost->host_lock);
diff --git a/drivers/scsi/sym53c8xx_2/sym_glue.h b/drivers/scsi/sym53c8xx_2/sym_glue.h
index 98261a5af87d..e5bd0afcb4d8 100644
--- a/drivers/scsi/sym53c8xx_2/sym_glue.h
+++ b/drivers/scsi/sym53c8xx_2/sym_glue.h
@@ -179,7 +179,6 @@ struct sym_shcb {
179 int unit; 179 int unit;
180 char inst_name[16]; 180 char inst_name[16];
181 char chip_name[8]; 181 char chip_name[8];
182 struct pci_dev *device;
183 182
184 struct Scsi_Host *host; 183 struct Scsi_Host *host;
185 184
@@ -266,7 +265,7 @@ void sym_xpt_done(struct sym_hcb *np, struct scsi_cmnd *ccb);
266void sym_xpt_async_bus_reset(struct sym_hcb *np); 265void sym_xpt_async_bus_reset(struct sym_hcb *np);
267void sym_xpt_async_sent_bdr(struct sym_hcb *np, int target); 266void sym_xpt_async_sent_bdr(struct sym_hcb *np, int target);
268int sym_setup_data_and_start (struct sym_hcb *np, struct scsi_cmnd *csio, struct sym_ccb *cp); 267int sym_setup_data_and_start (struct sym_hcb *np, struct scsi_cmnd *csio, struct sym_ccb *cp);
269void sym_log_bus_error(struct sym_hcb *np); 268void sym_log_bus_error(struct Scsi_Host *);
270void sym_dump_registers(struct sym_hcb *np); 269void sym_dump_registers(struct Scsi_Host *);
271 270
272#endif /* SYM_GLUE_H */ 271#endif /* SYM_GLUE_H */
diff --git a/drivers/scsi/sym53c8xx_2/sym_hipd.c b/drivers/scsi/sym53c8xx_2/sym_hipd.c
index 5d2079f9e596..3cf1209301a4 100644
--- a/drivers/scsi/sym53c8xx_2/sym_hipd.c
+++ b/drivers/scsi/sym53c8xx_2/sym_hipd.c
@@ -684,6 +684,8 @@ static void sym_set_bus_mode(struct sym_hcb *np, struct sym_nvram *nvram)
684 */ 684 */
685static int sym_prepare_setting(struct Scsi_Host *shost, struct sym_hcb *np, struct sym_nvram *nvram) 685static int sym_prepare_setting(struct Scsi_Host *shost, struct sym_hcb *np, struct sym_nvram *nvram)
686{ 686{
687 struct sym_data *sym_data = shost_priv(shost);
688 struct pci_dev *pdev = sym_data->pdev;
687 u_char burst_max; 689 u_char burst_max;
688 u32 period; 690 u32 period;
689 int i; 691 int i;
@@ -797,8 +799,8 @@ static int sym_prepare_setting(struct Scsi_Host *shost, struct sym_hcb *np, stru
797 * In dual channel mode, contention occurs if internal cycles 799 * In dual channel mode, contention occurs if internal cycles
798 * are used. Disable internal cycles. 800 * are used. Disable internal cycles.
799 */ 801 */
800 if (np->s.device->device == PCI_DEVICE_ID_LSI_53C1010_33 && 802 if (pdev->device == PCI_DEVICE_ID_LSI_53C1010_33 &&
801 np->s.device->revision < 0x1) 803 pdev->revision < 0x1)
802 np->rv_ccntl0 |= DILS; 804 np->rv_ccntl0 |= DILS;
803 805
804 /* 806 /*
@@ -821,10 +823,10 @@ static int sym_prepare_setting(struct Scsi_Host *shost, struct sym_hcb *np, stru
821 * this driver. The generic ncr driver that does not use 823 * this driver. The generic ncr driver that does not use
822 * LOAD/STORE instructions does not need this work-around. 824 * LOAD/STORE instructions does not need this work-around.
823 */ 825 */
824 if ((np->s.device->device == PCI_DEVICE_ID_NCR_53C810 && 826 if ((pdev->device == PCI_DEVICE_ID_NCR_53C810 &&
825 np->s.device->revision >= 0x10 && np->s.device->revision <= 0x11) || 827 pdev->revision >= 0x10 && pdev->revision <= 0x11) ||
826 (np->s.device->device == PCI_DEVICE_ID_NCR_53C860 && 828 (pdev->device == PCI_DEVICE_ID_NCR_53C860 &&
827 np->s.device->revision <= 0x1)) 829 pdev->revision <= 0x1))
828 np->features &= ~(FE_WRIE|FE_ERL|FE_ERMP); 830 np->features &= ~(FE_WRIE|FE_ERL|FE_ERMP);
829 831
830 /* 832 /*
@@ -890,7 +892,7 @@ static int sym_prepare_setting(struct Scsi_Host *shost, struct sym_hcb *np, stru
890 if ((SYM_SETUP_SCSI_LED || 892 if ((SYM_SETUP_SCSI_LED ||
891 (nvram->type == SYM_SYMBIOS_NVRAM || 893 (nvram->type == SYM_SYMBIOS_NVRAM ||
892 (nvram->type == SYM_TEKRAM_NVRAM && 894 (nvram->type == SYM_TEKRAM_NVRAM &&
893 np->s.device->device == PCI_DEVICE_ID_NCR_53C895))) && 895 pdev->device == PCI_DEVICE_ID_NCR_53C895))) &&
894 !(np->features & FE_LEDC) && !(np->sv_gpcntl & 0x01)) 896 !(np->features & FE_LEDC) && !(np->sv_gpcntl & 0x01))
895 np->features |= FE_LED0; 897 np->features |= FE_LED0;
896 898
@@ -1128,8 +1130,9 @@ restart_test:
1128 * First 24 register of the chip: 1130 * First 24 register of the chip:
1129 * r0..rf 1131 * r0..rf
1130 */ 1132 */
1131static void sym_log_hard_error(struct sym_hcb *np, u_short sist, u_char dstat) 1133static void sym_log_hard_error(struct Scsi_Host *shost, u_short sist, u_char dstat)
1132{ 1134{
1135 struct sym_hcb *np = sym_get_hcb(shost);
1133 u32 dsp; 1136 u32 dsp;
1134 int script_ofs; 1137 int script_ofs;
1135 int script_size; 1138 int script_size;
@@ -1182,17 +1185,18 @@ static void sym_log_hard_error(struct sym_hcb *np, u_short sist, u_char dstat)
1182 * PCI BUS error. 1185 * PCI BUS error.
1183 */ 1186 */
1184 if (dstat & (MDPE|BF)) 1187 if (dstat & (MDPE|BF))
1185 sym_log_bus_error(np); 1188 sym_log_bus_error(shost);
1186} 1189}
1187 1190
1188void sym_dump_registers(struct sym_hcb *np) 1191void sym_dump_registers(struct Scsi_Host *shost)
1189{ 1192{
1193 struct sym_hcb *np = sym_get_hcb(shost);
1190 u_short sist; 1194 u_short sist;
1191 u_char dstat; 1195 u_char dstat;
1192 1196
1193 sist = INW(np, nc_sist); 1197 sist = INW(np, nc_sist);
1194 dstat = INB(np, nc_dstat); 1198 dstat = INB(np, nc_dstat);
1195 sym_log_hard_error(np, sist, dstat); 1199 sym_log_hard_error(shost, sist, dstat);
1196} 1200}
1197 1201
1198static struct sym_chip sym_dev_table[] = { 1202static struct sym_chip sym_dev_table[] = {
@@ -1700,8 +1704,11 @@ static void sym_flush_busy_queue (struct sym_hcb *np, int cam_status)
1700 * 1: SCSI BUS RESET delivered or received. 1704 * 1: SCSI BUS RESET delivered or received.
1701 * 2: SCSI BUS MODE changed. 1705 * 2: SCSI BUS MODE changed.
1702 */ 1706 */
1703void sym_start_up (struct sym_hcb *np, int reason) 1707void sym_start_up(struct Scsi_Host *shost, int reason)
1704{ 1708{
1709 struct sym_data *sym_data = shost_priv(shost);
1710 struct pci_dev *pdev = sym_data->pdev;
1711 struct sym_hcb *np = sym_data->ncb;
1705 int i; 1712 int i;
1706 u32 phys; 1713 u32 phys;
1707 1714
@@ -1750,7 +1757,7 @@ void sym_start_up (struct sym_hcb *np, int reason)
1750 * This also let point to first position the start 1757 * This also let point to first position the start
1751 * and done queue pointers used from SCRIPTS. 1758 * and done queue pointers used from SCRIPTS.
1752 */ 1759 */
1753 np->fw_patch(np); 1760 np->fw_patch(shost);
1754 1761
1755 /* 1762 /*
1756 * Wakeup all pending jobs. 1763 * Wakeup all pending jobs.
@@ -1792,7 +1799,7 @@ void sym_start_up (struct sym_hcb *np, int reason)
1792 /* 1799 /*
1793 * For now, disable AIP generation on C1010-66. 1800 * For now, disable AIP generation on C1010-66.
1794 */ 1801 */
1795 if (np->s.device->device == PCI_DEVICE_ID_LSI_53C1010_66) 1802 if (pdev->device == PCI_DEVICE_ID_LSI_53C1010_66)
1796 OUTB(np, nc_aipcntl1, DISAIP); 1803 OUTB(np, nc_aipcntl1, DISAIP);
1797 1804
1798 /* 1805 /*
@@ -1802,8 +1809,8 @@ void sym_start_up (struct sym_hcb *np, int reason)
1802 * that from SCRIPTS for each selection/reselection, but 1809 * that from SCRIPTS for each selection/reselection, but
1803 * I just don't want. :) 1810 * I just don't want. :)
1804 */ 1811 */
1805 if (np->s.device->device == PCI_DEVICE_ID_LSI_53C1010_33 && 1812 if (pdev->device == PCI_DEVICE_ID_LSI_53C1010_33 &&
1806 np->s.device->revision < 1) 1813 pdev->revision < 1)
1807 OUTB(np, nc_stest1, INB(np, nc_stest1) | 0x30); 1814 OUTB(np, nc_stest1, INB(np, nc_stest1) | 0x30);
1808 1815
1809 /* 1816 /*
@@ -1811,9 +1818,9 @@ void sym_start_up (struct sym_hcb *np, int reason)
1811 * Disable overlapped arbitration for some dual function devices, 1818 * Disable overlapped arbitration for some dual function devices,
1812 * regardless revision id (kind of post-chip-design feature. ;-)) 1819 * regardless revision id (kind of post-chip-design feature. ;-))
1813 */ 1820 */
1814 if (np->s.device->device == PCI_DEVICE_ID_NCR_53C875) 1821 if (pdev->device == PCI_DEVICE_ID_NCR_53C875)
1815 OUTB(np, nc_ctest0, (1<<5)); 1822 OUTB(np, nc_ctest0, (1<<5));
1816 else if (np->s.device->device == PCI_DEVICE_ID_NCR_53C896) 1823 else if (pdev->device == PCI_DEVICE_ID_NCR_53C896)
1817 np->rv_ccntl0 |= DPR; 1824 np->rv_ccntl0 |= DPR;
1818 1825
1819 /* 1826 /*
@@ -2218,8 +2225,9 @@ static void sym_int_udc (struct sym_hcb *np)
2218 * mode to eight bit asynchronous, etc... 2225 * mode to eight bit asynchronous, etc...
2219 * So, just reinitializing all except chip should be enough. 2226 * So, just reinitializing all except chip should be enough.
2220 */ 2227 */
2221static void sym_int_sbmc (struct sym_hcb *np) 2228static void sym_int_sbmc(struct Scsi_Host *shost)
2222{ 2229{
2230 struct sym_hcb *np = sym_get_hcb(shost);
2223 u_char scsi_mode = INB(np, nc_stest4) & SMODE; 2231 u_char scsi_mode = INB(np, nc_stest4) & SMODE;
2224 2232
2225 /* 2233 /*
@@ -2232,7 +2240,7 @@ static void sym_int_sbmc (struct sym_hcb *np)
2232 * Should suspend command processing for a few seconds and 2240 * Should suspend command processing for a few seconds and
2233 * reinitialize all except the chip. 2241 * reinitialize all except the chip.
2234 */ 2242 */
2235 sym_start_up (np, 2); 2243 sym_start_up(shost, 2);
2236} 2244}
2237 2245
2238/* 2246/*
@@ -2762,7 +2770,9 @@ reset_all:
2762 2770
2763irqreturn_t sym_interrupt(struct Scsi_Host *shost) 2771irqreturn_t sym_interrupt(struct Scsi_Host *shost)
2764{ 2772{
2765 struct sym_hcb *np = sym_get_hcb(shost); 2773 struct sym_data *sym_data = shost_priv(shost);
2774 struct sym_hcb *np = sym_data->ncb;
2775 struct pci_dev *pdev = sym_data->pdev;
2766 u_char istat, istatc; 2776 u_char istat, istatc;
2767 u_char dstat; 2777 u_char dstat;
2768 u_short sist; 2778 u_short sist;
@@ -2818,7 +2828,7 @@ irqreturn_t sym_interrupt(struct Scsi_Host *shost)
2818 /* Prevent deadlock waiting on a condition that may 2828 /* Prevent deadlock waiting on a condition that may
2819 * never clear. */ 2829 * never clear. */
2820 if (unlikely(sist == 0xffff && dstat == 0xff)) { 2830 if (unlikely(sist == 0xffff && dstat == 0xff)) {
2821 if (pci_channel_offline(np->s.device)) 2831 if (pci_channel_offline(pdev))
2822 return IRQ_NONE; 2832 return IRQ_NONE;
2823 } 2833 }
2824 } while (istatc & (SIP|DIP)); 2834 } while (istatc & (SIP|DIP));
@@ -2873,7 +2883,7 @@ irqreturn_t sym_interrupt(struct Scsi_Host *shost)
2873 */ 2883 */
2874 if (sist & RST) { 2884 if (sist & RST) {
2875 printf("%s: SCSI BUS reset detected.\n", sym_name(np)); 2885 printf("%s: SCSI BUS reset detected.\n", sym_name(np));
2876 sym_start_up (np, 1); 2886 sym_start_up(shost, 1);
2877 return IRQ_HANDLED; 2887 return IRQ_HANDLED;
2878 } 2888 }
2879 2889
@@ -2882,7 +2892,7 @@ irqreturn_t sym_interrupt(struct Scsi_Host *shost)
2882 2892
2883 if (!(sist & (GEN|HTH|SGE)) && 2893 if (!(sist & (GEN|HTH|SGE)) &&
2884 !(dstat & (MDPE|BF|ABRT|IID))) { 2894 !(dstat & (MDPE|BF|ABRT|IID))) {
2885 if (sist & SBMC) sym_int_sbmc (np); 2895 if (sist & SBMC) sym_int_sbmc(shost);
2886 else if (sist & STO) sym_int_sto (np); 2896 else if (sist & STO) sym_int_sto (np);
2887 else if (sist & UDC) sym_int_udc (np); 2897 else if (sist & UDC) sym_int_udc (np);
2888 else goto unknown_int; 2898 else goto unknown_int;
@@ -2896,7 +2906,7 @@ irqreturn_t sym_interrupt(struct Scsi_Host *shost)
2896 * Reset everything. 2906 * Reset everything.
2897 */ 2907 */
2898 2908
2899 sym_log_hard_error(np, sist, dstat); 2909 sym_log_hard_error(shost, sist, dstat);
2900 2910
2901 if ((sist & (GEN|HTH|SGE)) || 2911 if ((sist & (GEN|HTH|SGE)) ||
2902 (dstat & (MDPE|BF|ABRT|IID))) { 2912 (dstat & (MDPE|BF|ABRT|IID))) {
diff --git a/drivers/scsi/sym53c8xx_2/sym_hipd.h b/drivers/scsi/sym53c8xx_2/sym_hipd.h
index a9c08668b98c..ad078805e62b 100644
--- a/drivers/scsi/sym53c8xx_2/sym_hipd.h
+++ b/drivers/scsi/sym53c8xx_2/sym_hipd.h
@@ -909,7 +909,7 @@ struct sym_hcb {
909 struct sym_fwb_ba fwb_bas; /* Useful SCRIPTB bus addresses */ 909 struct sym_fwb_ba fwb_bas; /* Useful SCRIPTB bus addresses */
910 struct sym_fwz_ba fwz_bas; /* Useful SCRIPTZ bus addresses */ 910 struct sym_fwz_ba fwz_bas; /* Useful SCRIPTZ bus addresses */
911 void (*fw_setup)(struct sym_hcb *np, struct sym_fw *fw); 911 void (*fw_setup)(struct sym_hcb *np, struct sym_fw *fw);
912 void (*fw_patch)(struct sym_hcb *np); 912 void (*fw_patch)(struct Scsi_Host *);
913 char *fw_name; 913 char *fw_name;
914 914
915 /* 915 /*
@@ -1055,7 +1055,7 @@ void sym_start_next_ccbs(struct sym_hcb *np, struct sym_lcb *lp, int maxn);
1055#else 1055#else
1056void sym_put_start_queue(struct sym_hcb *np, struct sym_ccb *cp); 1056void sym_put_start_queue(struct sym_hcb *np, struct sym_ccb *cp);
1057#endif 1057#endif
1058void sym_start_up(struct sym_hcb *np, int reason); 1058void sym_start_up(struct Scsi_Host *, int reason);
1059irqreturn_t sym_interrupt(struct Scsi_Host *); 1059irqreturn_t sym_interrupt(struct Scsi_Host *);
1060int sym_clear_tasks(struct sym_hcb *np, int cam_status, int target, int lun, int task); 1060int sym_clear_tasks(struct sym_hcb *np, int cam_status, int target, int lun, int task);
1061struct sym_ccb *sym_get_ccb(struct sym_hcb *np, struct scsi_cmnd *cmd, u_char tag_order); 1061struct sym_ccb *sym_get_ccb(struct sym_hcb *np, struct scsi_cmnd *cmd, u_char tag_order);