aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/eata_pio.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/eata_pio.c')
-rw-r--r--drivers/scsi/eata_pio.c127
1 files changed, 68 insertions, 59 deletions
diff --git a/drivers/scsi/eata_pio.c b/drivers/scsi/eata_pio.c
index 771b01984cbc..d312633db92b 100644
--- a/drivers/scsi/eata_pio.c
+++ b/drivers/scsi/eata_pio.c
@@ -71,11 +71,11 @@
71#include "eata_pio.h" 71#include "eata_pio.h"
72 72
73 73
74static uint ISAbases[MAXISA] = { 74static unsigned int ISAbases[MAXISA] = {
75 0x1F0, 0x170, 0x330, 0x230 75 0x1F0, 0x170, 0x330, 0x230
76}; 76};
77 77
78static uint ISAirqs[MAXISA] = { 78static unsigned int ISAirqs[MAXISA] = {
79 14, 12, 15, 11 79 14, 12, 15, 11
80}; 80};
81 81
@@ -84,7 +84,7 @@ static unsigned char EISAbases[] = {
84 1, 1, 1, 1, 1, 1, 1, 1 84 1, 1, 1, 1, 1, 1, 1, 1
85}; 85};
86 86
87static uint registered_HBAs; 87static unsigned int registered_HBAs;
88static struct Scsi_Host *last_HBA; 88static struct Scsi_Host *last_HBA;
89static struct Scsi_Host *first_HBA; 89static struct Scsi_Host *first_HBA;
90static unsigned char reg_IRQ[16]; 90static unsigned char reg_IRQ[16];
@@ -165,6 +165,7 @@ static int eata_pio_proc_info(struct Scsi_Host *shost, char *buffer, char **star
165 165
166static int eata_pio_release(struct Scsi_Host *sh) 166static int eata_pio_release(struct Scsi_Host *sh)
167{ 167{
168 hostdata *hd = SD(sh);
168 if (sh->irq && reg_IRQ[sh->irq] == 1) 169 if (sh->irq && reg_IRQ[sh->irq] == 1)
169 free_irq(sh->irq, NULL); 170 free_irq(sh->irq, NULL);
170 else 171 else
@@ -173,10 +174,13 @@ static int eata_pio_release(struct Scsi_Host *sh)
173 if (sh->io_port && sh->n_io_port) 174 if (sh->io_port && sh->n_io_port)
174 release_region(sh->io_port, sh->n_io_port); 175 release_region(sh->io_port, sh->n_io_port);
175 } 176 }
177 /* At this point the PCI reference can go */
178 if (hd->pdev)
179 pci_dev_put(hd->pdev);
176 return 1; 180 return 1;
177} 181}
178 182
179static void IncStat(struct scsi_pointer *SCp, uint Increment) 183static void IncStat(struct scsi_pointer *SCp, unsigned int Increment)
180{ 184{
181 SCp->ptr += Increment; 185 SCp->ptr += Increment;
182 if ((SCp->this_residual -= Increment) == 0) { 186 if ((SCp->this_residual -= Increment) == 0) {
@@ -190,46 +194,49 @@ static void IncStat(struct scsi_pointer *SCp, uint Increment)
190 } 194 }
191} 195}
192 196
193static void eata_pio_int_handler(int irq, void *dev_id, struct pt_regs *regs); 197static irqreturn_t eata_pio_int_handler(int irq, void *dev_id, struct pt_regs *regs);
194 198
195static irqreturn_t do_eata_pio_int_handler(int irq, void *dev_id, 199static irqreturn_t do_eata_pio_int_handler(int irq, void *dev_id,
196 struct pt_regs *regs) 200 struct pt_regs *regs)
197{ 201{
198 unsigned long flags; 202 unsigned long flags;
199 struct Scsi_Host *dev = dev_id; 203 struct Scsi_Host *dev = dev_id;
204 irqreturn_t ret;
200 205
201 spin_lock_irqsave(dev->host_lock, flags); 206 spin_lock_irqsave(dev->host_lock, flags);
202 eata_pio_int_handler(irq, dev_id, regs); 207 ret = eata_pio_int_handler(irq, dev_id, regs);
203 spin_unlock_irqrestore(dev->host_lock, flags); 208 spin_unlock_irqrestore(dev->host_lock, flags);
204 return IRQ_HANDLED; 209 return ret;
205} 210}
206 211
207static void eata_pio_int_handler(int irq, void *dev_id, struct pt_regs *regs) 212static irqreturn_t eata_pio_int_handler(int irq, void *dev_id, struct pt_regs *regs)
208{ 213{
209 uint eata_stat = 0xfffff; 214 unsigned int eata_stat = 0xfffff;
210 struct scsi_cmnd *cmd; 215 struct scsi_cmnd *cmd;
211 hostdata *hd; 216 hostdata *hd;
212 struct eata_ccb *cp; 217 struct eata_ccb *cp;
213 uint base; 218 unsigned long base;
214 uint x, z; 219 unsigned int x, z;
215 struct Scsi_Host *sh; 220 struct Scsi_Host *sh;
216 unsigned short zwickel = 0; 221 unsigned short zwickel = 0;
217 unsigned char stat, odd; 222 unsigned char stat, odd;
223 irqreturn_t ret = IRQ_NONE;
218 224
219 for (x = 1, sh = first_HBA; x <= registered_HBAs; x++, sh = SD(sh)->prev) 225 for (x = 1, sh = first_HBA; x <= registered_HBAs; x++, sh = SD(sh)->prev)
220 { 226 {
221 if (sh->irq != irq) 227 if (sh->irq != irq)
222 continue; 228 continue;
223 if (inb((uint) sh->base + HA_RSTATUS) & HA_SBUSY) 229 if (inb(sh->base + HA_RSTATUS) & HA_SBUSY)
224 continue; 230 continue;
225 231
226 int_counter++; 232 int_counter++;
233 ret = IRQ_HANDLED;
227 234
228 hd = SD(sh); 235 hd = SD(sh);
229 236
230 cp = &hd->ccb[0]; 237 cp = &hd->ccb[0];
231 cmd = cp->cmd; 238 cmd = cp->cmd;
232 base = (uint) cmd->device->host->base; 239 base = cmd->device->host->base;
233 240
234 do { 241 do {
235 stat = inb(base + HA_RSTATUS); 242 stat = inb(base + HA_RSTATUS);
@@ -304,7 +311,7 @@ static void eata_pio_int_handler(int irq, void *dev_id, struct pt_regs *regs)
304 if (!(inb(base + HA_RSTATUS) & HA_SERROR)) { 311 if (!(inb(base + HA_RSTATUS) & HA_SERROR)) {
305 cmd->result = (DID_OK << 16); 312 cmd->result = (DID_OK << 16);
306 hd->devflags |= (1 << cp->cp_id); 313 hd->devflags |= (1 << cp->cp_id);
307 } else if (hd->devflags & 1 << cp->cp_id) 314 } else if (hd->devflags & (1 << cp->cp_id))
308 cmd->result = (DID_OK << 16) + 0x02; 315 cmd->result = (DID_OK << 16) + 0x02;
309 else 316 else
310 cmd->result = (DID_NO_CONNECT << 16); 317 cmd->result = (DID_NO_CONNECT << 16);
@@ -313,7 +320,7 @@ static void eata_pio_int_handler(int irq, void *dev_id, struct pt_regs *regs)
313 cp->status = FREE; 320 cp->status = FREE;
314 eata_stat = inb(base + HA_RSTATUS); 321 eata_stat = inb(base + HA_RSTATUS);
315 printk(KERN_CRIT "eata_pio: int_handler, freeing locked " "queueslot\n"); 322 printk(KERN_CRIT "eata_pio: int_handler, freeing locked " "queueslot\n");
316 return; 323 return ret;
317 } 324 }
318#if DBG_INTR2 325#if DBG_INTR2
319 if (stat != 0x50) 326 if (stat != 0x50)
@@ -325,12 +332,12 @@ static void eata_pio_int_handler(int irq, void *dev_id, struct pt_regs *regs)
325 cmd->scsi_done(cmd); 332 cmd->scsi_done(cmd);
326 } 333 }
327 334
328 return; 335 return ret;
329} 336}
330 337
331static inline uint eata_pio_send_command(uint base, unsigned char command) 338static inline unsigned int eata_pio_send_command(unsigned long base, unsigned char command)
332{ 339{
333 uint loop = HZ / 2; 340 unsigned int loop = 50;
334 341
335 while (inb(base + HA_RSTATUS) & HA_SBUSY) 342 while (inb(base + HA_RSTATUS) & HA_SBUSY)
336 if (--loop == 0) 343 if (--loop == 0)
@@ -349,8 +356,8 @@ static inline uint eata_pio_send_command(uint base, unsigned char command)
349static int eata_pio_queue(struct scsi_cmnd *cmd, 356static int eata_pio_queue(struct scsi_cmnd *cmd,
350 void (*done)(struct scsi_cmnd *)) 357 void (*done)(struct scsi_cmnd *))
351{ 358{
352 uint x, y; 359 unsigned int x, y;
353 uint base; 360 unsigned long base;
354 361
355 hostdata *hd; 362 hostdata *hd;
356 struct Scsi_Host *sh; 363 struct Scsi_Host *sh;
@@ -360,7 +367,7 @@ static int eata_pio_queue(struct scsi_cmnd *cmd,
360 367
361 hd = HD(cmd); 368 hd = HD(cmd);
362 sh = cmd->device->host; 369 sh = cmd->device->host;
363 base = (uint) sh->base; 370 base = sh->base;
364 371
365 /* use only slot 0, as 2001 can handle only one cmd at a time */ 372 /* use only slot 0, as 2001 can handle only one cmd at a time */
366 373
@@ -395,9 +402,9 @@ static int eata_pio_queue(struct scsi_cmnd *cmd,
395 cp->DataIn = 0; /* Input mode */ 402 cp->DataIn = 0; /* Input mode */
396 403
397 cp->Interpret = (cmd->device->id == hd->hostid); 404 cp->Interpret = (cmd->device->id == hd->hostid);
398 cp->cp_datalen = htonl((unsigned long) cmd->request_bufflen); 405 cp->cp_datalen = cpu_to_be32(cmd->request_bufflen);
399 cp->Auto_Req_Sen = 0; 406 cp->Auto_Req_Sen = 0;
400 cp->cp_reqDMA = htonl(0); 407 cp->cp_reqDMA = 0;
401 cp->reqlen = 0; 408 cp->reqlen = 0;
402 409
403 cp->cp_id = cmd->device->id; 410 cp->cp_id = cmd->device->id;
@@ -406,7 +413,7 @@ static int eata_pio_queue(struct scsi_cmnd *cmd,
406 cp->cp_identify = 1; 413 cp->cp_identify = 1;
407 memcpy(cp->cp_cdb, cmd->cmnd, COMMAND_SIZE(*cmd->cmnd)); 414 memcpy(cp->cp_cdb, cmd->cmnd, COMMAND_SIZE(*cmd->cmnd));
408 415
409 cp->cp_statDMA = htonl(0); 416 cp->cp_statDMA = 0;
410 417
411 cp->cp_viraddr = cp; 418 cp->cp_viraddr = cp;
412 cp->cmd = cmd; 419 cp->cmd = cmd;
@@ -445,14 +452,14 @@ static int eata_pio_queue(struct scsi_cmnd *cmd,
445 452
446 DBG(DBG_QUEUE, scmd_printk(KERN_DEBUG, cmd, 453 DBG(DBG_QUEUE, scmd_printk(KERN_DEBUG, cmd,
447 "Queued base %#.4lx pid: %ld " 454 "Queued base %#.4lx pid: %ld "
448 "slot %d irq %d\n", (long) sh->base, cmd->pid, y, sh->irq)); 455 "slot %d irq %d\n", sh->base, cmd->pid, y, sh->irq));
449 456
450 return (0); 457 return (0);
451} 458}
452 459
453static int eata_pio_abort(struct scsi_cmnd *cmd) 460static int eata_pio_abort(struct scsi_cmnd *cmd)
454{ 461{
455 uint loop = HZ; 462 unsigned int loop = 100;
456 463
457 DBG(DBG_ABNORM, scmd_printk(KERN_WARNING, cmd, 464 DBG(DBG_ABNORM, scmd_printk(KERN_WARNING, cmd,
458 "eata_pio_abort called pid: %ld\n", 465 "eata_pio_abort called pid: %ld\n",
@@ -485,7 +492,7 @@ static int eata_pio_abort(struct scsi_cmnd *cmd)
485 492
486static int eata_pio_host_reset(struct scsi_cmnd *cmd) 493static int eata_pio_host_reset(struct scsi_cmnd *cmd)
487{ 494{
488 uint x, limit = 0; 495 unsigned int x, limit = 0;
489 unsigned char success = 0; 496 unsigned char success = 0;
490 struct scsi_cmnd *sp; 497 struct scsi_cmnd *sp;
491 struct Scsi_Host *host = cmd->device->host; 498 struct Scsi_Host *host = cmd->device->host;
@@ -518,7 +525,7 @@ static int eata_pio_host_reset(struct scsi_cmnd *cmd)
518 } 525 }
519 526
520 /* hard reset the HBA */ 527 /* hard reset the HBA */
521 outb(EATA_CMD_RESET, (uint) cmd->device->host->base + HA_WCOMMAND); 528 outb(EATA_CMD_RESET, cmd->device->host->base + HA_WCOMMAND);
522 529
523 DBG(DBG_ABNORM, printk(KERN_WARNING "eata_pio_reset: board reset done.\n")); 530 DBG(DBG_ABNORM, printk(KERN_WARNING "eata_pio_reset: board reset done.\n"));
524 HD(cmd)->state = RESET; 531 HD(cmd)->state = RESET;
@@ -558,7 +565,7 @@ static int eata_pio_host_reset(struct scsi_cmnd *cmd)
558 } 565 }
559} 566}
560 567
561static char *get_pio_board_data(unsigned long base, uint irq, uint id, unsigned long cplen, unsigned short cppadlen) 568static char *get_pio_board_data(unsigned long base, unsigned int irq, unsigned int id, unsigned long cplen, unsigned short cppadlen)
562{ 569{
563 struct eata_ccb cp; 570 struct eata_ccb cp;
564 static char buff[256]; 571 static char buff[256];
@@ -570,8 +577,8 @@ static char *get_pio_board_data(unsigned long base, uint irq, uint id, unsigned
570 cp.DataIn = 1; 577 cp.DataIn = 1;
571 cp.Interpret = 1; /* Interpret command */ 578 cp.Interpret = 1; /* Interpret command */
572 579
573 cp.cp_datalen = htonl(254); 580 cp.cp_datalen = cpu_to_be32(254);
574 cp.cp_dataDMA = htonl(0); 581 cp.cp_dataDMA = cpu_to_be32(0);
575 582
576 cp.cp_id = id; 583 cp.cp_id = id;
577 cp.cp_lun = 0; 584 cp.cp_lun = 0;
@@ -583,7 +590,7 @@ static char *get_pio_board_data(unsigned long base, uint irq, uint id, unsigned
583 cp.cp_cdb[4] = 254; 590 cp.cp_cdb[4] = 254;
584 cp.cp_cdb[5] = 0; 591 cp.cp_cdb[5] = 0;
585 592
586 if (eata_pio_send_command((uint) base, EATA_CMD_PIO_SEND_CP)) 593 if (eata_pio_send_command(base, EATA_CMD_PIO_SEND_CP))
587 return (NULL); 594 return (NULL);
588 while (!(inb(base + HA_RSTATUS) & HA_SDRQ)); 595 while (!(inb(base + HA_RSTATUS) & HA_SDRQ));
589 outsw(base + HA_RDATA, &cp, cplen); 596 outsw(base + HA_RDATA, &cp, cplen);
@@ -604,7 +611,7 @@ static char *get_pio_board_data(unsigned long base, uint irq, uint id, unsigned
604 } 611 }
605} 612}
606 613
607static int get_pio_conf_PIO(u32 base, struct get_conf *buf) 614static int get_pio_conf_PIO(unsigned long base, struct get_conf *buf)
608{ 615{
609 unsigned long loop = HZ / 2; 616 unsigned long loop = HZ / 2;
610 int z; 617 int z;
@@ -619,30 +626,30 @@ static int get_pio_conf_PIO(u32 base, struct get_conf *buf)
619 if (--loop == 0) 626 if (--loop == 0)
620 goto fail; 627 goto fail;
621 628
622 DBG(DBG_PIO && DBG_PROBE, printk(KERN_DEBUG "Issuing PIO READ CONFIG to HBA at %#x\n", base)); 629 DBG(DBG_PIO && DBG_PROBE, printk(KERN_DEBUG "Issuing PIO READ CONFIG to HBA at %#lx\n", base));
623 eata_pio_send_command(base, EATA_CMD_PIO_READ_CONFIG); 630 eata_pio_send_command(base, EATA_CMD_PIO_READ_CONFIG);
624 631
625 loop = HZ / 2; 632 loop = 50;
626 for (p = (unsigned short *) buf; (long) p <= ((long) buf + (sizeof(struct get_conf) / 2)); p++) { 633 for (p = (unsigned short *) buf; (long) p <= ((long) buf + (sizeof(struct get_conf) / 2)); p++) {
627 while (!(inb(base + HA_RSTATUS) & HA_SDRQ)) 634 while (!(inb(base + HA_RSTATUS) & HA_SDRQ))
628 if (--loop == 0) 635 if (--loop == 0)
629 goto fail; 636 goto fail;
630 637
631 loop = HZ / 2; 638 loop = 50;
632 *p = inw(base + HA_RDATA); 639 *p = inw(base + HA_RDATA);
633 } 640 }
634 if (inb(base + HA_RSTATUS) & HA_SERROR) { 641 if (inb(base + HA_RSTATUS) & HA_SERROR) {
635 DBG(DBG_PROBE, printk("eata_dma: get_conf_PIO, error during " 642 DBG(DBG_PROBE, printk("eata_dma: get_conf_PIO, error during "
636 "transfer for HBA at %x\n", base)); 643 "transfer for HBA at %lx\n", base));
637 goto fail; 644 goto fail;
638 } 645 }
639 646
640 if (htonl(EATA_SIGNATURE) != buf->signature) 647 if (cpu_to_be32(EATA_SIGNATURE) != buf->signature)
641 goto fail; 648 goto fail;
642 649
643 DBG(DBG_PIO && DBG_PROBE, printk(KERN_NOTICE "EATA Controller found " 650 DBG(DBG_PIO && DBG_PROBE, printk(KERN_NOTICE "EATA Controller found "
644 "at %#4x EATA Level: %x\n", 651 "at %#4lx EATA Level: %x\n",
645 base, (uint) (buf->version))); 652 base, (unsigned int) (buf->version)));
646 653
647 while (inb(base + HA_RSTATUS) & HA_SDRQ) 654 while (inb(base + HA_RSTATUS) & HA_SDRQ)
648 inw(base + HA_RDATA); 655 inw(base + HA_RDATA);
@@ -665,12 +672,12 @@ static int get_pio_conf_PIO(u32 base, struct get_conf *buf)
665static void print_pio_config(struct get_conf *gc) 672static void print_pio_config(struct get_conf *gc)
666{ 673{
667 printk("Please check values: (read config data)\n"); 674 printk("Please check values: (read config data)\n");
668 printk("LEN: %d ver:%d OCS:%d TAR:%d TRNXFR:%d MORES:%d\n", (uint) ntohl(gc->len), gc->version, gc->OCS_enabled, gc->TAR_support, gc->TRNXFR, gc->MORE_support); 675 printk("LEN: %d ver:%d OCS:%d TAR:%d TRNXFR:%d MORES:%d\n", be32_to_cpu(gc->len), gc->version, gc->OCS_enabled, gc->TAR_support, gc->TRNXFR, gc->MORE_support);
669 printk("HAAV:%d SCSIID0:%d ID1:%d ID2:%d QUEUE:%d SG:%d SEC:%d\n", gc->HAA_valid, gc->scsi_id[3], gc->scsi_id[2], gc->scsi_id[1], ntohs(gc->queuesiz), ntohs(gc->SGsiz), gc->SECOND); 676 printk("HAAV:%d SCSIID0:%d ID1:%d ID2:%d QUEUE:%d SG:%d SEC:%d\n", gc->HAA_valid, gc->scsi_id[3], gc->scsi_id[2], gc->scsi_id[1], be16_to_cpu(gc->queuesiz), be16_to_cpu(gc->SGsiz), gc->SECOND);
670 printk("IRQ:%d IRQT:%d FORCADR:%d MCH:%d RIDQ:%d\n", gc->IRQ, gc->IRQ_TR, gc->FORCADR, gc->MAX_CHAN, gc->ID_qest); 677 printk("IRQ:%d IRQT:%d FORCADR:%d MCH:%d RIDQ:%d\n", gc->IRQ, gc->IRQ_TR, gc->FORCADR, gc->MAX_CHAN, gc->ID_qest);
671} 678}
672 679
673static uint print_selftest(uint base) 680static unsigned int print_selftest(unsigned int base)
674{ 681{
675 unsigned char buffer[512]; 682 unsigned char buffer[512];
676#ifdef VERBOSE_SETUP 683#ifdef VERBOSE_SETUP
@@ -697,7 +704,7 @@ static uint print_selftest(uint base)
697 return (!(inb(base + HA_RSTATUS) & HA_SERROR)); 704 return (!(inb(base + HA_RSTATUS) & HA_SERROR));
698} 705}
699 706
700static int register_pio_HBA(long base, struct get_conf *gc) 707static int register_pio_HBA(long base, struct get_conf *gc, struct pci_dev *pdev)
701{ 708{
702 unsigned long size = 0; 709 unsigned long size = 0;
703 char *buff; 710 char *buff;
@@ -714,17 +721,17 @@ static int register_pio_HBA(long base, struct get_conf *gc)
714 return 0; 721 return 0;
715 } 722 }
716 723
717 if ((buff = get_pio_board_data((uint) base, gc->IRQ, gc->scsi_id[3], cplen = (htonl(gc->cplen) + 1) / 2, cppadlen = (htons(gc->cppadlen) + 1) / 2)) == NULL) { 724 if ((buff = get_pio_board_data(base, gc->IRQ, gc->scsi_id[3], cplen = (cpu_to_be32(gc->cplen) + 1) / 2, cppadlen = (cpu_to_be16(gc->cppadlen) + 1) / 2)) == NULL) {
718 printk("HBA at %#lx didn't react on INQUIRY. Sorry.\n", (unsigned long) base); 725 printk("HBA at %#lx didn't react on INQUIRY. Sorry.\n", base);
719 return 0; 726 return 0;
720 } 727 }
721 728
722 if (!print_selftest(base) && !ALLOW_DMA_BOARDS) { 729 if (!print_selftest(base) && !ALLOW_DMA_BOARDS) {
723 printk("HBA at %#lx failed while performing self test & setup.\n", (unsigned long) base); 730 printk("HBA at %#lx failed while performing self test & setup.\n", base);
724 return 0; 731 return 0;
725 } 732 }
726 733
727 size = sizeof(hostdata) + (sizeof(struct eata_ccb) * ntohs(gc->queuesiz)); 734 size = sizeof(hostdata) + (sizeof(struct eata_ccb) * be16_to_cpu(gc->queuesiz));
728 735
729 sh = scsi_register(&driver_template, size); 736 sh = scsi_register(&driver_template, size);
730 if (sh == NULL) 737 if (sh == NULL)
@@ -749,8 +756,8 @@ static int register_pio_HBA(long base, struct get_conf *gc)
749 756
750 hd = SD(sh); 757 hd = SD(sh);
751 758
752 memset(hd->ccb, 0, (sizeof(struct eata_ccb) * ntohs(gc->queuesiz))); 759 memset(hd->ccb, 0, (sizeof(struct eata_ccb) * be16_to_cpu(gc->queuesiz)));
753 memset(hd->reads, 0, sizeof(unsigned long) * 26); 760 memset(hd->reads, 0, sizeof(hd->reads));
754 761
755 strlcpy(SD(sh)->vendor, &buff[8], sizeof(SD(sh)->vendor)); 762 strlcpy(SD(sh)->vendor, &buff[8], sizeof(SD(sh)->vendor));
756 strlcpy(SD(sh)->name, &buff[16], sizeof(SD(sh)->name)); 763 strlcpy(SD(sh)->name, &buff[16], sizeof(SD(sh)->name));
@@ -761,7 +768,7 @@ static int register_pio_HBA(long base, struct get_conf *gc)
761 SD(sh)->revision[4] = buff[35]; 768 SD(sh)->revision[4] = buff[35];
762 SD(sh)->revision[5] = 0; 769 SD(sh)->revision[5] = 0;
763 770
764 switch (ntohl(gc->len)) { 771 switch (be32_to_cpu(gc->len)) {
765 case 0x1c: 772 case 0x1c:
766 SD(sh)->EATA_revision = 'a'; 773 SD(sh)->EATA_revision = 'a';
767 break; 774 break;
@@ -777,7 +784,7 @@ static int register_pio_HBA(long base, struct get_conf *gc)
777 SD(sh)->EATA_revision = '?'; 784 SD(sh)->EATA_revision = '?';
778 } 785 }
779 786
780 if (ntohl(gc->len) >= 0x22) { 787 if (be32_to_cpu(gc->len) >= 0x22) {
781 if (gc->is_PCI) 788 if (gc->is_PCI)
782 hd->bustype = IS_PCI; 789 hd->bustype = IS_PCI;
783 else if (gc->is_EISA) 790 else if (gc->is_EISA)
@@ -811,6 +818,8 @@ static int register_pio_HBA(long base, struct get_conf *gc)
811 818
812 hd->channel = 0; 819 hd->channel = 0;
813 820
821 hd->pdev = pci_dev_get(pdev); /* Keep a PCI reference */
822
814 sh->max_id = 8; 823 sh->max_id = 8;
815 sh->max_lun = 8; 824 sh->max_lun = 8;
816 825
@@ -841,7 +850,7 @@ static void find_pio_ISA(struct get_conf *buf)
841 continue; 850 continue;
842 if (!get_pio_conf_PIO(ISAbases[i], buf)) 851 if (!get_pio_conf_PIO(ISAbases[i], buf))
843 continue; 852 continue;
844 if (!register_pio_HBA(ISAbases[i], buf)) 853 if (!register_pio_HBA(ISAbases[i], buf, NULL))
845 release_region(ISAbases[i], 9); 854 release_region(ISAbases[i], 9);
846 else 855 else
847 ISAbases[i] = 0; 856 ISAbases[i] = 0;
@@ -873,7 +882,7 @@ static void find_pio_EISA(struct get_conf *buf)
873 if (get_pio_conf_PIO(base, buf)) { 882 if (get_pio_conf_PIO(base, buf)) {
874 DBG(DBG_PROBE && DBG_EISA, print_pio_config(buf)); 883 DBG(DBG_PROBE && DBG_EISA, print_pio_config(buf));
875 if (buf->IRQ) { 884 if (buf->IRQ) {
876 if (!register_pio_HBA(base, buf)) 885 if (!register_pio_HBA(base, buf, NULL))
877 release_region(base, 9); 886 release_region(base, 9);
878 } else { 887 } else {
879 printk(KERN_NOTICE "eata_dma: No valid IRQ. HBA " "removed from list\n"); 888 printk(KERN_NOTICE "eata_dma: No valid IRQ. HBA " "removed from list\n");
@@ -896,9 +905,9 @@ static void find_pio_PCI(struct get_conf *buf)
896 printk("eata_dma: kernel PCI support not enabled. Skipping scan for PCI HBAs.\n"); 905 printk("eata_dma: kernel PCI support not enabled. Skipping scan for PCI HBAs.\n");
897#else 906#else
898 struct pci_dev *dev = NULL; 907 struct pci_dev *dev = NULL;
899 u32 base, x; 908 unsigned long base, x;
900 909
901 while ((dev = pci_find_device(PCI_VENDOR_ID_DPT, PCI_DEVICE_ID_DPT, dev)) != NULL) { 910 while ((dev = pci_get_device(PCI_VENDOR_ID_DPT, PCI_DEVICE_ID_DPT, dev)) != NULL) {
902 DBG(DBG_PROBE && DBG_PCI, printk("eata_pio: find_PCI, HBA at %s\n", pci_name(dev))); 911 DBG(DBG_PROBE && DBG_PCI, printk("eata_pio: find_PCI, HBA at %s\n", pci_name(dev)));
903 if (pci_enable_device(dev)) 912 if (pci_enable_device(dev))
904 continue; 913 continue;
@@ -926,7 +935,7 @@ static void find_pio_PCI(struct get_conf *buf)
926 * eventually remove it from the EISA and ISA list 935 * eventually remove it from the EISA and ISA list
927 */ 936 */
928 937
929 if (!register_pio_HBA(base, buf)) { 938 if (!register_pio_HBA(base, buf, dev)) {
930 release_region(base, 9); 939 release_region(base, 9);
931 continue; 940 continue;
932 } 941 }
@@ -976,12 +985,12 @@ static int eata_pio_detect(struct scsi_host_template *tpnt)
976 printk("Registered HBAs:\n"); 985 printk("Registered HBAs:\n");
977 printk("HBA no. Boardtype: Revis: EATA: Bus: BaseIO: IRQ: Ch: ID: Pr:" " QS: SG: CPL:\n"); 986 printk("HBA no. Boardtype: Revis: EATA: Bus: BaseIO: IRQ: Ch: ID: Pr:" " QS: SG: CPL:\n");
978 for (i = 1; i <= registered_HBAs; i++) { 987 for (i = 1; i <= registered_HBAs; i++) {
979 printk("scsi%-2d: %.10s v%s 2.0%c %s %#.4x %2d %d %d %c" 988 printk("scsi%-2d: %.10s v%s 2.0%c %s %#.4lx %2d %d %d %c"
980 " %2d %2d %2d\n", 989 " %2d %2d %2d\n",
981 HBA_ptr->host_no, SD(HBA_ptr)->name, SD(HBA_ptr)->revision, 990 HBA_ptr->host_no, SD(HBA_ptr)->name, SD(HBA_ptr)->revision,
982 SD(HBA_ptr)->EATA_revision, (SD(HBA_ptr)->bustype == 'P') ? 991 SD(HBA_ptr)->EATA_revision, (SD(HBA_ptr)->bustype == 'P') ?
983 "PCI " : (SD(HBA_ptr)->bustype == 'E') ? "EISA" : "ISA ", 992 "PCI " : (SD(HBA_ptr)->bustype == 'E') ? "EISA" : "ISA ",
984 (uint) HBA_ptr->base, HBA_ptr->irq, SD(HBA_ptr)->channel, HBA_ptr->this_id, 993 HBA_ptr->base, HBA_ptr->irq, SD(HBA_ptr)->channel, HBA_ptr->this_id,
985 SD(HBA_ptr)->primary ? 'Y' : 'N', HBA_ptr->can_queue, 994 SD(HBA_ptr)->primary ? 'Y' : 'N', HBA_ptr->can_queue,
986 HBA_ptr->sg_tablesize, HBA_ptr->cmd_per_lun); 995 HBA_ptr->sg_tablesize, HBA_ptr->cmd_per_lun);
987 HBA_ptr = SD(HBA_ptr)->next; 996 HBA_ptr = SD(HBA_ptr)->next;