#include <linux/tty.h>
#include <linux/tty_flip.h>
#include <linux/module.h>
+#include <linux/moduleparam.h>
#include <linux/usb.h>
#include <asm/uaccess.h>
-
-#ifdef CONFIG_USB_SERIAL_DEBUG
- static int debug = 1;
-#else
- static int debug;
-#endif
-
#include "usb-serial.h"
-
+static int debug;
+
#ifdef CONFIG_USB_SERIAL_GENERIC
static __u16 vendor = 0x05f9;
static __u16 product = 0xffff;
-MODULE_PARM(vendor, "h");
+module_param(vendor, ushort, 0);
MODULE_PARM_DESC(vendor, "User specified USB idVendor");
-MODULE_PARM(product, "h");
+module_param(product, ushort, 0);
MODULE_PARM_DESC(product, "User specified USB idProduct");
static struct usb_device_id generic_device_ids[2]; /* Initially all zeroes. */
.num_ports = 1,
.shutdown = usb_serial_generic_shutdown,
};
+
+/* we want to look at all devices, as the vendor/product id can change
+ * depending on the command line argument */
+static struct usb_device_id generic_serial_ids[] = {
+ {.driver_info = 42},
+ {}
+};
+
+static int generic_probe(struct usb_interface *interface,
+ const struct usb_device_id *id)
+{
+ const struct usb_device_id *id_pattern;
+
+ id_pattern = usb_match_id(interface, generic_device_ids);
+ if (id_pattern != NULL)
+ return usb_serial_probe(interface, id);
+ return -ENODEV;
+}
+
+static struct usb_driver generic_driver = {
+ .owner = THIS_MODULE,
+ .name = "usbserial_generic",
+ .probe = generic_probe,
+ .disconnect = usb_serial_disconnect,
+ .id_table = generic_serial_ids,
+};
#endif
int usb_serial_generic_register (int _debug)
/* register our generic driver with ourselves */
retval = usb_serial_register (&usb_serial_generic_device);
+ if (retval)
+ goto exit;
+ retval = usb_register(&generic_driver);
+ if (retval)
+ usb_serial_deregister(&usb_serial_generic_device);
+exit:
#endif
return retval;
}
{
#ifdef CONFIG_USB_SERIAL_GENERIC
/* remove our generic driver */
+ usb_deregister(&generic_driver);
usb_serial_deregister (&usb_serial_generic_device);
#endif
}
struct usb_serial *serial = port->serial;
int result = 0;
- if (port_paranoia_check (port, __FUNCTION__))
- return -ENODEV;
-
dbg("%s - port %d", __FUNCTION__, port->number);
/* force low_latency on so that our tty_push actually forces the data through,
if (serial->dev) {
/* shutdown any bulk reads that might be going on */
if (serial->num_bulk_out)
- usb_unlink_urb (port->write_urb);
+ usb_kill_urb(port->write_urb);
if (serial->num_bulk_in)
- usb_unlink_urb (port->read_urb);
+ usb_kill_urb(port->read_urb);
}
}
generic_cleanup (port);
}
-int usb_serial_generic_write (struct usb_serial_port *port, int from_user, const unsigned char *buf, int count)
+int usb_serial_generic_write(struct usb_serial_port *port, const unsigned char *buf, int count)
{
struct usb_serial *serial = port->serial;
int result;
+ unsigned char *data;
dbg("%s - port %d", __FUNCTION__, port->number);
count = (count > port->bulk_out_size) ? port->bulk_out_size : count;
- if (from_user) {
- if (copy_from_user(port->write_urb->transfer_buffer, buf, count))
- return -EFAULT;
- }
- else {
- memcpy (port->write_urb->transfer_buffer, buf, count);
- }
-
- usb_serial_debug_data (__FILE__, __FUNCTION__, count, port->write_urb->transfer_buffer);
+ memcpy (port->write_urb->transfer_buffer, buf, count);
+ data = port->write_urb->transfer_buffer;
+ usb_serial_debug_data(debug, &port->dev, __FUNCTION__, count, data);
/* set up our urb */
usb_fill_bulk_urb (port->write_urb, serial->dev,
void usb_serial_generic_read_bulk_callback (struct urb *urb, struct pt_regs *regs)
{
struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
- struct usb_serial *serial = get_usb_serial (port, __FUNCTION__);
+ struct usb_serial *serial = port->serial;
struct tty_struct *tty;
unsigned char *data = urb->transfer_buffer;
int i;
dbg("%s - port %d", __FUNCTION__, port->number);
- if (!serial) {
- dbg("%s - bad serial pointer, exiting", __FUNCTION__);
- return;
- }
-
if (urb->status) {
dbg("%s - nonzero read bulk status received: %d", __FUNCTION__, urb->status);
return;
}
- usb_serial_debug_data (__FILE__, __FUNCTION__, urb->actual_length, data);
+ usb_serial_debug_data(debug, &port->dev, __FUNCTION__, urb->actual_length, data);
tty = port->tty;
if (tty && urb->actual_length) {
void usb_serial_generic_write_bulk_callback (struct urb *urb, struct pt_regs *regs)
{
struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
- struct usb_serial *serial = get_usb_serial (port, __FUNCTION__);
dbg("%s - port %d", __FUNCTION__, port->number);
- if (!serial) {
- dbg("%s - bad serial pointer, exiting", __FUNCTION__);
- return;
- }
-
if (urb->status) {
dbg("%s - nonzero write bulk status received: %d", __FUNCTION__, urb->status);
return;