/*
* USB Serial Converter driver
*
- * Copyright (C) 1999 - 2003 Greg Kroah-Hartman (greg@kroah.com)
+ * Copyright (C) 1999 - 2004 Greg Kroah-Hartman (greg@kroah.com)
* Copyright (C) 2000 Peter Berger (pberger@brimson.com)
* Copyright (C) 2000 Al Borchers (borchers@steinerpoint.com)
*
#include <linux/tty_driver.h>
#include <linux/tty_flip.h>
#include <linux/module.h>
+#include <linux/moduleparam.h>
#include <linux/spinlock.h>
#include <linux/list.h>
#include <linux/smp_lock.h>
}
if (good_spot == 0)
continue;
-
- serial->magic = USB_SERIAL_MAGIC;
+
*minor = i;
dbg("%s - minor base = %d", __FUNCTION__, *minor);
for (i = *minor; (i < (*minor + num_ports)) && (i < SERIAL_TTY_MINORS); ++i)
/* get the serial object associated with this tty pointer */
serial = usb_serial_get_by_index(tty->index);
-
- if (serial_paranoia_check (serial, __FUNCTION__))
- return -ENODEV;
+ if (!serial) {
+ retval = -ENODEV;
+ goto bailout;
+ }
/* set up our port structure making the tty driver remember our port object, and us it */
portNumber = tty->index - serial->minor;
static void serial_close(struct tty_struct *tty, struct file * filp)
{
struct usb_serial_port *port = (struct usb_serial_port *) tty->driver_data;
- struct usb_serial *serial = get_usb_serial (port, __FUNCTION__);
- if (!serial)
+ if (!port)
return;
dbg("%s - port %d", __FUNCTION__, port->number);
static int serial_write (struct tty_struct * tty, int from_user, const unsigned char *buf, int count)
{
struct usb_serial_port *port = (struct usb_serial_port *) tty->driver_data;
- struct usb_serial *serial = get_usb_serial (port, __FUNCTION__);
int retval = -EINVAL;
- if (!serial)
- return -ENODEV;
-
dbg("%s - port %d, %d byte(s)", __FUNCTION__, port->number, count);
if (!port->open_count) {
}
/* pass on to the driver specific version of this function */
- retval = serial->type->write(port, from_user, buf, count);
+ retval = port->serial->type->write(port, from_user, buf, count);
exit:
return retval;
static int serial_write_room (struct tty_struct *tty)
{
struct usb_serial_port *port = (struct usb_serial_port *) tty->driver_data;
- struct usb_serial *serial = get_usb_serial (port, __FUNCTION__);
int retval = -EINVAL;
- if (!serial)
- return -ENODEV;
-
dbg("%s - port %d", __FUNCTION__, port->number);
if (!port->open_count) {
}
/* pass on to the driver specific version of this function */
- retval = serial->type->write_room(port);
+ retval = port->serial->type->write_room(port);
exit:
return retval;
static int serial_chars_in_buffer (struct tty_struct *tty)
{
struct usb_serial_port *port = (struct usb_serial_port *) tty->driver_data;
- struct usb_serial *serial = get_usb_serial (port, __FUNCTION__);
int retval = -EINVAL;
- if (!serial)
- return -ENODEV;
-
dbg("%s = port %d", __FUNCTION__, port->number);
if (!port->open_count) {
}
/* pass on to the driver specific version of this function */
- retval = serial->type->chars_in_buffer(port);
+ retval = port->serial->type->chars_in_buffer(port);
exit:
return retval;
static void serial_throttle (struct tty_struct * tty)
{
struct usb_serial_port *port = (struct usb_serial_port *) tty->driver_data;
- struct usb_serial *serial = get_usb_serial (port, __FUNCTION__);
-
- if (!serial)
- return;
dbg("%s - port %d", __FUNCTION__, port->number);
}
/* pass on to the driver specific version of this function */
- if (serial->type->throttle)
- serial->type->throttle(port);
+ if (port->serial->type->throttle)
+ port->serial->type->throttle(port);
exit:
;
static void serial_unthrottle (struct tty_struct * tty)
{
struct usb_serial_port *port = (struct usb_serial_port *) tty->driver_data;
- struct usb_serial *serial = get_usb_serial (port, __FUNCTION__);
-
- if (!serial)
- return;
dbg("%s - port %d", __FUNCTION__, port->number);
}
/* pass on to the driver specific version of this function */
- if (serial->type->unthrottle)
- serial->type->unthrottle(port);
+ if (port->serial->type->unthrottle)
+ port->serial->type->unthrottle(port);
exit:
;
static int serial_ioctl (struct tty_struct *tty, struct file * file, unsigned int cmd, unsigned long arg)
{
struct usb_serial_port *port = (struct usb_serial_port *) tty->driver_data;
- struct usb_serial *serial = get_usb_serial (port, __FUNCTION__);
int retval = -ENODEV;
- if (!serial)
- return -ENODEV;
-
dbg("%s - port %d, cmd 0x%.4x", __FUNCTION__, port->number, cmd);
if (!port->open_count) {
}
/* pass on to the driver specific version of this function if it is available */
- if (serial->type->ioctl)
- retval = serial->type->ioctl(port, file, cmd, arg);
+ if (port->serial->type->ioctl)
+ retval = port->serial->type->ioctl(port, file, cmd, arg);
else
retval = -ENOIOCTLCMD;
static void serial_set_termios (struct tty_struct *tty, struct termios * old)
{
struct usb_serial_port *port = (struct usb_serial_port *) tty->driver_data;
- struct usb_serial *serial = get_usb_serial (port, __FUNCTION__);
-
- if (!serial)
- return;
dbg("%s - port %d", __FUNCTION__, port->number);
}
/* pass on to the driver specific version of this function if it is available */
- if (serial->type->set_termios)
- serial->type->set_termios(port, old);
+ if (port->serial->type->set_termios)
+ port->serial->type->set_termios(port, old);
exit:
;
static void serial_break (struct tty_struct *tty, int break_state)
{
struct usb_serial_port *port = (struct usb_serial_port *) tty->driver_data;
- struct usb_serial *serial = get_usb_serial (port, __FUNCTION__);
-
- if (!serial)
- return;
dbg("%s - port %d", __FUNCTION__, port->number);
}
/* pass on to the driver specific version of this function if it is available */
- if (serial->type->break_ctl)
- serial->type->break_ctl(port, break_state);
+ if (port->serial->type->break_ctl)
+ port->serial->type->break_ctl(port, break_state);
exit:
;
static int serial_tiocmget (struct tty_struct *tty, struct file *file)
{
struct usb_serial_port *port = (struct usb_serial_port *) tty->driver_data;
- struct usb_serial *serial = get_usb_serial (port, __FUNCTION__);
-
- if (!serial)
- goto exit;
dbg("%s - port %d", __FUNCTION__, port->number);
goto exit;
}
- if (serial->type->tiocmget)
- return serial->type->tiocmget(port, file);
+ if (port->serial->type->tiocmget)
+ return port->serial->type->tiocmget(port, file);
exit:
return -EINVAL;
unsigned int set, unsigned int clear)
{
struct usb_serial_port *port = (struct usb_serial_port *) tty->driver_data;
- struct usb_serial *serial = get_usb_serial (port, __FUNCTION__);
-
- if (!serial)
- goto exit;
dbg("%s - port %d", __FUNCTION__, port->number);
goto exit;
}
- if (serial->type->tiocmset)
- return serial->type->tiocmset(port, file, set, clear);
+ if (port->serial->type->tiocmset)
+ return port->serial->type->tiocmset(port, file, set, clear);
exit:
return -EINVAL;
void usb_serial_port_softint(void *private)
{
struct usb_serial_port *port = (struct usb_serial_port *)private;
- struct usb_serial *serial;
struct tty_struct *tty;
dbg("%s - port %d", __FUNCTION__, port->number);
if (!port)
return;
- serial = get_usb_serial (port, __FUNCTION__);
- if (!serial)
- return;
-
tty = port->tty;
if (!tty)
return;
(dev->descriptor.idProduct == ATEN_PRODUCT_ID))) {
if (interface != dev->actconfig->interface[0]) {
/* check out the endpoints of the other interface*/
- iface_desc = &dev->actconfig->interface[0]->altsetting[0];
+ iface_desc = dev->actconfig->interface[0]->cur_altsetting;
for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) {
endpoint = &iface_desc->endpoint[i].desc;
if ((endpoint->bEndpointAddress & 0x80) &&
memset(port, 0x00, sizeof(struct usb_serial_port));
port->number = i + serial->minor;
port->serial = serial;
- port->magic = USB_SERIAL_PORT_MAGIC;
INIT_WORK(&port->work, usb_serial_port_softint, port);
serial->port[i] = port;
}
MODULE_DESCRIPTION( DRIVER_DESC );
MODULE_LICENSE("GPL");
-MODULE_PARM(debug, "i");
+module_param(debug, bool, S_IRUGO | S_IWUSR);
MODULE_PARM_DESC(debug, "Debug enabled or not");