linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/4]: ezusb cleanup, FX2 support, firmware downloading support
       [not found] <785f10f2-79bc-4708-9c57-7b505d75f223@shmail0>
@ 2012-09-13 20:12 ` Rene Buergel
  2012-09-13 20:14   ` [PATCH v2 1/4]: " Rene Buergel
                     ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Rene Buergel @ 2012-09-13 20:12 UTC (permalink / raw)
  To: linux-usb, linux-kernel

Hello,

this is V2 of 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
ezusb: move ezusb.c from drivers/usb/serial to drivers/usb/misc

--
René Bürgel

SOHARD Embedded Systems GmbH

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH v2 1/4]: ezusb cleanup, FX2 support, firmware downloading support
  2012-09-13 20:12 ` [PATCH v2 0/4]: ezusb cleanup, FX2 support, firmware downloading support Rene Buergel
@ 2012-09-13 20:14   ` Rene Buergel
  2012-09-13 20:15   ` [PATCH v2 2/4]: add support for Cypress FX2LP Rene Buergel
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 10+ messages in thread
From: Rene Buergel @ 2012-09-13 20:14 UTC (permalink / raw)
  To: linux-usb, linux-kernel

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

Signed-off-by: René Bürgel <rene.buergel@sohard.de>
--
diff --git a/drivers/usb/serial/ezusb.c b/drivers/usb/serial/ezusb.c
index 800e8eb..3048b52d 100644
--- a/drivers/usb/serial/ezusb.c
+++ b/drivers/usb/serial/ezusb.c
@@ -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);
diff --git a/drivers/usb/serial/keyspan.c b/drivers/usb/serial/keyspan.c
index af0b70e..f0d4f3f 100644
--- a/drivers/usb/serial/keyspan.c
+++ b/drivers/usb/serial/keyspan.c
@@ -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;
diff --git a/drivers/usb/serial/keyspan_pda.c b/drivers/usb/serial/keyspan_pda.c
index a4ac3cf..1290b6f 100644
--- a/drivers/usb/serial/keyspan_pda.c
+++ b/drivers/usb/serial/keyspan_pda.c
@@ -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;
diff --git a/drivers/usb/serial/whiteheat.c b/drivers/usb/serial/whiteheat.c
index 473635e..fc72591 100644
--- a/drivers/usb/serial/whiteheat.c
+++ b/drivers/usb/serial/whiteheat.c
@@ -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);
diff --git a/include/linux/usb/serial.h b/include/linux/usb/serial.h
index 86c0b45..a101507 100644
--- a/include/linux/usb/serial.h
+++ b/include/linux/usb/serial.h
@@ -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

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH v2 2/4]: add support for Cypress FX2LP
  2012-09-13 20:12 ` [PATCH v2 0/4]: ezusb cleanup, FX2 support, firmware downloading support Rene Buergel
  2012-09-13 20:14   ` [PATCH v2 1/4]: " Rene Buergel
@ 2012-09-13 20:15   ` Rene Buergel
  2012-09-14  5:01     ` Greg KH
  2012-09-13 20:17   ` [PATCH v2 3/4]: add functions for firmware download Rene Buergel
  2012-09-13 20:19   ` [PATCH v2 4/4]: ezusb: move ezusb.c from drivers/usb/serial to drivers/usb/misc Rene Buergel
  3 siblings, 1 reply; 10+ messages in thread
From: Rene Buergel @ 2012-09-13 20:15 UTC (permalink / raw)
  To: linux-usb, linux-kernel

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])

Signed-off-by: René Bürgel <rene.buergel@...>
--
diff --git a/drivers/usb/serial/ezusb.c b/drivers/usb/serial/ezusb.c
index 3048b52d..351988d 100644
--- a/drivers/usb/serial/ezusb.c
+++ b/drivers/usb/serial/ezusb.c
@@ -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);
diff --git a/drivers/usb/serial/keyspan.c b/drivers/usb/serial/keyspan.c
index f0d4f3f..32bebde 100644
--- a/drivers/usb/serial/keyspan.c
+++ b/drivers/usb/serial/keyspan.c
@@ -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;
diff --git a/drivers/usb/serial/keyspan_pda.c b/drivers/usb/serial/keyspan_pda.c
index 1290b6f..87c5812 100644
--- a/drivers/usb/serial/keyspan_pda.c
+++ b/drivers/usb/serial/keyspan_pda.c
@@ -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;
diff --git a/drivers/usb/serial/whiteheat.c b/drivers/usb/serial/whiteheat.c
index fc72591..228eb64 100644
--- a/drivers/usb/serial/whiteheat.c
+++ b/drivers/usb/serial/whiteheat.c
@@ -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);
diff --git a/include/linux/usb/ezusb.h b/include/linux/usb/ezusb.h
new file mode 100644
index 0000000..fc618d8
--- /dev/null
+++ b/include/linux/usb/ezusb.h
@@ -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 */
diff --git a/include/linux/usb/serial.h b/include/linux/usb/serial.h
index a101507..588861c 100644
--- a/include/linux/usb/serial.h
+++ b/include/linux/usb/serial.h
@@ -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);

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 3/4]: add functions for firmware download
  2012-09-13 20:12 ` [PATCH v2 0/4]: ezusb cleanup, FX2 support, firmware downloading support Rene Buergel
  2012-09-13 20:14   ` [PATCH v2 1/4]: " Rene Buergel
  2012-09-13 20:15   ` [PATCH v2 2/4]: add support for Cypress FX2LP Rene Buergel
