5757#include <linux/ethtool.h>
5858#include <linux/dma-mapping.h>
5959#include <linux/wait.h>
60+ #include <linux/firmware.h>
6061#include <asm/uaccess.h>
6162#include <asm/byteorder.h>
6263
6364#undef DEBUG
6465
65- #include "kawethfw.h"
66-
6766#define KAWETH_MTU 1514
6867#define KAWETH_BUF_SIZE 1664
6968#define KAWETH_TX_TIMEOUT (5 * HZ)
108107MODULE_AUTHOR ("Michael Zappe <zapman@interlan.net>, Stephane Alnet <stephane@u-picardie.fr>, Brad Hards <bhards@bigpond.net.au> and Oliver Neukum <oliver@neukum.org>" );
109108MODULE_DESCRIPTION ("KL5USB101 USB Ethernet driver" );
110109MODULE_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" );
111114
112115static const char driver_name [] = "kaweth" ;
113116
@@ -385,17 +388,28 @@ static int kaweth_set_receive_filter(struct kaweth_device *kaweth,
385388 * kaweth_download_firmware
386389 ****************************************************************/
387390static int kaweth_download_firmware (struct kaweth_device * kaweth ,
388- __u8 * data ,
389- __u16 data_len ,
391+ const char * fwname ,
390392 __u8 interrupt ,
391393 __u8 type )
392394{
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 );
395407 return - ENOSPC ;
396408 }
409+ data_len = fw -> size ;
410+ memcpy (kaweth -> firmware_buf , fw -> data , fw -> size );
397411
398- memcpy ( kaweth -> firmware_buf , data , data_len );
412+ release_firmware ( fw );
399413
400414 kaweth -> firmware_buf [2 ] = (data_len & 0xFF ) - 7 ;
401415 kaweth -> firmware_buf [3 ] = data_len >> 8 ;
@@ -406,8 +420,7 @@ static int kaweth_download_firmware(struct kaweth_device *kaweth,
406420 kaweth -> firmware_buf [2 ]);
407421
408422 dbg ("Downloading firmware at %p to kaweth device at %p" ,
409- data ,
410- kaweth );
423+ fw -> data , kaweth );
411424 dbg ("Firmware length: %d" , data_len );
412425
413426 return kaweth_control (kaweth ,
@@ -1009,26 +1022,23 @@ static int kaweth_probe(
10091022 info ("Downloading firmware..." );
10101023 kaweth -> firmware_buf = (__u8 * )__get_free_page (GFP_KERNEL );
10111024 if ((result = kaweth_download_firmware (kaweth ,
1012- kaweth_new_code ,
1013- len_kaweth_new_code ,
1025+ "kaweth/new_code.bin" ,
10141026 100 ,
10151027 2 )) < 0 ) {
10161028 err ("Error downloading firmware (%d)" , result );
10171029 goto err_fw ;
10181030 }
10191031
10201032 if ((result = kaweth_download_firmware (kaweth ,
1021- kaweth_new_code_fix ,
1022- len_kaweth_new_code_fix ,
1033+ "kaweth/new_code_fix.bin" ,
10231034 100 ,
10241035 3 )) < 0 ) {
10251036 err ("Error downloading firmware fix (%d)" , result );
10261037 goto err_fw ;
10271038 }
10281039
10291040 if ((result = kaweth_download_firmware (kaweth ,
1030- kaweth_trigger_code ,
1031- len_kaweth_trigger_code ,
1041+ "kaweth/trigger_code.bin" ,
10321042 126 ,
10331043 2 )) < 0 ) {
10341044 err ("Error downloading trigger code (%d)" , result );
@@ -1037,8 +1047,7 @@ static int kaweth_probe(
10371047 }
10381048
10391049 if ((result = kaweth_download_firmware (kaweth ,
1040- kaweth_trigger_code_fix ,
1041- len_kaweth_trigger_code_fix ,
1050+ "kaweth/trigger_code_fix.bin" ,
10421051 126 ,
10431052 3 )) < 0 ) {
10441053 err ("Error downloading trigger code fix (%d)" , result );
0 commit comments