diff options
author | Ondrej Zary <linux@rainbow-software.org> | 2015-02-06 17:11:49 -0500 |
---|---|---|
committer | James Bottomley <JBottomley@Odin.com> | 2015-04-09 21:08:49 -0400 |
commit | 68ea9de3a6256195ab4d92fa7d0edf6ed657a500 (patch) | |
tree | b202e3a9b73acad5a418dc23b0142544cdca9219 | |
parent | 954a9fd79b165c14e136e8f90e822ba3d186f6b1 (diff) |
aha1542: Pass struct Scsi_Host * to functions
Pass struct Scsi_Host * to functions instead of base address.
This reduces the number of parameters and is also required for printk
conversion.
Signed-off-by: Ondrej Zary <linux@rainbow-software.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: James Bottomley <JBottomley@Odin.com>
-rw-r--r-- | drivers/scsi/aha1542.c | 125 |
1 files changed, 63 insertions, 62 deletions
diff --git a/drivers/scsi/aha1542.c b/drivers/scsi/aha1542.c index 16cb6f9d8307..12b90a2325c8 100644 --- a/drivers/scsi/aha1542.c +++ b/drivers/scsi/aha1542.c | |||
@@ -217,53 +217,53 @@ static int makecode(unsigned hosterr, unsigned scsierr) | |||
217 | return scsierr | (hosterr << 16); | 217 | return scsierr | (hosterr << 16); |
218 | } | 218 | } |
219 | 219 | ||
220 | static int aha1542_test_port(int bse, struct Scsi_Host *sh) | 220 | static int aha1542_test_port(struct Scsi_Host *sh) |
221 | { | 221 | { |
222 | u8 inquiry_result[4]; | 222 | u8 inquiry_result[4]; |
223 | int i; | 223 | int i; |
224 | 224 | ||
225 | /* Quick and dirty test for presence of the card. */ | 225 | /* Quick and dirty test for presence of the card. */ |
226 | if (inb(STATUS(bse)) == 0xff) | 226 | if (inb(STATUS(sh->io_port)) == 0xff) |
227 | return 0; | 227 | return 0; |
228 | 228 | ||
229 | /* Reset the adapter. I ought to make a hard reset, but it's not really necessary */ | 229 | /* Reset the adapter. I ought to make a hard reset, but it's not really necessary */ |
230 | 230 | ||
231 | /* In case some other card was probing here, reset interrupts */ | 231 | /* In case some other card was probing here, reset interrupts */ |
232 | aha1542_intr_reset(bse); /* reset interrupts, so they don't block */ | 232 | aha1542_intr_reset(sh->io_port); /* reset interrupts, so they don't block */ |
233 | 233 | ||
234 | outb(SRST | IRST /*|SCRST */ , CONTROL(bse)); | 234 | outb(SRST | IRST /*|SCRST */ , CONTROL(sh->io_port)); |
235 | 235 | ||
236 | mdelay(20); /* Wait a little bit for things to settle down. */ | 236 | mdelay(20); /* Wait a little bit for things to settle down. */ |
237 | 237 | ||
238 | /* Expect INIT and IDLE, any of the others are bad */ | 238 | /* Expect INIT and IDLE, any of the others are bad */ |
239 | if (!wait_mask(STATUS(bse), STATMASK, INIT | IDLE, STST | DIAGF | INVDCMD | DF | CDF, 0)) | 239 | if (!wait_mask(STATUS(sh->io_port), STATMASK, INIT | IDLE, STST | DIAGF | INVDCMD | DF | CDF, 0)) |
240 | return 0; | 240 | return 0; |
241 | 241 | ||
242 | /* Shouldn't have generated any interrupts during reset */ | 242 | /* Shouldn't have generated any interrupts during reset */ |
243 | if (inb(INTRFLAGS(bse)) & INTRMASK) | 243 | if (inb(INTRFLAGS(sh->io_port)) & INTRMASK) |
244 | return 0; | 244 | return 0; |
245 | 245 | ||
246 | /* Perform a host adapter inquiry instead so we do not need to set | 246 | /* Perform a host adapter inquiry instead so we do not need to set |
247 | up the mailboxes ahead of time */ | 247 | up the mailboxes ahead of time */ |
248 | 248 | ||
249 | aha1542_outb(bse, CMD_INQUIRY); | 249 | aha1542_outb(sh->io_port, CMD_INQUIRY); |
250 | 250 | ||
251 | for (i = 0; i < 4; i++) { | 251 | for (i = 0; i < 4; i++) { |
252 | if (!wait_mask(STATUS(bse), DF, DF, 0, 0)) | 252 | if (!wait_mask(STATUS(sh->io_port), DF, DF, 0, 0)) |
253 | return 0; | 253 | return 0; |
254 | inquiry_result[i] = inb(DATA(bse)); | 254 | inquiry_result[i] = inb(DATA(sh->io_port)); |
255 | } | 255 | } |
256 | 256 | ||
257 | /* Reading port should reset DF */ | 257 | /* Reading port should reset DF */ |
258 | if (inb(STATUS(bse)) & DF) | 258 | if (inb(STATUS(sh->io_port)) & DF) |
259 | return 0; | 259 | return 0; |
260 | 260 | ||
261 | /* When HACC, command is completed, and we're though testing */ | 261 | /* When HACC, command is completed, and we're though testing */ |
262 | if (!wait_mask(INTRFLAGS(bse), HACC, HACC, 0, 0)) | 262 | if (!wait_mask(INTRFLAGS(sh->io_port), HACC, HACC, 0, 0)) |
263 | return 0; | 263 | return 0; |
264 | 264 | ||
265 | /* Clear interrupts */ | 265 | /* Clear interrupts */ |
266 | outb(IRST, CONTROL(bse)); | 266 | outb(IRST, CONTROL(sh->io_port)); |
267 | 267 | ||
268 | return 1; | 268 | return 1; |
269 | } | 269 | } |
@@ -581,7 +581,7 @@ static int aha1542_queuecommand_lck(struct scsi_cmnd *cmd, void (*done) (struct | |||
581 | static DEF_SCSI_QCMD(aha1542_queuecommand) | 581 | static DEF_SCSI_QCMD(aha1542_queuecommand) |
582 | 582 | ||
583 | /* Initialize mailboxes */ | 583 | /* Initialize mailboxes */ |
584 | static void setup_mailboxes(int bse, struct Scsi_Host *sh) | 584 | static void setup_mailboxes(struct Scsi_Host *sh) |
585 | { | 585 | { |
586 | struct aha1542_hostdata *aha1542 = shost_priv(sh); | 586 | struct aha1542_hostdata *aha1542 = shost_priv(sh); |
587 | int i; | 587 | int i; |
@@ -594,43 +594,43 @@ static void setup_mailboxes(int bse, struct Scsi_Host *sh) | |||
594 | mb[i].status = mb[AHA1542_MAILBOXES + i].status = 0; | 594 | mb[i].status = mb[AHA1542_MAILBOXES + i].status = 0; |
595 | any2scsi(mb[i].ccbptr, isa_virt_to_bus(&ccb[i])); | 595 | any2scsi(mb[i].ccbptr, isa_virt_to_bus(&ccb[i])); |
596 | }; | 596 | }; |
597 | aha1542_intr_reset(bse); /* reset interrupts, so they don't block */ | 597 | aha1542_intr_reset(sh->io_port); /* reset interrupts, so they don't block */ |
598 | any2scsi((mb_cmd + 2), isa_virt_to_bus(mb)); | 598 | any2scsi((mb_cmd + 2), isa_virt_to_bus(mb)); |
599 | if (aha1542_out(bse, mb_cmd, 5)) | 599 | if (aha1542_out(sh->io_port, mb_cmd, 5)) |
600 | printk(KERN_ERR "aha1542_detect: failed setting up mailboxes\n"); | 600 | printk(KERN_ERR "aha1542_detect: failed setting up mailboxes\n"); |
601 | aha1542_intr_reset(bse); | 601 | aha1542_intr_reset(sh->io_port); |
602 | } | 602 | } |
603 | 603 | ||
604 | static int aha1542_getconfig(int base_io, unsigned int *irq_level, unsigned char *dma_chan, unsigned int *scsi_id) | 604 | static int aha1542_getconfig(struct Scsi_Host *sh) |
605 | { | 605 | { |
606 | u8 inquiry_result[3]; | 606 | u8 inquiry_result[3]; |
607 | int i; | 607 | int i; |
608 | i = inb(STATUS(base_io)); | 608 | i = inb(STATUS(sh->io_port)); |
609 | if (i & DF) { | 609 | if (i & DF) { |
610 | i = inb(DATA(base_io)); | 610 | i = inb(DATA(sh->io_port)); |
611 | }; | 611 | }; |
612 | aha1542_outb(base_io, CMD_RETCONF); | 612 | aha1542_outb(sh->io_port, CMD_RETCONF); |
613 | aha1542_in(base_io, inquiry_result, 3, 0); | 613 | aha1542_in(sh->io_port, inquiry_result, 3, 0); |
614 | if (!wait_mask(INTRFLAGS(base_io), INTRMASK, HACC, 0, 0)) | 614 | if (!wait_mask(INTRFLAGS(sh->io_port), INTRMASK, HACC, 0, 0)) |
615 | printk(KERN_ERR "aha1542_detect: query board settings\n"); | 615 | printk(KERN_ERR "aha1542_detect: query board settings\n"); |
616 | aha1542_intr_reset(base_io); | 616 | aha1542_intr_reset(sh->io_port); |
617 | switch (inquiry_result[0]) { | 617 | switch (inquiry_result[0]) { |
618 | case 0x80: | 618 | case 0x80: |
619 | *dma_chan = 7; | 619 | sh->dma_channel = 7; |
620 | break; | 620 | break; |
621 | case 0x40: | 621 | case 0x40: |
622 | *dma_chan = 6; | 622 | sh->dma_channel = 6; |
623 | break; | 623 | break; |
624 | case 0x20: | 624 | case 0x20: |
625 | *dma_chan = 5; | 625 | sh->dma_channel = 5; |
626 | break; | 626 | break; |
627 | case 0x01: | 627 | case 0x01: |
628 | *dma_chan = 0; | 628 | sh->dma_channel = 0; |
629 | break; | 629 | break; |
630 | case 0: | 630 | case 0: |
631 | /* This means that the adapter, although Adaptec 1542 compatible, doesn't use a DMA channel. | 631 | /* This means that the adapter, although Adaptec 1542 compatible, doesn't use a DMA channel. |
632 | Currently only aware of the BusLogic BT-445S VL-Bus adapter which needs this. */ | 632 | Currently only aware of the BusLogic BT-445S VL-Bus adapter which needs this. */ |
633 | *dma_chan = 0xFF; | 633 | sh->dma_channel = 0xFF; |
634 | break; | 634 | break; |
635 | default: | 635 | default: |
636 | printk(KERN_ERR "Unable to determine Adaptec DMA priority. Disabling board\n"); | 636 | printk(KERN_ERR "Unable to determine Adaptec DMA priority. Disabling board\n"); |
@@ -638,35 +638,35 @@ static int aha1542_getconfig(int base_io, unsigned int *irq_level, unsigned char | |||
638 | }; | 638 | }; |
639 | switch (inquiry_result[1]) { | 639 | switch (inquiry_result[1]) { |
640 | case 0x40: | 640 | case 0x40: |
641 | *irq_level = 15; | 641 | sh->irq = 15; |
642 | break; | 642 | break; |
643 | case 0x20: | 643 | case 0x20: |
644 | *irq_level = 14; | 644 | sh->irq = 14; |
645 | break; | 645 | break; |
646 | case 0x8: | 646 | case 0x8: |
647 | *irq_level = 12; | 647 | sh->irq = 12; |
648 | break; | 648 | break; |
649 | case 0x4: | 649 | case 0x4: |
650 | *irq_level = 11; | 650 | sh->irq = 11; |
651 | break; | 651 | break; |
652 | case 0x2: | 652 | case 0x2: |
653 | *irq_level = 10; | 653 | sh->irq = 10; |
654 | break; | 654 | break; |
655 | case 0x1: | 655 | case 0x1: |
656 | *irq_level = 9; | 656 | sh->irq = 9; |
657 | break; | 657 | break; |
658 | default: | 658 | default: |
659 | printk(KERN_ERR "Unable to determine Adaptec IRQ level. Disabling board\n"); | 659 | printk(KERN_ERR "Unable to determine Adaptec IRQ level. Disabling board\n"); |
660 | return -1; | 660 | return -1; |
661 | }; | 661 | }; |
662 | *scsi_id = inquiry_result[2] & 7; | 662 | sh->this_id = inquiry_result[2] & 7; |
663 | return 0; | 663 | return 0; |
664 | } | 664 | } |
665 | 665 | ||
666 | /* This function should only be called for 1542C boards - we can detect | 666 | /* This function should only be called for 1542C boards - we can detect |
667 | the special firmware settings and unlock the board */ | 667 | the special firmware settings and unlock the board */ |
668 | 668 | ||
669 | static int aha1542_mbenable(int base) | 669 | static int aha1542_mbenable(struct Scsi_Host *sh) |
670 | { | 670 | { |
671 | static u8 mbenable_cmd[3]; | 671 | static u8 mbenable_cmd[3]; |
672 | static u8 mbenable_result[2]; | 672 | static u8 mbenable_result[2]; |
@@ -674,12 +674,12 @@ static int aha1542_mbenable(int base) | |||
674 | 674 | ||
675 | retval = BIOS_TRANSLATION_6432; | 675 | retval = BIOS_TRANSLATION_6432; |
676 | 676 | ||
677 | aha1542_outb(base, CMD_EXTBIOS); | 677 | aha1542_outb(sh->io_port, CMD_EXTBIOS); |
678 | if (aha1542_in(base, mbenable_result, 2, 100)) | 678 | if (aha1542_in(sh->io_port, mbenable_result, 2, 100)) |
679 | return retval; | 679 | return retval; |
680 | if (!wait_mask(INTRFLAGS(base), INTRMASK, HACC, 0, 100)) | 680 | if (!wait_mask(INTRFLAGS(sh->io_port), INTRMASK, HACC, 0, 100)) |
681 | goto fail; | 681 | goto fail; |
682 | aha1542_intr_reset(base); | 682 | aha1542_intr_reset(sh->io_port); |
683 | 683 | ||
684 | if ((mbenable_result[0] & 0x08) || mbenable_result[1]) { | 684 | if ((mbenable_result[0] & 0x08) || mbenable_result[1]) { |
685 | mbenable_cmd[0] = CMD_MBENABLE; | 685 | mbenable_cmd[0] = CMD_MBENABLE; |
@@ -689,33 +689,34 @@ static int aha1542_mbenable(int base) | |||
689 | if ((mbenable_result[0] & 0x08) && (mbenable_result[1] & 0x03)) | 689 | if ((mbenable_result[0] & 0x08) && (mbenable_result[1] & 0x03)) |
690 | retval = BIOS_TRANSLATION_25563; | 690 | retval = BIOS_TRANSLATION_25563; |
691 | 691 | ||
692 | if (aha1542_out(base, mbenable_cmd, 3)) | 692 | if (aha1542_out(sh->io_port, mbenable_cmd, 3)) |
693 | goto fail; | 693 | goto fail; |
694 | }; | 694 | }; |
695 | while (0) { | 695 | while (0) { |
696 | fail: | 696 | fail: |
697 | printk(KERN_ERR "aha1542_mbenable: Mailbox init failed\n"); | 697 | printk(KERN_ERR "aha1542_mbenable: Mailbox init failed\n"); |
698 | } | 698 | } |
699 | aha1542_intr_reset(base); | 699 | aha1542_intr_reset(sh->io_port); |
700 | return retval; | 700 | return retval; |
701 | } | 701 | } |
702 | 702 | ||
703 | /* Query the board to find out if it is a 1542 or a 1740, or whatever. */ | 703 | /* Query the board to find out if it is a 1542 or a 1740, or whatever. */ |
704 | static int aha1542_query(int base_io, int *transl) | 704 | static int aha1542_query(struct Scsi_Host *sh) |
705 | { | 705 | { |
706 | struct aha1542_hostdata *aha1542 = shost_priv(sh); | ||
706 | u8 inquiry_result[4]; | 707 | u8 inquiry_result[4]; |
707 | int i; | 708 | int i; |
708 | i = inb(STATUS(base_io)); | 709 | i = inb(STATUS(sh->io_port)); |
709 | if (i & DF) { | 710 | if (i & DF) { |
710 | i = inb(DATA(base_io)); | 711 | i = inb(DATA(sh->io_port)); |
711 | }; | 712 | }; |
712 | aha1542_outb(base_io, CMD_INQUIRY); | 713 | aha1542_outb(sh->io_port, CMD_INQUIRY); |
713 | aha1542_in(base_io, inquiry_result, 4, 0); | 714 | aha1542_in(sh->io_port, inquiry_result, 4, 0); |
714 | if (!wait_mask(INTRFLAGS(base_io), INTRMASK, HACC, 0, 0)) | 715 | if (!wait_mask(INTRFLAGS(sh->io_port), INTRMASK, HACC, 0, 0)) |
715 | printk(KERN_ERR "aha1542_detect: query card type\n"); | 716 | printk(KERN_ERR "aha1542_detect: query card type\n"); |
716 | aha1542_intr_reset(base_io); | 717 | aha1542_intr_reset(sh->io_port); |
717 | 718 | ||
718 | *transl = BIOS_TRANSLATION_6432; /* Default case */ | 719 | aha1542->bios_translation = BIOS_TRANSLATION_6432; /* Default case */ |
719 | 720 | ||
720 | /* For an AHA1740 series board, we ignore the board since there is a | 721 | /* For an AHA1740 series board, we ignore the board since there is a |
721 | hardware bug which can lead to wrong blocks being returned if the board | 722 | hardware bug which can lead to wrong blocks being returned if the board |
@@ -731,7 +732,7 @@ static int aha1542_query(int base_io, int *transl) | |||
731 | /* Always call this - boards that do not support extended bios translation | 732 | /* Always call this - boards that do not support extended bios translation |
732 | will ignore the command, and we will set the proper default */ | 733 | will ignore the command, and we will set the proper default */ |
733 | 734 | ||
734 | *transl = aha1542_mbenable(base_io); | 735 | aha1542->bios_translation = aha1542_mbenable(sh); |
735 | 736 | ||
736 | return 0; | 737 | return 0; |
737 | } | 738 | } |
@@ -807,13 +808,19 @@ static struct Scsi_Host *aha1542_hw_init(struct scsi_host_template *tpnt, struct | |||
807 | goto release; | 808 | goto release; |
808 | aha1542 = shost_priv(sh); | 809 | aha1542 = shost_priv(sh); |
809 | 810 | ||
810 | if (!aha1542_test_port(base_io, sh)) | 811 | sh->unique_id = base_io; |
812 | sh->io_port = base_io; | ||
813 | sh->n_io_port = AHA1542_REGION_SIZE; | ||
814 | aha1542->aha1542_last_mbi_used = 2 * AHA1542_MAILBOXES - 1; | ||
815 | aha1542->aha1542_last_mbo_used = AHA1542_MAILBOXES - 1; | ||
816 | |||
817 | if (!aha1542_test_port(sh)) | ||
811 | goto unregister; | 818 | goto unregister; |
812 | 819 | ||
813 | aha1542_set_bus_times(indx); | 820 | aha1542_set_bus_times(indx); |
814 | if (aha1542_query(base_io, &aha1542->bios_translation)) | 821 | if (aha1542_query(sh)) |
815 | goto unregister; | 822 | goto unregister; |
816 | if (aha1542_getconfig(base_io, &sh->irq, &sh->dma_channel, &sh->this_id) == -1) | 823 | if (aha1542_getconfig(sh) == -1) |
817 | goto unregister; | 824 | goto unregister; |
818 | 825 | ||
819 | printk(KERN_INFO "Adaptec AHA-1542 (SCSI-ID %d) at IO 0x%x, IRQ %d", sh->this_id, base_io, sh->irq); | 826 | printk(KERN_INFO "Adaptec AHA-1542 (SCSI-ID %d) at IO 0x%x, IRQ %d", sh->this_id, base_io, sh->irq); |
@@ -823,7 +830,7 @@ static struct Scsi_Host *aha1542_hw_init(struct scsi_host_template *tpnt, struct | |||
823 | if (aha1542->bios_translation == BIOS_TRANSLATION_25563) | 830 | if (aha1542->bios_translation == BIOS_TRANSLATION_25563) |
824 | printk(KERN_INFO "aha1542.c: Using extended bios translation\n"); | 831 | printk(KERN_INFO "aha1542.c: Using extended bios translation\n"); |
825 | 832 | ||
826 | setup_mailboxes(base_io, sh); | 833 | setup_mailboxes(sh); |
827 | 834 | ||
828 | if (request_irq(sh->irq, do_aha1542_intr_handle, 0, | 835 | if (request_irq(sh->irq, do_aha1542_intr_handle, 0, |
829 | "aha1542", sh)) { | 836 | "aha1542", sh)) { |
@@ -841,12 +848,6 @@ static struct Scsi_Host *aha1542_hw_init(struct scsi_host_template *tpnt, struct | |||
841 | } | 848 | } |
842 | } | 849 | } |
843 | 850 | ||
844 | sh->unique_id = base_io; | ||
845 | sh->io_port = base_io; | ||
846 | sh->n_io_port = AHA1542_REGION_SIZE; | ||
847 | aha1542->aha1542_last_mbi_used = 2 * AHA1542_MAILBOXES - 1; | ||
848 | aha1542->aha1542_last_mbo_used = AHA1542_MAILBOXES - 1; | ||
849 | |||
850 | if (scsi_add_host(sh, pdev)) | 851 | if (scsi_add_host(sh, pdev)) |
851 | goto free_dma; | 852 | goto free_dma; |
852 | 853 | ||
@@ -973,7 +974,7 @@ static int aha1542_reset(struct scsi_cmnd *cmd, u8 reset_cmd) | |||
973 | * us again after host reset. | 974 | * us again after host reset. |
974 | */ | 975 | */ |
975 | if (reset_cmd & HRST) | 976 | if (reset_cmd & HRST) |
976 | setup_mailboxes(cmd->device->host->io_port, cmd->device->host); | 977 | setup_mailboxes(cmd->device->host); |
977 | /* | 978 | /* |
978 | * Now try to pick up the pieces. For all pending commands, | 979 | * Now try to pick up the pieces. For all pending commands, |
979 | * free any internal data structures, and basically clear things | 980 | * free any internal data structures, and basically clear things |