@ 2012-09-13 20:17   ` Rene Buergel
  2012-09-13 20:19   ` [PATCH v2 4/4]: ezusb: move ezusb.c from drivers/usb/serial to drivers/usb/misc Rene Buergel
  3 siblings, 0 replies; 10+ messages in thread
From: Rene Buergel @ 2012-09-13 20:17 UTC (permalink / raw)
  To: linux-usb, linux-kernel

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 <rene.buergel@sohard.de>
--
diff --git a/drivers/usb/serial/ezusb.c b/drivers/usb/serial/ezusb.c
index 351988d..867a3e1 100644
--- a/drivers/usb/serial/ezusb.c
+++ b/drivers/usb/serial/ezusb.c
@@ -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);
+
diff --git a/drivers/usb/serial/keyspan.c b/drivers/usb/serial/keyspan.c
index 32bebde..523586d 100644
--- a/drivers/usb/serial/keyspan.c
+++ b/drivers/usb/serial/keyspan.c
@@ -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;
diff --git a/drivers/usb/serial/keyspan_pda.c b/drivers/usb/serial/keyspan_pda.c
index 87c5812..bf0bb37 100644
--- a/drivers/usb/serial/keyspan_pda.c
+++ b/drivers/usb/serial/keyspan_pda.c
@@ -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;
diff --git a/drivers/usb/serial/whiteheat.c b/drivers/usb/serial/whiteheat.c
index b34665c..a9ad0c5 100644
--- a/drivers/usb/serial/whiteheat.c
+++ b/drivers/usb/serial/whiteheat.c
@@ -33,8 +33,6 @@
 #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 */
 
 static bool debug;
