Signed-off-by: Marek Belisko <[email protected]>
---
 .../staging/ft1000/ft1000-usb/ft1000_download.c    |   62 --------------------
 drivers/staging/ft1000/ft1000-usb/ft1000_usb.c     |   31 ++++++----
 2 files changed, 20 insertions(+), 73 deletions(-)

diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_download.c
b/drivers/staging/ft1000/ft1000-usb/ft1000_download.c
index a889606..3594521 100644
--- a/drivers/staging/ft1000/ft1000-usb/ft1000_download.c
+++ b/drivers/staging/ft1000/ft1000-usb/ft1000_download.c
@@ -149,68 +149,6 @@ u16 fix_ft1000_write_dpram32(struct ft1000_device
*ft1000dev, USHORT indx,
                             PUCHAR buffer);

 //---------------------------------------------------------------------------
-// Function:    getfw
-//
-// Parameters:  char *fn - input DSP image file name
-//              int  *pimgsz - output DSP image file size
-// Returns:     DSP image buffer
-//
-// Description: Read the DSP image file into a char buffer
-//
-// Notes:
-//
-//---------------------------------------------------------------------------
-char *getfw(char *fn, int *pimgsz)
-{
-       struct file *fd;
-       mm_segment_t fs = get_fs();
-       loff_t pos;
-       char *pfwimg;
-       int fwimgsz;
-
-       set_fs(get_ds());
-
-       fd = filp_open(fn, 0, 0);
-       if (IS_ERR(fd)) {
-               DEBUG("FT1000:%s:can not open dsp image\n", __FUNCTION__);
-               set_fs(fs);
-               return NULL;
-       }
-
-       fwimgsz = i_size_read(fd->f_dentry->d_inode);
-       *pimgsz = fwimgsz;
-
-       if (fwimgsz <= 0) {
-               DEBUG("FT1000:%s:invalid file size\n", __FUNCTION__);
-               filp_close(fd, current->files);
-               set_fs(fs);
-               return NULL;
-       }
-       pfwimg = (char *)vmalloc(fwimgsz);
-       if (pfwimg == NULL) {
-               DEBUG("FT1000:%s:can not allocate memory for dsp image\n",
-                     __FUNCTION__);
-               filp_close(fd, current->files);
-               set_fs(fs);
-               return NULL;
-       }
-       pos = 0;
-       if (vfs_read(fd, pfwimg, fwimgsz, &pos) != fwimgsz) {
-               vfree(pfwimg);
-               DEBUG("FT1000:%s:failed to read firmware image\n",
-                     __FUNCTION__);
-               filp_close(fd, current->files);
-               set_fs(fs);
-               return NULL;
-       }
-
-       filp_close(fd, current->files);
-       set_fs(fs);
-
-       return pfwimg;
-}
-
-//---------------------------------------------------------------------------
 // Function:    check_usb_db
 //
 // Parameters:  struct ft1000_device  - device structure
diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_usb.c
b/drivers/staging/ft1000/ft1000-usb/ft1000_usb.c
index ee6e1a8..4c1774f 100644
--- a/drivers/staging/ft1000/ft1000-usb/ft1000_usb.c
+++ b/drivers/staging/ft1000/ft1000-usb/ft1000_usb.c
@@ -26,6 +26,7 @@
 //#include <asm/io.h>
 //#include <asm/system.h>
 #include <linux/kthread.h>
+#include <linux/firmware.h>

 MODULE_DESCRIPTION("FT1000 EXPRESS CARD DRIVER");
 MODULE_LICENSE("Dual MPL/GPL");
@@ -47,7 +48,6 @@ MODULE_DEVICE_TABLE(usb, id_table);

 extern struct ft1000_device *pdevobj[MAX_NUM_CARDS + 2];

-char *getfw(char *fn, int *pimgsz);

 int ft1000_close(struct net_device *net);
 void dsp_reload(struct ft1000_device *ft1000dev);
@@ -107,10 +107,12 @@ static int ft1000_probe(struct usb_interface *interface,

        struct ft1000_device *ft1000dev;
        FT1000_INFO *pft1000info;
+       const struct firmware *dsp_fw;
+       int ret = 0, size;

        if (!(ft1000dev = kmalloc(sizeof(struct ft1000_device), GFP_KERNEL))) {
                printk("out of memory allocating device structure\n");
-               return 0;
+               return -ENOMEM;
        }

        memset(ft1000dev, 0, sizeof(*ft1000dev));
@@ -124,7 +126,6 @@ static int ft1000_probe(struct usb_interface *interface,
        ft1000dev->dev = dev;
        ft1000dev->status = 0;
        ft1000dev->net = NULL;
-       //ft1000dev->device_lock = SPIN_LOCK_UNLOCKED;
        spin_lock_init(&ft1000dev->device_lock);
        ft1000dev->tx_urb = usb_alloc_urb(0, GFP_ATOMIC);
        ft1000dev->rx_urb = usb_alloc_urb(0, GFP_ATOMIC);
@@ -180,15 +181,23 @@ static int ft1000_probe(struct usb_interface *interface,
        DEBUG("bulk_in=%d, bulk_out=%d\n", ft1000dev->bulk_in_endpointAddr,
              ft1000dev->bulk_out_endpointAddr);

-       //read DSP image
-       pFileStart = (void *)getfw("/etc/flarion/ft3000.img", &FileLength);
-
-       if (pFileStart == NULL) {
-               DEBUG("ft1000_probe: Read DSP image failed\n");
-               return 0;
+       ret = request_firmware(&dsp_fw, "ft3000.img", &dev->dev);
+       if (ret < 0) {
+               printk("Error reading firmware. ret:%d\n", ret);        
+               return -ENOMEM;
+       }       
+       
+       size = max_t(uint, dsp_fw->size, 4096);
+       pFileStart = kmalloc(size, GFP_KERNEL);
+       
+       if (!pFileStart) {
+               release_firmware(dsp_fw);
+               return -ENOMEM;
        }
-       //for ( i=0; i< MAX_NUM_CARDS+2; i++)
-       //    pdevobj[i] = NULL;
+
+       memcpy(pFileStart, dsp_fw->data, dsp_fw->size);
+       FileLength = dsp_fw->size;
+       release_firmware(dsp_fw);

        //download dsp image
        DEBUG("ft1000_probe: start downloading dsp image...\n");
-- 
1.7.1
_______________________________________________
devel mailing list
[email protected]
http://driverdev.linuxdriverproject.org/mailman/listinfo/devel

Reply via email to