Skip to contentSkip to conversation

: ezusb cleanup, FX2 support, firmware downloading support

PATCH Superseded René Bürgel 3 participants 9 messages Aug 3, 2012 – Aug 24, 2012

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover : ezusb cleanup, FX2 support, firmware downloading support

Hello,

this is a patches-series for controllers using the ezusb-functions.

ezusb: remove dependency to usb_serial interface
euzsb: add support for Cypress FX2LP
ezusb: add functions for firmware download

Signature · 18 lines
René Bürgel

SOHARD Embedded Systems GmbH
Wuerzburger Str. 197
90766 Fuerth

Tel: +49 (0)911 97341-541
Fax: +49 (0)911 97341-510

Geschäftsführer: Sebastian Schnitzenbaumer, Peter Feltens
Sitz: Fürth; HRB 11482 beim Amtsgericht Fürth

USt-IdNr. DE 814982820
St-Nr. 218/137/60182
WEEE-Reg.Nr. DE 70097646

Webseite: http://www.sohard.de
Webshop: http://shop.sohard.de
#1 lore raw

Re: [PATCH 1/3]: ezusb: remove dependency to usb_serial interface

This patch removes the dependency on the usb_serial interface and names some magic constants

--

drivers/usb/serial/ezusb.c +14 -14
index 800e8eb..3048b52d 100644
@@ -9,24 +9,24 @@
  */
 
 #include <linux/kernel.h>
-#include <linux/errno.h>
 #include <linux/init.h>
 #include <linux/slab.h>
-#include <linux/tty.h>
 #include <linux/module.h>
 #include <linux/usb.h>
-#include <linux/usb/serial.h>
 
 /* EZ-USB Control and Status Register.  Bit 0 controls 8051 reset */
 #define CPUCS_REG    0x7F92
 
