aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRene Buergel <rene.buergel@sohard.de>2012-09-13 16:14:38 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-09-14 00:59:51 -0400
commit99495c7061892f0312c0119725b550bb221634ce (patch)
treecde4743b6d5461d666f5158080a24dba057abfe6
parent8321652ae22f38830af5b553f3a316d68948ddce (diff)
USB: ezusb: remove dependancy on usb_serial
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> -- Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/usb/serial/ezusb.c28
-rw-r--r--drivers/usb/serial/keyspan.c6
-rw-r--r--drivers/usb/serial/keyspan_pda.c6
-rw-r--r--drivers/usb/serial/whiteheat.c26
-rw-r--r--include/linux/usb/serial.h4
5 files changed, 35 insertions, 35 deletions
diff --git a/drivers/usb/serial/ezusb.c b/drivers/usb/serial/ezusb.c
index 800e8eb6000..3048b52d2d3 100644
--- a/drivers/usb/serial/ezusb.c
+++ b/drivers/usb/serial/ezusb.c
@@ -9,24 +9,24 @@
9 */ 9 */
10 10
11#include <linux/kernel.h> 11#include <linux/kernel.h>
12#include <linux/errno.h>
13#include <linux/init.h> 12#include <linux/init.h>
14#include <linux/slab.h> 13#include <linux/slab.h>
15#include <linux/tty.h>
16#include <linux/module.h> 14#include <linux/module.h>
17#include <linux/usb.h> 15#include <linux/usb.h>
18#include <linux/usb/serial.h>
19 16
20/* EZ-USB Control and Status Register. Bit 0 controls 8051 reset */ 17/* EZ-USB Control and Status Register. Bit 0 controls 8051 reset */
21#define CPUCS_REG 0x7F92 18#define CPUCS_REG 0x7F92
22 19
23int ezusb_writememory(struct usb_serial *serial, int address, 20/* Command for writing to internal memory */
21#define WRITE_INT_RAM 0xA0
22
23int ezusb_writememory(struct usb_device *dev, int address,
24 unsigned char *data, int length, __u8 request) 24 unsigned char *data, int length, __u8 request)
25{ 25{
26 int result; 26 int result;
27 unsigned char *transfer_buffer; 27 unsigned char *transfer_buffer;
28 28
29 if (!serial->dev) { 29 if (!dev) {
30 printk(KERN_ERR "ezusb: %s - no physical device present, " 30 printk(KERN_ERR "ezusb: %s - no physical device present, "
31 "failing.\n", __func__); 31 "failing.\n", __func__);
32 return -ENODEV; 32 return -ENODEV;
@@ -34,25 +34,25 @@ int ezusb_writememory(struct usb_serial *serial, int address,
34 34
35 transfer_buffer = kmemdup(data, length, GFP_KERNEL); 35 transfer_buffer = kmemdup(data, length, GFP_KERNEL);
36 if (!transfer_buffer) { 36 if (!transfer_buffer) {
37 dev_err(&serial->dev->dev, "%s - kmalloc(%d) failed.\n", 37 dev_err(&dev->dev, "%s - kmalloc(%d) failed.\n",
38 __func__, length); 38 __func__, length);
39 return -ENOMEM; 39 return -ENOMEM;
40 } 40 }
41 result = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), 41 result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), request,
42 request, 0x40, address, 0, transfer_buffer, length, 3000); 42 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
43 address, 0, transfer_buffer, length, 3000);
44
43 kfree(transfer_buffer); 45 kfree(transfer_buffer);
44 return result; 46 return result;
45} 47}
46EXPORT_SYMBOL_GPL(ezusb_writememory); 48EXPORT_SYMBOL_GPL(ezusb_writememory);
47 49
48int ezusb_set_reset(struct usb_serial *serial, unsigned char reset_bit) 50int ezusb_set_reset(struct usb_device *dev, unsigned char reset_bit)
49{ 51{
50 int response; 52 int response = ezusb_writememory(dev, CPUCS_REG, &reset_bit, 1, WRITE_INT_RAM);
51
52 response = ezusb_writememory(serial, CPUCS_REG, &reset_bit, 1, 0xa0);
53 if (response < 0) 53 if (response < 0)
54 dev_err(&serial->dev->dev, "%s- %d failed\n", 54 dev_err(&dev->dev, "%s-%d failed: %d\n",
55 __func__, reset_bit); 55 __func__, reset_bit, response);
56 return response; 56 return response;
57} 57}
58EXPORT_SYMBOL_GPL(ezusb_set_reset); 58EXPORT_SYMBOL_GPL(ezusb_set_reset);
diff --git a/drivers/usb/serial/keyspan.c b/drivers/usb/serial/keyspan.c
index af0b70eaf03..f0d4f3fcf4f 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)
1241 dbg("Uploading Keyspan %s firmware.", fw_name); 1241 dbg("Uploading Keyspan %s firmware.", fw_name);
1242 1242
1243 /* download the firmware image */ 1243 /* download the firmware image */
1244 response = ezusb_set_reset(serial, 1); 1244 response = ezusb_set_reset(serial->dev, 1);
1245 1245
1246 record = (const struct ihex_binrec *)fw->data; 1246 record = (const struct ihex_binrec *)fw->data;
1247 1247
1248 while (record) { 1248 while (record) {
1249 response = ezusb_writememory(serial, be32_to_cpu(record->addr), 1249 response = ezusb_writememory(serial->dev, be32_to_cpu(record->addr),
1250 (unsigned char *)record->data, 1250 (unsigned char *)record->data,
1251 be16_to_cpu(record->len), 0xa0); 1251 be16_to_cpu(record->len), 0xa0);
1252 if (response < 0) { 1252 if (response < 0) {
@@ -1260,7 +1260,7 @@ static int keyspan_fake_startup(struct usb_serial *serial)
1260 release_firmware(fw); 1260 release_firmware(fw);
1261 /* bring device out of reset. Renumeration will occur in a 1261 /* bring device out of reset. Renumeration will occur in a
1262 moment and the new device will bind to the real driver */ 1262 moment and the new device will bind to the real driver */
1263 response = ezusb_set_reset(serial, 0); 1263 response = ezusb_set_reset(serial->dev, 0);
1264 1264
1265 /* we don't want this device to have a driver assigned to it. */ 1265 /* we don't want this device to have a driver assigned to it. */
1266 return 1; 1266 return 1;
diff --git a/drivers/usb/serial/keyspan_pda.c b/drivers/usb/serial/keyspan_pda.c
index a4ac3cfeffc..1290b6f0a05 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)
682 const struct firmware *fw; 682 const struct firmware *fw;
683 683
684 /* download the firmware here ... */ 684 /* download the firmware here ... */
685 response = ezusb_set_reset(serial, 1); 685 response = ezusb_set_reset(serial->dev, 1);
686 686
687 if (0) { ; } 687 if (0) { ; }
688#ifdef KEYSPAN 688#ifdef KEYSPAN
@@ -707,7 +707,7 @@ static int keyspan_pda_fake_startup(struct usb_serial *serial)
707 record = (const struct ihex_binrec *)fw->data; 707 record = (const struct ihex_binrec *)fw->data;
708 708
709 while (record) { 709 while (record) {
710 response = ezusb_writememory(serial, be32_to_cpu(record->addr), 710 response = ezusb_writememory(serial->dev, be32_to_cpu(record->addr),
711 (unsigned char *)record->data, 711 (unsigned char *)record->data,
712 be16_to_cpu(record->len), 0xa0); 712 be16_to_cpu(record->len), 0xa0);
713 if (response < 0) { 713 if (response < 0) {
@@ -722,7 +722,7 @@ static int keyspan_pda_fake_startup(struct usb_serial *serial)
722 release_firmware(fw); 722 release_firmware(fw);
723 /* bring device out of reset. Renumeration will occur in a moment 723 /* bring device out of reset. Renumeration will occur in a moment
724 and the new device will bind to the real driver */ 724 and the new device will bind to the real driver */
725 response = ezusb_set_reset(serial, 0); 725 response = ezusb_set_reset(serial->dev, 0);
726 726
727 /* we want this device to fail to have a driver assigned to it. */ 727 /* we want this device to fail to have a driver assigned to it. */
728 return 1; 728 return 1;
diff --git a/drivers/usb/serial/whiteheat.c b/drivers/usb/serial/whiteheat.c
index 473635e7f5d..fc72591711e 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,
213 goto out; 213 goto out;
214 } 214 }
215 ret = 0; 215 ret = 0;
216 response = ezusb_set_reset (serial, 1); 216 response = ezusb_set_reset(serial->dev, 1);
217 217
218 record = (const struct ihex_binrec *)loader_fw->data; 218 record = (const struct ihex_binrec *)loader_fw->data;
219 while (record) { 219 while (record) {
220 response = ezusb_writememory (serial, be32_to_cpu(record->addr), 220 response = ezusb_writememory(serial->dev, be32_to_cpu(record->addr),
221 (unsigned char *)record->data, 221 (unsigned char *)record->data,
222 be16_to_cpu(record->len), 0xa0); 222 be16_to_cpu(record->len), 0xa0);
223 if (response < 0) { 223 if (response < 0) {
224 dev_err(&serial->dev->dev, "%s - ezusb_writememory " 224 dev_err(&serial->dev->dev, "%s - ezusb_writememory "
225 "failed for loader (%d %04X %p %d)\n", 225 "failed for loader (%d %04X %p %d)\n",
@@ -230,15 +230,15 @@ static int whiteheat_firmware_download(struct usb_serial *serial,
230 record = ihex_next_binrec(record); 230 record = ihex_next_binrec(record);
231 } 231 }
232 232
233 response = ezusb_set_reset(serial, 0); 233 response = ezusb_set_reset(serial->dev, 0);
234 234
235 record = (const struct ihex_binrec *)firmware_fw->data; 235 record = (const struct ihex_binrec *)firmware_fw->data;
236 while (record && be32_to_cpu(record->addr) < 0x1b40) 236 while (record && be32_to_cpu(record->addr) < 0x1b40)
237 record = ihex_next_binrec(record); 237 record = ihex_next_binrec(record);
238 while (record) { 238 while (record) {
239 response = ezusb_writememory (serial, be32_to_cpu(record->addr), 239 response = ezusb_writememory(serial->dev, be32_to_cpu(record->addr),
240 (unsigned char *)record->data, 240 (unsigned char *)record->data,
241 be16_to_cpu(record->len), 0xa3); 241 be16_to_cpu(record->len), 0xa3);
242 if (response < 0) { 242 if (response < 0) {
243 dev_err(&serial->dev->dev, "%s - ezusb_writememory " 243 dev_err(&serial->dev->dev, "%s - ezusb_writememory "
244 "failed for first firmware step " 244 "failed for first firmware step "
@@ -250,13 +250,13 @@ static int whiteheat_firmware_download(struct usb_serial *serial,
250 ++record; 250 ++record;
251 } 251 }
252 252
253 response = ezusb_set_reset(serial, 1); 253 response = ezusb_set_reset(serial->dev, 1);
254 254
255 record = (const struct ihex_binrec *)firmware_fw->data; 255 record = (const struct ihex_binrec *)firmware_fw->data;
256 while (record && be32_to_cpu(record->addr) < 0x1b40) { 256 while (record && be32_to_cpu(record->addr) < 0x1b40) {
257 response = ezusb_writememory (serial, be32_to_cpu(record->addr), 257 response = ezusb_writememory(serial->dev, be32_to_cpu(record->addr),
258 (unsigned char *)record->data, 258 (unsigned char *)record->data,
259 be16_to_cpu(record->len), 0xa0); 259 be16_to_cpu(record->len), 0xa0);
260 if (response < 0) { 260 if (response < 0) {
261 dev_err(&serial->dev->dev, "%s - ezusb_writememory " 261 dev_err(&serial->dev->dev, "%s - ezusb_writememory "
262 "failed for second firmware step " 262 "failed for second firmware step "
@@ -268,7 +268,7 @@ static int whiteheat_firmware_download(struct usb_serial *serial,
268 ++record; 268 ++record;
269 } 269 }
270 ret = 0; 270 ret = 0;
271 response = ezusb_set_reset (serial, 0); 271 response = ezusb_set_reset(serial->dev, 0);
272 out: 272 out:
273 release_firmware(loader_fw); 273 release_firmware(loader_fw);
274 release_firmware(firmware_fw); 274 release_firmware(firmware_fw);
diff --git a/include/linux/usb/serial.h b/include/linux/usb/serial.h
index 9e9a0a8991e..6bed6db619b 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);
301extern int usb_serial_suspend(struct usb_interface *intf, pm_message_t message); 301extern int usb_serial_suspend(struct usb_interface *intf, pm_message_t message);
302extern int usb_serial_resume(struct usb_interface *intf); 302extern int usb_serial_resume(struct usb_interface *intf);
303 303
304extern int ezusb_writememory(struct usb_serial *serial, int address, 304extern int ezusb_writememory(struct usb_device *dev, int address,
305 unsigned char *data, int length, __u8 bRequest); 305 unsigned char *data, int length, __u8 bRequest);
306extern int ezusb_set_reset(struct usb_serial *serial, unsigned char reset_bit); 306extern int ezusb_set_reset(struct usb_device *dev, unsigned char reset_bit);
307 307
308/* USB Serial console functions */ 308/* USB Serial console functions */
309#ifdef CONFIG_USB_SERIAL_CONSOLE 309#ifdef CONFIG_USB_SERIAL_CONSOLE