aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/sym53c8xx_2/sym_glue.c
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/sym53c8xx_2/sym_glue.c
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/sym53c8xx_2/sym_glue.c')
-rw-r--r--drivers/scsi/sym53c8xx_2/sym_glue.c97
1 files changed, 49 insertions, 48 deletions
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);