@@ -196,84 +194,15 @@ static int firm_report_tx_done(struct usb_serial_port *port);
 static int whiteheat_firmware_download(struct usb_serial *serial,
 					const struct usb_device_id *id)
 {
-	int response, ret = -ENOENT;
-	const struct firmware *loader_fw = NULL, *firmware_fw = NULL;
-	const struct ihex_binrec *record;
+	int response;
 
-	if (request_ihex_firmware(&firmware_fw, "whiteheat.fw",
-				  &serial->dev->dev)) {
-		dev_err(&serial->dev->dev,
-			"%s - request \"whiteheat.fw\" failed\n", __func__);
-		goto out;
-	}
-	if (request_ihex_firmware(&loader_fw, "whiteheat_loader.fw",
-			     &serial->dev->dev)) {
-		dev_err(&serial->dev->dev,
-			"%s - request \"whiteheat_loader.fw\" failed\n",
-			__func__);
-		goto out;
-	}
-	ret = 0;
-	response = ezusb_fx1_set_reset(serial->dev, 1);
-
-	record = (const struct ihex_binrec *)loader_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, "%s - ezusb_writememory "
-				"failed for loader (%d %04X %p %d)\n",
-				__func__, response, be32_to_cpu(record->addr),
-				record->data, be16_to_cpu(record->len));
-			break;
-		}
-		record = ihex_next_binrec(record);
-	}
-
-	response = ezusb_fx1_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->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 "
-				"(%d %04X %p %d)\n", __func__, response,
-				be32_to_cpu(record->addr), record->data,
-				be16_to_cpu(record->len));
-			break;
-		}
-		++record;
-	}
-
-	response = ezusb_fx1_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->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 "
-				"(%d %04X %p %d)\n", __func__, response,
-				be32_to_cpu(record->addr), record->data,
-				be16_to_cpu(record->len));
-			break;
-		}
-		++record;
+	response = ezusb_fx1_ihex_firmware_download(serial->dev, "whiteheat_loader.fw");
+	if (response >= 0) {
+		response = ezusb_fx1_ihex_firmware_download(serial->dev, "whiteheat.fw");
+		if (response >= 0)
+			return 0;
 	}
