Commit d94f43cd authored by Oliver Neukum's avatar Oliver Neukum Committed by Greg Kroah-Hartman

[PATCH] USB: saving memory on kaweth

this saves memory by making the buffer for firmware temporary.
parent 19db13b2
...@@ -75,6 +75,7 @@ ...@@ -75,6 +75,7 @@
#define KAWETH_MTU 1514 #define KAWETH_MTU 1514
#define KAWETH_BUF_SIZE 1664 #define KAWETH_BUF_SIZE 1664
#define KAWETH_TX_TIMEOUT (5 * HZ) #define KAWETH_TX_TIMEOUT (5 * HZ)
#define KAWETH_SCRATCH_SIZE 32
#define KAWETH_FIRMWARE_BUF_SIZE 4096 #define KAWETH_FIRMWARE_BUF_SIZE 4096
#define KAWETH_CONTROL_TIMEOUT (30 * HZ) #define KAWETH_CONTROL_TIMEOUT (30 * HZ)
...@@ -220,7 +221,8 @@ struct kaweth_device ...@@ -220,7 +221,8 @@ struct kaweth_device
struct urb *tx_urb; struct urb *tx_urb;
struct urb *irq_urb; struct urb *irq_urb;
__u8 firmware_buf[KAWETH_FIRMWARE_BUF_SIZE]; __u8 *firmware_buf;
__u8 scratch[KAWETH_SCRATCH_SIZE];
__u8 tx_buf[KAWETH_BUF_SIZE]; __u8 tx_buf[KAWETH_BUF_SIZE];
__u8 rx_buf[KAWETH_BUF_SIZE]; __u8 rx_buf[KAWETH_BUF_SIZE];
__u8 intbuffer[INTBUFFERSIZE]; __u8 intbuffer[INTBUFFERSIZE];
...@@ -312,7 +314,7 @@ static int kaweth_set_urb_size(struct kaweth_device *kaweth, __u16 urb_size) ...@@ -312,7 +314,7 @@ static int kaweth_set_urb_size(struct kaweth_device *kaweth, __u16 urb_size)
USB_TYPE_VENDOR | USB_DIR_OUT | USB_RECIP_DEVICE, USB_TYPE_VENDOR | USB_DIR_OUT | USB_RECIP_DEVICE,
urb_size, urb_size,
0, 0,
(void *)&kaweth->firmware_buf, (void *)&kaweth->scratch,
0, 0,
KAWETH_CONTROL_TIMEOUT); KAWETH_CONTROL_TIMEOUT);
...@@ -334,7 +336,7 @@ static int kaweth_set_sofs_wait(struct kaweth_device *kaweth, __u16 sofs_wait) ...@@ -334,7 +336,7 @@ static int kaweth_set_sofs_wait(struct kaweth_device *kaweth, __u16 sofs_wait)
USB_TYPE_VENDOR | USB_DIR_OUT | USB_RECIP_DEVICE, USB_TYPE_VENDOR | USB_DIR_OUT | USB_RECIP_DEVICE,
sofs_wait, sofs_wait,
0, 0,
(void *)&kaweth->firmware_buf, (void *)&kaweth->scratch,
0, 0,
KAWETH_CONTROL_TIMEOUT); KAWETH_CONTROL_TIMEOUT);
...@@ -357,7 +359,7 @@ static int kaweth_set_receive_filter(struct kaweth_device *kaweth, ...@@ -357,7 +359,7 @@ static int kaweth_set_receive_filter(struct kaweth_device *kaweth,
USB_TYPE_VENDOR | USB_DIR_OUT | USB_RECIP_DEVICE, USB_TYPE_VENDOR | USB_DIR_OUT | USB_RECIP_DEVICE,
receive_filter, receive_filter,
0, 0,
(void *)&kaweth->firmware_buf, (void *)&kaweth->scratch,
0, 0,
KAWETH_CONTROL_TIMEOUT); KAWETH_CONTROL_TIMEOUT);
...@@ -399,7 +401,7 @@ static int kaweth_download_firmware(struct kaweth_device *kaweth, ...@@ -399,7 +401,7 @@ static int kaweth_download_firmware(struct kaweth_device *kaweth,
USB_TYPE_VENDOR | USB_DIR_OUT | USB_RECIP_DEVICE, USB_TYPE_VENDOR | USB_DIR_OUT | USB_RECIP_DEVICE,
0, 0,
0, 0,
(void *)&kaweth->firmware_buf, (void *)kaweth->firmware_buf,
data_len, data_len,
KAWETH_CONTROL_TIMEOUT); KAWETH_CONTROL_TIMEOUT);
} }
...@@ -427,7 +429,7 @@ static int kaweth_trigger_firmware(struct kaweth_device *kaweth, ...@@ -427,7 +429,7 @@ static int kaweth_trigger_firmware(struct kaweth_device *kaweth,
USB_TYPE_VENDOR | USB_DIR_OUT | USB_RECIP_DEVICE, USB_TYPE_VENDOR | USB_DIR_OUT | USB_RECIP_DEVICE,
0, 0,
0, 0,
(void *)&kaweth->firmware_buf, (void *)kaweth->firmware_buf,
8, 8,
KAWETH_CONTROL_TIMEOUT); KAWETH_CONTROL_TIMEOUT);
} }
...@@ -755,7 +757,7 @@ static void kaweth_async_set_rx_mode(struct kaweth_device *kaweth) ...@@ -755,7 +757,7 @@ static void kaweth_async_set_rx_mode(struct kaweth_device *kaweth)
USB_TYPE_VENDOR | USB_DIR_OUT | USB_RECIP_DEVICE, USB_TYPE_VENDOR | USB_DIR_OUT | USB_RECIP_DEVICE,
packet_filter_bitmap, packet_filter_bitmap,
0, 0,
(void *)&kaweth->firmware_buf, (void *)&kaweth->scratch,
0, 0,
KAWETH_CONTROL_TIMEOUT); KAWETH_CONTROL_TIMEOUT);
...@@ -840,12 +842,14 @@ static void *kaweth_probe( ...@@ -840,12 +842,14 @@ static void *kaweth_probe(
} else { } else {
/* Download the firmware */ /* Download the firmware */
kaweth_info("Downloading firmware..."); kaweth_info("Downloading firmware...");
kaweth->firmware_buf = (__u8 *)__get_free_page(GFP_KERNEL);
if ((result = kaweth_download_firmware(kaweth, if ((result = kaweth_download_firmware(kaweth,
kaweth_new_code, kaweth_new_code,
len_kaweth_new_code, len_kaweth_new_code,
100, 100,
2)) < 0) { 2)) < 0) {
kaweth_err("Error downloading firmware (%d)", result); kaweth_err("Error downloading firmware (%d)", result);
free_page((unsigned long)kaweth->firmware_buf);
kfree(kaweth); kfree(kaweth);
return NULL; return NULL;
} }
...@@ -856,6 +860,7 @@ static void *kaweth_probe( ...@@ -856,6 +860,7 @@ static void *kaweth_probe(
100, 100,
3)) < 0) { 3)) < 0) {
kaweth_err("Error downloading firmware fix (%d)", result); kaweth_err("Error downloading firmware fix (%d)", result);
free_page((unsigned long)kaweth->firmware_buf);
kfree(kaweth); kfree(kaweth);
return NULL; return NULL;
} }
...@@ -866,6 +871,7 @@ static void *kaweth_probe( ...@@ -866,6 +871,7 @@ static void *kaweth_probe(
126, 126,
2)) < 0) { 2)) < 0) {
kaweth_err("Error downloading trigger code (%d)", result); kaweth_err("Error downloading trigger code (%d)", result);
free_page((unsigned long)kaweth->firmware_buf);
kfree(kaweth); kfree(kaweth);
return NULL; return NULL;
} }
...@@ -876,6 +882,7 @@ static void *kaweth_probe( ...@@ -876,6 +882,7 @@ static void *kaweth_probe(
126, 126,
3)) < 0) { 3)) < 0) {
kaweth_err("Error downloading trigger code fix (%d)", result); kaweth_err("Error downloading trigger code fix (%d)", result);
free_page((unsigned long)kaweth->firmware_buf);
kfree(kaweth); kfree(kaweth);
return NULL; return NULL;
} }
...@@ -883,12 +890,14 @@ static void *kaweth_probe( ...@@ -883,12 +890,14 @@ static void *kaweth_probe(
if ((result = kaweth_trigger_firmware(kaweth, 126)) < 0) { if ((result = kaweth_trigger_firmware(kaweth, 126)) < 0) {
kaweth_err("Error triggering firmware (%d)", result); kaweth_err("Error triggering firmware (%d)", result);
free_page((unsigned long)kaweth->firmware_buf);
kfree(kaweth); kfree(kaweth);
return NULL; return NULL;
} }
/* Device will now disappear for a moment... */ /* Device will now disappear for a moment... */
kaweth_info("Firmware loaded. I'll be back..."); kaweth_info("Firmware loaded. I'll be back...");
free_page((unsigned long)kaweth->firmware_buf);
kfree(kaweth); kfree(kaweth);
return NULL; return NULL;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment