diff options
author | Christian Lamparter <chunkeey@web.de> | 2008-09-01 16:48:41 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2008-09-05 16:17:47 -0400 |
commit | 4e416a6f49b710bfe162f0cb24bc68c74493d2a0 (patch) | |
tree | 76e4a5e4a7e1cd65b142d841e5134404f970a99d /drivers/net/wireless/p54/p54usb.c | |
parent | 0c25970dc1b0d46f2357e7c4b267ab7b93eb7cdd (diff) |
p54: enhance firmware parser to reduce memory waste
This patch greatly reduces one of biggest memory waste in the driver.
The firmware headers provides the right values for extra head-/tailroom
and mtu size which are usually much lower than the old hardcoded ones.
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 | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/drivers/net/wireless/p54/p54usb.c b/drivers/net/wireless/p54/p54usb.c index 8a420df605af..4dca209a6e07 100644 --- a/drivers/net/wireless/p54/p54usb.c +++ b/drivers/net/wireless/p54/p54usb.c | |||
@@ -95,7 +95,7 @@ static void p54u_rx_cb(struct urb *urb) | |||
95 | skb_pull(skb, sizeof(struct net2280_tx_hdr)); | 95 | skb_pull(skb, sizeof(struct net2280_tx_hdr)); |
96 | 96 | ||
97 | if (p54_rx(dev, skb)) { | 97 | if (p54_rx(dev, skb)) { |
98 | skb = dev_alloc_skb(MAX_RX_SIZE); | 98 | skb = dev_alloc_skb(priv->common.rx_mtu + 32); |
99 | if (unlikely(!skb)) { | 99 | if (unlikely(!skb)) { |
100 | usb_free_urb(urb); | 100 | usb_free_urb(urb); |
101 | /* TODO check rx queue length and refill *somewhere* */ | 101 | /* TODO check rx queue length and refill *somewhere* */ |
@@ -145,7 +145,7 @@ static int p54u_init_urbs(struct ieee80211_hw *dev) | |||
145 | struct p54u_rx_info *info; | 145 | struct p54u_rx_info *info; |
146 | 146 | ||
147 | while (skb_queue_len(&priv->rx_queue) < 32) { | 147 | while (skb_queue_len(&priv->rx_queue) < 32) { |
148 | skb = __dev_alloc_skb(MAX_RX_SIZE, GFP_KERNEL); | 148 | skb = __dev_alloc_skb(priv->common.rx_mtu + 32, GFP_KERNEL); |
149 | if (!skb) | 149 | if (!skb) |
150 | break; | 150 | break; |
151 | entry = usb_alloc_urb(0, GFP_KERNEL); | 151 | entry = usb_alloc_urb(0, GFP_KERNEL); |
@@ -153,7 +153,10 @@ static int p54u_init_urbs(struct ieee80211_hw *dev) | |||
153 | kfree_skb(skb); | 153 | kfree_skb(skb); |
154 | break; | 154 | break; |
155 | } | 155 | } |
156 | usb_fill_bulk_urb(entry, priv->udev, usb_rcvbulkpipe(priv->udev, P54U_PIPE_DATA), skb_tail_pointer(skb), MAX_RX_SIZE, p54u_rx_cb, skb); | 156 | usb_fill_bulk_urb(entry, priv->udev, |
157 | usb_rcvbulkpipe(priv->udev, P54U_PIPE_DATA), | ||
158 | skb_tail_pointer(skb), | ||
159 | priv->common.rx_mtu + 32, p54u_rx_cb, skb); | ||
157 | info = (struct p54u_rx_info *) skb->cb; | 160 | info = (struct p54u_rx_info *) skb->cb; |
158 | info->urb = entry; | 161 | info->urb = entry; |
159 | info->dev = dev; | 162 | info->dev = dev; |
@@ -412,7 +415,9 @@ static int p54u_upload_firmware_3887(struct ieee80211_hw *dev) | |||
412 | goto err_req_fw_failed; | 415 | goto err_req_fw_failed; |
413 | } | 416 | } |
414 | 417 | ||
415 | p54_parse_firmware(dev, fw_entry); | 418 | err = p54_parse_firmware(dev, fw_entry); |
419 | if (err) | ||
420 | goto err_upload_failed; | ||
416 | 421 | ||
417 | left = block_size = min((size_t)P54U_FW_BLOCK, fw_entry->size); | 422 | left = block_size = min((size_t)P54U_FW_BLOCK, fw_entry->size); |
418 | strcpy(buf, start_string); | 423 | strcpy(buf, start_string); |
@@ -549,7 +554,12 @@ static int p54u_upload_firmware_net2280(struct ieee80211_hw *dev) | |||
549 | return err; | 554 | return err; |
550 | } | 555 | } |
551 | 556 | ||
552 | p54_parse_firmware(dev, fw_entry); | 557 | err = p54_parse_firmware(dev, fw_entry); |
558 | if (err) { | ||
559 | kfree(buf); | ||
560 | release_firmware(fw_entry); | ||
561 | return err; | ||
562 | } | ||
553 | 563 | ||
554 | #define P54U_WRITE(type, addr, data) \ | 564 | #define P54U_WRITE(type, addr, data) \ |
555 | do {\ | 565 | do {\ |