-	ret = 0;
-	response = ezusb_fx1_set_reset(serial->dev, 0);
- out:
-	release_firmware(loader_fw);
-	release_firmware(firmware_fw);
-	return ret;
+	return -ENOENT;
 }
 
 

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 4/4]: ezusb: move ezusb.c from drivers/usb/serial to drivers/usb/misc
  2012-09-13 20:12 ` [PATCH v2 0/4]: ezusb cleanup, FX2 support, firmware downloading support Rene Buergel
                     ` (2 preceding siblings ...)
  2012-09-13 20:17   ` [PATCH v2 3/4]: add functions for firmware download Rene Buergel
@ 2012-09-13 20:19   ` Rene Buergel
  2012-09-14  5:03     ` Greg KH
  3 siblings, 1 reply; 10+ messages in thread
From: Rene Buergel @ 2012-09-13 20:19 UTC (permalink / raw)
  To: linux-usb, linux-kernel

This patch moves drivers/usb/serial/ezusb.c to drivers/usb/misc/and
adapts Makefiles and Kconfigs

Signed-off-by: René Bürgel <rene.buergel@sohard.de>
--
diff --git a/drivers/usb/misc/Kconfig b/drivers/usb/misc/Kconfig
index 1bfcd02..1c63b54 100644
--- a/drivers/usb/misc/Kconfig
+++ b/drivers/usb/misc/Kconfig
@@ -244,3 +244,7 @@ config USB_YUREX
 	  To compile this driver as a module, choose M here: the
 	  module will be called yurex.
 
+config USB_EZUSB
+	bool "Functions for loading firmware on EZUSB chips"
+	help
+	    Say Y here if you need EZUSB device support.
diff --git a/drivers/usb/misc/Makefile b/drivers/usb/misc/Makefile
index 796ce7e..f1f7815 100644
--- a/drivers/usb/misc/Makefile
+++ b/drivers/usb/misc/Makefile
@@ -11,6 +11,7 @@ obj-$(CONFIG_USB_CYPRESS_CY7C63)	+= cypress_cy7c63.o
 obj-$(CONFIG_USB_CYTHERM)		+= cytherm.o
 obj-$(CONFIG_USB_EMI26)			+= emi26.o
 obj-$(CONFIG_USB_EMI62)			+= emi62.o
+obj-$(CONFIG_USB_EZUSB)			+= ezusb.o
 obj-$(CONFIG_USB_FTDI_ELAN)		+= ftdi-elan.o
 obj-$(CONFIG_USB_IDMOUSE)		+= idmouse.o
 obj-$(CONFIG_USB_IOWARRIOR)		+= iowarrior.o
diff --git a/drivers/usb/misc/ezusb.c b/drivers/usb/misc/ezusb.c
new file mode 100644
index 0000000..867a3e1
--- /dev/null
+++ b/drivers/usb/misc/ezusb.c
@@ -0,0 +1,163 @@
+/*
+ * EZ-USB specific functions used by some of the USB to Serial drivers.
+ *
+ * Copyright (C) 1999 - 2002 Greg Kroah-Hartman (greg@kroah.com)
+ *
+ *	This program is free software; you can redistribute it and/or
+ *	modify it under the terms of the GNU General Public License version
+ *	2 as published by the Free Software Foundation.
+ */
+
+#include <linux/kernel.h>
+#include <linux/init.h>
+#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 */
+	unsigned short cpucs_reg;
+	unsigned short max_internal_adress;
+};
+
+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)
+{
+	int result;
+	unsigned char *transfer_buffer;
+
+	if (!dev) {
+		printk(KERN_ERR "ezusb: %s - no physical device present, "
+		       "failing.\n", __func__);
+		return -ENODEV;
+	}
+
+	transfer_buffer = kmemdup(data, length, GFP_KERNEL);
+	if (!transfer_buffer) {
+		dev_err(&dev->dev, "%s - kmalloc(%d) failed.\n",
+							__func__, length);
+		return -ENOMEM;
+	}
+	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_device *dev, unsigned short cpucs_reg,
+			 unsigned char reset_bit)
+{
+	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;
+}
+
+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);
+
+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);
+
diff --git a/drivers/usb/serial/Kconfig b/drivers/usb/serial/Kconfig
index 325d291..73b5e6f 100644
--- a/drivers/usb/serial/Kconfig
+++ b/drivers/usb/serial/Kconfig
@@ -42,11 +42,6 @@ config USB_SERIAL_CONSOLE
 
 	  If unsure, say N.
 
-config USB_EZUSB
-	bool "Functions for loading firmware on EZUSB chips"
-	help
-	    Say Y here if you need EZUSB device support.
-
 config USB_SERIAL_GENERIC
 	bool "USB Generic Serial Driver"
 	help
diff --git a/drivers/usb/serial/Makefile b/drivers/usb/serial/Makefile
index 1dc483a..12b56bb 100644
--- a/drivers/usb/serial/Makefile
+++ b/drivers/usb/serial/Makefile
@@ -9,7 +9,6 @@ obj-$(CONFIG_USB_SERIAL)			+= usbserial.o
 usbserial-y := usb-serial.o generic.o bus.o
 
 usbserial-$(CONFIG_USB_SERIAL_CONSOLE)	+= console.o
-usbserial-$(CONFIG_USB_EZUSB)		+= ezusb.o
 
 obj-$(CONFIG_USB_SERIAL_AIRCABLE)		+= aircable.o
 obj-$(CONFIG_USB_SERIAL_ARK3116)		+= ark3116.o
diff --git a/drivers/usb/serial/ezusb.c b/drivers/usb/serial/ezusb.c
deleted file mode 100644
index 867a3e1..0000000
--- a/drivers/usb/serial/ezusb.c
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- * EZ-USB specific functions used by some of the USB to Serial drivers.
- *
- * Copyright (C) 1999 - 2002 Greg Kroah-Hartman (greg@kroah.com)
- *
- *	This program is free software; you can redistribute it and/or
- *	modify it under the terms of the GNU General Public License version
- *	2 as published by the Free Software Foundation.
- */
-
-#include <linux/kernel.h>
-#include <linux/init.h>
-#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 */
-	unsigned short cpucs_reg;
-	unsigned short max_internal_adress;
-};
-
-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)
-{
-	int result;
-	unsigned char *transfer_buffer;
-
-	if (!dev) {
-		printk(KERN_ERR "ezusb: %s - no physical device present, "
-		       "failing.\n", __func__);
-		return -ENODEV;
-	}
-
-	transfer_buffer = kmemdup(data, length, GFP_KERNEL);
-	if (!transfer_buffer) {
-		dev_err(&dev->dev, "%s - kmalloc(%d) failed.\n",
-							__func__, length);
-		return -ENOMEM;
-	}
-	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_device *dev, unsigned short cpucs_reg,
-			 unsigned char reset_bit)
-{
-	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;
-}
-
-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);
-
-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);
-

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 2/4]: add support for Cypress FX2LP
  2012-09-13 20:15   ` [PATCH v2 2/4]: add support for Cypress FX2LP Rene Buergel
