]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
staging: comedi: usbdux: move firmware request/upload into (*auto_attach)
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Mon, 20 May 2013 21:30:04 +0000 (14:30 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 21 May 2013 17:59:11 +0000 (10:59 -0700)
The last step the usb_driver (*probe) does before handing off to the
comedi_driver (*auto_attach) is requesting and uploading the firmware.

Move the request/upload into the (*auto_attach) so we can use the
comedi_load_firmware() helper.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/comedi/drivers/usbdux.c

index 405a345149035041765cb41bc7bc2730039041a3..59a2046dc86e80d62923b261915f356a21402c46 100644 (file)
@@ -2249,13 +2249,22 @@ static int usbdux_auto_attach(struct comedi_device *dev,
                              unsigned long context_unused)
 {
        struct usb_interface *uinterf = comedi_to_usb_interface(dev);
+       struct usbduxsub *this_usbduxsub = usb_get_intfdata(uinterf);
+       struct usb_device *usb = usbduxsub->usbdev;
+       const struct firmware *fw;
        int ret;
-       struct usbduxsub *this_usbduxsub;
+
+       ret = request_firmware(&fw, FIRMWARE, &usb->dev);
+       if (ret == 0) {
+               ret = firmware_upload(this_usbduxsub, fw->data, fw->size);
+               release_firmware(fw);
+       }
+       if (ret < 0)
+               return ret;
 
        dev->private = NULL;
 
        down(&start_stop_sem);
-       this_usbduxsub = usb_get_intfdata(uinterf);
        if (!this_usbduxsub || !this_usbduxsub->probed) {
                dev_err(dev->class_dev,
                        "usbdux: error: auto_attach failed, not connected\n");
@@ -2295,10 +2304,8 @@ static int usbdux_usb_probe(struct usb_interface *uinterf,
 {
        struct usb_device *udev = interface_to_usbdev(uinterf);
        struct device *dev = &uinterf->dev;
-       const struct firmware *fw;
        int i;
        int index;
-       int ret;
 
        dev_dbg(dev, "comedi_: usbdux_: "
                "finding a free structure for the usb-device\n");
@@ -2515,14 +2522,6 @@ static int usbdux_usb_probe(struct usb_interface *uinterf,
        usbduxsub[index].probed = 1;
        up(&start_stop_sem);
 
-       ret = request_firmware(&fw, FIRMWARE, &udev->dev);
-       if (ret == 0) {
-               ret = firmware_upload(&usbduxsub[index], fw->data, fw->size);
-               release_firmware(fw);
-       }
-       if (ret < 0)
-               return ret;
-
        return comedi_usb_auto_config(uinterf, &usbdux_driver, 0);
 }