Input: mtouchusb was indented with spaces instead of tabs, pass

through Lindent and adjust results.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
This commit is contained in:
Dmitry Torokhov 2005-05-29 02:29:08 -05:00
parent 05f091ab4c
commit 8baf9ed400

View File

@ -42,9 +42,9 @@
#include <linux/config.h> #include <linux/config.h>
#ifdef CONFIG_USB_DEBUG #ifdef CONFIG_USB_DEBUG
#define DEBUG #define DEBUG
#else #else
#undef DEBUG #undef DEBUG
#endif #endif
#include <linux/kernel.h> #include <linux/kernel.h>
@ -93,275 +93,262 @@ module_param(raw_coordinates, bool, S_IRUGO | S_IWUSR);
MODULE_PARM_DESC(raw_coordinates, "report raw coordinate values (y, default) or hardware-calibrated coordinate values (n)"); MODULE_PARM_DESC(raw_coordinates, "report raw coordinate values (y, default) or hardware-calibrated coordinate values (n)");
struct mtouch_usb { struct mtouch_usb {
unsigned char *data; unsigned char *data;
dma_addr_t data_dma; dma_addr_t data_dma;
struct urb *irq; struct urb *irq;
struct usb_device *udev; struct usb_device *udev;
struct input_dev input; struct input_dev input;
int open; int open;
char name[128]; char name[128];
char phys[64]; char phys[64];
}; };
static struct usb_device_id mtouchusb_devices [] = { static struct usb_device_id mtouchusb_devices[] = {
{ USB_DEVICE(0x0596, 0x0001) }, { USB_DEVICE(0x0596, 0x0001) },
{ } { }
}; };
static void mtouchusb_irq(struct urb *urb, struct pt_regs *regs) static void mtouchusb_irq(struct urb *urb, struct pt_regs *regs)
{ {
struct mtouch_usb *mtouch = urb->context; struct mtouch_usb *mtouch = urb->context;
int retval; int retval;
switch (urb->status) { switch (urb->status) {
case 0: case 0:
/* success */ /* success */
break; break;
case -ETIMEDOUT: case -ETIMEDOUT:
/* this urb is timing out */ /* this urb is timing out */
dbg("%s - urb timed out - was the device unplugged?", dbg("%s - urb timed out - was the device unplugged?",
__FUNCTION__); __FUNCTION__);
return; return;
case -ECONNRESET: case -ECONNRESET:
case -ENOENT: case -ENOENT:
case -ESHUTDOWN: case -ESHUTDOWN:
/* this urb is terminated, clean up */ /* this urb is terminated, clean up */
dbg("%s - urb shutting down with status: %d", dbg("%s - urb shutting down with status: %d",
__FUNCTION__, urb->status); __FUNCTION__, urb->status);
return; return;
default: default:
dbg("%s - nonzero urb status received: %d", dbg("%s - nonzero urb status received: %d",
__FUNCTION__, urb->status); __FUNCTION__, urb->status);
goto exit; goto exit;
} }
input_regs(&mtouch->input, regs); input_regs(&mtouch->input, regs);
input_report_key(&mtouch->input, BTN_TOUCH, input_report_key(&mtouch->input, BTN_TOUCH,
MTOUCHUSB_GET_TOUCHED(mtouch->data)); MTOUCHUSB_GET_TOUCHED(mtouch->data));
input_report_abs(&mtouch->input, ABS_X, input_report_abs(&mtouch->input, ABS_X, MTOUCHUSB_GET_XC(mtouch->data));
MTOUCHUSB_GET_XC(mtouch->data)); input_report_abs(&mtouch->input, ABS_Y,
input_report_abs(&mtouch->input, ABS_Y,
(raw_coordinates ? MTOUCHUSB_MAX_RAW_YC : MTOUCHUSB_MAX_CALIB_YC) (raw_coordinates ? MTOUCHUSB_MAX_RAW_YC : MTOUCHUSB_MAX_CALIB_YC)
- MTOUCHUSB_GET_YC(mtouch->data)); - MTOUCHUSB_GET_YC(mtouch->data));
input_sync(&mtouch->input); input_sync(&mtouch->input);
exit: exit:
retval = usb_submit_urb (urb, GFP_ATOMIC); retval = usb_submit_urb(urb, GFP_ATOMIC);
if (retval) if (retval)
err ("%s - usb_submit_urb failed with result: %d", err("%s - usb_submit_urb failed with result: %d",
__FUNCTION__, retval); __FUNCTION__, retval);
} }
static int mtouchusb_open (struct input_dev *input) static int mtouchusb_open(struct input_dev *input)
{ {
struct mtouch_usb *mtouch = input->private; struct mtouch_usb *mtouch = input->private;
if (mtouch->open++) if (mtouch->open++)
return 0; return 0;
mtouch->irq->dev = mtouch->udev; mtouch->irq->dev = mtouch->udev;
if (usb_submit_urb (mtouch->irq, GFP_ATOMIC)) { if (usb_submit_urb(mtouch->irq, GFP_ATOMIC)) {
mtouch->open--; mtouch->open--;
return -EIO; return -EIO;
} }
return 0; return 0;
} }
static void mtouchusb_close (struct input_dev *input) static void mtouchusb_close(struct input_dev *input)
{ {
struct mtouch_usb *mtouch = input->private; struct mtouch_usb *mtouch = input->private;
if (!--mtouch->open) if (!--mtouch->open)
usb_kill_urb (mtouch->irq); usb_kill_urb(mtouch->irq);
} }
static int mtouchusb_alloc_buffers(struct usb_device *udev, struct mtouch_usb *mtouch) static int mtouchusb_alloc_buffers(struct usb_device *udev, struct mtouch_usb *mtouch)
{ {
dbg("%s - called", __FUNCTION__); dbg("%s - called", __FUNCTION__);
mtouch->data = usb_buffer_alloc(udev, MTOUCHUSB_REPORT_DATA_SIZE, mtouch->data = usb_buffer_alloc(udev, MTOUCHUSB_REPORT_DATA_SIZE,
SLAB_ATOMIC, &mtouch->data_dma); SLAB_ATOMIC, &mtouch->data_dma);
if (!mtouch->data) if (!mtouch->data)
return -1; return -1;
return 0; return 0;
} }
static void mtouchusb_free_buffers(struct usb_device *udev, struct mtouch_usb *mtouch) static void mtouchusb_free_buffers(struct usb_device *udev, struct mtouch_usb *mtouch)
{ {
dbg("%s - called", __FUNCTION__); dbg("%s - called", __FUNCTION__);
if (mtouch->data) if (mtouch->data)
usb_buffer_free(udev, MTOUCHUSB_REPORT_DATA_SIZE, usb_buffer_free(udev, MTOUCHUSB_REPORT_DATA_SIZE,
mtouch->data, mtouch->data_dma); mtouch->data, mtouch->data_dma);
} }
static int mtouchusb_probe(struct usb_interface *intf, const struct usb_device_id *id) static int mtouchusb_probe(struct usb_interface *intf, const struct usb_device_id *id)
{ {
struct mtouch_usb *mtouch; struct mtouch_usb *mtouch;
struct usb_host_interface *interface; struct usb_host_interface *interface;
struct usb_endpoint_descriptor *endpoint; struct usb_endpoint_descriptor *endpoint;
struct usb_device *udev = interface_to_usbdev (intf); struct usb_device *udev = interface_to_usbdev(intf);
char path[64]; char path[64];
int nRet; int nRet;
dbg("%s - called", __FUNCTION__); dbg("%s - called", __FUNCTION__);
dbg("%s - setting interface", __FUNCTION__); dbg("%s - setting interface", __FUNCTION__);
interface = intf->cur_altsetting; interface = intf->cur_altsetting;
dbg("%s - setting endpoint", __FUNCTION__); dbg("%s - setting endpoint", __FUNCTION__);
endpoint = &interface->endpoint[0].desc; endpoint = &interface->endpoint[0].desc;
if (!(mtouch = kmalloc (sizeof (struct mtouch_usb), GFP_KERNEL))) { if (!(mtouch = kmalloc(sizeof(struct mtouch_usb), GFP_KERNEL))) {
err("%s - Out of memory.", __FUNCTION__); err("%s - Out of memory.", __FUNCTION__);
return -ENOMEM; return -ENOMEM;
} }
memset(mtouch, 0, sizeof(struct mtouch_usb)); memset(mtouch, 0, sizeof(struct mtouch_usb));
mtouch->udev = udev; mtouch->udev = udev;
dbg("%s - allocating buffers", __FUNCTION__); dbg("%s - allocating buffers", __FUNCTION__);
if (mtouchusb_alloc_buffers(udev, mtouch)) { if (mtouchusb_alloc_buffers(udev, mtouch)) {
mtouchusb_free_buffers(udev, mtouch); mtouchusb_free_buffers(udev, mtouch);
kfree(mtouch); kfree(mtouch);
return -ENOMEM; return -ENOMEM;
} }
mtouch->input.private = mtouch; mtouch->input.private = mtouch;
mtouch->input.open = mtouchusb_open; mtouch->input.open = mtouchusb_open;
mtouch->input.close = mtouchusb_close; mtouch->input.close = mtouchusb_close;
usb_make_path(udev, path, 64); usb_make_path(udev, path, 64);
sprintf(mtouch->phys, "%s/input0", path); sprintf(mtouch->phys, "%s/input0", path);
mtouch->input.name = mtouch->name; mtouch->input.name = mtouch->name;
mtouch->input.phys = mtouch->phys; mtouch->input.phys = mtouch->phys;
mtouch->input.id.bustype = BUS_USB; mtouch->input.id.bustype = BUS_USB;
mtouch->input.id.vendor = le16_to_cpu(udev->descriptor.idVendor); mtouch->input.id.vendor = le16_to_cpu(udev->descriptor.idVendor);
mtouch->input.id.product = le16_to_cpu(udev->descriptor.idProduct); mtouch->input.id.product = le16_to_cpu(udev->descriptor.idProduct);
mtouch->input.id.version = le16_to_cpu(udev->descriptor.bcdDevice); mtouch->input.id.version = le16_to_cpu(udev->descriptor.bcdDevice);
mtouch->input.dev = &intf->dev; mtouch->input.dev = &intf->dev;
mtouch->input.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); mtouch->input.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
mtouch->input.absbit[0] = BIT(ABS_X) | BIT(ABS_Y); mtouch->input.absbit[0] = BIT(ABS_X) | BIT(ABS_Y);
mtouch->input.keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); mtouch->input.keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH);
/* Used to Scale Compensated Data and Flip Y */ /* Used to Scale Compensated Data and Flip Y */
mtouch->input.absmin[ABS_X] = MTOUCHUSB_MIN_XC; mtouch->input.absmin[ABS_X] = MTOUCHUSB_MIN_XC;
mtouch->input.absmax[ABS_X] = raw_coordinates ? \ mtouch->input.absmax[ABS_X] = raw_coordinates ?
MTOUCHUSB_MAX_RAW_XC : MTOUCHUSB_MAX_CALIB_XC; MTOUCHUSB_MAX_RAW_XC : MTOUCHUSB_MAX_CALIB_XC;
mtouch->input.absfuzz[ABS_X] = MTOUCHUSB_XC_FUZZ; mtouch->input.absfuzz[ABS_X] = MTOUCHUSB_XC_FUZZ;
mtouch->input.absflat[ABS_X] = MTOUCHUSB_XC_FLAT; mtouch->input.absflat[ABS_X] = MTOUCHUSB_XC_FLAT;
mtouch->input.absmin[ABS_Y] = MTOUCHUSB_MIN_YC; mtouch->input.absmin[ABS_Y] = MTOUCHUSB_MIN_YC;
mtouch->input.absmax[ABS_Y] = raw_coordinates ? \ mtouch->input.absmax[ABS_Y] = raw_coordinates ?
MTOUCHUSB_MAX_RAW_YC : MTOUCHUSB_MAX_CALIB_YC; MTOUCHUSB_MAX_RAW_YC : MTOUCHUSB_MAX_CALIB_YC;
mtouch->input.absfuzz[ABS_Y] = MTOUCHUSB_YC_FUZZ; mtouch->input.absfuzz[ABS_Y] = MTOUCHUSB_YC_FUZZ;
mtouch->input.absflat[ABS_Y] = MTOUCHUSB_YC_FLAT; mtouch->input.absflat[ABS_Y] = MTOUCHUSB_YC_FLAT;
if (udev->manufacturer) if (udev->manufacturer)
strcat(mtouch->name, udev->manufacturer); strcat(mtouch->name, udev->manufacturer);
if (udev->product) if (udev->product)
sprintf(mtouch->name, "%s %s", mtouch->name, udev->product); sprintf(mtouch->name, "%s %s", mtouch->name, udev->product);
if (!strlen(mtouch->name)) if (!strlen(mtouch->name))
sprintf(mtouch->name, "USB Touchscreen %04x:%04x", sprintf(mtouch->name, "USB Touchscreen %04x:%04x",
mtouch->input.id.vendor, mtouch->input.id.product); mtouch->input.id.vendor, mtouch->input.id.product);
nRet = usb_control_msg(mtouch->udev, nRet = usb_control_msg(mtouch->udev, usb_rcvctrlpipe(udev, 0),
usb_rcvctrlpipe(udev, 0), MTOUCHUSB_RESET,
MTOUCHUSB_RESET, USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 1, 0, NULL, 0, USB_CTRL_SET_TIMEOUT);
1, dbg("%s - usb_control_msg - MTOUCHUSB_RESET - bytes|err: %d",
0, __FUNCTION__, nRet);
NULL,
0,
USB_CTRL_SET_TIMEOUT);
dbg("%s - usb_control_msg - MTOUCHUSB_RESET - bytes|err: %d",
__FUNCTION__, nRet);
dbg("%s - usb_alloc_urb: mtouch->irq", __FUNCTION__); dbg("%s - usb_alloc_urb: mtouch->irq", __FUNCTION__);
mtouch->irq = usb_alloc_urb(0, GFP_KERNEL); mtouch->irq = usb_alloc_urb(0, GFP_KERNEL);
if (!mtouch->irq) { if (!mtouch->irq) {
dbg("%s - usb_alloc_urb failed: mtouch->irq", __FUNCTION__); dbg("%s - usb_alloc_urb failed: mtouch->irq", __FUNCTION__);
mtouchusb_free_buffers(udev, mtouch); mtouchusb_free_buffers(udev, mtouch);
kfree(mtouch); kfree(mtouch);
return -ENOMEM; return -ENOMEM;
} }
dbg("%s - usb_fill_int_urb", __FUNCTION__); dbg("%s - usb_fill_int_urb", __FUNCTION__);
usb_fill_int_urb(mtouch->irq, usb_fill_int_urb(mtouch->irq, mtouch->udev,
mtouch->udev, usb_rcvintpipe(mtouch->udev, 0x81),
usb_rcvintpipe(mtouch->udev, 0x81), mtouch->data, MTOUCHUSB_REPORT_DATA_SIZE,
mtouch->data, mtouchusb_irq, mtouch, endpoint->bInterval);
MTOUCHUSB_REPORT_DATA_SIZE,
mtouchusb_irq,
mtouch,
endpoint->bInterval);
dbg("%s - input_register_device", __FUNCTION__); dbg("%s - input_register_device", __FUNCTION__);
input_register_device(&mtouch->input); input_register_device(&mtouch->input);
nRet = usb_control_msg(mtouch->udev, nRet = usb_control_msg(mtouch->udev, usb_rcvctrlpipe(udev, 0),
usb_rcvctrlpipe(udev, 0), MTOUCHUSB_ASYNC_REPORT,
MTOUCHUSB_ASYNC_REPORT, USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 1, 1, NULL, 0, USB_CTRL_SET_TIMEOUT);
1, dbg("%s - usb_control_msg - MTOUCHUSB_ASYNC_REPORT - bytes|err: %d",
1, __FUNCTION__, nRet);
NULL,
0,
USB_CTRL_SET_TIMEOUT);
dbg("%s - usb_control_msg - MTOUCHUSB_ASYNC_REPORT - bytes|err: %d",
__FUNCTION__, nRet);
printk(KERN_INFO "input: %s on %s\n", mtouch->name, path); printk(KERN_INFO "input: %s on %s\n", mtouch->name, path);
usb_set_intfdata(intf, mtouch); usb_set_intfdata(intf, mtouch);
return 0; return 0;
} }
static void mtouchusb_disconnect(struct usb_interface *intf) static void mtouchusb_disconnect(struct usb_interface *intf)
{ {
struct mtouch_usb *mtouch = usb_get_intfdata (intf); struct mtouch_usb *mtouch = usb_get_intfdata(intf);
dbg("%s - called", __FUNCTION__); dbg("%s - called", __FUNCTION__);
usb_set_intfdata(intf, NULL); usb_set_intfdata(intf, NULL);
if (mtouch) { if (mtouch) {
dbg("%s - mtouch is initialized, cleaning up", __FUNCTION__); dbg("%s - mtouch is initialized, cleaning up", __FUNCTION__);
usb_kill_urb(mtouch->irq); usb_kill_urb(mtouch->irq);
input_unregister_device(&mtouch->input); input_unregister_device(&mtouch->input);
usb_free_urb(mtouch->irq); usb_free_urb(mtouch->irq);
mtouchusb_free_buffers(interface_to_usbdev(intf), mtouch); mtouchusb_free_buffers(interface_to_usbdev(intf), mtouch);
kfree(mtouch); kfree(mtouch);
} }
} }
MODULE_DEVICE_TABLE (usb, mtouchusb_devices); MODULE_DEVICE_TABLE(usb, mtouchusb_devices);
static struct usb_driver mtouchusb_driver = { static struct usb_driver mtouchusb_driver = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.name = "mtouchusb", .name = "mtouchusb",
.probe = mtouchusb_probe, .probe = mtouchusb_probe,
.disconnect = mtouchusb_disconnect, .disconnect = mtouchusb_disconnect,
.id_table = mtouchusb_devices, .id_table = mtouchusb_devices,
}; };
static int __init mtouchusb_init(void) { static int __init mtouchusb_init(void)
dbg("%s - called", __FUNCTION__); {
return usb_register(&mtouchusb_driver); dbg("%s - called", __FUNCTION__);
return usb_register(&mtouchusb_driver);
} }
static void __exit mtouchusb_cleanup(void) { static void __exit mtouchusb_cleanup(void)
dbg("%s - called", __FUNCTION__); {
usb_deregister(&mtouchusb_driver); dbg("%s - called", __FUNCTION__);
usb_deregister(&mtouchusb_driver);
} }
module_init(mtouchusb_init); module_init(mtouchusb_init);
module_exit(mtouchusb_cleanup); module_exit(mtouchusb_cleanup);
MODULE_AUTHOR( DRIVER_AUTHOR ); MODULE_AUTHOR(DRIVER_AUTHOR);
MODULE_DESCRIPTION( DRIVER_DESC ); MODULE_DESCRIPTION(DRIVER_DESC);
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");