aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/usb/kaweth.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/usb/kaweth.c')
-rw-r--r--drivers/net/usb/kaweth.c43
1 files changed, 26 insertions, 17 deletions
diff --git a/drivers/net/usb/kaweth.c b/drivers/net/usb/kaweth.c
index 7c66b052f55a..d6829db51b45 100644
--- a/drivers/net/usb/kaweth.c
+++ b/drivers/net/usb/kaweth.c
@@ -57,13 +57,12 @@
57#include <linux/ethtool.h> 57#include <linux/ethtool.h>
58#include <linux/dma-mapping.h> 58#include <linux/dma-mapping.h>
59#include <linux/wait.h> 59#include <linux/wait.h>
60#include <linux/firmware.h>
60#include <asm/uaccess.h> 61#include <asm/uaccess.h>
61#include <asm/byteorder.h> 62#include <asm/byteorder.h>
62 63
63#undef DEBUG 64#undef DEBUG
64 65
65#include "kawethfw.h"
66
67#define KAWETH_MTU 1514 66#define KAWETH_MTU 1514
68#define KAWETH_BUF_SIZE 1664 67#define KAWETH_BUF_SIZE 1664
69#define KAWETH_TX_TIMEOUT (5 * HZ) 68#define KAWETH_TX_TIMEOUT (5 * HZ)
@@ -108,6 +107,10 @@
108MODULE_AUTHOR("Michael Zappe <zapman@interlan.net>, Stephane Alnet <stephane@u-picardie.fr>, Brad Hards <bhards@bigpond.net.au> and Oliver Neukum <oliver@neukum.org>"); 107MODULE_AUTHOR("Michael Zappe <zapman@interlan.net>, Stephane Alnet <stephane@u-picardie.fr>, Brad Hards <bhards@bigpond.net.au> and Oliver Neukum <oliver@neukum.org>");
109MODULE_DESCRIPTION("KL5USB101 USB Ethernet driver"); 108MODULE_DESCRIPTION("KL5USB101 USB Ethernet driver");
110MODULE_LICENSE("GPL"); 109MODULE_LICENSE("GPL");
110MODULE_FIRMWARE("kaweth/new_code.bin");
111MODULE_FIRMWARE("kaweth/new_code_fix.bin");
112MODULE_FIRMWARE("kaweth/trigger_code.bin");
113MODULE_FIRMWARE("kaweth/trigger_code_fix.bin");
111 114
112static const char driver_name[] = "kaweth"; 115static const char driver_name[] = "kaweth";
113 116
@@ -385,17 +388,28 @@ static int kaweth_set_receive_filter(struct kaweth_device *kaweth,
385 * kaweth_download_firmware 388 * kaweth_download_firmware
386 ****************************************************************/ 389 ****************************************************************/
387static int kaweth_download_firmware(struct kaweth_device *kaweth, 390static int kaweth_download_firmware(struct kaweth_device *kaweth,
388 __u8 *data, 391 const char *fwname,
389 __u16 data_len,
390 __u8 interrupt, 392 __u8 interrupt,
391 __u8 type) 393 __u8 type)
392{ 394{
393 if(data_len > KAWETH_FIRMWARE_BUF_SIZE) { 395 const struct firmware *fw;
394 err("Firmware too big: %d", data_len); 396 int data_len;
397 int ret;
398
399 ret = request_firmware(&fw, fwname, &kaweth->dev->dev);
400 if (ret) {
401 err("Firmware request failed\n");
402 return ret;
403 }
404
405 if (fw->size > KAWETH_FIRMWARE_BUF_SIZE) {
406 err("Firmware too big: %zu", fw->size);
395 return -ENOSPC; 407 return -ENOSPC;
396 } 408 }
409 data_len = fw->size;
410 memcpy(kaweth->firmware_buf, fw->data, fw->size);
397 411
398 memcpy(kaweth->firmware_buf, data, data_len); 412 release_firmware(fw);
399 413
400 kaweth->firmware_buf[2] = (data_len & 0xFF) - 7; 414 kaweth->firmware_buf[2] = (data_len & 0xFF) - 7;
401 kaweth->firmware_buf[3] = data_len >> 8; 415 kaweth->firmware_buf[3] = data_len >> 8;
@@ -406,8 +420,7 @@ static int kaweth_download_firmware(struct kaweth_device *kaweth,
406 kaweth->firmware_buf[2]); 420 kaweth->firmware_buf[2]);
407 421
408 dbg("Downloading firmware at %p to kaweth device at %p", 422 dbg("Downloading firmware at %p to kaweth device at %p",
409 data, 423 fw->data, kaweth);
410 kaweth);
411 dbg("Firmware length: %d", data_len); 424 dbg("Firmware length: %d", data_len);
412 425
413 return kaweth_control(kaweth, 426 return kaweth_control(kaweth,
@@ -1009,8 +1022,7 @@ static int kaweth_probe(
1009 info("Downloading firmware..."); 1022 info("Downloading firmware...");
1010 kaweth->firmware_buf = (__u8 *)__get_free_page(GFP_KERNEL); 1023 kaweth->firmware_buf = (__u8 *)__get_free_page(GFP_KERNEL);
1011 if ((result = kaweth_download_firmware(kaweth, 1024 if ((result = kaweth_download_firmware(kaweth,
1012 kaweth_new_code, 1025 "kaweth/new_code.bin",
1013 len_kaweth_new_code,
1014 100, 1026 100,
1015 2)) < 0) { 1027 2)) < 0) {
1016 err("Error downloading firmware (%d)", result); 1028 err("Error downloading firmware (%d)", result);
@@ -1018,8 +1030,7 @@ static int kaweth_probe(
1018 } 1030 }
1019 1031
1020 if ((result = kaweth_download_firmware(kaweth, 1032 if ((result = kaweth_download_firmware(kaweth,
1021 kaweth_new_code_fix, 1033 "kaweth/new_code_fix.bin",
1022 len_kaweth_new_code_fix,
1023 100, 1034 100,
1024 3)) < 0) { 1035 3)) < 0) {
1025 err("Error downloading firmware fix (%d)", result); 1036 err("Error downloading firmware fix (%d)", result);
@@ -1027,8 +1038,7 @@ static int kaweth_probe(
1027 } 1038 }
1028 1039
1029 if ((result = kaweth_download_firmware(kaweth, 1040 if ((result = kaweth_download_firmware(kaweth,
1030 kaweth_trigger_code, 1041 "kaweth/trigger_code.bin",
1031 len_kaweth_trigger_code,
1032 126, 1042 126,
1033 2)) < 0) { 1043 2)) < 0) {
1034 err("Error downloading trigger code (%d)", result); 1044 err("Error downloading trigger code (%d)", result);
@@ -1037,8 +1047,7 @@ static int kaweth_probe(
1037 } 1047 }
1038 1048
1039 if ((result = kaweth_download_firmware(kaweth, 1049 if ((result = kaweth_download_firmware(kaweth,
1040 kaweth_trigger_code_fix, 1050 "kaweth/trigger_code_fix.bin",
1041 len_kaweth_trigger_code_fix,
1042 126, 1051 126,
1043 3)) < 0) { 1052 3)) < 0) {
1044 err("Error downloading trigger code fix (%d)", result); 1053 err("Error downloading trigger code fix (%d)", result);