diff options
author | Dominik Brodowski <linux@dominikbrodowski.net> | 2008-07-29 02:38:55 -0400 |
---|---|---|
committer | Dominik Brodowski <linux@dominikbrodowski.net> | 2008-08-22 19:21:23 -0400 |
commit | 0e6f9d2708409cd8e864cdb94edbe599872a19d1 (patch) | |
tree | 398f993c6a50996483e9b48285f4971fa72e6e4e /drivers/scsi/pcmcia/sym53c500_cs.c | |
parent | ed58872aa33e16a0d5352080e47c65fa14e6ad1c (diff) |
pcmcia: use pcmcia_loop_config in scsi pcmcia drivers
Use the config loop helper in scsi pcmcia drivers.
CC: James E.J. Bottomley <James.Bottomley@HansenPartnership.com>
CC: linux-scsi@vger.kernel.org
Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
Diffstat (limited to 'drivers/scsi/pcmcia/sym53c500_cs.c')
-rw-r--r-- | drivers/scsi/pcmcia/sym53c500_cs.c | 45 |
1 files changed, 20 insertions, 25 deletions
diff --git a/drivers/scsi/pcmcia/sym53c500_cs.c b/drivers/scsi/pcmcia/sym53c500_cs.c index 0be232b58ffb..15369d9e3121 100644 --- a/drivers/scsi/pcmcia/sym53c500_cs.c +++ b/drivers/scsi/pcmcia/sym53c500_cs.c | |||
@@ -700,15 +700,26 @@ static struct scsi_host_template sym53c500_driver_template = { | |||
700 | #define CS_CHECK(fn, ret) \ | 700 | #define CS_CHECK(fn, ret) \ |
701 | do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) | 701 | do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) |
702 | 702 | ||
703 | static int SYM53C500_config_check(struct pcmcia_device *p_dev, | ||
704 | cistpl_cftable_entry_t *cfg, | ||
705 | void *priv_data) | ||
706 | { | ||
707 | p_dev->conf.ConfigIndex = cfg->index; | ||
708 | p_dev->io.BasePort1 = cfg->io.win[0].base; | ||
709 | p_dev->io.NumPorts1 = cfg->io.win[0].len; | ||
710 | |||
711 | if (p_dev->io.BasePort1 == 0) | ||
712 | return -ENODEV; | ||
713 | |||
714 | return pcmcia_request_io(p_dev, &p_dev->io); | ||
715 | } | ||
716 | |||
703 | static int | 717 | static int |
704 | SYM53C500_config(struct pcmcia_device *link) | 718 | SYM53C500_config(struct pcmcia_device *link) |
705 | { | 719 | { |
706 | struct scsi_info_t *info = link->priv; | 720 | struct scsi_info_t *info = link->priv; |
707 | tuple_t tuple; | 721 | int last_ret, last_fn; |
708 | cisparse_t parse; | ||
709 | int i, last_ret, last_fn; | ||
710 | int irq_level, port_base; | 722 | int irq_level, port_base; |
711 | unsigned short tuple_data[32]; | ||
712 | struct Scsi_Host *host; | 723 | struct Scsi_Host *host; |
713 | struct scsi_host_template *tpnt = &sym53c500_driver_template; | 724 | struct scsi_host_template *tpnt = &sym53c500_driver_template; |
714 | struct sym53c500_data *data; | 725 | struct sym53c500_data *data; |
@@ -717,27 +728,10 @@ SYM53C500_config(struct pcmcia_device *link) | |||
717 | 728 | ||
718 | info->manf_id = link->manf_id; | 729 | info->manf_id = link->manf_id; |
719 | 730 | ||
720 | tuple.TupleData = (cisdata_t *)tuple_data; | 731 | last_ret = pcmcia_loop_config(link, SYM53C500_config_check, NULL); |
721 | tuple.TupleDataMax = 64; | 732 | if (last_ret) { |
722 | tuple.TupleOffset = 0; | 733 | cs_error(link, RequestIO, last_ret); |
723 | 734 | goto failed; | |
724 | tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; | ||
725 | CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); | ||
726 | while (1) { | ||
727 | if (pcmcia_get_tuple_data(link, &tuple) != 0 || | ||
728 | pcmcia_parse_tuple(link, &tuple, &parse) != 0) | ||
729 | goto next_entry; | ||
730 | link->conf.ConfigIndex = parse.cftable_entry.index; | ||
731 | link->io.BasePort1 = parse.cftable_entry.io.win[0].base; | ||
732 | link->io.NumPorts1 = parse.cftable_entry.io.win[0].len; | ||
733 | |||
734 | if (link->io.BasePort1 != 0) { | ||
735 | i = pcmcia_request_io(link, &link->io); | ||
736 | if (i == CS_SUCCESS) | ||
737 | break; | ||
738 | } | ||
739 | next_entry: | ||
740 | CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(link, &tuple)); | ||
741 | } | 735 | } |
742 | 736 | ||
743 | CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); | 737 | CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); |
@@ -831,6 +825,7 @@ err_release: | |||
831 | 825 | ||
832 | cs_failed: | 826 | cs_failed: |
833 | cs_error(link, last_fn, last_ret); | 827 | cs_error(link, last_fn, last_ret); |
828 | failed: | ||
834 | SYM53C500_release(link); | 829 | SYM53C500_release(link); |
835 | return -ENODEV; | 830 | return -ENODEV; |
836 | } /* SYM53C500_config */ | 831 | } /* SYM53C500_config */ |