@ 2012-09-14  5:01     ` Greg KH
  0 siblings, 0 replies; 10+ messages in thread
From: Greg KH @ 2012-09-14  5:01 UTC (permalink / raw)
  To: Rene Buergel; +Cc: linux-usb, linux-kernel

On Thu, Sep 13, 2012 at 10:15:47PM +0200, Rene Buergel wrote:
> 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])
> 
> Signed-off-by: René Bürgel <rene.buergel@...>
> --

Shouldn't this be 3 '-' characters?

Also, you forgot to put your email address in here :(

Care to resend this, and the two after it?  I took the first one.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 4/4]: ezusb: move ezusb.c from drivers/usb/serial to drivers/usb/misc
  2012-09-13 20:19   ` [PATCH v2 4/4]: ezusb: move ezusb.c from drivers/usb/serial to drivers/usb/misc Rene Buergel
@ 2012-09-14  5:03     ` Greg KH
  2012-09-14  6:52       ` Rene Buergel
  2012-09-14  6:55       ` Rene Buergel
  0 siblings, 2 replies; 10+ messages in thread
From: Greg KH @ 2012-09-14  5:03 UTC (permalink / raw)
  To: Rene Buergel; +Cc: linux-usb, linux-kernel

On Thu, Sep 13, 2012 at 10:19:11PM +0200, Rene Buergel wrote:
> This patch moves drivers/usb/serial/ezusb.c to drivers/usb/misc/and
> adapts Makefiles and Kconfigs
> 
> Signed-off-by: René Bürgel <rene.buergel@sohard.de>
> --
> diff --git a/drivers/usb/misc/Kconfig b/drivers/usb/misc/Kconfig
> index 1bfcd02..1c63b54 100644
> --- a/drivers/usb/misc/Kconfig
> +++ b/drivers/usb/misc/Kconfig
> @@ -244,3 +244,7 @@ config USB_YUREX
>  	  To compile this driver as a module, choose M here: the
>  	  module will be called yurex.
>  
> +config USB_EZUSB
> +	bool "Functions for loading firmware on EZUSB chips"
> +	help
> +	    Say Y here if you need EZUSB device support.
> diff --git a/drivers/usb/misc/Makefile b/drivers/usb/misc/Makefile
> index 796ce7e..f1f7815 100644
> --- a/drivers/usb/misc/Makefile
> +++ b/drivers/usb/misc/Makefile
> @@ -11,6 +11,7 @@ obj-$(CONFIG_USB_CYPRESS_CY7C63)	+= cypress_cy7c63.o
>  obj-$(CONFIG_USB_CYTHERM)		+= cytherm.o
>  obj-$(CONFIG_USB_EMI26)			+= emi26.o
>  obj-$(CONFIG_USB_EMI62)			+= emi62.o
> +obj-$(CONFIG_USB_EZUSB)			+= ezusb.o
>  obj-$(CONFIG_USB_FTDI_ELAN)		+= ftdi-elan.o
>  obj-$(CONFIG_USB_IDMOUSE)		+= idmouse.o
>  obj-$(CONFIG_USB_IOWARRIOR)		+= iowarrior.o
> diff --git a/drivers/usb/misc/ezusb.c b/drivers/usb/misc/ezusb.c
> new file mode 100644
> index 0000000..867a3e1
> --- /dev/null
> +++ b/drivers/usb/misc/ezusb.c

Git should show this as a move, not as a "add a file and remove a file"
type patch.  Are you generating it properly?

Also, why move it?  Are there other modules that need to use it?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 4/4]: ezusb: move ezusb.c from drivers/usb/serial to drivers/usb/misc
  2012-09-14  5:03     ` Greg KH
