diff options
author | Dominik Brodowski <linux@dominikbrodowski.net> | 2009-10-18 12:22:32 -0400 |
---|---|---|
committer | Dominik Brodowski <linux@dominikbrodowski.net> | 2009-11-08 12:06:32 -0500 |
commit | 7d2e8d00b47b973c92db4df7444d5e6d3bb945f9 (patch) | |
tree | 22286fa095d0340245e83ca9c7695f42f65c141a /drivers/net | |
parent | 6ae3b84d979308671bf6f6a2123c258a8603d61c (diff) |
pcmcia: use pre-determined values
A few PCMCIA network drivers can make use of values provided by the pcmcia
core, instead of tedious, independent CIS parsing.
xirc32ps_cs.c: manf_id
hostap_cs.c: multifunction count
b43/pcmcia.c: ConfigBase address and "Present"
smc91c92_cs.c: By default, mhz_setup() can use VERS_1 as it is stored
in struct pcmcia_device. Only some cards require workarounds, such as
reading out VERS_1 twice.
CC: David S. Miller <davem@davemloft.net>
CC: netdev@vger.kernel.org
CC: linux-wireless@vger.kernel.org
Acked-by: John W. Linville <linville@tuxdriver.com>
Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
Diffstat (limited to 'drivers/net')
-rw-r--r-- | drivers/net/pcmcia/smc91c92_cs.c | 11 | ||||
-rw-r--r-- | drivers/net/pcmcia/xirc2ps_cs.c | 12 | ||||
-rw-r--r-- | drivers/net/wireless/b43/pcmcia.c | 20 | ||||
-rw-r--r-- | drivers/net/wireless/hostap/hostap_cs.c | 21 |
4 files changed, 19 insertions, 45 deletions
diff --git a/drivers/net/pcmcia/smc91c92_cs.c b/drivers/net/pcmcia/smc91c92_cs.c index 7bde2cd34c7e..af03759d186d 100644 --- a/drivers/net/pcmcia/smc91c92_cs.c +++ b/drivers/net/pcmcia/smc91c92_cs.c | |||
@@ -545,6 +545,14 @@ static int mhz_setup(struct pcmcia_device *link) | |||
545 | u_char *buf, *station_addr; | 545 | u_char *buf, *station_addr; |
546 | int rc; | 546 | int rc; |
547 | 547 | ||
548 | /* Read the station address from the CIS. It is stored as the last | ||
549 | (fourth) string in the Version 1 Version/ID tuple. */ | ||
550 | if ((link->prod_id[3]) && | ||
551 | (cvt_ascii_address(dev, link->prod_id[3]) == 0)) | ||
552 | return 0; | ||
553 | |||
554 | /* Workarounds for broken cards start here. */ | ||
555 | |||
548 | cfg_mem = kmalloc(sizeof(struct smc_cfg_mem), GFP_KERNEL); | 556 | cfg_mem = kmalloc(sizeof(struct smc_cfg_mem), GFP_KERNEL); |
549 | if (!cfg_mem) | 557 | if (!cfg_mem) |
550 | return -1; | 558 | return -1; |
@@ -557,8 +565,7 @@ static int mhz_setup(struct pcmcia_device *link) | |||
557 | tuple->TupleData = (cisdata_t *)buf; | 565 | tuple->TupleData = (cisdata_t *)buf; |
558 | tuple->TupleDataMax = 255; | 566 | tuple->TupleDataMax = 255; |
559 | 567 | ||
560 | /* Read the station address from the CIS. It is stored as the last | 568 | /* Ugh -- the EM1144 card has two VERS_1 tuples!?! */ |
561 | (fourth) string in the Version 1 Version/ID tuple. */ | ||
562 | tuple->DesiredTuple = CISTPL_VERS_1; | 569 | tuple->DesiredTuple = CISTPL_VERS_1; |
563 | if (first_tuple(link, tuple, parse) != 0) { | 570 | if (first_tuple(link, tuple, parse) != 0) { |
564 | rc = -1; | 571 | rc = -1; |
diff --git a/drivers/net/pcmcia/xirc2ps_cs.c b/drivers/net/pcmcia/xirc2ps_cs.c index cf8423102538..5e203230144f 100644 --- a/drivers/net/pcmcia/xirc2ps_cs.c +++ b/drivers/net/pcmcia/xirc2ps_cs.c | |||
@@ -792,13 +792,12 @@ xirc2ps_config(struct pcmcia_device * link) | |||
792 | tuple.TupleOffset = 0; | 792 | tuple.TupleOffset = 0; |
793 | 793 | ||
794 | /* Is this a valid card */ | 794 | /* Is this a valid card */ |
795 | tuple.DesiredTuple = CISTPL_MANFID; | 795 | if (link->has_manf_id == 0) { |
796 | if ((err=first_tuple(link, &tuple, &parse))) { | ||
797 | printk(KNOT_XIRC "manfid not found in CIS\n"); | 796 | printk(KNOT_XIRC "manfid not found in CIS\n"); |
798 | goto failure; | 797 | goto failure; |
799 | } | 798 | } |
800 | 799 | ||
801 | switch(parse.manfid.manf) { | 800 | switch (link->manf_id) { |
802 | case MANFID_XIRCOM: | 801 | case MANFID_XIRCOM: |
803 | local->manf_str = "Xircom"; | 802 | local->manf_str = "Xircom"; |
804 | break; | 803 | break; |
@@ -822,6 +821,13 @@ xirc2ps_config(struct pcmcia_device * link) | |||
822 | } | 821 | } |
823 | DEBUG(0, "found %s card\n", local->manf_str); | 822 | DEBUG(0, "found %s card\n", local->manf_str); |
824 | 823 | ||
824 | /* needed for the additional fields to be parsed by set_card_type() */ | ||
825 | tuple.DesiredTuple = CISTPL_MANFID; | ||
826 | err = first_tuple(link, &tuple, &parse) | ||
827 | if (err) { | ||
828 | printk(KNOT_XIRC "manfid not found in CIS\n"); | ||
829 | goto failure; | ||
830 | } | ||
825 | if (!set_card_type(link, buf)) { | 831 | if (!set_card_type(link, buf)) { |
826 | printk(KNOT_XIRC "this card is not supported\n"); | 832 | printk(KNOT_XIRC "this card is not supported\n"); |
827 | goto failure; | 833 | goto failure; |
diff --git a/drivers/net/wireless/b43/pcmcia.c b/drivers/net/wireless/b43/pcmcia.c index 6c3a74964ab8..cd14b7e8ba80 100644 --- a/drivers/net/wireless/b43/pcmcia.c +++ b/drivers/net/wireless/b43/pcmcia.c | |||
@@ -65,35 +65,15 @@ static int __devinit b43_pcmcia_probe(struct pcmcia_device *dev) | |||
65 | struct ssb_bus *ssb; | 65 | struct ssb_bus *ssb; |
66 | win_req_t win; | 66 | win_req_t win; |
67 | memreq_t mem; | 67 | memreq_t mem; |
68 | tuple_t tuple; | ||
69 | cisparse_t parse; | ||
70 | int err = -ENOMEM; | 68 | int err = -ENOMEM; |
71 | int res = 0; | 69 | int res = 0; |
72 | unsigned char buf[64]; | ||
73 | 70 | ||
74 | ssb = kzalloc(sizeof(*ssb), GFP_KERNEL); | 71 | ssb = kzalloc(sizeof(*ssb), GFP_KERNEL); |
75 | if (!ssb) | 72 | if (!ssb) |
76 | goto out_error; | 73 | goto out_error; |
77 | 74 | ||
78 | err = -ENODEV; | 75 | err = -ENODEV; |
79 | tuple.DesiredTuple = CISTPL_CONFIG; | ||
80 | tuple.Attributes = 0; | ||
81 | tuple.TupleData = buf; | ||
82 | tuple.TupleDataMax = sizeof(buf); | ||
83 | tuple.TupleOffset = 0; | ||
84 | 76 | ||
85 | res = pcmcia_get_first_tuple(dev, &tuple); | ||
86 | if (res != 0) | ||
87 | goto err_kfree_ssb; | ||
88 | res = pcmcia_get_tuple_data(dev, &tuple); | ||
89 | if (res != 0) | ||
90 | goto err_kfree_ssb; | ||
91 | res = pcmcia_parse_tuple(&tuple, &parse); | ||
92 | if (res != 0) | ||
93 | goto err_kfree_ssb; | ||
94 | |||
95 | dev->conf.ConfigBase = parse.config.base; | ||
96 | dev->conf.Present = parse.config.rmask[0]; | ||
97 | dev->conf.Attributes = CONF_ENABLE_IRQ; | 77 | dev->conf.Attributes = CONF_ENABLE_IRQ; |
98 | dev->conf.IntType = INT_MEMORY_AND_IO; | 78 | dev->conf.IntType = INT_MEMORY_AND_IO; |
99 | 79 | ||
diff --git a/drivers/net/wireless/hostap/hostap_cs.c b/drivers/net/wireless/hostap/hostap_cs.c index ad8eab4a639b..31b60dd87bfe 100644 --- a/drivers/net/wireless/hostap/hostap_cs.c +++ b/drivers/net/wireless/hostap/hostap_cs.c | |||
@@ -274,9 +274,6 @@ static int sandisk_enable_wireless(struct net_device *dev) | |||
274 | conf_reg_t reg; | 274 | conf_reg_t reg; |
275 | struct hostap_interface *iface = netdev_priv(dev); | 275 | struct hostap_interface *iface = netdev_priv(dev); |
276 | local_info_t *local = iface->local; | 276 | local_info_t *local = iface->local; |
277 | tuple_t tuple; | ||
278 | cisparse_t *parse = NULL; | ||
279 | u_char buf[64]; | ||
280 | struct hostap_cs_priv *hw_priv = local->hw_priv; | 277 | struct hostap_cs_priv *hw_priv = local->hw_priv; |
281 | 278 | ||
282 | if (hw_priv->link->io.NumPorts1 < 0x42) { | 279 | if (hw_priv->link->io.NumPorts1 < 0x42) { |
@@ -285,28 +282,13 @@ static int sandisk_enable_wireless(struct net_device *dev) | |||
285 | goto done; | 282 | goto done; |
286 | } | 283 | } |
287 | 284 | ||
288 | parse = kmalloc(sizeof(cisparse_t), GFP_KERNEL); | ||
289 | if (parse == NULL) { | ||
290 | ret = -ENOMEM; | ||
291 | goto done; | ||
292 | } | ||
293 | |||
294 | tuple.Attributes = TUPLE_RETURN_COMMON; | ||
295 | tuple.TupleData = buf; | ||
296 | tuple.TupleDataMax = sizeof(buf); | ||
297 | tuple.TupleOffset = 0; | ||
298 | |||
299 | if (hw_priv->link->manf_id != 0xd601 || hw_priv->link->card_id != 0x0101) { | 285 | if (hw_priv->link->manf_id != 0xd601 || hw_priv->link->card_id != 0x0101) { |
300 | /* No SanDisk manfid found */ | 286 | /* No SanDisk manfid found */ |
301 | ret = -ENODEV; | 287 | ret = -ENODEV; |
302 | goto done; | 288 | goto done; |
303 | } | 289 | } |
304 | 290 | ||
305 | tuple.DesiredTuple = CISTPL_LONGLINK_MFC; | 291 | if (hw_priv->link->socket->functions < 2) { |
306 | if (pcmcia_get_first_tuple(hw_priv->link, &tuple) || | ||
307 | pcmcia_get_tuple_data(hw_priv->link, &tuple) || | ||
308 | pcmcia_parse_tuple(&tuple, parse) || | ||
309 | parse->longlink_mfc.nfn < 2) { | ||
310 | /* No multi-function links found */ | 292 | /* No multi-function links found */ |
311 | ret = -ENODEV; | 293 | ret = -ENODEV; |
312 | goto done; | 294 | goto done; |
@@ -354,7 +336,6 @@ static int sandisk_enable_wireless(struct net_device *dev) | |||
354 | udelay(10); | 336 | udelay(10); |
355 | 337 | ||
356 | done: | 338 | done: |
357 | kfree(parse); | ||
358 | return ret; | 339 | return ret; |
359 | } | 340 | } |
360 | 341 | ||