Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * USB IR Dongle driver |
| 3 | * |
| 4 | * Copyright (C) 2001-2002 Greg Kroah-Hartman (greg@kroah.com) |
| 5 | * Copyright (C) 2002 Gary Brubaker (xavyer@ix.netcom.com) |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; either version 2 of the License, or |
| 10 | * (at your option) any later version. |
| 11 | * |
| 12 | * This driver allows a USB IrDA device to be used as a "dumb" serial device. |
| 13 | * This can be useful if you do not have access to a full IrDA stack on the |
| 14 | * other side of the connection. If you do have an IrDA stack on both devices, |
| 15 | * please use the usb-irda driver, as it contains the proper error checking and |
| 16 | * other goodness of a full IrDA stack. |
| 17 | * |
| 18 | * Portions of this driver were taken from drivers/net/irda/irda-usb.c, which |
| 19 | * was written by Roman Weissgaerber <weissg@vienna.at>, Dag Brattli |
| 20 | * <dag@brattli.net>, and Jean Tourrilhes <jt@hpl.hp.com> |
| 21 | * |
Felipe Balbi | e0d795e | 2008-06-03 14:47:52 +0300 | [diff] [blame] | 22 | * See Documentation/usb/usb-serial.txt for more information on using this |
| 23 | * driver |
| 24 | * |
| 25 | * 2008_Jun_02 Felipe Balbi <me@felipebalbi.com> |
| 26 | * Introduced common header to be used also in USB Gadget Framework. |
| 27 | * Still needs some other style fixes. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | * |
Alan Cox | 8eb04cf | 2008-11-11 14:48:44 +0000 | [diff] [blame] | 29 | * 2007_Jun_21 Alan Cox <alan@lxorguk.ukuu.org.uk> |
Alan Cox | a6ea438 | 2007-06-22 14:44:54 +0100 | [diff] [blame] | 30 | * Minimal cleanups for some of the driver problens and tty layer abuse. |
| 31 | * Still needs fixing to allow multiple dongles. |
| 32 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | * 2002_Mar_07 greg kh |
| 34 | * moved some needed structures and #define values from the |
| 35 | * net/irda/irda-usb.h file into our file, as we don't want to depend on |
| 36 | * that codebase compiling correctly :) |
| 37 | * |
| 38 | * 2002_Jan_14 gb |
| 39 | * Added module parameter to force specific number of XBOFs. |
| 40 | * Added ir_xbof_change(). |
| 41 | * Reorganized read_bulk_callback error handling. |
| 42 | * Switched from FILL_BULK_URB() to usb_fill_bulk_urb(). |
| 43 | * |
| 44 | * 2001_Nov_08 greg kh |
| 45 | * Changed the irda_usb_find_class_desc() function based on comments and |
| 46 | * code from Martin Diehl. |
| 47 | * |
| 48 | * 2001_Nov_01 greg kh |
| 49 | * Added support for more IrDA USB devices. |
| 50 | * Added support for zero packet. Added buffer override paramater, so |
| 51 | * users can transfer larger packets at once if they wish. Both patches |
| 52 | * came from Dag Brattli <dag@obexcode.com>. |
| 53 | * |
| 54 | * 2001_Oct_07 greg kh |
| 55 | * initial version released. |
| 56 | */ |
| 57 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | #include <linux/kernel.h> |
| 59 | #include <linux/errno.h> |
| 60 | #include <linux/init.h> |
| 61 | #include <linux/slab.h> |
| 62 | #include <linux/tty.h> |
| 63 | #include <linux/tty_driver.h> |
| 64 | #include <linux/tty_flip.h> |
| 65 | #include <linux/module.h> |
| 66 | #include <linux/spinlock.h> |
Felipe Balbi | e0d795e | 2008-06-03 14:47:52 +0300 | [diff] [blame] | 67 | #include <linux/uaccess.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | #include <linux/usb.h> |
Greg Kroah-Hartman | a969888 | 2006-07-11 21:22:58 -0700 | [diff] [blame] | 69 | #include <linux/usb/serial.h> |
Felipe Balbi | e0d795e | 2008-06-03 14:47:52 +0300 | [diff] [blame] | 70 | #include <linux/usb/irda.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 71 | |
| 72 | /* |
| 73 | * Version Information |
| 74 | */ |
| 75 | #define DRIVER_VERSION "v0.4" |
| 76 | #define DRIVER_AUTHOR "Greg Kroah-Hartman <greg@kroah.com>" |
| 77 | #define DRIVER_DESC "USB IR Dongle driver" |
| 78 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 79 | static int debug; |
| 80 | |
| 81 | /* if overridden by the user, then use their value for the size of the read and |
| 82 | * write urbs */ |
| 83 | static int buffer_size; |
Felipe Balbi | e0d795e | 2008-06-03 14:47:52 +0300 | [diff] [blame] | 84 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 | /* if overridden by the user, then use the specified number of XBOFs */ |
| 86 | static int xbof = -1; |
| 87 | |
Alan Cox | 95da310 | 2008-07-22 11:09:07 +0100 | [diff] [blame] | 88 | static int ir_startup (struct usb_serial *serial); |
Alan Cox | a509a7e | 2009-09-19 13:13:26 -0700 | [diff] [blame] | 89 | static int ir_open(struct tty_struct *tty, struct usb_serial_port *port); |
Alan Cox | 335f851 | 2009-06-11 12:26:29 +0100 | [diff] [blame] | 90 | static void ir_close(struct usb_serial_port *port); |
Alan Cox | 95da310 | 2008-07-22 11:09:07 +0100 | [diff] [blame] | 91 | static int ir_write(struct tty_struct *tty, struct usb_serial_port *port, |
| 92 | const unsigned char *buf, int count); |
| 93 | static void ir_write_bulk_callback (struct urb *urb); |
| 94 | static void ir_read_bulk_callback (struct urb *urb); |
| 95 | static void ir_set_termios(struct tty_struct *tty, |
| 96 | struct usb_serial_port *port, struct ktermios *old_termios); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 97 | |
Alan Cox | a6ea438 | 2007-06-22 14:44:54 +0100 | [diff] [blame] | 98 | /* Not that this lot means you can only have one per system */ |
Felipe Balbi | e0d795e | 2008-06-03 14:47:52 +0300 | [diff] [blame] | 99 | static u8 ir_baud; |
| 100 | static u8 ir_xbof; |
| 101 | static u8 ir_add_bof; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 102 | |
Felipe Balbi | e0d795e | 2008-06-03 14:47:52 +0300 | [diff] [blame] | 103 | static struct usb_device_id ir_id_table[] = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 104 | { USB_DEVICE(0x050f, 0x0180) }, /* KC Technology, KC-180 */ |
| 105 | { USB_DEVICE(0x08e9, 0x0100) }, /* XTNDAccess */ |
| 106 | { USB_DEVICE(0x09c4, 0x0011) }, /* ACTiSys ACT-IR2000U */ |
Felipe Balbi | e0d795e | 2008-06-03 14:47:52 +0300 | [diff] [blame] | 107 | { USB_INTERFACE_INFO(USB_CLASS_APP_SPEC, USB_SUBCLASS_IRDA, 0) }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 108 | { } /* Terminating entry */ |
| 109 | }; |
| 110 | |
Felipe Balbi | e0d795e | 2008-06-03 14:47:52 +0300 | [diff] [blame] | 111 | MODULE_DEVICE_TABLE(usb, ir_id_table); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 112 | |
| 113 | static struct usb_driver ir_driver = { |
Felipe Balbi | e0d795e | 2008-06-03 14:47:52 +0300 | [diff] [blame] | 114 | .name = "ir-usb", |
| 115 | .probe = usb_serial_probe, |
| 116 | .disconnect = usb_serial_disconnect, |
| 117 | .id_table = ir_id_table, |
| 118 | .no_dynamic_id = 1, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 119 | }; |
| 120 | |
Greg Kroah-Hartman | ea65370 | 2005-06-20 21:15:16 -0700 | [diff] [blame] | 121 | static struct usb_serial_driver ir_device = { |
Felipe Balbi | e0d795e | 2008-06-03 14:47:52 +0300 | [diff] [blame] | 122 | .driver = { |
| 123 | .owner = THIS_MODULE, |
| 124 | .name = "ir-usb", |
Greg Kroah-Hartman | 18fcac3 | 2005-06-20 21:15:16 -0700 | [diff] [blame] | 125 | }, |
Felipe Balbi | e0d795e | 2008-06-03 14:47:52 +0300 | [diff] [blame] | 126 | .description = "IR Dongle", |
| 127 | .usb_driver = &ir_driver, |
| 128 | .id_table = ir_id_table, |
| 129 | .num_ports = 1, |
| 130 | .set_termios = ir_set_termios, |
| 131 | .attach = ir_startup, |
| 132 | .open = ir_open, |
| 133 | .close = ir_close, |
| 134 | .write = ir_write, |
| 135 | .write_bulk_callback = ir_write_bulk_callback, |
| 136 | .read_bulk_callback = ir_read_bulk_callback, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 137 | }; |
| 138 | |
Felipe Balbi | e0d795e | 2008-06-03 14:47:52 +0300 | [diff] [blame] | 139 | static inline void irda_usb_dump_class_desc(struct usb_irda_cs_descriptor *desc) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 140 | { |
| 141 | dbg("bLength=%x", desc->bLength); |
| 142 | dbg("bDescriptorType=%x", desc->bDescriptorType); |
Felipe Balbi | e0d795e | 2008-06-03 14:47:52 +0300 | [diff] [blame] | 143 | dbg("bcdSpecRevision=%x", __le16_to_cpu(desc->bcdSpecRevision)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 144 | dbg("bmDataSize=%x", desc->bmDataSize); |
| 145 | dbg("bmWindowSize=%x", desc->bmWindowSize); |
| 146 | dbg("bmMinTurnaroundTime=%d", desc->bmMinTurnaroundTime); |
Felipe Balbi | e0d795e | 2008-06-03 14:47:52 +0300 | [diff] [blame] | 147 | dbg("wBaudRate=%x", __le16_to_cpu(desc->wBaudRate)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 148 | dbg("bmAdditionalBOFs=%x", desc->bmAdditionalBOFs); |
| 149 | dbg("bIrdaRateSniff=%x", desc->bIrdaRateSniff); |
| 150 | dbg("bMaxUnicastList=%x", desc->bMaxUnicastList); |
| 151 | } |
| 152 | |
| 153 | /*------------------------------------------------------------------*/ |
| 154 | /* |
| 155 | * Function irda_usb_find_class_desc(dev, ifnum) |
| 156 | * |
| 157 | * Returns instance of IrDA class descriptor, or NULL if not found |
| 158 | * |
| 159 | * The class descriptor is some extra info that IrDA USB devices will |
| 160 | * offer to us, describing their IrDA characteristics. We will use that in |
| 161 | * irda_usb_init_qos() |
| 162 | * |
| 163 | * Based on the same function in drivers/net/irda/irda-usb.c |
| 164 | */ |
Felipe Balbi | e0d795e | 2008-06-03 14:47:52 +0300 | [diff] [blame] | 165 | static struct usb_irda_cs_descriptor * |
| 166 | irda_usb_find_class_desc(struct usb_device *dev, unsigned int ifnum) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 167 | { |
Felipe Balbi | e0d795e | 2008-06-03 14:47:52 +0300 | [diff] [blame] | 168 | struct usb_irda_cs_descriptor *desc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 169 | int ret; |
Felipe Balbi | e0d795e | 2008-06-03 14:47:52 +0300 | [diff] [blame] | 170 | |
| 171 | desc = kzalloc(sizeof(*desc), GFP_KERNEL); |
| 172 | if (!desc) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 173 | return NULL; |
Felipe Balbi | e0d795e | 2008-06-03 14:47:52 +0300 | [diff] [blame] | 174 | |
| 175 | ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), |
| 176 | USB_REQ_CS_IRDA_GET_CLASS_DESC, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 177 | USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE, |
| 178 | 0, ifnum, desc, sizeof(*desc), 1000); |
Felipe Balbi | e0d795e | 2008-06-03 14:47:52 +0300 | [diff] [blame] | 179 | |
Harvey Harrison | 441b62c | 2008-03-03 16:08:34 -0800 | [diff] [blame] | 180 | dbg("%s - ret=%d", __func__, ret); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 181 | if (ret < sizeof(*desc)) { |
| 182 | dbg("%s - class descriptor read %s (%d)", |
Harvey Harrison | 441b62c | 2008-03-03 16:08:34 -0800 | [diff] [blame] | 183 | __func__, |
Felipe Balbi | e0d795e | 2008-06-03 14:47:52 +0300 | [diff] [blame] | 184 | (ret < 0) ? "failed" : "too short", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 185 | ret); |
| 186 | goto error; |
| 187 | } |
Felipe Balbi | e0d795e | 2008-06-03 14:47:52 +0300 | [diff] [blame] | 188 | if (desc->bDescriptorType != USB_DT_CS_IRDA) { |
Harvey Harrison | 441b62c | 2008-03-03 16:08:34 -0800 | [diff] [blame] | 189 | dbg("%s - bad class descriptor type", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 190 | goto error; |
| 191 | } |
Felipe Balbi | e0d795e | 2008-06-03 14:47:52 +0300 | [diff] [blame] | 192 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 193 | irda_usb_dump_class_desc(desc); |
| 194 | return desc; |
Felipe Balbi | e0d795e | 2008-06-03 14:47:52 +0300 | [diff] [blame] | 195 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 196 | error: |
| 197 | kfree(desc); |
| 198 | return NULL; |
| 199 | } |
| 200 | |
| 201 | |
| 202 | static u8 ir_xbof_change(u8 xbof) |
| 203 | { |
| 204 | u8 result; |
Felipe Balbi | e0d795e | 2008-06-03 14:47:52 +0300 | [diff] [blame] | 205 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 206 | /* reference irda-usb.c */ |
Felipe Balbi | e0d795e | 2008-06-03 14:47:52 +0300 | [diff] [blame] | 207 | switch (xbof) { |
| 208 | case 48: |
| 209 | result = 0x10; |
| 210 | break; |
| 211 | case 28: |
| 212 | case 24: |
| 213 | result = 0x20; |
| 214 | break; |
| 215 | default: |
| 216 | case 12: |
| 217 | result = 0x30; |
| 218 | break; |
| 219 | case 5: |
| 220 | case 6: |
| 221 | result = 0x40; |
| 222 | break; |
| 223 | case 3: |
| 224 | result = 0x50; |
| 225 | break; |
| 226 | case 2: |
| 227 | result = 0x60; |
| 228 | break; |
| 229 | case 1: |
| 230 | result = 0x70; |
| 231 | break; |
| 232 | case 0: |
| 233 | result = 0x80; |
| 234 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 235 | } |
Felipe Balbi | e0d795e | 2008-06-03 14:47:52 +0300 | [diff] [blame] | 236 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 237 | return(result); |
| 238 | } |
| 239 | |
| 240 | |
Felipe Balbi | e0d795e | 2008-06-03 14:47:52 +0300 | [diff] [blame] | 241 | static int ir_startup(struct usb_serial *serial) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 242 | { |
Felipe Balbi | e0d795e | 2008-06-03 14:47:52 +0300 | [diff] [blame] | 243 | struct usb_irda_cs_descriptor *irda_desc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 244 | |
Felipe Balbi | e0d795e | 2008-06-03 14:47:52 +0300 | [diff] [blame] | 245 | irda_desc = irda_usb_find_class_desc(serial->dev, 0); |
| 246 | if (!irda_desc) { |
| 247 | dev_err(&serial->dev->dev, |
| 248 | "IRDA class descriptor not found, device not bound\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 249 | return -ENODEV; |
| 250 | } |
| 251 | |
Felipe Balbi | e0d795e | 2008-06-03 14:47:52 +0300 | [diff] [blame] | 252 | dbg("%s - Baud rates supported:%s%s%s%s%s%s%s%s%s", |
Harvey Harrison | 441b62c | 2008-03-03 16:08:34 -0800 | [diff] [blame] | 253 | __func__, |
Felipe Balbi | e0d795e | 2008-06-03 14:47:52 +0300 | [diff] [blame] | 254 | (irda_desc->wBaudRate & USB_IRDA_BR_2400) ? " 2400" : "", |
| 255 | (irda_desc->wBaudRate & USB_IRDA_BR_9600) ? " 9600" : "", |
| 256 | (irda_desc->wBaudRate & USB_IRDA_BR_19200) ? " 19200" : "", |
| 257 | (irda_desc->wBaudRate & USB_IRDA_BR_38400) ? " 38400" : "", |
| 258 | (irda_desc->wBaudRate & USB_IRDA_BR_57600) ? " 57600" : "", |
| 259 | (irda_desc->wBaudRate & USB_IRDA_BR_115200) ? " 115200" : "", |
| 260 | (irda_desc->wBaudRate & USB_IRDA_BR_576000) ? " 576000" : "", |
| 261 | (irda_desc->wBaudRate & USB_IRDA_BR_1152000) ? " 1152000" : "", |
| 262 | (irda_desc->wBaudRate & USB_IRDA_BR_4000000) ? " 4000000" : ""); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 263 | |
Felipe Balbi | e0d795e | 2008-06-03 14:47:52 +0300 | [diff] [blame] | 264 | switch (irda_desc->bmAdditionalBOFs) { |
| 265 | case USB_IRDA_AB_48: |
| 266 | ir_add_bof = 48; |
| 267 | break; |
| 268 | case USB_IRDA_AB_24: |
| 269 | ir_add_bof = 24; |
| 270 | break; |
| 271 | case USB_IRDA_AB_12: |
| 272 | ir_add_bof = 12; |
| 273 | break; |
| 274 | case USB_IRDA_AB_6: |
| 275 | ir_add_bof = 6; |
| 276 | break; |
| 277 | case USB_IRDA_AB_3: |
| 278 | ir_add_bof = 3; |
| 279 | break; |
| 280 | case USB_IRDA_AB_2: |
| 281 | ir_add_bof = 2; |
| 282 | break; |
| 283 | case USB_IRDA_AB_1: |
| 284 | ir_add_bof = 1; |
| 285 | break; |
| 286 | case USB_IRDA_AB_0: |
| 287 | ir_add_bof = 0; |
| 288 | break; |
| 289 | default: |
| 290 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 291 | } |
| 292 | |
Felipe Balbi | e0d795e | 2008-06-03 14:47:52 +0300 | [diff] [blame] | 293 | kfree(irda_desc); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 294 | |
Felipe Balbi | e0d795e | 2008-06-03 14:47:52 +0300 | [diff] [blame] | 295 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 296 | } |
| 297 | |
Alan Cox | a509a7e | 2009-09-19 13:13:26 -0700 | [diff] [blame] | 298 | static int ir_open(struct tty_struct *tty, struct usb_serial_port *port) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 299 | { |
| 300 | char *buffer; |
| 301 | int result = 0; |
| 302 | |
Harvey Harrison | 441b62c | 2008-03-03 16:08:34 -0800 | [diff] [blame] | 303 | dbg("%s - port %d", __func__, port->number); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 304 | |
| 305 | if (buffer_size) { |
| 306 | /* override the default buffer sizes */ |
Felipe Balbi | e0d795e | 2008-06-03 14:47:52 +0300 | [diff] [blame] | 307 | buffer = kmalloc(buffer_size, GFP_KERNEL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 308 | if (!buffer) { |
Felipe Balbi | e0d795e | 2008-06-03 14:47:52 +0300 | [diff] [blame] | 309 | dev_err(&port->dev, "%s - out of memory.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 310 | return -ENOMEM; |
| 311 | } |
Felipe Balbi | e0d795e | 2008-06-03 14:47:52 +0300 | [diff] [blame] | 312 | kfree(port->read_urb->transfer_buffer); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 313 | port->read_urb->transfer_buffer = buffer; |
| 314 | port->read_urb->transfer_buffer_length = buffer_size; |
| 315 | |
Felipe Balbi | e0d795e | 2008-06-03 14:47:52 +0300 | [diff] [blame] | 316 | buffer = kmalloc(buffer_size, GFP_KERNEL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 317 | if (!buffer) { |
Felipe Balbi | e0d795e | 2008-06-03 14:47:52 +0300 | [diff] [blame] | 318 | dev_err(&port->dev, "%s - out of memory.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 319 | return -ENOMEM; |
| 320 | } |
Felipe Balbi | e0d795e | 2008-06-03 14:47:52 +0300 | [diff] [blame] | 321 | kfree(port->write_urb->transfer_buffer); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 322 | port->write_urb->transfer_buffer = buffer; |
| 323 | port->write_urb->transfer_buffer_length = buffer_size; |
| 324 | port->bulk_out_size = buffer_size; |
| 325 | } |
| 326 | |
| 327 | /* Start reading from the device */ |
Felipe Balbi | e0d795e | 2008-06-03 14:47:52 +0300 | [diff] [blame] | 328 | usb_fill_bulk_urb( |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 329 | port->read_urb, |
Felipe Balbi | e0d795e | 2008-06-03 14:47:52 +0300 | [diff] [blame] | 330 | port->serial->dev, |
| 331 | usb_rcvbulkpipe(port->serial->dev, |
| 332 | port->bulk_in_endpointAddress), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 333 | port->read_urb->transfer_buffer, |
| 334 | port->read_urb->transfer_buffer_length, |
| 335 | ir_read_bulk_callback, |
| 336 | port); |
| 337 | result = usb_submit_urb(port->read_urb, GFP_KERNEL); |
| 338 | if (result) |
Felipe Balbi | e0d795e | 2008-06-03 14:47:52 +0300 | [diff] [blame] | 339 | dev_err(&port->dev, |
| 340 | "%s - failed submitting read urb, error %d\n", |
| 341 | __func__, result); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 342 | |
| 343 | return result; |
| 344 | } |
| 345 | |
Alan Cox | 335f851 | 2009-06-11 12:26:29 +0100 | [diff] [blame] | 346 | static void ir_close(struct usb_serial_port *port) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 347 | { |
Harvey Harrison | 441b62c | 2008-03-03 16:08:34 -0800 | [diff] [blame] | 348 | dbg("%s - port %d", __func__, port->number); |
Felipe Balbi | e0d795e | 2008-06-03 14:47:52 +0300 | [diff] [blame] | 349 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 350 | /* shutdown our bulk read */ |
| 351 | usb_kill_urb(port->read_urb); |
| 352 | } |
| 353 | |
Alan Cox | 95da310 | 2008-07-22 11:09:07 +0100 | [diff] [blame] | 354 | static int ir_write(struct tty_struct *tty, struct usb_serial_port *port, |
| 355 | const unsigned char *buf, int count) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 356 | { |
| 357 | unsigned char *transfer_buffer; |
| 358 | int result; |
| 359 | int transfer_size; |
| 360 | |
Harvey Harrison | 441b62c | 2008-03-03 16:08:34 -0800 | [diff] [blame] | 361 | dbg("%s - port = %d, count = %d", __func__, port->number, count); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 362 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 363 | if (count == 0) |
| 364 | return 0; |
| 365 | |
Peter Zijlstra | e81ee63 | 2006-09-25 12:51:41 +0200 | [diff] [blame] | 366 | spin_lock_bh(&port->lock); |
Greg Kroah-Hartman | 507ca9b | 2005-04-23 12:49:16 -0700 | [diff] [blame] | 367 | if (port->write_urb_busy) { |
Peter Zijlstra | e81ee63 | 2006-09-25 12:51:41 +0200 | [diff] [blame] | 368 | spin_unlock_bh(&port->lock); |
Harvey Harrison | 441b62c | 2008-03-03 16:08:34 -0800 | [diff] [blame] | 369 | dbg("%s - already writing", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 370 | return 0; |
| 371 | } |
Greg Kroah-Hartman | 507ca9b | 2005-04-23 12:49:16 -0700 | [diff] [blame] | 372 | port->write_urb_busy = 1; |
Peter Zijlstra | e81ee63 | 2006-09-25 12:51:41 +0200 | [diff] [blame] | 373 | spin_unlock_bh(&port->lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 374 | |
| 375 | transfer_buffer = port->write_urb->transfer_buffer; |
| 376 | transfer_size = min(count, port->bulk_out_size - 1); |
| 377 | |
| 378 | /* |
| 379 | * The first byte of the packet we send to the device contains an |
Felipe Balbi | e0d795e | 2008-06-03 14:47:52 +0300 | [diff] [blame] | 380 | * inbound header which indicates an additional number of BOFs and |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 381 | * a baud rate change. |
| 382 | * |
| 383 | * See section 5.4.2.2 of the USB IrDA spec. |
| 384 | */ |
| 385 | *transfer_buffer = ir_xbof | ir_baud; |
| 386 | ++transfer_buffer; |
| 387 | |
Felipe Balbi | e0d795e | 2008-06-03 14:47:52 +0300 | [diff] [blame] | 388 | memcpy(transfer_buffer, buf, transfer_size); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 389 | |
Felipe Balbi | e0d795e | 2008-06-03 14:47:52 +0300 | [diff] [blame] | 390 | usb_fill_bulk_urb( |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 391 | port->write_urb, |
| 392 | port->serial->dev, |
| 393 | usb_sndbulkpipe(port->serial->dev, |
| 394 | port->bulk_out_endpointAddress), |
| 395 | port->write_urb->transfer_buffer, |
| 396 | transfer_size + 1, |
| 397 | ir_write_bulk_callback, |
| 398 | port); |
| 399 | |
| 400 | port->write_urb->transfer_flags = URB_ZERO_PACKET; |
| 401 | |
Felipe Balbi | e0d795e | 2008-06-03 14:47:52 +0300 | [diff] [blame] | 402 | result = usb_submit_urb(port->write_urb, GFP_ATOMIC); |
Greg Kroah-Hartman | 507ca9b | 2005-04-23 12:49:16 -0700 | [diff] [blame] | 403 | if (result) { |
| 404 | port->write_urb_busy = 0; |
Felipe Balbi | e0d795e | 2008-06-03 14:47:52 +0300 | [diff] [blame] | 405 | dev_err(&port->dev, |
| 406 | "%s - failed submitting write urb, error %d\n", |
| 407 | __func__, result); |
Greg Kroah-Hartman | 507ca9b | 2005-04-23 12:49:16 -0700 | [diff] [blame] | 408 | } else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 409 | result = transfer_size; |
| 410 | |
| 411 | return result; |
| 412 | } |
| 413 | |
Felipe Balbi | e0d795e | 2008-06-03 14:47:52 +0300 | [diff] [blame] | 414 | static void ir_write_bulk_callback(struct urb *urb) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 415 | { |
Ming Lei | cdc9779 | 2008-02-24 18:41:47 +0800 | [diff] [blame] | 416 | struct usb_serial_port *port = urb->context; |
Greg Kroah-Hartman | 3152b74 | 2007-06-15 15:44:13 -0700 | [diff] [blame] | 417 | int status = urb->status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 418 | |
Harvey Harrison | 441b62c | 2008-03-03 16:08:34 -0800 | [diff] [blame] | 419 | dbg("%s - port %d", __func__, port->number); |
Greg Kroah-Hartman | 507ca9b | 2005-04-23 12:49:16 -0700 | [diff] [blame] | 420 | |
| 421 | port->write_urb_busy = 0; |
Greg Kroah-Hartman | 3152b74 | 2007-06-15 15:44:13 -0700 | [diff] [blame] | 422 | if (status) { |
| 423 | dbg("%s - nonzero write bulk status received: %d", |
Harvey Harrison | 441b62c | 2008-03-03 16:08:34 -0800 | [diff] [blame] | 424 | __func__, status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 425 | return; |
| 426 | } |
| 427 | |
Felipe Balbi | e0d795e | 2008-06-03 14:47:52 +0300 | [diff] [blame] | 428 | usb_serial_debug_data( |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 429 | debug, |
| 430 | &port->dev, |
Harvey Harrison | 441b62c | 2008-03-03 16:08:34 -0800 | [diff] [blame] | 431 | __func__, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 432 | urb->actual_length, |
| 433 | urb->transfer_buffer); |
| 434 | |
Pete Zaitcev | cf2c748 | 2006-05-22 21:58:49 -0700 | [diff] [blame] | 435 | usb_serial_port_softint(port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 436 | } |
| 437 | |
Felipe Balbi | e0d795e | 2008-06-03 14:47:52 +0300 | [diff] [blame] | 438 | static void ir_read_bulk_callback(struct urb *urb) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 439 | { |
Ming Lei | cdc9779 | 2008-02-24 18:41:47 +0800 | [diff] [blame] | 440 | struct usb_serial_port *port = urb->context; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 441 | struct tty_struct *tty; |
| 442 | unsigned char *data = urb->transfer_buffer; |
| 443 | int result; |
Greg Kroah-Hartman | 3152b74 | 2007-06-15 15:44:13 -0700 | [diff] [blame] | 444 | int status = urb->status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 445 | |
Harvey Harrison | 441b62c | 2008-03-03 16:08:34 -0800 | [diff] [blame] | 446 | dbg("%s - port %d", __func__, port->number); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 447 | |
Alan Cox | 95da310 | 2008-07-22 11:09:07 +0100 | [diff] [blame] | 448 | if (!port->port.count) { |
Harvey Harrison | 441b62c | 2008-03-03 16:08:34 -0800 | [diff] [blame] | 449 | dbg("%s - port closed.", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 450 | return; |
| 451 | } |
| 452 | |
Greg Kroah-Hartman | 3152b74 | 2007-06-15 15:44:13 -0700 | [diff] [blame] | 453 | switch (status) { |
Felipe Balbi | e0d795e | 2008-06-03 14:47:52 +0300 | [diff] [blame] | 454 | case 0: /* Successful */ |
Felipe Balbi | e0d795e | 2008-06-03 14:47:52 +0300 | [diff] [blame] | 455 | /* |
| 456 | * The first byte of the packet we get from the device |
| 457 | * contains a busy indicator and baud rate change. |
| 458 | * See section 5.4.1.2 of the USB IrDA spec. |
| 459 | */ |
| 460 | if ((*data & 0x0f) > 0) |
| 461 | ir_baud = *data & 0x0f; |
Alan Cox | 95da310 | 2008-07-22 11:09:07 +0100 | [diff] [blame] | 462 | usb_serial_debug_data(debug, &port->dev, __func__, |
| 463 | urb->actual_length, data); |
Alan Cox | 4a90f09 | 2008-10-13 10:39:46 +0100 | [diff] [blame] | 464 | tty = tty_port_tty_get(&port->port); |
Felipe Balbi | e0d795e | 2008-06-03 14:47:52 +0300 | [diff] [blame] | 465 | if (tty_buffer_request_room(tty, urb->actual_length - 1)) { |
Alan Cox | 95da310 | 2008-07-22 11:09:07 +0100 | [diff] [blame] | 466 | tty_insert_flip_string(tty, data+1, urb->actual_length - 1); |
Felipe Balbi | e0d795e | 2008-06-03 14:47:52 +0300 | [diff] [blame] | 467 | tty_flip_buffer_push(tty); |
| 468 | } |
Alan Cox | 4a90f09 | 2008-10-13 10:39:46 +0100 | [diff] [blame] | 469 | tty_kref_put(tty); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 470 | |
Felipe Balbi | e0d795e | 2008-06-03 14:47:52 +0300 | [diff] [blame] | 471 | /* |
| 472 | * No break here. |
| 473 | * We want to resubmit the urb so we can read |
| 474 | * again. |
| 475 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 476 | |
Felipe Balbi | e0d795e | 2008-06-03 14:47:52 +0300 | [diff] [blame] | 477 | case -EPROTO: /* taking inspiration from pl2303.c */ |
Alan Cox | 95da310 | 2008-07-22 11:09:07 +0100 | [diff] [blame] | 478 | /* Continue trying to always read */ |
Felipe Balbi | e0d795e | 2008-06-03 14:47:52 +0300 | [diff] [blame] | 479 | usb_fill_bulk_urb( |
| 480 | port->read_urb, |
Alan Cox | 95da310 | 2008-07-22 11:09:07 +0100 | [diff] [blame] | 481 | port->serial->dev, |
Felipe Balbi | e0d795e | 2008-06-03 14:47:52 +0300 | [diff] [blame] | 482 | usb_rcvbulkpipe(port->serial->dev, |
| 483 | port->bulk_in_endpointAddress), |
| 484 | port->read_urb->transfer_buffer, |
| 485 | port->read_urb->transfer_buffer_length, |
| 486 | ir_read_bulk_callback, |
| 487 | port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 488 | |
Felipe Balbi | e0d795e | 2008-06-03 14:47:52 +0300 | [diff] [blame] | 489 | result = usb_submit_urb(port->read_urb, GFP_ATOMIC); |
| 490 | if (result) |
Alan Cox | 95da310 | 2008-07-22 11:09:07 +0100 | [diff] [blame] | 491 | dev_err(&port->dev, "%s - failed resubmitting read urb, error %d\n", |
Felipe Balbi | e0d795e | 2008-06-03 14:47:52 +0300 | [diff] [blame] | 492 | __func__, result); |
Alan Cox | 95da310 | 2008-07-22 11:09:07 +0100 | [diff] [blame] | 493 | break ; |
Felipe Balbi | e0d795e | 2008-06-03 14:47:52 +0300 | [diff] [blame] | 494 | default: |
| 495 | dbg("%s - nonzero read bulk status received: %d", |
Alan Cox | 95da310 | 2008-07-22 11:09:07 +0100 | [diff] [blame] | 496 | __func__, status); |
| 497 | break ; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 498 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 499 | return; |
| 500 | } |
| 501 | |
Alan Cox | 95da310 | 2008-07-22 11:09:07 +0100 | [diff] [blame] | 502 | static void ir_set_termios(struct tty_struct *tty, |
| 503 | struct usb_serial_port *port, struct ktermios *old_termios) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 504 | { |
| 505 | unsigned char *transfer_buffer; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 506 | int result; |
Alan Cox | a6ea438 | 2007-06-22 14:44:54 +0100 | [diff] [blame] | 507 | speed_t baud; |
| 508 | int ir_baud; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 509 | |
Harvey Harrison | 441b62c | 2008-03-03 16:08:34 -0800 | [diff] [blame] | 510 | dbg("%s - port %d", __func__, port->number); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 511 | |
Alan Cox | 95da310 | 2008-07-22 11:09:07 +0100 | [diff] [blame] | 512 | baud = tty_get_baud_rate(tty); |
Alan Cox | a6ea438 | 2007-06-22 14:44:54 +0100 | [diff] [blame] | 513 | |
| 514 | /* |
| 515 | * FIXME, we should compare the baud request against the |
| 516 | * capability stated in the IR header that we got in the |
| 517 | * startup function. |
| 518 | */ |
| 519 | |
| 520 | switch (baud) { |
Felipe Balbi | e0d795e | 2008-06-03 14:47:52 +0300 | [diff] [blame] | 521 | case 2400: |
| 522 | ir_baud = USB_IRDA_BR_2400; |
| 523 | break; |
| 524 | case 9600: |
| 525 | ir_baud = USB_IRDA_BR_9600; |
| 526 | break; |
| 527 | case 19200: |
| 528 | ir_baud = USB_IRDA_BR_19200; |
| 529 | break; |
| 530 | case 38400: |
| 531 | ir_baud = USB_IRDA_BR_38400; |
| 532 | break; |
| 533 | case 57600: |
| 534 | ir_baud = USB_IRDA_BR_57600; |
| 535 | break; |
| 536 | case 115200: |
| 537 | ir_baud = USB_IRDA_BR_115200; |
| 538 | break; |
| 539 | case 576000: |
| 540 | ir_baud = USB_IRDA_BR_576000; |
| 541 | break; |
| 542 | case 1152000: |
| 543 | ir_baud = USB_IRDA_BR_1152000; |
| 544 | break; |
| 545 | case 4000000: |
| 546 | ir_baud = USB_IRDA_BR_4000000; |
| 547 | break; |
| 548 | default: |
| 549 | ir_baud = USB_IRDA_BR_9600; |
| 550 | baud = 9600; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 551 | } |
| 552 | |
Alan Cox | a6ea438 | 2007-06-22 14:44:54 +0100 | [diff] [blame] | 553 | if (xbof == -1) |
| 554 | ir_xbof = ir_xbof_change(ir_add_bof); |
| 555 | else |
| 556 | ir_xbof = ir_xbof_change(xbof) ; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 557 | |
Alan Cox | a6ea438 | 2007-06-22 14:44:54 +0100 | [diff] [blame] | 558 | /* FIXME need to check to see if our write urb is busy right |
| 559 | * now, or use a urb pool. |
| 560 | * |
| 561 | * send the baud change out on an "empty" data packet |
| 562 | */ |
| 563 | transfer_buffer = port->write_urb->transfer_buffer; |
| 564 | *transfer_buffer = ir_xbof | ir_baud; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 565 | |
Felipe Balbi | e0d795e | 2008-06-03 14:47:52 +0300 | [diff] [blame] | 566 | usb_fill_bulk_urb( |
Alan Cox | a6ea438 | 2007-06-22 14:44:54 +0100 | [diff] [blame] | 567 | port->write_urb, |
| 568 | port->serial->dev, |
Felipe Balbi | e0d795e | 2008-06-03 14:47:52 +0300 | [diff] [blame] | 569 | usb_sndbulkpipe(port->serial->dev, |
| 570 | port->bulk_out_endpointAddress), |
Alan Cox | a6ea438 | 2007-06-22 14:44:54 +0100 | [diff] [blame] | 571 | port->write_urb->transfer_buffer, |
| 572 | 1, |
| 573 | ir_write_bulk_callback, |
| 574 | port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 575 | |
Alan Cox | a6ea438 | 2007-06-22 14:44:54 +0100 | [diff] [blame] | 576 | port->write_urb->transfer_flags = URB_ZERO_PACKET; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 577 | |
Felipe Balbi | e0d795e | 2008-06-03 14:47:52 +0300 | [diff] [blame] | 578 | result = usb_submit_urb(port->write_urb, GFP_KERNEL); |
Alan Cox | a6ea438 | 2007-06-22 14:44:54 +0100 | [diff] [blame] | 579 | if (result) |
Felipe Balbi | e0d795e | 2008-06-03 14:47:52 +0300 | [diff] [blame] | 580 | dev_err(&port->dev, |
| 581 | "%s - failed submitting write urb, error %d\n", |
| 582 | __func__, result); |
Alan Cox | 560aac2 | 2007-10-18 01:24:20 -0700 | [diff] [blame] | 583 | |
| 584 | /* Only speed changes are supported */ |
Alan Cox | 95da310 | 2008-07-22 11:09:07 +0100 | [diff] [blame] | 585 | tty_termios_copy_hw(tty->termios, old_termios); |
| 586 | tty_encode_baud_rate(tty, baud, baud); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 587 | } |
| 588 | |
Felipe Balbi | e0d795e | 2008-06-03 14:47:52 +0300 | [diff] [blame] | 589 | static int __init ir_init(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 590 | { |
| 591 | int retval; |
Felipe Balbi | e0d795e | 2008-06-03 14:47:52 +0300 | [diff] [blame] | 592 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 593 | retval = usb_serial_register(&ir_device); |
| 594 | if (retval) |
| 595 | goto failed_usb_serial_register; |
Felipe Balbi | e0d795e | 2008-06-03 14:47:52 +0300 | [diff] [blame] | 596 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 597 | retval = usb_register(&ir_driver); |
Felipe Balbi | e0d795e | 2008-06-03 14:47:52 +0300 | [diff] [blame] | 598 | if (retval) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 599 | goto failed_usb_register; |
Felipe Balbi | e0d795e | 2008-06-03 14:47:52 +0300 | [diff] [blame] | 600 | |
Greg Kroah-Hartman | c197a8d | 2008-08-18 13:21:04 -0700 | [diff] [blame] | 601 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" |
| 602 | DRIVER_DESC "\n"); |
Felipe Balbi | e0d795e | 2008-06-03 14:47:52 +0300 | [diff] [blame] | 603 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 604 | return 0; |
Felipe Balbi | e0d795e | 2008-06-03 14:47:52 +0300 | [diff] [blame] | 605 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 606 | failed_usb_register: |
| 607 | usb_serial_deregister(&ir_device); |
Felipe Balbi | e0d795e | 2008-06-03 14:47:52 +0300 | [diff] [blame] | 608 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 609 | failed_usb_serial_register: |
| 610 | return retval; |
| 611 | } |
| 612 | |
Felipe Balbi | e0d795e | 2008-06-03 14:47:52 +0300 | [diff] [blame] | 613 | static void __exit ir_exit(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 614 | { |
Felipe Balbi | e0d795e | 2008-06-03 14:47:52 +0300 | [diff] [blame] | 615 | usb_deregister(&ir_driver); |
| 616 | usb_serial_deregister(&ir_device); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 617 | } |
| 618 | |
| 619 | |
| 620 | module_init(ir_init); |
| 621 | module_exit(ir_exit); |
| 622 | |
| 623 | MODULE_AUTHOR(DRIVER_AUTHOR); |
| 624 | MODULE_DESCRIPTION(DRIVER_DESC); |
| 625 | MODULE_LICENSE("GPL"); |
| 626 | |
| 627 | module_param(debug, bool, S_IRUGO | S_IWUSR); |
| 628 | MODULE_PARM_DESC(debug, "Debug enabled or not"); |
| 629 | module_param(xbof, int, 0); |
| 630 | MODULE_PARM_DESC(xbof, "Force specific number of XBOFs"); |
| 631 | module_param(buffer_size, int, 0); |
| 632 | MODULE_PARM_DESC(buffer_size, "Size of the transfer buffers"); |
| 633 | |