Skip to content

Commit

Permalink
staging: comedi: usbdux: move firmware request/upload into (*auto_att…
Browse files Browse the repository at this point in the history
…ach)

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 <[email protected]>
Cc Ian Abbott <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
bigguiness authored and gregkh committed May 21, 2013
1 parent 4bf6bfe commit 997beda
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions drivers/staging/comedi/drivers/usbdux.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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);
}

Expand Down

0 comments on commit 997beda

Please sign in to comment.