@ 2012-09-14  6:52       ` Rene Buergel
  2012-09-14 10:04         ` Sebastian Andrzej Siewior
  2012-09-14  6:55       ` Rene Buergel
  1 sibling, 1 reply; 10+ messages in thread
From: Rene Buergel @ 2012-09-14  6:52 UTC (permalink / raw)
  To: linux-usb, linux-kernel

> Git should show this as a move, not as a "add a file and remove a
> file"
> type patch.  Are you generating it properly?

Whats the proper way to do this? I did a git mv, git commit and than git diff on that commit hash.


> Also, why move it?  Are there other modules that need to use it?
> 
> thanks,
> 
> greg k-h
> 

we discussed this a while ago, i had some trouble getting the patches due to changing my workplace.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 4/4]: ezusb: move ezusb.c from drivers/usb/serial to drivers/usb/misc
  2012-09-14  5:03     ` Greg KH
  2012-09-14  6:52       ` Rene Buergel
@ 2012-09-14  6:55       ` Rene Buergel
  1 sibling, 0 replies; 10+ messages in thread
From: Rene Buergel @ 2012-09-14  6:55 UTC (permalink / raw)
  To: linux-usb, linux-kernel

> Also, why move it?  Are there other modules that need to use it?

Fullquote from Aug, 24:
> > > > - 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
> 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 4/4]: ezusb: move ezusb.c from drivers/usb/serial to drivers/usb/misc
  2012-09-14  6:52       ` Rene Buergel
@ 2012-09-14 10:04         ` Sebastian Andrzej Siewior
  0 siblings, 0 replies; 10+ messages in thread
From: Sebastian Andrzej Siewior @ 2012-09-14 10:04 UTC (permalink / raw)
  To: Rene Buergel; +Cc: linux-usb, linux-kernel

On Fri, Sep 14, 2012 at 08:52:58AM +0200, Rene Buergel wrote:
> > Git should show this as a move, not as a "add a file and remove a
> > file"
> > type patch.  Are you generating it properly?
> 
> Whats the proper way to do this? I did a git mv, git commit and than git diff on that commit hash.

Thatis okay but while you create the patch you should use the -M switch in
`git format-patch` command. You could also try to use `git send-email` which
should create proper threads and avoid copy/paste formating problems (in case
there were any).

Sebastian

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2012-09-14 10:04 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <785f10f2-79bc-4708-9c57-7b505d75f223@shmail0>
2012-09-13 20:12 ` [PATCH v2 0/4]: ezusb cleanup, FX2 support, firmware downloading support Rene Buergel
2012-09-13 20:14   ` [PATCH v2 1/4]: " Rene Buergel
2012-09-13 20:15   ` [PATCH v2 2/4]: add support for Cypress FX2LP Rene Buergel
2012-09-14  5:01     ` Greg KH
2012-09-13 20:17   ` [PATCH v2 3/4]: add functions for firmware download Rene Buergel
2012-09-13 20:19   ` [PATCH v2 4/4]: ezusb: move ezusb.c from drivers/usb/serial to drivers/usb/misc Rene Buergel
2012-09-14  5:03     ` Greg KH
2012-09-14  6:52       ` Rene Buergel
2012-09-14 10:04         ` Sebastian Andrzej Siewior
2012-09-14  6:55       ` Rene Buergel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).