aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/hamradio/yam.c
diff options
context:
space:
mode:
authorJaswinder Singh Rajput <jaswinderrajput@gmail.com>2009-03-30 08:47:21 -0400
committerJaswinder Singh Rajput <jaswinderrajput@gmail.com>2009-03-30 09:57:07 -0400
commita7a5eb9d4eb9908709df66e8f8f1724b5b108258 (patch)
tree0c0a14f88631956d6147e910d3d09c02971022ad /drivers/net/hamradio/yam.c
parent7c757eb9f804782fb39d0ae2c1a88ffb9309138e (diff)
yam: use request_firmware
Added predef variable in add_mcs() to support predefined mcs data Signed-off-by: Jaswinder Singh Rajput <jaswinderrajput@gmail.com>
Diffstat (limited to 'drivers/net/hamradio/yam.c')
-rw-r--r--drivers/net/hamradio/yam.c64
1 files changed, 58 insertions, 6 deletions
diff --git a/drivers/net/hamradio/yam.c b/drivers/net/hamradio/yam.c
index 500a40b2afe7..b06691937ce9 100644
--- a/drivers/net/hamradio/yam.c
+++ b/drivers/net/hamradio/yam.c
@@ -55,6 +55,8 @@
55#include <asm/system.h> 55#include <asm/system.h>
56#include <linux/interrupt.h> 56#include <linux/interrupt.h>
57#include <linux/ioport.h> 57#include <linux/ioport.h>
58#include <linux/firmware.h>
59#include <linux/platform_device.h>
58 60
59#include <linux/netdevice.h> 61#include <linux/netdevice.h>
60#include <linux/if_arp.h> 62#include <linux/if_arp.h>
@@ -71,8 +73,6 @@
71#include <linux/init.h> 73#include <linux/init.h>
72 74
73#include <linux/yam.h> 75#include <linux/yam.h>
74#include "yam9600.h"
75#include "yam1200.h"
76 76
77/* --------------------------------------------------------------------- */ 77/* --------------------------------------------------------------------- */
78 78
@@ -82,6 +82,9 @@ static const char yam_drvinfo[] __initdata = KERN_INFO \
82 82
83/* --------------------------------------------------------------------- */ 83/* --------------------------------------------------------------------- */
84 84
85#define FIRMWARE_9600 "yam/9600.bin"
86#define FIRMWARE_1200 "yam/1200.bin"
87
85#define YAM_9600 1 88#define YAM_9600 1
86#define YAM_1200 2 89#define YAM_1200 2
87 90
@@ -342,9 +345,51 @@ static int fpga_write(int iobase, unsigned char wrd)
342 return 0; 345 return 0;
343} 346}
344 347
345static unsigned char *add_mcs(unsigned char *bits, int bitrate) 348/*
349 * predef should be 0 for loading user defined mcs
350 * predef should be YAM_1200 for loading predef 1200 mcs
351 * predef should be YAM_9600 for loading predef 9600 mcs
352 */
353static unsigned char *add_mcs(unsigned char *bits, int bitrate,
354 unsigned int predef)
346{ 355{
356 const char *fw_name[2] = {FIRMWARE_9600, FIRMWARE_1200};
357 const struct firmware *fw;
358 struct platform_device *pdev;
347 struct yam_mcs *p; 359 struct yam_mcs *p;
360 int err;
361
362 switch (predef) {
363 case 0:
364 fw = NULL;
365 break;
366 case YAM_1200:
367 case YAM_9600:
368 predef--;
369 pdev = platform_device_register_simple("yam", 0, NULL, 0);
370 if (IS_ERR(pdev)) {
371 printk(KERN_ERR "yam: Failed to register firmware\n");
372 return NULL;
373 }
374 err = request_firmware(&fw, fw_name[predef], &pdev->dev);
375 platform_device_unregister(pdev);
376 if (err) {
377 printk(KERN_ERR "Failed to load firmware \"%s\"\n",
378 fw_name[predef]);
379 return NULL;
380 }
381 if (fw->size != YAM_FPGA_SIZE) {
382 printk(KERN_ERR "Bogus length %zu in firmware \"%s\"\n",
383 fw->size, fw_name[predef]);
384 release_firmware(fw);
385 return NULL;
386 }
387 bits = (unsigned char *)fw->data;
388 break;
389 default:
390 printk(KERN_ERR "yam: Invalid predef number %u\n", predef);
391 return NULL;
392 }
348 393
349 /* If it already exists, replace the bit data */ 394 /* If it already exists, replace the bit data */
350 p = yam_data; 395 p = yam_data;
@@ -359,6 +404,7 @@ static unsigned char *add_mcs(unsigned char *bits, int bitrate)
359 /* Allocate a new mcs */ 404 /* Allocate a new mcs */
360 if ((p = kmalloc(sizeof(struct yam_mcs), GFP_KERNEL)) == NULL) { 405 if ((p = kmalloc(sizeof(struct yam_mcs), GFP_KERNEL)) == NULL) {
361 printk(KERN_WARNING "YAM: no memory to allocate mcs\n"); 406 printk(KERN_WARNING "YAM: no memory to allocate mcs\n");
407 release_firmware(fw);
362 return NULL; 408 return NULL;
363 } 409 }
364 memcpy(p->bits, bits, YAM_FPGA_SIZE); 410 memcpy(p->bits, bits, YAM_FPGA_SIZE);
@@ -366,6 +412,7 @@ static unsigned char *add_mcs(unsigned char *bits, int bitrate)
366 p->next = yam_data; 412 p->next = yam_data;
367 yam_data = p; 413 yam_data = p;
368 414
415 release_firmware(fw);
369 return p->bits; 416 return p->bits;
370} 417}
371 418
@@ -383,9 +430,11 @@ static unsigned char *get_mcs(int bitrate)
383 /* Load predefined mcs data */ 430 /* Load predefined mcs data */
384 switch (bitrate) { 431 switch (bitrate) {
385 case 1200: 432 case 1200:
386 return add_mcs(bits_1200, bitrate); 433 /* setting predef as YAM_1200 for loading predef 1200 mcs */
434 return add_mcs(NULL, bitrate, YAM_1200);
387 default: 435 default:
388 return add_mcs(bits_9600, bitrate); 436 /* setting predef as YAM_9600 for loading predef 9600 mcs */
437 return add_mcs(NULL, bitrate, YAM_9600);
389 } 438 }
390} 439}
391 440
@@ -936,7 +985,8 @@ static int yam_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
936 kfree(ym); 985 kfree(ym);
937 return -EINVAL; 986 return -EINVAL;
938 } 987 }
939 add_mcs(ym->bits, ym->bitrate); 988 /* setting predef as 0 for loading userdefined mcs data */
989 add_mcs(ym->bits, ym->bitrate, 0);
940 kfree(ym); 990 kfree(ym);
941 break; 991 break;
942 992
@@ -1159,6 +1209,8 @@ static void __exit yam_cleanup_driver(void)
1159MODULE_AUTHOR("Frederic Rible F1OAT frible@teaser.fr"); 1209MODULE_AUTHOR("Frederic Rible F1OAT frible@teaser.fr");
1160MODULE_DESCRIPTION("Yam amateur radio modem driver"); 1210MODULE_DESCRIPTION("Yam amateur radio modem driver");
1161MODULE_LICENSE("GPL"); 1211MODULE_LICENSE("GPL");
1212MODULE_FIRMWARE(FIRMWARE_1200);
1213MODULE_FIRMWARE(FIRMWARE_9600);
1162 1214
1163module_init(yam_init_driver); 1215module_init(yam_init_driver);
1164module_exit(yam_cleanup_driver); 1216module_exit(yam_cleanup_driver);