mirror of https://gitee.com/openkylin/linux.git
USB: ssu100: remove max_packet_size calculation
The max_packet_size logic is taken from ftdi_sio, but it's not needed for this device. This also makes proces_read_urb simpler. Signed-off-by: Bill Pemberton <wfp5p@virginia.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
parent
c8ddb2713c
commit
f7043ecbb3
|
@ -79,7 +79,6 @@ struct ssu100_port_private {
|
||||||
u8 shadowLSR;
|
u8 shadowLSR;
|
||||||
u8 shadowMSR;
|
u8 shadowMSR;
|
||||||
wait_queue_head_t delta_msr_wait; /* Used for TIOCMIWAIT */
|
wait_queue_head_t delta_msr_wait; /* Used for TIOCMIWAIT */
|
||||||
unsigned short max_packet_size;
|
|
||||||
struct async_icount icount;
|
struct async_icount icount;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -464,36 +463,6 @@ static int ssu100_ioctl(struct tty_struct *tty, struct file *file,
|
||||||
return -ENOIOCTLCMD;
|
return -ENOIOCTLCMD;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ssu100_set_max_packet_size(struct usb_serial_port *port)
|
|
||||||
{
|
|
||||||
struct ssu100_port_private *priv = usb_get_serial_port_data(port);
|
|
||||||
struct usb_serial *serial = port->serial;
|
|
||||||
struct usb_device *udev = serial->dev;
|
|
||||||
|
|
||||||
struct usb_interface *interface = serial->interface;
|
|
||||||
struct usb_endpoint_descriptor *ep_desc = &interface->cur_altsetting->endpoint[1].desc;
|
|
||||||
|
|
||||||
unsigned num_endpoints;
|
|
||||||
int i;
|
|
||||||
unsigned long flags;
|
|
||||||
|
|
||||||
num_endpoints = interface->cur_altsetting->desc.bNumEndpoints;
|
|
||||||
dev_info(&udev->dev, "Number of endpoints %d\n", num_endpoints);
|
|
||||||
|
|
||||||
for (i = 0; i < num_endpoints; i++) {
|
|
||||||
dev_info(&udev->dev, "Endpoint %d MaxPacketSize %d\n", i+1,
|
|
||||||
interface->cur_altsetting->endpoint[i].desc.wMaxPacketSize);
|
|
||||||
ep_desc = &interface->cur_altsetting->endpoint[i].desc;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* set max packet size based on descriptor */
|
|
||||||
spin_lock_irqsave(&priv->status_lock, flags);
|
|
||||||
priv->max_packet_size = ep_desc->wMaxPacketSize;
|
|
||||||
spin_unlock_irqrestore(&priv->status_lock, flags);
|
|
||||||
|
|
||||||
dev_info(&udev->dev, "Setting MaxPacketSize %d\n", priv->max_packet_size);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int ssu100_attach(struct usb_serial *serial)
|
static int ssu100_attach(struct usb_serial *serial)
|
||||||
{
|
{
|
||||||
struct ssu100_port_private *priv;
|
struct ssu100_port_private *priv;
|
||||||
|
@ -511,7 +480,6 @@ static int ssu100_attach(struct usb_serial *serial)
|
||||||
spin_lock_init(&priv->status_lock);
|
spin_lock_init(&priv->status_lock);
|
||||||
init_waitqueue_head(&priv->delta_msr_wait);
|
init_waitqueue_head(&priv->delta_msr_wait);
|
||||||
usb_set_serial_port_data(port, priv);
|
usb_set_serial_port_data(port, priv);
|
||||||
ssu100_set_max_packet_size(port);
|
|
||||||
|
|
||||||
return ssu100_initdevice(serial->dev);
|
return ssu100_initdevice(serial->dev);
|
||||||
}
|
}
|
||||||
|
@ -641,13 +609,14 @@ static void ssu100_update_lsr(struct usb_serial_port *port, u8 lsr,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ssu100_process_packet(struct tty_struct *tty,
|
static int ssu100_process_packet(struct urb *urb,
|
||||||
struct usb_serial_port *port,
|
struct tty_struct *tty)
|
||||||
struct ssu100_port_private *priv,
|
|
||||||
char *packet, int len)
|
|
||||||
{
|
{
|
||||||
int i;
|
struct usb_serial_port *port = urb->context;
|
||||||
|
char *packet = (char *)urb->transfer_buffer;
|
||||||
char flag = TTY_NORMAL;
|
char flag = TTY_NORMAL;
|
||||||
|
u32 len = urb->actual_length;
|
||||||
|
int i;
|
||||||
char *ch;
|
char *ch;
|
||||||
|
|
||||||
dbg("%s - port %d", __func__, port->number);
|
dbg("%s - port %d", __func__, port->number);
|
||||||
|
@ -685,12 +654,8 @@ static int ssu100_process_packet(struct tty_struct *tty,
|
||||||
static void ssu100_process_read_urb(struct urb *urb)
|
static void ssu100_process_read_urb(struct urb *urb)
|
||||||
{
|
{
|
||||||
struct usb_serial_port *port = urb->context;
|
struct usb_serial_port *port = urb->context;
|
||||||
struct ssu100_port_private *priv = usb_get_serial_port_data(port);
|
|
||||||
char *data = (char *)urb->transfer_buffer;
|
|
||||||
struct tty_struct *tty;
|
struct tty_struct *tty;
|
||||||
int count = 0;
|
int count;
|
||||||
int i;
|
|
||||||
int len;
|
|
||||||
|
|
||||||
dbg("%s", __func__);
|
dbg("%s", __func__);
|
||||||
|
|
||||||
|
@ -698,10 +663,7 @@ static void ssu100_process_read_urb(struct urb *urb)
|
||||||
if (!tty)
|
if (!tty)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (i = 0; i < urb->actual_length; i += priv->max_packet_size) {
|
count = ssu100_process_packet(urb, tty);
|
||||||
len = min_t(int, urb->actual_length - i, priv->max_packet_size);
|
|
||||||
count += ssu100_process_packet(tty, port, priv, &data[i], len);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (count)
|
if (count)
|
||||||
tty_flip_buffer_push(tty);
|
tty_flip_buffer_push(tty);
|
||||||
|
@ -717,8 +679,6 @@ static struct usb_serial_driver ssu100_device = {
|
||||||
.id_table = id_table,
|
.id_table = id_table,
|
||||||
.usb_driver = &ssu100_driver,
|
.usb_driver = &ssu100_driver,
|
||||||
.num_ports = 1,
|
.num_ports = 1,
|
||||||
.bulk_in_size = 256,
|
|
||||||
.bulk_out_size = 256,
|
|
||||||
.open = ssu100_open,
|
.open = ssu100_open,
|
||||||
.close = ssu100_close,
|
.close = ssu100_close,
|
||||||
.attach = ssu100_attach,
|
.attach = ssu100_attach,
|
||||||
|
|
Loading…
Reference in New Issue