-int ezusb_writememory(struct usb_serial *serial, int address,
+/* Command for writing to internal memory */
+#define WRITE_INT_RAM 0xA0
+
+int ezusb_writememory(struct usb_device *dev, int address,
                 unsigned char *data, int length, __u8 request)
 {
     int result;
     unsigned char *transfer_buffer;
 
-    if (!serial->dev) {
+    if (!dev) {
         printk(KERN_ERR "ezusb: %s - no physical device present, "
                "failing.\n", __func__);
         return -ENODEV;
@@ -34,25 +34,25 @@ int ezusb_writememory(struct usb_serial *serial, int address,
 
     transfer_buffer = kmemdup(data, length, GFP_KERNEL);
     if (!transfer_buffer) {
-        dev_err(&serial->dev->dev, "%s - kmalloc(%d) failed.\n",
+        dev_err(&dev->dev, "%s - kmalloc(%d) failed.\n",
                             __func__, length);
         return -ENOMEM;
     }
-    result = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
-             request, 0x40, address, 0, transfer_buffer, length, 3000);
+    result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), request,
+                 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
+                 address, 0, transfer_buffer, length, 3000);
+
     kfree(transfer_buffer);
     return result;
 }
 EXPORT_SYMBOL_GPL(ezusb_writememory);
 
-int ezusb_set_reset(struct usb_serial *serial, unsigned char reset_bit)
+int ezusb_set_reset(struct usb_device *dev, unsigned char reset_bit)
 {
-    int response;
-
-    response = ezusb_writememory(serial, CPUCS_REG, &reset_bit, 1, 0xa0);
+    int response = ezusb_writememory(dev, CPUCS_REG, &reset_bit, 1, WRITE_INT_RAM);
     if (response < 0)
-        dev_err(&serial->dev->dev, "%s- %d failed\n",
-                        __func__, reset_bit);
+        dev_err(&dev->dev, "%s-%d failed: %d\n",
+                        __func__, reset_bit, response);
     return response;
 }
 EXPORT_SYMBOL_GPL(ezusb_set_reset);
drivers/usb/serial/keyspan.c +3 -3
index af0b70e..f0d4f3f 100644
@@ -1241,12 +1241,12 @@ static int keyspan_fake_startup(struct usb_serial *serial)
     dbg("Uploading Keyspan %s firmware.", fw_name);
 
         /* download the firmware image */
-    response = ezusb_set_reset(serial, 1);
+    response = ezusb_set_reset(serial->dev, 1);
 
     record = (const struct ihex_binrec *)fw->data;
 
     while (record) {
-        response = ezusb_writememory(serial, be32_to_cpu(record->addr),
+        response = ezusb_writememory(serial->dev, be32_to_cpu(record->addr),
                          (unsigned char *)record->data,
                          be16_to_cpu(record->len), 0xa0);
         if (response < 0) {
@@ -1260,7 +1260,7 @@ static int keyspan_fake_startup(struct usb_serial *serial)
     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_set_reset(serial, 0);
+    response = ezusb_set_reset(serial->dev, 0);
 
     /* we don't want this device to have a driver assigned to it. */
     return 1;
drivers/usb/serial/keyspan_pda.c +3 -3
index a4ac3cf..1290b6f 100644
@@ -682,7 +682,7 @@ static int keyspan_pda_fake_startup(struct usb_serial *serial)
     const struct firmware *fw;
 
     /* download the firmware here ... */
-    response = ezusb_set_reset(serial, 1);
+    response = ezusb_set_reset(serial->dev, 1);
 
     if (0) { ; }
 #ifdef KEYSPAN
@@ -707,7 +707,7 @@ static int keyspan_pda_fake_startup(struct usb_serial *serial)
     record = (const struct ihex_binrec *)fw->data;
 
     while (record) {
-        response = ezusb_writememory(serial, be32_to_cpu(record->addr),
+        response = ezusb_writememory(serial->dev, be32_to_cpu(record->addr),
                          (unsigned char *)record->data,
                          be16_to_cpu(record->len), 0xa0);
         if (response < 0) {
@@ -722,7 +722,7 @@ static int keyspan_pda_fake_startup(struct usb_serial *serial)
     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_set_reset(serial, 0);
+    response = ezusb_set_reset(serial->dev, 0);
 
     /* we want this device to fail to have a driver assigned to it. */
     return 1;
drivers/usb/serial/whiteheat.c +13 -13
index 473635e..fc72591 100644
@@ -213,13 +213,13 @@ static int whiteheat_firmware_download(struct usb_serial *serial,
         goto out;
     }
     ret = 0;
-    response = ezusb_set_reset (serial, 1);
+    response = ezusb_set_reset(serial->dev, 1);
 
     record = (const struct ihex_binrec *)loader_fw->data;
     while (record) {
-        response = ezusb_writememory (serial, be32_to_cpu(record->addr),
-                          (unsigned char *)record->data,
-                          be16_to_cpu(record->len), 0xa0);
+        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, "%s - ezusb_writememory "
                 "failed for loader (%d %04X %p %d)\n",
@@ -230,15 +230,15 @@ static int whiteheat_firmware_download(struct usb_serial *serial,
         record = ihex_next_binrec(record);
     }
 
-    response = ezusb_set_reset(serial, 0);
+    response = ezusb_set_reset(serial->dev, 0);
 
     record = (const struct ihex_binrec *)firmware_fw->data;
     while (record && be32_to_cpu(record->addr) < 0x1b40)
         record = ihex_next_binrec(record);
     while (record) {
-        response = ezusb_writememory (serial, be32_to_cpu(record->addr),
-                          (unsigned char *)record->data,
-                          be16_to_cpu(record->len), 0xa3);
+        response = ezusb_writememory(serial->dev, be32_to_cpu(record->addr),
+                         (unsigned char *)record->data,
+                         be16_to_cpu(record->len), 0xa3);
         if (response < 0) {
             dev_err(&serial->dev->dev, "%s - ezusb_writememory "
                 "failed for first firmware step "
@@ -250,13 +250,13 @@ static int whiteheat_firmware_download(struct usb_serial *serial,
         ++record;
     }
 
-    response = ezusb_set_reset(serial, 1);
+    response = ezusb_set_reset(serial->dev, 1);
 
     record = (const struct ihex_binrec *)firmware_fw->data;
     while (record && be32_to_cpu(record->addr) < 0x1b40) {
-        response = ezusb_writememory (serial, be32_to_cpu(record->addr),
-                          (unsigned char *)record->data,
-                          be16_to_cpu(record->len), 0xa0);
+        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, "%s - ezusb_writememory "
                 "failed for second firmware step "
@@ -268,7 +268,7 @@ static int whiteheat_firmware_download(struct usb_serial *serial,
         ++record;
     }
     ret = 0;
-    response = ezusb_set_reset (serial, 0);
+    response = ezusb_set_reset(serial->dev, 0);
  out:
     release_firmware(loader_fw);
     release_firmware(firmware_fw);
include/linux/usb/serial.h +0 -0
index 86c0b45..a101507 100644
@@ -301,9 +301,9 @@ extern void usb_serial_port_softint(struct usb_serial_port *port);
 extern int usb_serial_suspend(struct usb_interface *intf, pm_message_t 

message);
extern int usb_serial_resume(struct usb_interface *intf);

-extern int ezusb_writememory(struct usb_serial *serial, int address, +extern int ezusb_writememory(struct usb_device *dev, int address,

                  unsigned char *data, int length, __u8 bRequest);

-extern int ezusb_set_reset(struct usb_serial *serial, unsigned char reset_bit); +extern int ezusb_set_reset(struct usb_device *dev, unsigned char reset_bit);

/* USB Serial console functions */
#ifdef CONFIG_USB_SERIAL_CONSOLE

#2 lore raw
In reply to René Bürgel

This Patch adds support for the newer Cypress FX2LP. It also adapts three drivers currently using ezusb to the interface change. (whiteheat and keyspan[_pda])

--

drivers/usb/serial/ezusb.c +31 -6
index 3048b52d..351988d 100644
@@ -14,11 +14,25 @@
 #include <linux/module.h>
 #include <linux/usb.h>
 
-/* EZ-USB Control and Status Register.  Bit 0 controls 8051 reset */
-#define CPUCS_REG    0x7F92
+struct ezusb_fx_type {
+    /* EZ-USB Control and Status Register.  Bit 0 controls 8051 reset */
+    unsigned short cpucs_reg;
+    unsigned short max_internal_adress;
+};
 
-/* Command for writing to internal memory */
+struct ezusb_fx_type ezusb_fx1 = {
+    .cpucs_reg = 0x7F92,
+    .max_internal_adress = 0x1B3F,
+};
+
+struct ezusb_fx_type ezusb_fx2 = {
+    .cpucs_reg = 0xE600,
+    .max_internal_adress = 0x3FFF,
+};
+
+/* Commands for writing to memory */
 #define WRITE_INT_RAM 0xA0
+#define WRITE_EXT_RAM 0xA3
 
 int ezusb_writememory(struct usb_device *dev, int address,
                 unsigned char *data, int length, __u8 request)
@@ -47,13 +61,24 @@ int ezusb_writememory(struct usb_device *dev, int address,
 }
 EXPORT_SYMBOL_GPL(ezusb_writememory);
 
-int ezusb_set_reset(struct usb_device *dev, unsigned char reset_bit)
+int ezusb_set_reset(struct usb_device *dev, unsigned short cpucs_reg,
+             unsigned char reset_bit)
 {
-    int response = ezusb_writememory(dev, CPUCS_REG, &reset_bit, 1, WRITE_INT_RAM);
+    int response = ezusb_writememory(dev, cpucs_reg, &reset_bit, 1, WRITE_INT_RAM);
     if (response < 0)
         dev_err(&dev->dev, "%s-%d failed: %d\n",
                         __func__, reset_bit, response);
     return response;
 }
-EXPORT_SYMBOL_GPL(ezusb_set_reset);
 
+int ezusb_fx1_set_reset(struct usb_device *dev, unsigned char reset_bit)
+{
+    return ezusb_set_reset(dev, ezusb_fx1.cpucs_reg, reset_bit);
+}
+EXPORT_SYMBOL_GPL(ezusb_fx1_set_reset);
+
+int ezusb_fx2_set_reset(struct usb_device *dev, unsigned char reset_bit)
+{
+    return ezusb_set_reset(dev, ezusb_fx2.cpucs_reg, reset_bit);
+}
+EXPORT_SYMBOL_GPL(ezusb_fx2_set_reset);
drivers/usb/serial/keyspan.c +3 -2
index f0d4f3f..32bebde 100644
@@ -43,6 +43,7 @@
 #include <linux/uaccess.h>
 #include <linux/usb.h>
 #include <linux/usb/serial.h>
+#include <linux/usb/ezusb.h>
 #include "keyspan.h"
 
 static bool debug;
@@ -1241,7 +1242,7 @@ static int keyspan_fake_startup(struct usb_serial *serial)
     dbg("Uploading Keyspan %s firmware.", fw_name);
 
         /* download the firmware image */
-    response = ezusb_set_reset(serial->dev, 1);
+    response = ezusb_fx1_set_reset(serial->dev, 1);
 
     record = (const struct ihex_binrec *)fw->data;
 
@@ -1260,7 +1261,7 @@ static int keyspan_fake_startup(struct usb_serial *serial)
     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_set_reset(serial->dev, 0);
+    response = ezusb_fx1_set_reset(serial->dev, 0);
 
     /* we don't want this device to have a driver assigned to it. */
     return 1;
drivers/usb/serial/keyspan_pda.c +3 -2
index 1290b6f..87c5812 100644
@@ -30,6 +30,7 @@
 #include <linux/uaccess.h>
 #include <linux/usb.h>
 #include <linux/usb/serial.h>
+#include <linux/usb/ezusb.h>
 
 static bool debug;
 
@@ -682,7 +683,7 @@ static int keyspan_pda_fake_startup(struct usb_serial *serial)
     const struct firmware *fw;
 
     /* download the firmware here ... */
-    response = ezusb_set_reset(serial->dev, 1);
+    response = ezusb_fx1_set_reset(serial->dev, 1);
 
     if (0) { ; }
 #ifdef KEYSPAN
@@ -722,7 +723,7 @@ static int keyspan_pda_fake_startup(struct usb_serial *serial)
     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_set_reset(serial->dev, 0);
+    response = ezusb_fx1_set_reset(serial->dev, 0);
 
     /* we want this device to fail to have a driver assigned to it. */
     return 1;
drivers/usb/serial/whiteheat.c +5 -4
index fc72591..228eb64 100644
@@ -32,6 +32,7 @@
 #include <linux/serial_reg.h>
 #include <linux/serial.h>
 #include <linux/usb/serial.h>
+#include <linux/usb/ezusb.h>
 #include <linux/firmware.h>
 #include <linux/ihex.h>
 #include "whiteheat.h"            /* WhiteHEAT specific commands */
@@ -213,7 +214,7 @@ static int whiteheat_firmware_download(struct usb_serial *serial,
         goto out;
     }
     ret = 0;
-    response = ezusb_set_reset(serial->dev, 1);
+    response = ezusb_fx1_set_reset(serial->dev, 1);
 
     record = (const struct ihex_binrec *)loader_fw->data;
     while (record) {
@@ -230,7 +231,7 @@ static int whiteheat_firmware_download(struct usb_serial *serial,
         record = ihex_next_binrec(record);
     }
 
-    response = ezusb_set_reset(serial->dev, 0);
+    response = ezusb_fx1_set_reset(serial->dev, 0);
 
     record = (const struct ihex_binrec *)firmware_fw->data;
     while (record && be32_to_cpu(record->addr) < 0x1b40)
@@ -250,7 +251,7 @@ static int whiteheat_firmware_download(struct usb_serial *serial,
         ++record;
     }
 
-    response = ezusb_set_reset(serial->dev, 1);
+    response = ezusb_fx1_set_reset(serial->dev, 1);
 
     record = (const struct ihex_binrec *)firmware_fw->data;
     while (record && be32_to_cpu(record->addr) < 0x1b40) {
@@ -268,7 +269,7 @@ static int whiteheat_firmware_download(struct usb_serial *serial,
         ++record;
     }
     ret = 0;
-    response = ezusb_set_reset(serial->dev, 0);
+    response = ezusb_fx1_set_reset(serial->dev, 0);
  out:
     release_firmware(loader_fw);
     release_firmware(firmware_fw);
include/linux/usb/ezusb.h new file +16 -0
new file mode 100644
index 0000000..fc618d8
@@ -0,0 +1,16 @@
+#ifndef __EZUSB_H
+#define __EZUSB_H
+
+
+extern int ezusb_writememory(struct usb_device *dev, int address,
+                 unsigned char *data, int length, __u8 bRequest);
+
+extern int ezusb_fx1_set_reset(struct usb_device *dev, unsigned char reset_bit);
+extern int ezusb_fx2_set_reset(struct usb_device *dev, unsigned char reset_bit);
+
+extern int ezusb_fx1_ihex_firmware_download(struct usb_device *dev,
+                        const char *firmware_path);
+extern int ezusb_fx2_ihex_firmware_download(struct usb_device *dev,
+                        const char *firmware_path);
+
+#endif /* __EZUSB_H */
include/linux/usb/serial.h +0 -0
index a101507..588861c 100644
@@ -301,10 +301,6 @@ extern void usb_serial_port_softint(struct usb_serial_port *port);
 extern int usb_serial_suspend(struct usb_interface *intf, pm_message_t 

message);
extern int usb_serial_resume(struct usb_interface *intf);

-extern int ezusb_writememory(struct usb_device *dev, int address,
- unsigned char *data, int length, __u8 bRequest);
-extern int ezusb_set_reset(struct usb_device *dev, unsigned char reset_bit); -
/* USB Serial console functions */
#ifdef CONFIG_USB_SERIAL_CONSOLE
extern void usb_serial_console_init(int debug, int minor);

#3 lore raw
In reply to René Bürgel

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

--

drivers/usb/serial/ezusb.c +79 -0
index 351988d..867a3e1 100644
@@ -13,6 +13,8 @@
 #include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/usb.h>
+#include <linux/firmware.h>
+#include <linux/ihex.h>
 
 struct ezusb_fx_type {
     /* EZ-USB Control and Status Register.  Bit 0 controls 8051 reset */
@@ -82,3 +84,80 @@ int ezusb_fx2_set_reset(struct usb_device *dev, unsigned char reset_bit)
     return ezusb_set_reset(dev, ezusb_fx2.cpucs_reg, reset_bit);
 }
 EXPORT_SYMBOL_GPL(ezusb_fx2_set_reset);
+
+static int ezusb_ihex_firmware_download(struct usb_device *dev,
+                    struct ezusb_fx_type fx,
+                    const char *firmware_path)
+{
+    int ret = -ENOENT;
+    const struct firmware *firmware = NULL;
+    const struct ihex_binrec *record;
+
+    if (request_ihex_firmware(&firmware, firmware_path,
+                  &dev->dev)) {
+        dev_err(&dev->dev,
+            "%s - request \"%s\" failed\n",
+            __func__, firmware_path);
+        goto out;
+    }
+
+    ret = ezusb_set_reset(dev, fx.cpucs_reg, 0);
+    if (ret < 0)
+        goto out;
+
+    record = (const struct ihex_binrec *)firmware->data;
+    for (; record; record = ihex_next_binrec(record)) {
+        if (be32_to_cpu(record->addr) > fx.max_internal_adress) {
+            ret = ezusb_writememory(dev, be32_to_cpu(record->addr),
+                        (unsigned char *)record->data,
+                        be16_to_cpu(record->len), WRITE_EXT_RAM);
+            if (ret < 0) {
+                dev_err(&dev->dev, "%s - ezusb_writememory "
+                    "failed writing internal memory "
+                    "(%d %04X %p %d)\n", __func__, ret,
+                    be32_to_cpu(record->addr), record->data,
+                    be16_to_cpu(record->len));
+                goto out;
+            }
+        }
+    }
+
+    ret = ezusb_set_reset(dev, fx.cpucs_reg, 1);
+    if (ret < 0)
+        goto out;
+    record = (const struct ihex_binrec *)firmware->data;
+    for (; record; record = ihex_next_binrec(record)) {
+        if (be32_to_cpu(record->addr) <= fx.max_internal_adress) {
+            ret = ezusb_writememory(dev, be32_to_cpu(record->addr),
+                        (unsigned char *)record->data,
+                        be16_to_cpu(record->len), WRITE_INT_RAM);
+            if (ret < 0) {
+                dev_err(&dev->dev, "%s - ezusb_writememory "
+                    "failed writing external memory "
+                    "(%d %04X %p %d)\n", __func__, ret,
+                    be32_to_cpu(record->addr), record->data,
+                    be16_to_cpu(record->len));
+                goto out;
+            }
+        }
+    }
+    ret = ezusb_set_reset(dev, fx.cpucs_reg, 0);
+out:
+    release_firmware(firmware);
+    return ret;
+}
+
+int ezusb_fx1_ihex_firmware_download(struct usb_device *dev,
+                     const char *firmware_path)
+{
+    return ezusb_ihex_firmware_download(dev, ezusb_fx1, firmware_path);
+}
+EXPORT_SYMBOL_GPL(ezusb_fx1_ihex_firmware_download);
+
+int ezusb_fx2_ihex_firmware_download(struct usb_device *dev,
+                     const char *firmware_path)
+{
+    return ezusb_ihex_firmware_download(dev, ezusb_fx2, firmware_path);
+}
+EXPORT_SYMBOL_GPL(ezusb_fx2_ihex_firmware_download);
+
drivers/usb/serial/keyspan.c +8 -31
index 32bebde..523586d 100644
@@ -38,8 +38,6 @@
 #include <linux/tty_flip.h>
 #include <linux/module.h>
 #include <linux/spinlock.h>
-#include <linux/firmware.h>
-#include <linux/ihex.h>
 #include <linux/uaccess.h>
 #include <linux/usb.h>
 #include <linux/usb/serial.h>
@@ -1163,10 +1161,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;
 
     dbg("Keyspan startup version %04x product %04x",
         le16_to_cpu(serial->dev->descriptor.bcdDevice),
@@ -1234,34 +1229,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;
-    }
-
     dbg("Uploading Keyspan %s firmware.", 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;
drivers/usb/serial/keyspan_pda.c +5 -24
index 87c5812..bf0bb37 100644
@@ -25,8 +25,6 @@
 #include <linux/module.h>
 #include <linux/spinlock.h>
 #include <linux/workqueue.h>
-#include <linux/firmware.h>
-#include <linux/ihex.h>
 #include <linux/uaccess.h>
 #include <linux/usb.h>
 #include <linux/usb/serial.h>
@@ -679,8 +677,6 @@ static int keyspan_pda_fake_startup(struct usb_serial *serial)
 {
     int response;
     const char *fw_name;
-    const struct ihex_binrec *record;
-    const struct firmware *fw;
 
     /* download the firmware here ... */
     response = ezusb_fx1_set_reset(serial->dev, 1);
@@ -700,30 +696,15 @@ static int keyspan_pda_fake_startup(struct usb_serial *serial)
             __func__);
         return -ENODEV;
     }
-    if (request_ihex_firmware(&fw, fw_name, &serial->dev->dev)) {
+
+    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;
     }
-    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 PDA 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);
-    }
-    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 want this device to fail to have a driver assigned to it. */
     return 1;
drivers/usb/serial/whiteheat.c +7 -78

97 lines not on this page · raw message

#4 lore raw
In reply to René Bürgel
Quoted 7 lines · René Bürgel

Hello,

this is a patches-series for controllers using the ezusb-functions.

ezusb: remove dependency to usb_serial interface
euzsb: add support for Cypress FX2LP
ezusb: add functions for firmware download

Nice series, but your patches are white-space damaged, and I can't apply them at all.

Also, your third patch has the wrong Subject: line :(

Care to resend them in a format that I can apply them in?

thanks,

greg k-h

#5 lore raw

----- Ursprüngliche Mail -----

Quoted 13 lines · René Bürgel
Quoted 7 lines

Hello,

this is a patches-series for controllers using the ezusb-functions.

ezusb: remove dependency to usb_serial interface
euzsb: add support for Cypress FX2LP
ezusb: add functions for firmware download

Nice series, but your patches are white-space damaged, and I can't apply
them at all.

Quoted 8 lines

Also, your third patch has the wrong Subject: line

Care to resend them in a format that I can apply them in?

thanks,

greg k-h

Thanks for reviewing it.

I will check my email-settings and resend the patches.

I'm sorry about the wrong Subject line, this will be corrected when resending.

I got some further questions:
- Although i removed the dependency from ezusb to usb_serial, ezusb.c still resides in drivers/usb/serial.
Can you give me a hint, where to put it instead?
I would like to do that with an additional patch.
- is it fine to base the soon-to-be-resent patches on 3.6-rc2?

René Bürgel

maintainer
#6 lore raw
Quoted 27 lines · Rene Buergel

----- Ursprüngliche Mail -----

Quoted 13 lines · René Bürgel
Quoted 7 lines

Hello,

this is a patches-series for controllers using the ezusb-functions.

ezusb: remove dependency to usb_serial interface
euzsb: add support for Cypress FX2LP
ezusb: add functions for firmware download

Nice series, but your patches are white-space damaged, and I can't apply
them at all.

Quoted 8 lines

Also, your third patch has the wrong Subject: line

Care to resend them in a format that I can apply them in?

thanks,

greg k-h

Thanks for reviewing it.

I will check my email-settings and resend the patches.

Quoted 7 lines

I'm sorry about the wrong Subject line, this will be corrected when resending.

I got some further questions:
- Although i removed the dependency from ezusb to usb_serial, ezusb.c still resides in drivers/usb/serial.
Can you give me a hint, where to put it instead? I would like to do that with an additional patch.

Why do you want to move it?

Quoted 1 line

- is it fine to base the soon-to-be-resent patches on 3.6-rc2?

You should redo them against the linux-next tree, which has many more patches than 3.6-rc2.

greg k-h

#7 lore raw
Quoted 7 lines
Quoted 5 lines

- Although i removed the dependency from ezusb to usb_serial, ezusb.c still resides in drivers/usb/serial.
Can you give me a hint, where to put it instead? I would like to do that with an additional patch.

Why do you want to move it?

because is has nothing to do with any serial stuff anymore...

Quoted 5 lines
Quoted 2 lines

- is it fine to base the soon-to-be-resent patches on 3.6-rc2?

You should redo them against the linux-next tree, which has many more patches than 3.6-rc2.

ok, thanks!

Quoted 3 lines

greg k-h

René Bürgel

maintainer
#8 lore raw
Quoted 9 lines · Rene Buergel
Quoted 7 lines
Quoted 5 lines

- Although i removed the dependency from ezusb to usb_serial, ezusb.c still resides in drivers/usb/serial.
Can you give me a hint, where to put it instead? I would like to do that with an additional patch.

Why do you want to move it?

because is has nothing to do with any serial stuff anymore...

Fair enough, how about drivers/usb/misc/ instead?

greg k-h