staging: vt6656: Keep firmware loading local and release firware.
authorMalcolm Priestley <tvboxspy@gmail.com>
Sun, 7 Oct 2012 10:41:31 +0000 (11:41 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 22 Oct 2012 20:26:40 +0000 (13:26 -0700)
Firmware is retained unreleased for the entire duration of the
driver.

When done release firmware and if the need be request firmware again.

Signed-off-by: Malcolm Priestley <tvboxspy@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/vt6656/device.h
drivers/staging/vt6656/firmware.c
drivers/staging/vt6656/main_usb.c

index 6370d1039103d3d36027947e014d1643a9f3d1ea..8d9b9c1a2d50e72f8ebfd81801b051b1faf66d82 100644 (file)
@@ -418,7 +418,6 @@ typedef struct __device_info {
     struct net_device*          dev;
     struct net_device_stats     stats;
 
-    const struct firmware      *firmware;
 
     OPTIONS                     sOpts;
 
index 8c8126a3540b426a69756872968664dadad38aba..8831ea03c00152864ca4336980624ac16dcef769 100644 (file)
@@ -61,28 +61,24 @@ FIRMWAREbDownload(
      PSDevice pDevice
     )
 {
+       struct device *dev = &pDevice->usb->dev;
        const struct firmware *fw;
        int NdisStatus;
        void *pBuffer = NULL;
        BOOL result = FALSE;
        u16 wLength;
-       int ii;
+       int ii, rc;
+
 
        DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->Download firmware\n");
        spin_unlock_irq(&pDevice->lock);
 
-       if (!pDevice->firmware) {
-               struct device *dev = &pDevice->usb->dev;
-               int rc;
-
-               rc = request_firmware(&pDevice->firmware, FIRMWARE_NAME, dev);
-               if (rc) {
-                       dev_err(dev, "firmware file %s request failed (%d)\n",
-                               FIRMWARE_NAME, rc);
+       rc = request_firmware(&fw, FIRMWARE_NAME, dev);
+       if (rc) {
+               dev_err(dev, "firmware file %s request failed (%d)\n",
+                       FIRMWARE_NAME, rc);
                        goto out;
-               }
        }
-       fw = pDevice->firmware;
 
        pBuffer = kmalloc(FIRMWARE_CHUNK_SIZE, GFP_KERNEL);
        if (!pBuffer)
@@ -103,10 +99,12 @@ FIRMWAREbDownload(
                DBG_PRT(MSG_LEVEL_DEBUG,
                        KERN_INFO"Download firmware...%d %zu\n", ii, fw->size);
                if (NdisStatus != STATUS_SUCCESS)
-                       goto out;
+                       goto free_fw;
         }
 
        result = TRUE;
+free_fw:
+       release_firmware(fw);
 
 out:
        kfree(pBuffer);
index ad422dea702badae6888a5d19235e1c7e39bea92..d402df9161e100e259b463cf27994bfa214568d0 100644 (file)
@@ -1219,7 +1219,6 @@ static void __devexit vt6656_disconnect(struct usb_interface *intf)
        }
 
        device_release_WPADEV(device);
-       release_firmware(device->firmware);
 
        usb_set_intfdata(intf, NULL);
        usb_put_dev(interface_to_usbdev(intf));