yam: use request_firmware
Subsystems (2)
PATCH 1/1 yam: use request_firmware
Added predef variable in add_mcs() to support predefined mcs data
Signed-off-by Jaswinder Singh <[email protected]>
--- drivers/net/hamradio/yam.c | 85 +++++++++-- drivers/net/hamradio/yam1200.h | 343 ---------------------------------------- drivers/net/hamradio/yam9600.h | 343 ---------------------------------------- firmware/Makefile | 1 + firmware/WHENCE | 12 ++ firmware/yam/1200.bin.ihex | 342 +++++++++++++++++++++++++++++++++++++++ firmware/yam/9600.bin.ihex | 342 +++++++++++++++++++++++++++++++++++++++ 7 files changed, 769 insertions(+), 699 deletions(-) delete mode 100644 drivers/net/hamradio/yam1200.h delete mode 100644 drivers/net/hamradio/yam9600.h create mode 100644 firmware/yam/1200.bin.ihex create mode 100644 firmware/yam/9600.bin.ihex
drivers/net/hamradio/yam.c +72 -13
@@ -55,6 +55,8 @@#include <asm/system.h> #include <linux/interrupt.h> #include <linux/ioport.h> +#include <linux/firmware.h> +#include <linux/platform_device.h> #include <linux/netdevice.h> #include <linux/if_arp.h>
@@ -71,8 +73,6 @@#include <linux/init.h> #include <linux/yam.h> -#include "yam9600.h" -#include "yam1200.h" /* --------------------------------------------------------------------- */
@@ -345,16 +345,60 @@ static int fpga_write(int iobase, unsigned char wrd)return 0 ; } -static unsigned char *add_mcs (unsigned char *bits,int bitrate) +/* +* predef should be 0 for loading user defined mcs +* predef should be YAM_9600 for loading predef 9600 mcs +* predef should be YAM_1200 for loading predef 1200 mcs +*/ +static unsigned char *add_mcs (unsigned char *bits,int bitrate, +unsigned int predef) { -struct yam_mcs *p; +struct platform_device *pdev; +const struct firmware *fw; +const char *fw_name[2 ] = {"yam/9600.bin" ,"yam/1200.bin" }; +struct yam_mcs *p = yam_data; +int err; + +/* Setting err as -EINVAL so that all exits from out */ +if (predef ==YAM_1200 || predef ==YAM_9600 ) { + pdev =platform_device_register_simple ("yam" ,0 ,NULL ,0 ); + err =IS_ERR (pdev); +if (err) { +printk (KERN_ERR "yam: Failed to register firmware\n" ); + goto out; + } + err =request_firmware (&fw, fw_name[predef -1 ], &pdev->dev); +platform_device_unregister (pdev); +if (err) { +printk (KERN_ERR "Failed to load firmware \"%s\"\n" , + fw_name[predef -1 ]); + goto out; + } +platform_device_unregister (pdev); +if (fw->size !=YAM_FPGA_SIZE ) { +printk (KERN_ERR "Bogus length %zu in firmware \"%s\"\n" , + fw->size, fw_name[predef -1 ]); + err = -EINVAL ; + goto out; + } + }else { +if (predef) { +printk (KERN_ERR "yam: Invalid predef number %u\n" , + predef); + err = -EINVAL ; + goto out; + }else + err =0 ; + }/* If it already exists, replace the bit data */ - p = yam_data;while (p) {if (p->bitrate == bitrate) { -memcpy (p->bits, bits,YAM_FPGA_SIZE ); -return p->bits; +if (predef) +memcpy (p->bits, fw->data,YAM_FPGA_SIZE ); +else +memcpy (p->bits, bits,YAM_FPGA_SIZE ); + goto out; } p = p->next; }
@@ -362,14 +406,24 @@ static unsigned char *add_mcs(unsigned char *bits, int bitrate)/* Allocate a new mcs */ if ((p =kmalloc (sizeof (struct yam_mcs ),GFP_KERNEL )) ==NULL ) {printk (KERN_WARNING "YAM: no memory to allocate mcs\n" ); -return NULL ; + err = -ENOMEM ; + goto out; } -memcpy (p->bits, bits,YAM_FPGA_SIZE ); +if (predef) +memcpy (p->bits, fw->data,YAM_FPGA_SIZE ); +else +memcpy (p->bits, bits,YAM_FPGA_SIZE ); p->bitrate = bitrate; p->next = yam_data; yam_data = p; -return p->bits; +out: +if (fw) +release_firmware (fw); +if (err) +return NULL ; +else +return p->bits; }static unsigned char *get_mcs (int bitrate)
@@ -386,9 +440,11 @@ static unsigned char *get_mcs(int bitrate)/* Load predefined mcs data */ switch (bitrate) {case 1200 : -return add_mcs (bits_1200, bitrate); +/* setting predef as YAM_1200 for loading predef 1200 mcs */ +return add_mcs (NULL , bitrate,YAM_1200 );default : -return add_mcs (bits_9600, bitrate); +/* setting predef as YAM_9600 for loading predef 9600 mcs */ +return add_mcs (NULL , bitrate,YAM_9600 ); } }
@@ -960,7 +1016,8 @@ static int yam_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)kfree (ym);return -EINVAL ; } -add_mcs (ym->bits, ym->bitrate); +/* setting predef as 0 for loading userdefined mcs data */ +add_mcs (ym->bits, ym->bitrate,0 );kfree (ym);break ;
@@ -1182,6 +1239,8 @@ static void __exit yam_cleanup_driver(void)MODULE_AUTHOR ("Frederic Rible F1OAT [email protected]" );MODULE_DESCRIPTION ("Yam amateur radio modem driver" );MODULE_LICENSE ("GPL" ); +MODULE_FIRMWARE ("yam/1200.bin" ); +MODULE_FIRMWARE ("yam/9600.bin" );module_init (yam_init_driver);module_exit (yam_cleanup_driver);
drivers/net/hamradio/yam1200.h deleted +0 -343
343 lines not on this page · raw message
drivers/net/hamradio/yam9600.h deleted +0 -343
343 lines not on this page · raw message
firmware/Makefile +1 -0
@@ -95,6 +95,7 @@ fw-shipped-$(CONFIG_USB_SERIAL_KEYSPAN_PDA) += keyspan_pda/keyspan_pda.fw fw-shipped-$(CONFIG_USB_SERIAL_XIRCOM) += keyspan_pda/xircom_pgs.fw fw-shipped-$(CONFIG_USB_VICAM) += vicam/firmware.fw fw-shipped-$(CONFIG_VIDEO_CPIA2) += cpia2/stv0672_vp4.bin +fw-shipped-$(CONFIG_YAM) += yam/1200.bin yam/9600.bin fw-shipped-all := $(fw-shipped-y) $(fw-shipped-m) $(fw-shipped-)
firmware/WHENCE +12 -0
@@ -534,3 +534,15 @@ Licence: Allegedly GPL, but no source visible. Marked: Found in hex form in kernel source. -------------------------------------------------------------------------- + +Driver: YAM - YAM driver for AX.25 + +File: yam/1200.bin +File: yam/9600.bin + +Licence: + * (C) F6FBB 1998 + +Found in hex form in kernel source. + +--------------------------------------------------------------------------
firmware/yam/1200.bin.ihex new file +342 -0
342 lines not on this page · raw message
firmware/yam/9600.bin.ihex new file +342 -0
342 lines not on this page · raw message
Signature · 1 line
1.5.5.1