From 8d733e26c076f47e7774c0e5baa74c9b1c01199a Mon Sep 17 00:00:00 2001 From: Rene Buergel Date: Tue, 18 Sep 2012 09:02:01 +0200 Subject: USB: ezusb: add functions for firmware download MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch adds new functions to upload firmware to the controller. The drivers currently using ezusb are adapted to use these new functions. This also fixes a bug occuring during firmware loading in the whiteheat-driver: The driver iterates over an ihex-formatted firmware using ++ on a "const struct ihex_binrec*" which leads to faulty results, because ihex data is read as length. The function "ihex_next_binrec(record)" has so be used to work correctly Signed-off-by: René Bürgel Signed-off-by: Greg Kroah-Hartman --- drivers/usb/serial/keyspan.c | 39 ++++++++------------------------------- 1 file changed, 8 insertions(+), 31 deletions(-) (limited to 'drivers/usb/serial/keyspan.c') diff --git a/drivers/usb/serial/keyspan.c b/drivers/usb/serial/keyspan.c index 4f25849d343e..0acb07131f6e 100644 --- a/drivers/usb/serial/keyspan.c +++ b/drivers/usb/serial/keyspan.c @@ -38,8 +38,6 @@ #include #include #include -#include -#include #include #include #include @@ -1167,10 +1165,7 @@ static void keyspan_close(struct usb_serial_port *port) /* download the firmware to a pre-renumeration device */ static int keyspan_fake_startup(struct usb_serial *serial) { - int response; - const struct ihex_binrec *record; - char *fw_name; - const struct firmware *fw; + char *fw_name; dev_dbg(&serial->dev->dev, "Keyspan startup version %04x product %04x\n", le16_to_cpu(serial->dev->descriptor.bcdDevice), @@ -1238,34 +1233,16 @@ static int keyspan_fake_startup(struct usb_serial *serial) return 1; } - if (request_ihex_firmware(&fw, fw_name, &serial->dev->dev)) { - dev_err(&serial->dev->dev, "Required keyspan firmware image (%s) unavailable.\n", fw_name); - return 1; - } - dev_dbg(&serial->dev->dev, "Uploading Keyspan %s firmware.\n", fw_name); - /* download the firmware image */ - response = ezusb_fx1_set_reset(serial->dev, 1); - - record = (const struct ihex_binrec *)fw->data; - - while (record) { - response = ezusb_writememory(serial->dev, be32_to_cpu(record->addr), - (unsigned char *)record->data, - be16_to_cpu(record->len), 0xa0); - if (response < 0) { - dev_err(&serial->dev->dev, "ezusb_writememory failed for Keyspan firmware (%d %04X %p %d)\n", - response, be32_to_cpu(record->addr), - record->data, be16_to_cpu(record->len)); - break; - } - record = ihex_next_binrec(record); + if (ezusb_fx1_ihex_firmware_download(serial->dev, fw_name) < 0) { + dev_err(&serial->dev->dev, "failed to load firmware \"%s\"\n", + fw_name); + return -ENOENT; } - release_firmware(fw); - /* bring device out of reset. Renumeration will occur in a - moment and the new device will bind to the real driver */ - response = ezusb_fx1_set_reset(serial->dev, 0); + + /* after downloading firmware Renumeration will occur in a + moment and the new device will bind to the real driver */ /* we don't want this device to have a driver assigned to it. */ return 1; -- cgit v1.2.3