From f9eb8a3b141350f1f6525142d23fb8fb2131011b Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 20 May 2013 14:28:29 -0700 Subject: [PATCH] staging: comedi: usbduxfast: use comedi_load_firmware() Use comedi_load_firmware() instead of duplicating the code in a private function. Signed-off-by: H Hartley Sweeten Cc Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbduxfast.c | 40 +++++---------------- 1 file changed, 9 insertions(+), 31 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbduxfast.c b/drivers/staging/comedi/drivers/usbduxfast.c index f4546b3c4d6d..27898c44e543 100644 --- a/drivers/staging/comedi/drivers/usbduxfast.c +++ b/drivers/staging/comedi/drivers/usbduxfast.c @@ -36,7 +36,6 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include -#include #include #include #include @@ -978,23 +977,24 @@ static int usbduxfast_attach_common(struct comedi_device *dev) } static int usbduxfast_upload_firmware(struct comedi_device *dev, - const struct firmware *fw) + const u8 *data, size_t size, + unsigned long context) { struct usb_device *usb = comedi_to_usb_dev(dev); uint8_t *buf; unsigned char *tmp; int ret; - if (!fw->data) + if (!data) return 0; - if (fw->size > FIRMWARE_MAX_LEN) { + if (size > FIRMWARE_MAX_LEN) { dev_err(dev->class_dev, "firmware binary too large for FX2\n"); return -ENOMEM; } /* we generate a local buffer for the firmware */ - buf = kmemdup(fw->data, fw->size, GFP_KERNEL); + buf = kmemdup(data, size, GFP_KERNEL); if (!buf) return -ENOMEM; @@ -1023,7 +1023,7 @@ static int usbduxfast_upload_firmware(struct comedi_device *dev, USBDUXFASTSUB_FIRMWARE, VENDOR_DIR_OUT, 0, 0x0000, - buf, fw->size, + buf, size, EZTIMEOUT); if (ret < 0) { dev_err(dev->class_dev, "firmware upload failed\n"); @@ -1047,22 +1047,6 @@ done: return ret; } -static int usbduxfast_request_firmware(struct comedi_device *dev) -{ - struct usb_device *usb = comedi_to_usb_dev(dev); - const struct firmware *fw; - int ret; - - ret = request_firmware(&fw, FIRMWARE, &usb->dev); - if (ret) - return ret; - - ret = usbduxfast_upload_firmware(dev, fw); - release_firmware(fw); - - return ret; -} - static int usbduxfast_auto_attach(struct comedi_device *dev, unsigned long context_unused) { @@ -1107,16 +1091,10 @@ static int usbduxfast_auto_attach(struct comedi_device *dev, if (!devpriv->inbuf) return -ENOMEM; - /* - * Request, and upload, the firmware so we can - * complete the comedi_driver (*auto_attach). - */ - ret = usbduxfast_request_firmware(dev); - if (ret) { - dev_err(dev->class_dev, "could not load firmware (err=%d)\n", - ret); + ret = comedi_load_firmware(dev, &usb->dev, FIRMWARE, + usbduxfast_upload_firmware, 0); + if (ret) return ret; - } return usbduxfast_attach_common(dev); } -- 2.20.1