[PATCH 14/15] staging: comedi: usbduxsigma: move firmware request/upload into (*auto_attach)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxxxxxx>
Cc Ian Abbott <abbotti@xxxxxxxxx>
Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
---
 drivers/staging/comedi/drivers/usbduxsigma.c | 26 ++++++++++++--------------
 1 file changed, 12 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/comedi/drivers/usbduxsigma.c b/drivers/staging/comedi/drivers/usbduxsigma.c
index 15c5bd1..26357b9 100644
--- a/drivers/staging/comedi/drivers/usbduxsigma.c
+++ b/drivers/staging/comedi/drivers/usbduxsigma.c
@@ -2234,12 +2234,22 @@ static int usbduxsigma_auto_attach(struct comedi_device *dev,
 				   unsigned long context_unused)
 {
 	struct usb_interface *uinterf = comedi_to_usb_interface(dev);
+	struct usbduxsub *uds = usb_get_intfdata(uinterf);
+	struct usb_device *usb = uds->usbdev;
+	const struct firmware *fw;
 	int ret;
-	struct usbduxsub *uds;
+
+	ret = request_firmware(&fw, FIRMWARE, &usb->dev);
+	if (ret == 0) {
+		ret = firmwareUpload(uds, fw->data, fw->size);
+		release_firmware(fw);
+	}
+	if (ret < 0)
+		return ret;
 
 	dev->private = NULL;
+
 	down(&start_stop_sem);
-	uds = usb_get_intfdata(uinterf);
 	if (!uds || !uds->probed) {
 		dev_err(dev->class_dev,
 			"usbduxsigma: error: auto_attach failed, not connected\n");
@@ -2279,10 +2289,8 @@ static int usbduxsigma_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");
@@ -2500,16 +2508,6 @@ static int usbduxsigma_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 = firmwareUpload(&usbduxsub[index], fw->data, fw->size);
-		release_firmware(fw);
-	}
-	if (ret) {
-		dev_err(dev, "Could not load firmware (err=%d)\n", ret);
-		return ret;
-	}
-
 	return comedi_usb_auto_config(uinterf, &usbduxsigma_driver, 0);;
 }
 
-- 
1.8.1.4

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/devel




[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux