diff options
author | Christian Lamparter <chunkeey@web.de> | 2008-09-01 16:48:51 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2008-09-05 16:17:48 -0400 |
commit | 7cb770729ba895f73253dfcd46c3fcba45d896f9 (patch) | |
tree | 8a970a683779490b478b9737154cb5d2e792c0a5 /drivers/net/wireless/p54/p54usb.c | |
parent | 4e416a6f49b710bfe162f0cb24bc68c74493d2a0 (diff) |
p54: move eeprom code into common library
Both p54pci and p54usb uses a good chunk of device specific code to
get the data from the device's eeprom into the drivers memory.
So, this patch reduces the code size and will it make life easier if
someone wants to implement ethtool eeprom dumping features.
Signed-off-by: Christian Lamparter <chunkeey@web.de>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/p54/p54usb.c')
-rw-r--r-- | drivers/net/wireless/p54/p54usb.c | 88 |
1 files changed, 5 insertions, 83 deletions
diff --git a/drivers/net/wireless/p54/p54usb.c b/drivers/net/wireless/p54/p54usb.c index 4dca209a6e07..eca858c40b1f 100644 --- a/drivers/net/wireless/p54/p54usb.c +++ b/drivers/net/wireless/p54/p54usb.c | |||
@@ -315,73 +315,6 @@ static int p54u_bulk_msg(struct p54u_priv *priv, unsigned int ep, | |||
315 | data, len, &alen, 2000); | 315 | data, len, &alen, 2000); |
316 | } | 316 | } |
317 | 317 | ||
318 | static int p54u_read_eeprom(struct ieee80211_hw *dev) | ||
319 | { | ||
320 | struct p54u_priv *priv = dev->priv; | ||
321 | void *buf; | ||
322 | struct p54_control_hdr *hdr; | ||
323 | int err, alen; | ||
324 | size_t offset = priv->hw_type ? 0x10 : 0x20; | ||
325 | |||
326 | buf = kmalloc(0x2020, GFP_KERNEL); | ||
327 | if (!buf) { | ||
328 | printk(KERN_ERR "p54usb: cannot allocate memory for " | ||
329 | "eeprom readback!\n"); | ||
330 | return -ENOMEM; | ||
331 | } | ||
332 | |||
333 | if (priv->hw_type) { | ||
334 | *((u32 *) buf) = priv->common.rx_start; | ||
335 | err = p54u_bulk_msg(priv, P54U_PIPE_DATA, buf, sizeof(u32)); | ||
336 | if (err) { | ||
337 | printk(KERN_ERR "p54usb: addr send failed\n"); | ||
338 | goto fail; | ||
339 | } | ||
340 | } else { | ||
341 | struct net2280_reg_write *reg = buf; | ||
342 | reg->port = cpu_to_le16(NET2280_DEV_U32); | ||
343 | reg->addr = cpu_to_le32(P54U_DEV_BASE); | ||
344 | reg->val = cpu_to_le32(ISL38XX_DEV_INT_DATA); | ||
345 | err = p54u_bulk_msg(priv, P54U_PIPE_DEV, buf, sizeof(*reg)); | ||
346 | if (err) { | ||
347 | printk(KERN_ERR "p54usb: dev_int send failed\n"); | ||
348 | goto fail; | ||
349 | } | ||
350 | } | ||
351 | |||
352 | hdr = buf + priv->common.tx_hdr_len; | ||
353 | p54_fill_eeprom_readback(hdr); | ||
354 | hdr->req_id = cpu_to_le32(priv->common.rx_start); | ||
355 | if (priv->common.tx_hdr_len) { | ||
356 | struct net2280_tx_hdr *tx_hdr = buf; | ||
357 | tx_hdr->device_addr = hdr->req_id; | ||
358 | tx_hdr->len = cpu_to_le16(EEPROM_READBACK_LEN); | ||
359 | } | ||
360 | |||
361 | /* we can just pretend to send 0x2000 bytes of nothing in the headers */ | ||
362 | err = p54u_bulk_msg(priv, P54U_PIPE_DATA, buf, | ||
363 | EEPROM_READBACK_LEN + priv->common.tx_hdr_len); | ||
364 | if (err) { | ||
365 | printk(KERN_ERR "p54usb: eeprom req send failed\n"); | ||
366 | goto fail; | ||
367 | } | ||
368 | |||
369 | err = usb_bulk_msg(priv->udev, | ||
370 | usb_rcvbulkpipe(priv->udev, P54U_PIPE_DATA), | ||
371 | buf, 0x2020, &alen, 1000); | ||
372 | if (!err && alen > offset) { | ||
373 | p54_parse_eeprom(dev, (u8 *)buf + offset, alen - offset); | ||
374 | } else { | ||
375 | printk(KERN_ERR "p54usb: eeprom read failed!\n"); | ||
376 | err = -EINVAL; | ||
377 | goto fail; | ||
378 | } | ||
379 | |||
380 | fail: | ||
381 | kfree(buf); | ||
382 | return err; | ||
383 | } | ||
384 | |||
385 | static int p54u_upload_firmware_3887(struct ieee80211_hw *dev) | 318 | static int p54u_upload_firmware_3887(struct ieee80211_hw *dev) |
386 | { | 319 | { |
387 | static char start_string[] = "~~~~<\r"; | 320 | static char start_string[] = "~~~~<\r"; |
@@ -861,31 +794,20 @@ static int __devinit p54u_probe(struct usb_interface *intf, | |||
861 | if (err) | 794 | if (err) |
862 | goto err_free_dev; | 795 | goto err_free_dev; |
863 | 796 | ||
864 | err = p54u_read_eeprom(dev); | 797 | skb_queue_head_init(&priv->rx_queue); |
798 | |||
799 | p54u_open(dev); | ||
800 | err = p54_read_eeprom(dev); | ||
801 | p54u_stop(dev); | ||
865 | if (err) | 802 | if (err) |
866 | goto err_free_dev; | 803 | goto err_free_dev; |
867 | 804 | ||
868 | if (!is_valid_ether_addr(dev->wiphy->perm_addr)) { | ||
869 | u8 perm_addr[ETH_ALEN]; | ||
870 | |||
871 | printk(KERN_WARNING "p54usb: Invalid hwaddr! Using randomly generated MAC addr\n"); | ||
872 | random_ether_addr(perm_addr); | ||
873 | SET_IEEE80211_PERM_ADDR(dev, perm_addr); | ||
874 | } | ||
875 | |||
876 | skb_queue_head_init(&priv->rx_queue); | ||
877 | |||
878 | err = ieee80211_register_hw(dev); | 805 | err = ieee80211_register_hw(dev); |
879 | if (err) { | 806 | if (err) { |
880 | printk(KERN_ERR "p54usb: Cannot register netdevice\n"); | 807 | printk(KERN_ERR "p54usb: Cannot register netdevice\n"); |
881 | goto err_free_dev; | 808 | goto err_free_dev; |
882 | } | 809 | } |
883 | 810 | ||
884 | printk(KERN_INFO "%s: hwaddr %s, isl38%02x\n", | ||
885 | wiphy_name(dev->wiphy), | ||
886 | print_mac(mac, dev->wiphy->perm_addr), | ||
887 | priv->common.version); | ||
888 | |||
889 | return 0; | 811 | return 0; |
890 | 812 | ||
891 | err_free_dev: | 813 | err_free_dev: |