57
57
#include <linux/ethtool.h>
58
58
#include <linux/dma-mapping.h>
59
59
#include <linux/wait.h>
60
+ #include <linux/firmware.h>
60
61
#include <asm/uaccess.h>
61
62
#include <asm/byteorder.h>
62
63
63
64
#undef DEBUG
64
65
65
- #include "kawethfw.h"
66
-
67
66
#define KAWETH_MTU 1514
68
67
#define KAWETH_BUF_SIZE 1664
69
68
#define KAWETH_TX_TIMEOUT (5 * HZ)
108
107
MODULE_AUTHOR (
"Michael Zappe <[email protected] >, Stephane Alnet <[email protected] >, Brad Hards <[email protected] > and Oliver Neukum <[email protected] >" );
109
108
MODULE_DESCRIPTION ("KL5USB101 USB Ethernet driver" );
110
109
MODULE_LICENSE ("GPL" );
110
+ MODULE_FIRMWARE ("kaweth/new_code.bin" );
111
+ MODULE_FIRMWARE ("kaweth/new_code_fix.bin" );
112
+ MODULE_FIRMWARE ("kaweth/trigger_code.bin" );
113
+ MODULE_FIRMWARE ("kaweth/trigger_code_fix.bin" );
111
114
112
115
static const char driver_name [] = "kaweth" ;
113
116
@@ -385,17 +388,28 @@ static int kaweth_set_receive_filter(struct kaweth_device *kaweth,
385
388
* kaweth_download_firmware
386
389
****************************************************************/
387
390
static int kaweth_download_firmware (struct kaweth_device * kaweth ,
388
- __u8 * data ,
389
- __u16 data_len ,
391
+ const char * fwname ,
390
392
__u8 interrupt ,
391
393
__u8 type )
392
394
{
393
- if (data_len > KAWETH_FIRMWARE_BUF_SIZE ) {
394
- err ("Firmware too big: %d" , data_len );
395
+ const struct firmware * fw ;
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
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
414
kaweth -> firmware_buf [2 ] = (data_len & 0xFF ) - 7 ;
401
415
kaweth -> firmware_buf [3 ] = data_len >> 8 ;
@@ -406,8 +420,7 @@ static int kaweth_download_firmware(struct kaweth_device *kaweth,
406
420
kaweth -> firmware_buf [2 ]);
407
421
408
422
dbg ("Downloading firmware at %p to kaweth device at %p" ,
409
- data ,
410
- kaweth );
423
+ fw -> data , kaweth );
411
424
dbg ("Firmware length: %d" , data_len );
412
425
413
426
return kaweth_control (kaweth ,
@@ -1009,26 +1022,23 @@ static int kaweth_probe(
1009
1022
info ("Downloading firmware..." );
1010
1023
kaweth -> firmware_buf = (__u8 * )__get_free_page (GFP_KERNEL );
1011
1024
if ((result = kaweth_download_firmware (kaweth ,
1012
- kaweth_new_code ,
1013
- len_kaweth_new_code ,
1025
+ "kaweth/new_code.bin" ,
1014
1026
100 ,
1015
1027
2 )) < 0 ) {
1016
1028
err ("Error downloading firmware (%d)" , result );
1017
1029
goto err_fw ;
1018
1030
}
1019
1031
1020
1032
if ((result = kaweth_download_firmware (kaweth ,
1021
- kaweth_new_code_fix ,
1022
- len_kaweth_new_code_fix ,
1033
+ "kaweth/new_code_fix.bin" ,
1023
1034
100 ,
1024
1035
3 )) < 0 ) {
1025
1036
err ("Error downloading firmware fix (%d)" , result );
1026
1037
goto err_fw ;
1027
1038
}
1028
1039
1029
1040
if ((result = kaweth_download_firmware (kaweth ,
1030
- kaweth_trigger_code ,
1031
- len_kaweth_trigger_code ,
1041
+ "kaweth/trigger_code.bin" ,
1032
1042
126 ,
1033
1043
2 )) < 0 ) {
1034
1044
err ("Error downloading trigger code (%d)" , result );
@@ -1037,8 +1047,7 @@ static int kaweth_probe(
1037
1047
}
1038
1048
1039
1049
if ((result = kaweth_download_firmware (kaweth ,
1040
- kaweth_trigger_code_fix ,
1041
- len_kaweth_trigger_code_fix ,
1050
+ "kaweth/trigger_code_fix.bin" ,
1042
1051
126 ,
1043
1052
3 )) < 0 ) {
1044
1053
err ("Error downloading trigger code fix (%d)" , result );
0 commit comments