tty-usb-visor: Coding style
Signed-off-by: Alan Cox <alan@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
@@ -9,7 +9,8 @@
|
|||||||
* modify it under the terms of the GNU General Public License version
|
* modify it under the terms of the GNU General Public License version
|
||||||
* 2 as published by the Free Software Foundation.
|
* 2 as published by the Free Software Foundation.
|
||||||
*
|
*
|
||||||
* See Documentation/usb/usb-serial.txt for more information on using this driver
|
* See Documentation/usb/usb-serial.txt for more information on using this
|
||||||
|
* driver
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -23,7 +24,7 @@
|
|||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
#include <linux/moduleparam.h>
|
#include <linux/moduleparam.h>
|
||||||
#include <linux/spinlock.h>
|
#include <linux/spinlock.h>
|
||||||
#include <asm/uaccess.h>
|
#include <linux/uaccess.h>
|
||||||
#include <linux/usb.h>
|
#include <linux/usb.h>
|
||||||
#include <linux/usb/serial.h>
|
#include <linux/usb/serial.h>
|
||||||
#include "visor.h"
|
#include "visor.h"
|
||||||
@@ -35,13 +36,17 @@
|
|||||||
#define DRIVER_DESC "USB HandSpring Visor / Palm OS driver"
|
#define DRIVER_DESC "USB HandSpring Visor / Palm OS driver"
|
||||||
|
|
||||||
/* function prototypes for a handspring visor */
|
/* function prototypes for a handspring visor */
|
||||||
static int visor_open (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp);
|
static int visor_open(struct tty_struct *tty, struct usb_serial_port *port,
|
||||||
static void visor_close (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp);
|
struct file *filp);
|
||||||
static int visor_write (struct tty_struct *tty, struct usb_serial_port *port, const unsigned char *buf, int count);
|
static void visor_close(struct tty_struct *tty, struct usb_serial_port *port,
|
||||||
|
struct file *filp);
|
||||||
|
static int visor_write(struct tty_struct *tty, struct usb_serial_port *port,
|
||||||
|
const unsigned char *buf, int count);
|
||||||
static int visor_write_room(struct tty_struct *tty);
|
static int visor_write_room(struct tty_struct *tty);
|
||||||
static void visor_throttle(struct tty_struct *tty);
|
static void visor_throttle(struct tty_struct *tty);
|
||||||
static void visor_unthrottle(struct tty_struct *tty);
|
static void visor_unthrottle(struct tty_struct *tty);
|
||||||
static int visor_probe (struct usb_serial *serial, const struct usb_device_id *id);
|
static int visor_probe(struct usb_serial *serial,
|
||||||
|
const struct usb_device_id *id);
|
||||||
static int visor_calc_num_ports(struct usb_serial *serial);
|
static int visor_calc_num_ports(struct usb_serial *serial);
|
||||||
static void visor_shutdown(struct usb_serial *serial);
|
static void visor_shutdown(struct usb_serial *serial);
|
||||||
static void visor_write_bulk_callback(struct urb *urb);
|
static void visor_write_bulk_callback(struct urb *urb);
|
||||||
@@ -50,8 +55,10 @@ static void visor_read_int_callback (struct urb *urb);
|
|||||||
static int clie_3_5_startup(struct usb_serial *serial);
|
static int clie_3_5_startup(struct usb_serial *serial);
|
||||||
static int treo_attach(struct usb_serial *serial);
|
static int treo_attach(struct usb_serial *serial);
|
||||||
static int clie_5_attach(struct usb_serial *serial);
|
static int clie_5_attach(struct usb_serial *serial);
|
||||||
static int palm_os_3_probe (struct usb_serial *serial, const struct usb_device_id *id);
|
static int palm_os_3_probe(struct usb_serial *serial,
|
||||||
static int palm_os_4_probe (struct usb_serial *serial, const struct usb_device_id *id);
|
const struct usb_device_id *id);
|
||||||
|
static int palm_os_4_probe(struct usb_serial *serial,
|
||||||
|
const struct usb_device_id *id);
|
||||||
|
|
||||||
/* Parameters that may be passed into the module. */
|
/* Parameters that may be passed into the module. */
|
||||||
static int debug;
|
static int debug;
|
||||||
@@ -178,7 +185,8 @@ static struct usb_driver visor_driver = {
|
|||||||
.no_dynamic_id = 1,
|
.no_dynamic_id = 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
/* All of the device info needed for the Handspring Visor, and Palm 4.0 devices */
|
/* All of the device info needed for the Handspring Visor,
|
||||||
|
and Palm 4.0 devices */
|
||||||
static struct usb_serial_driver handspring_device = {
|
static struct usb_serial_driver handspring_device = {
|
||||||
.driver = {
|
.driver = {
|
||||||
.owner = THIS_MODULE,
|
.owner = THIS_MODULE,
|
||||||
@@ -266,7 +274,8 @@ static int stats;
|
|||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* Handspring Visor specific driver functions
|
* Handspring Visor specific driver functions
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
static int visor_open (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp)
|
static int visor_open(struct tty_struct *tty, struct usb_serial_port *port,
|
||||||
|
struct file *filp)
|
||||||
{
|
{
|
||||||
struct usb_serial *serial = port->serial;
|
struct usb_serial *serial = port->serial;
|
||||||
struct visor_private *priv = usb_get_serial_port_data(port);
|
struct visor_private *priv = usb_get_serial_port_data(port);
|
||||||
@@ -304,7 +313,8 @@ static int visor_open (struct tty_struct *tty, struct usb_serial_port *port, str
|
|||||||
visor_read_bulk_callback, port);
|
visor_read_bulk_callback, port);
|
||||||
result = usb_submit_urb(port->read_urb, GFP_KERNEL);
|
result = usb_submit_urb(port->read_urb, GFP_KERNEL);
|
||||||
if (result) {
|
if (result) {
|
||||||
dev_err(&port->dev, "%s - failed submitting read urb, error %d\n",
|
dev_err(&port->dev,
|
||||||
|
"%s - failed submitting read urb, error %d\n",
|
||||||
__func__, result);
|
__func__, result);
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
@@ -313,7 +323,8 @@ static int visor_open (struct tty_struct *tty, struct usb_serial_port *port, str
|
|||||||
dbg("%s - adding interrupt input for treo", __func__);
|
dbg("%s - adding interrupt input for treo", __func__);
|
||||||
result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);
|
result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);
|
||||||
if (result)
|
if (result)
|
||||||
dev_err(&port->dev, "%s - failed submitting interrupt urb, error %d\n",
|
dev_err(&port->dev,
|
||||||
|
"%s - failed submitting interrupt urb, error %d\n",
|
||||||
__func__, result);
|
__func__, result);
|
||||||
}
|
}
|
||||||
exit:
|
exit:
|
||||||
@@ -402,7 +413,8 @@ static int visor_write(struct tty_struct *tty, struct usb_serial_port *port,
|
|||||||
/* send it down the pipe */
|
/* send it down the pipe */
|
||||||
status = usb_submit_urb(urb, GFP_ATOMIC);
|
status = usb_submit_urb(urb, GFP_ATOMIC);
|
||||||
if (status) {
|
if (status) {
|
||||||
dev_err(&port->dev, "%s - usb_submit_urb(write bulk) failed with status = %d\n",
|
dev_err(&port->dev,
|
||||||
|
"%s - usb_submit_urb(write bulk) failed with status = %d\n",
|
||||||
__func__, status);
|
__func__, status);
|
||||||
count = status;
|
count = status;
|
||||||
goto error;
|
goto error;
|
||||||
@@ -497,11 +509,13 @@ static void visor_read_bulk_callback (struct urb *urb)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data);
|
usb_serial_debug_data(debug, &port->dev, __func__,
|
||||||
|
urb->actual_length, data);
|
||||||
|
|
||||||
tty = port->port.tty;
|
tty = port->port.tty;
|
||||||
if (tty && urb->actual_length) {
|
if (tty && urb->actual_length) {
|
||||||
available_room = tty_buffer_request_room(tty, urb->actual_length);
|
available_room = tty_buffer_request_room(tty,
|
||||||
|
urb->actual_length);
|
||||||
if (available_room) {
|
if (available_room) {
|
||||||
tty_insert_flip_string(tty, data, available_room);
|
tty_insert_flip_string(tty, data, available_room);
|
||||||
tty_flip_buffer_push(tty);
|
tty_flip_buffer_push(tty);
|
||||||
@@ -523,10 +537,11 @@ static void visor_read_bulk_callback (struct urb *urb)
|
|||||||
visor_read_bulk_callback, port);
|
visor_read_bulk_callback, port);
|
||||||
result = usb_submit_urb(port->read_urb, GFP_ATOMIC);
|
result = usb_submit_urb(port->read_urb, GFP_ATOMIC);
|
||||||
if (result)
|
if (result)
|
||||||
dev_err(&port->dev, "%s - failed resubmitting read urb, error %d\n", __func__, result);
|
dev_err(&port->dev,
|
||||||
} else {
|
"%s - failed resubmitting read urb, error %d\n",
|
||||||
|
__func__, result);
|
||||||
|
} else
|
||||||
priv->actually_throttled = 1;
|
priv->actually_throttled = 1;
|
||||||
}
|
|
||||||
spin_unlock(&priv->lock);
|
spin_unlock(&priv->lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -566,7 +581,8 @@ static void visor_read_int_callback (struct urb *urb)
|
|||||||
exit:
|
exit:
|
||||||
result = usb_submit_urb(urb, GFP_ATOMIC);
|
result = usb_submit_urb(urb, GFP_ATOMIC);
|
||||||
if (result)
|
if (result)
|
||||||
dev_err(&urb->dev->dev, "%s - Error %d submitting interrupt urb\n",
|
dev_err(&urb->dev->dev,
|
||||||
|
"%s - Error %d submitting interrupt urb\n",
|
||||||
__func__, result);
|
__func__, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -599,10 +615,13 @@ static void visor_unthrottle (struct tty_struct *tty)
|
|||||||
port->read_urb->dev = port->serial->dev;
|
port->read_urb->dev = port->serial->dev;
|
||||||
result = usb_submit_urb(port->read_urb, GFP_ATOMIC);
|
result = usb_submit_urb(port->read_urb, GFP_ATOMIC);
|
||||||
if (result)
|
if (result)
|
||||||
dev_err(&port->dev, "%s - failed submitting read urb, error %d\n", __func__, result);
|
dev_err(&port->dev,
|
||||||
|
"%s - failed submitting read urb, error %d\n",
|
||||||
|
__func__, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int palm_os_3_probe (struct usb_serial *serial, const struct usb_device_id *id)
|
static int palm_os_3_probe(struct usb_serial *serial,
|
||||||
|
const struct usb_device_id *id)
|
||||||
{
|
{
|
||||||
struct device *dev = &serial->dev->dev;
|
struct device *dev = &serial->dev->dev;
|
||||||
struct visor_connection_info *connection_info;
|
struct visor_connection_info *connection_info;
|
||||||
@@ -634,11 +653,13 @@ static int palm_os_3_probe (struct usb_serial *serial, const struct usb_device_i
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (retval == sizeof(*connection_info)) {
|
if (retval == sizeof(*connection_info)) {
|
||||||
connection_info = (struct visor_connection_info *)transfer_buffer;
|
connection_info = (struct visor_connection_info *)
|
||||||
|
transfer_buffer;
|
||||||
|
|
||||||
num_ports = le16_to_cpu(connection_info->num_ports);
|
num_ports = le16_to_cpu(connection_info->num_ports);
|
||||||
for (i = 0; i < num_ports; ++i) {
|
for (i = 0; i < num_ports; ++i) {
|
||||||
switch (connection_info->connections[i].port_function_id) {
|
switch (
|
||||||
|
connection_info->connections[i].port_function_id) {
|
||||||
case VISOR_FUNCTION_GENERIC:
|
case VISOR_FUNCTION_GENERIC:
|
||||||
string = "Generic";
|
string = "Generic";
|
||||||
break;
|
break;
|
||||||
@@ -681,7 +702,8 @@ static int palm_os_3_probe (struct usb_serial *serial, const struct usb_device_i
|
|||||||
*/
|
*/
|
||||||
usb_set_serial_data(serial, (void *)(long)num_ports);
|
usb_set_serial_data(serial, (void *)(long)num_ports);
|
||||||
|
|
||||||
/* ask for the number of bytes available, but ignore the response as it is broken */
|
/* ask for the number of bytes available, but ignore the
|
||||||
|
response as it is broken */
|
||||||
retval = usb_control_msg(serial->dev,
|
retval = usb_control_msg(serial->dev,
|
||||||
usb_rcvctrlpipe(serial->dev, 0),
|
usb_rcvctrlpipe(serial->dev, 0),
|
||||||
VISOR_REQUEST_BYTES_AVAILABLE,
|
VISOR_REQUEST_BYTES_AVAILABLE,
|
||||||
@@ -698,7 +720,8 @@ exit:
|
|||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int palm_os_4_probe (struct usb_serial *serial, const struct usb_device_id *id)
|
static int palm_os_4_probe(struct usb_serial *serial,
|
||||||
|
const struct usb_device_id *id)
|
||||||
{
|
{
|
||||||
struct device *dev = &serial->dev->dev;
|
struct device *dev = &serial->dev->dev;
|
||||||
struct palm_ext_connection_info *connection_info;
|
struct palm_ext_connection_info *connection_info;
|
||||||
@@ -731,10 +754,12 @@ static int palm_os_4_probe (struct usb_serial *serial, const struct usb_device_i
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int visor_probe (struct usb_serial *serial, const struct usb_device_id *id)
|
static int visor_probe(struct usb_serial *serial,
|
||||||
|
const struct usb_device_id *id)
|
||||||
{
|
{
|
||||||
int retval = 0;
|
int retval = 0;
|
||||||
int (*startup) (struct usb_serial *serial, const struct usb_device_id *id);
|
int (*startup)(struct usb_serial *serial,
|
||||||
|
const struct usb_device_id *id);
|
||||||
|
|
||||||
dbg("%s", __func__);
|
dbg("%s", __func__);
|
||||||
|
|
||||||
@@ -801,11 +826,13 @@ static int clie_3_5_startup (struct usb_serial *serial)
|
|||||||
USB_REQ_GET_CONFIGURATION, USB_DIR_IN,
|
USB_REQ_GET_CONFIGURATION, USB_DIR_IN,
|
||||||
0, 0, &data, 1, 3000);
|
0, 0, &data, 1, 3000);
|
||||||
if (result < 0) {
|
if (result < 0) {
|
||||||
dev_err(dev, "%s: get config number failed: %d\n", __func__, result);
|
dev_err(dev, "%s: get config number failed: %d\n",
|
||||||
|
__func__, result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
if (result != 1) {
|
if (result != 1) {
|
||||||
dev_err(dev, "%s: get config number bad return length: %d\n", __func__, result);
|
dev_err(dev, "%s: get config number bad return length: %d\n",
|
||||||
|
__func__, result);
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -815,11 +842,14 @@ static int clie_3_5_startup (struct usb_serial *serial)
|
|||||||
USB_DIR_IN | USB_RECIP_INTERFACE,
|
USB_DIR_IN | USB_RECIP_INTERFACE,
|
||||||
0, 0, &data, 1, 3000);
|
0, 0, &data, 1, 3000);
|
||||||
if (result < 0) {
|
if (result < 0) {
|
||||||
dev_err(dev, "%s: get interface number failed: %d\n", __func__, result);
|
dev_err(dev, "%s: get interface number failed: %d\n",
|
||||||
|
__func__, result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
if (result != 1) {
|
if (result != 1) {
|
||||||
dev_err(dev, "%s: get interface number bad return length: %d\n", __func__, result);
|
dev_err(dev,
|
||||||
|
"%s: get interface number bad return length: %d\n",
|
||||||
|
__func__, result);
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -832,8 +862,10 @@ static int treo_attach (struct usb_serial *serial)
|
|||||||
|
|
||||||
/* Only do this endpoint hack for the Handspring devices with
|
/* Only do this endpoint hack for the Handspring devices with
|
||||||
* interrupt in endpoints, which for now are the Treo devices. */
|
* interrupt in endpoints, which for now are the Treo devices. */
|
||||||
if (!((le16_to_cpu(serial->dev->descriptor.idVendor) == HANDSPRING_VENDOR_ID) ||
|
if (!((le16_to_cpu(serial->dev->descriptor.idVendor)
|
||||||
(le16_to_cpu(serial->dev->descriptor.idVendor) == KYOCERA_VENDOR_ID)) ||
|
== HANDSPRING_VENDOR_ID) ||
|
||||||
|
(le16_to_cpu(serial->dev->descriptor.idVendor)
|
||||||
|
== KYOCERA_VENDOR_ID)) ||
|
||||||
(serial->num_interrupt_in == 0))
|
(serial->num_interrupt_in == 0))
|
||||||
goto generic_startup;
|
goto generic_startup;
|
||||||
|
|
||||||
@@ -847,12 +879,15 @@ static int treo_attach (struct usb_serial *serial)
|
|||||||
* apps that want to communicate on the second port.
|
* apps that want to communicate on the second port.
|
||||||
*/
|
*/
|
||||||
#define COPY_PORT(dest, src) \
|
#define COPY_PORT(dest, src) \
|
||||||
|
do { \
|
||||||
dest->read_urb = src->read_urb; \
|
dest->read_urb = src->read_urb; \
|
||||||
dest->bulk_in_endpointAddress = src->bulk_in_endpointAddress;\
|
dest->bulk_in_endpointAddress = src->bulk_in_endpointAddress;\
|
||||||
dest->bulk_in_buffer = src->bulk_in_buffer; \
|
dest->bulk_in_buffer = src->bulk_in_buffer; \
|
||||||
dest->interrupt_in_urb = src->interrupt_in_urb; \
|
dest->interrupt_in_urb = src->interrupt_in_urb; \
|
||||||
dest->interrupt_in_endpointAddress = src->interrupt_in_endpointAddress; \
|
dest->interrupt_in_endpointAddress = \
|
||||||
dest->interrupt_in_buffer = src->interrupt_in_buffer;
|
src->interrupt_in_endpointAddress;\
|
||||||
|
dest->interrupt_in_buffer = src->interrupt_in_buffer; \
|
||||||
|
} while (0);
|
||||||
|
|
||||||
swap_port = kmalloc(sizeof(*swap_port), GFP_KERNEL);
|
swap_port = kmalloc(sizeof(*swap_port), GFP_KERNEL);
|
||||||
if (!swap_port)
|
if (!swap_port)
|
||||||
@@ -871,8 +906,9 @@ static int clie_5_attach (struct usb_serial *serial)
|
|||||||
dbg("%s", __func__);
|
dbg("%s", __func__);
|
||||||
|
|
||||||
/* TH55 registers 2 ports.
|
/* TH55 registers 2 ports.
|
||||||
Communication in from the UX50/TH55 uses bulk_in_endpointAddress from port 0
|
Communication in from the UX50/TH55 uses bulk_in_endpointAddress
|
||||||
Communication out to the UX50/TH55 uses bulk_out_endpointAddress from port 1
|
from port 0. Communication out to the UX50/TH55 uses
|
||||||
|
bulk_out_endpointAddress from port 1
|
||||||
|
|
||||||
Lets do a quick and dirty mapping
|
Lets do a quick and dirty mapping
|
||||||
*/
|
*/
|
||||||
@@ -882,7 +918,8 @@ static int clie_5_attach (struct usb_serial *serial)
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
/* port 0 now uses the modified endpoint Address */
|
/* port 0 now uses the modified endpoint Address */
|
||||||
serial->port[0]->bulk_out_endpointAddress = serial->port[1]->bulk_out_endpointAddress;
|
serial->port[0]->bulk_out_endpointAddress =
|
||||||
|
serial->port[1]->bulk_out_endpointAddress;
|
||||||
|
|
||||||
return generic_startup(serial);
|
return generic_startup(serial);
|
||||||
}
|
}
|
||||||
@@ -907,10 +944,14 @@ static int __init visor_init (void)
|
|||||||
{
|
{
|
||||||
int i, retval;
|
int i, retval;
|
||||||
/* Only if parameters were passed to us */
|
/* Only if parameters were passed to us */
|
||||||
if ((vendor>0) && (product>0)) {
|
if (vendor > 0 && product > 0) {
|
||||||
struct usb_device_id usb_dev_temp[]=
|
struct usb_device_id usb_dev_temp[] = {
|
||||||
{{USB_DEVICE(vendor, product),
|
{
|
||||||
.driver_info = (kernel_ulong_t)&palm_os_4_probe }};
|
USB_DEVICE(vendor, product),
|
||||||
|
.driver_info =
|
||||||
|
(kernel_ulong_t) &palm_os_4_probe
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/* Find the last entry in id_table */
|
/* Find the last entry in id_table */
|
||||||
for (i = 0;; i++) {
|
for (i = 0;; i++) {
|
||||||
@@ -926,7 +967,8 @@ static int __init visor_init (void)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
info("Untested USB device specified at time of module insertion");
|
info(
|
||||||
|
"Untested USB device specified at time of module insertion");
|
||||||
info("Warning: This is not guaranteed to work");
|
info("Warning: This is not guaranteed to work");
|
||||||
info("Using a newer kernel is preferred to this method");
|
info("Using a newer kernel is preferred to this method");
|
||||||
info("Adding Palm OS protocol 4.x support for unknown device: 0x%x/0x%x",
|
info("Adding Palm OS protocol 4.x support for unknown device: 0x%x/0x%x",
|
||||||
|
Reference in New Issue
Block a user