Staging: comedi: jr3_pci: Use struct device from pci_dev for firmware loading.
authorFrank Mori Hess <fmhess@users.sourceforge.net>
Tue, 14 Apr 2009 16:59:47 +0000 (12:59 -0400)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 19 Jun 2009 18:00:31 +0000 (11:00 -0700)
Signed-off-by: Frank Mori Hess <fmhess@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/staging/comedi/drivers/jr3_pci.c

index ec5d9184f6a199f2f5912a7ff0fbfba47e375d20..c360492159b2206f36d8e80fc85a11f97cf141af 100644 (file)
@@ -48,55 +48,6 @@ Devices: [JR3] PCI force sensor board (jr3_pci)
 #include "comedi_pci.h"
 #include "jr3_pci.h"
 
-/* Hotplug firmware loading stuff */
-
-static void comedi_fw_release(struct device *dev)
-{
-       printk(KERN_DEBUG "firmware_sample_driver: ghost_release\n");
-}
-
-static struct device comedi_fw_device = {
-       .init_name = "comedi",
-       .release = comedi_fw_release
-};
-
-typedef int comedi_firmware_callback(struct comedi_device * dev,
-       const u8 * data, size_t size);
-
-static int comedi_load_firmware(struct comedi_device * dev,
-       char *name, comedi_firmware_callback cb)
-{
-       int result = 0;
-       const struct firmware *fw;
-       char *firmware_path;
-       static const char *prefix = "comedi/";
-
-       firmware_path = kmalloc(strlen(prefix) + strlen(name) + 1, GFP_KERNEL);
-       if (!firmware_path) {
-               result = -ENOMEM;
-       } else {
-               firmware_path[0] = '\0';
-               strcat(firmware_path, prefix);
-               strcat(firmware_path, name);
-               result = device_register(&comedi_fw_device);
-               if (result == 0) {
-                       result = request_firmware(&fw, firmware_path,
-                               &comedi_fw_device);
-                       if (result == 0) {
-                               if (!cb) {
-                                       result = -EINVAL;
-                               } else {
-                                       result = cb(dev, fw->data, fw->size);
-                               }
-                               release_firmware(fw);
-                       }
-                       device_unregister(&comedi_fw_device);
-               }
-               kfree(firmware_path);
-       }
-       return result;
-}
-
 #define PCI_VENDOR_ID_JR3 0x1762
 #define PCI_DEVICE_ID_JR3_1_CHANNEL 0x3111
 #define PCI_DEVICE_ID_JR3_2_CHANNEL 0x3112
@@ -168,6 +119,41 @@ struct jr3_pci_subdev_private {
        int retries;
 };
 
+/* Hotplug firmware loading stuff */
+
+typedef int comedi_firmware_callback(struct comedi_device *dev,
+                                    const u8 *data, size_t size);
+
+static int comedi_load_firmware(struct comedi_device *dev, char *name,
+                               comedi_firmware_callback cb)
+{
+       int result = 0;
+       const struct firmware *fw;
+       char *firmware_path;
+       static const char *prefix = "comedi/";
+       struct jr3_pci_dev_private *devpriv = dev->private;
+
+       firmware_path = kmalloc(strlen(prefix) + strlen(name) + 1, GFP_KERNEL);
+       if (!firmware_path) {
+               result = -ENOMEM;
+       } else {
+               firmware_path[0] = '\0';
+               strcat(firmware_path, prefix);
+               strcat(firmware_path, name);
+               result = request_firmware(&fw, firmware_path,
+                       &devpriv->pci_dev->dev);
+               if (result == 0) {
+                       if (!cb)
+                               result = -EINVAL;
+                       else
+                               result = cb(dev, fw->data, fw->size);
+                       release_firmware(fw);
+               }
+               kfree(firmware_path);
+       }
+       return result;
+}
+
 static struct poll_delay_t poll_delay_min_max(int min, int max)
 {
        struct poll_delay_t result;