David Herrmann | fb51b44 | 2011-07-05 13:45:08 +0200 | [diff] [blame] | 1 | /* |
| 2 | * HID driver for Nintendo Wiimote devices |
| 3 | * Copyright (c) 2011 David Herrmann |
| 4 | */ |
| 5 | |
| 6 | /* |
| 7 | * This program is free software; you can redistribute it and/or modify it |
| 8 | * under the terms of the GNU General Public License as published by the Free |
| 9 | * Software Foundation; either version 2 of the License, or (at your option) |
| 10 | * any later version. |
| 11 | */ |
| 12 | |
David Herrmann | 4d36e97 | 2011-07-05 13:45:12 +0200 | [diff] [blame] | 13 | #include <linux/atomic.h> |
David Herrmann | 672bc4e | 2011-07-05 13:45:11 +0200 | [diff] [blame] | 14 | #include <linux/device.h> |
David Herrmann | 02fb72a | 2011-07-05 13:45:09 +0200 | [diff] [blame] | 15 | #include <linux/hid.h> |
David Herrmann | 672bc4e | 2011-07-05 13:45:11 +0200 | [diff] [blame] | 16 | #include <linux/input.h> |
David Herrmann | fb51b44 | 2011-07-05 13:45:08 +0200 | [diff] [blame] | 17 | #include <linux/module.h> |
David Herrmann | 23c063c | 2011-07-05 13:45:14 +0200 | [diff] [blame] | 18 | #include <linux/spinlock.h> |
David Herrmann | 02fb72a | 2011-07-05 13:45:09 +0200 | [diff] [blame] | 19 | #include "hid-ids.h" |
David Herrmann | fb51b44 | 2011-07-05 13:45:08 +0200 | [diff] [blame] | 20 | |
| 21 | #define WIIMOTE_VERSION "0.1" |
| 22 | #define WIIMOTE_NAME "Nintendo Wii Remote" |
David Herrmann | 23c063c | 2011-07-05 13:45:14 +0200 | [diff] [blame] | 23 | #define WIIMOTE_BUFSIZE 32 |
| 24 | |
| 25 | struct wiimote_buf { |
| 26 | __u8 data[HID_MAX_BUFFER_SIZE]; |
| 27 | size_t size; |
| 28 | }; |
David Herrmann | fb51b44 | 2011-07-05 13:45:08 +0200 | [diff] [blame] | 29 | |
David Herrmann | e894d0e | 2011-07-05 13:45:10 +0200 | [diff] [blame] | 30 | struct wiimote_data { |
David Herrmann | 4d36e97 | 2011-07-05 13:45:12 +0200 | [diff] [blame] | 31 | atomic_t ready; |
David Herrmann | e894d0e | 2011-07-05 13:45:10 +0200 | [diff] [blame] | 32 | struct hid_device *hdev; |
David Herrmann | 672bc4e | 2011-07-05 13:45:11 +0200 | [diff] [blame] | 33 | struct input_dev *input; |
David Herrmann | 23c063c | 2011-07-05 13:45:14 +0200 | [diff] [blame] | 34 | |
| 35 | spinlock_t qlock; |
| 36 | __u8 head; |
| 37 | __u8 tail; |
| 38 | struct wiimote_buf outq[WIIMOTE_BUFSIZE]; |
| 39 | struct work_struct worker; |
David Herrmann | e894d0e | 2011-07-05 13:45:10 +0200 | [diff] [blame] | 40 | }; |
| 41 | |
David Herrmann | db30834 | 2011-07-05 13:45:17 +0200 | [diff] [blame^] | 42 | #define WIIPROTO_FLAG_LED1 0x01 |
| 43 | #define WIIPROTO_FLAG_LED2 0x02 |
| 44 | #define WIIPROTO_FLAG_LED3 0x04 |
| 45 | #define WIIPROTO_FLAG_LED4 0x08 |
| 46 | |
David Herrmann | 1abb9ad | 2011-07-05 13:45:16 +0200 | [diff] [blame] | 47 | enum wiiproto_reqs { |
David Herrmann | db30834 | 2011-07-05 13:45:17 +0200 | [diff] [blame^] | 48 | WIIPROTO_REQ_LED = 0x11, |
David Herrmann | 1abb9ad | 2011-07-05 13:45:16 +0200 | [diff] [blame] | 49 | WIIPROTO_REQ_DRM_K = 0x30, |
| 50 | }; |
| 51 | |
| 52 | enum wiiproto_keys { |
| 53 | WIIPROTO_KEY_LEFT, |
| 54 | WIIPROTO_KEY_RIGHT, |
| 55 | WIIPROTO_KEY_UP, |
| 56 | WIIPROTO_KEY_DOWN, |
| 57 | WIIPROTO_KEY_PLUS, |
| 58 | WIIPROTO_KEY_MINUS, |
| 59 | WIIPROTO_KEY_ONE, |
| 60 | WIIPROTO_KEY_TWO, |
| 61 | WIIPROTO_KEY_A, |
| 62 | WIIPROTO_KEY_B, |
| 63 | WIIPROTO_KEY_HOME, |
| 64 | WIIPROTO_KEY_COUNT |
| 65 | }; |
| 66 | |
| 67 | static __u16 wiiproto_keymap[] = { |
| 68 | KEY_LEFT, /* WIIPROTO_KEY_LEFT */ |
| 69 | KEY_RIGHT, /* WIIPROTO_KEY_RIGHT */ |
| 70 | KEY_UP, /* WIIPROTO_KEY_UP */ |
| 71 | KEY_DOWN, /* WIIPROTO_KEY_DOWN */ |
| 72 | KEY_NEXT, /* WIIPROTO_KEY_PLUS */ |
| 73 | KEY_PREVIOUS, /* WIIPROTO_KEY_MINUS */ |
| 74 | BTN_1, /* WIIPROTO_KEY_ONE */ |
| 75 | BTN_2, /* WIIPROTO_KEY_TWO */ |
| 76 | BTN_A, /* WIIPROTO_KEY_A */ |
| 77 | BTN_B, /* WIIPROTO_KEY_B */ |
| 78 | BTN_MODE, /* WIIPROTO_KEY_HOME */ |
| 79 | }; |
| 80 | |
David Herrmann | 0c218f1 | 2011-07-05 13:45:13 +0200 | [diff] [blame] | 81 | static ssize_t wiimote_hid_send(struct hid_device *hdev, __u8 *buffer, |
| 82 | size_t count) |
| 83 | { |
| 84 | __u8 *buf; |
| 85 | ssize_t ret; |
| 86 | |
| 87 | if (!hdev->hid_output_raw_report) |
| 88 | return -ENODEV; |
| 89 | |
| 90 | buf = kmemdup(buffer, count, GFP_KERNEL); |
| 91 | if (!buf) |
| 92 | return -ENOMEM; |
| 93 | |
| 94 | ret = hdev->hid_output_raw_report(hdev, buf, count, HID_OUTPUT_REPORT); |
| 95 | |
| 96 | kfree(buf); |
| 97 | return ret; |
| 98 | } |
| 99 | |
David Herrmann | 23c063c | 2011-07-05 13:45:14 +0200 | [diff] [blame] | 100 | static void wiimote_worker(struct work_struct *work) |
| 101 | { |
| 102 | struct wiimote_data *wdata = container_of(work, struct wiimote_data, |
| 103 | worker); |
| 104 | unsigned long flags; |
| 105 | |
| 106 | spin_lock_irqsave(&wdata->qlock, flags); |
| 107 | |
| 108 | while (wdata->head != wdata->tail) { |
| 109 | spin_unlock_irqrestore(&wdata->qlock, flags); |
| 110 | wiimote_hid_send(wdata->hdev, wdata->outq[wdata->tail].data, |
| 111 | wdata->outq[wdata->tail].size); |
| 112 | spin_lock_irqsave(&wdata->qlock, flags); |
| 113 | |
| 114 | wdata->tail = (wdata->tail + 1) % WIIMOTE_BUFSIZE; |
| 115 | } |
| 116 | |
| 117 | spin_unlock_irqrestore(&wdata->qlock, flags); |
| 118 | } |
| 119 | |
| 120 | static void wiimote_queue(struct wiimote_data *wdata, const __u8 *buffer, |
| 121 | size_t count) |
| 122 | { |
| 123 | unsigned long flags; |
| 124 | __u8 newhead; |
| 125 | |
| 126 | if (count > HID_MAX_BUFFER_SIZE) { |
| 127 | hid_warn(wdata->hdev, "Sending too large output report\n"); |
| 128 | return; |
| 129 | } |
| 130 | |
| 131 | /* |
| 132 | * Copy new request into our output queue and check whether the |
| 133 | * queue is full. If it is full, discard this request. |
| 134 | * If it is empty we need to start a new worker that will |
| 135 | * send out the buffer to the hid device. |
| 136 | * If the queue is not empty, then there must be a worker |
| 137 | * that is currently sending out our buffer and this worker |
| 138 | * will reschedule itself until the queue is empty. |
| 139 | */ |
| 140 | |
| 141 | spin_lock_irqsave(&wdata->qlock, flags); |
| 142 | |
| 143 | memcpy(wdata->outq[wdata->head].data, buffer, count); |
| 144 | wdata->outq[wdata->head].size = count; |
| 145 | newhead = (wdata->head + 1) % WIIMOTE_BUFSIZE; |
| 146 | |
| 147 | if (wdata->head == wdata->tail) { |
| 148 | wdata->head = newhead; |
| 149 | schedule_work(&wdata->worker); |
| 150 | } else if (newhead != wdata->tail) { |
| 151 | wdata->head = newhead; |
| 152 | } else { |
| 153 | hid_warn(wdata->hdev, "Output queue is full"); |
| 154 | } |
| 155 | |
| 156 | spin_unlock_irqrestore(&wdata->qlock, flags); |
| 157 | } |
| 158 | |
David Herrmann | db30834 | 2011-07-05 13:45:17 +0200 | [diff] [blame^] | 159 | static void wiiproto_req_leds(struct wiimote_data *wdata, int leds) |
| 160 | { |
| 161 | __u8 cmd[2]; |
| 162 | |
| 163 | cmd[0] = WIIPROTO_REQ_LED; |
| 164 | cmd[1] = 0; |
| 165 | |
| 166 | if (leds & WIIPROTO_FLAG_LED1) |
| 167 | cmd[1] |= 0x10; |
| 168 | if (leds & WIIPROTO_FLAG_LED2) |
| 169 | cmd[1] |= 0x20; |
| 170 | if (leds & WIIPROTO_FLAG_LED3) |
| 171 | cmd[1] |= 0x40; |
| 172 | if (leds & WIIPROTO_FLAG_LED4) |
| 173 | cmd[1] |= 0x80; |
| 174 | |
| 175 | wiimote_queue(wdata, cmd, sizeof(cmd)); |
| 176 | } |
| 177 | |
David Herrmann | 672bc4e | 2011-07-05 13:45:11 +0200 | [diff] [blame] | 178 | static int wiimote_input_event(struct input_dev *dev, unsigned int type, |
| 179 | unsigned int code, int value) |
| 180 | { |
David Herrmann | 4d36e97 | 2011-07-05 13:45:12 +0200 | [diff] [blame] | 181 | struct wiimote_data *wdata = input_get_drvdata(dev); |
| 182 | |
| 183 | if (!atomic_read(&wdata->ready)) |
| 184 | return -EBUSY; |
| 185 | /* smp_rmb: Make sure wdata->xy is available when wdata->ready is 1 */ |
| 186 | smp_rmb(); |
| 187 | |
David Herrmann | 672bc4e | 2011-07-05 13:45:11 +0200 | [diff] [blame] | 188 | return 0; |
| 189 | } |
| 190 | |
David Herrmann | 1abb9ad | 2011-07-05 13:45:16 +0200 | [diff] [blame] | 191 | static void handler_keys(struct wiimote_data *wdata, const __u8 *payload) |
| 192 | { |
| 193 | input_report_key(wdata->input, wiiproto_keymap[WIIPROTO_KEY_LEFT], |
| 194 | !!(payload[0] & 0x01)); |
| 195 | input_report_key(wdata->input, wiiproto_keymap[WIIPROTO_KEY_RIGHT], |
| 196 | !!(payload[0] & 0x02)); |
| 197 | input_report_key(wdata->input, wiiproto_keymap[WIIPROTO_KEY_DOWN], |
| 198 | !!(payload[0] & 0x04)); |
| 199 | input_report_key(wdata->input, wiiproto_keymap[WIIPROTO_KEY_UP], |
| 200 | !!(payload[0] & 0x08)); |
| 201 | input_report_key(wdata->input, wiiproto_keymap[WIIPROTO_KEY_PLUS], |
| 202 | !!(payload[0] & 0x10)); |
| 203 | input_report_key(wdata->input, wiiproto_keymap[WIIPROTO_KEY_TWO], |
| 204 | !!(payload[1] & 0x01)); |
| 205 | input_report_key(wdata->input, wiiproto_keymap[WIIPROTO_KEY_ONE], |
| 206 | !!(payload[1] & 0x02)); |
| 207 | input_report_key(wdata->input, wiiproto_keymap[WIIPROTO_KEY_B], |
| 208 | !!(payload[1] & 0x04)); |
| 209 | input_report_key(wdata->input, wiiproto_keymap[WIIPROTO_KEY_A], |
| 210 | !!(payload[1] & 0x08)); |
| 211 | input_report_key(wdata->input, wiiproto_keymap[WIIPROTO_KEY_MINUS], |
| 212 | !!(payload[1] & 0x10)); |
| 213 | input_report_key(wdata->input, wiiproto_keymap[WIIPROTO_KEY_HOME], |
| 214 | !!(payload[1] & 0x80)); |
| 215 | input_sync(wdata->input); |
| 216 | } |
| 217 | |
David Herrmann | a4d1919 | 2011-07-05 13:45:15 +0200 | [diff] [blame] | 218 | struct wiiproto_handler { |
| 219 | __u8 id; |
| 220 | size_t size; |
| 221 | void (*func)(struct wiimote_data *wdata, const __u8 *payload); |
| 222 | }; |
| 223 | |
| 224 | static struct wiiproto_handler handlers[] = { |
David Herrmann | 1abb9ad | 2011-07-05 13:45:16 +0200 | [diff] [blame] | 225 | { .id = WIIPROTO_REQ_DRM_K, .size = 2, .func = handler_keys }, |
David Herrmann | a4d1919 | 2011-07-05 13:45:15 +0200 | [diff] [blame] | 226 | { .id = 0 } |
| 227 | }; |
| 228 | |
David Herrmann | 02fb72a | 2011-07-05 13:45:09 +0200 | [diff] [blame] | 229 | static int wiimote_hid_event(struct hid_device *hdev, struct hid_report *report, |
| 230 | u8 *raw_data, int size) |
| 231 | { |
David Herrmann | 4d36e97 | 2011-07-05 13:45:12 +0200 | [diff] [blame] | 232 | struct wiimote_data *wdata = hid_get_drvdata(hdev); |
David Herrmann | a4d1919 | 2011-07-05 13:45:15 +0200 | [diff] [blame] | 233 | struct wiiproto_handler *h; |
| 234 | int i; |
David Herrmann | 4d36e97 | 2011-07-05 13:45:12 +0200 | [diff] [blame] | 235 | |
| 236 | if (!atomic_read(&wdata->ready)) |
| 237 | return -EBUSY; |
| 238 | /* smp_rmb: Make sure wdata->xy is available when wdata->ready is 1 */ |
| 239 | smp_rmb(); |
| 240 | |
David Herrmann | 02fb72a | 2011-07-05 13:45:09 +0200 | [diff] [blame] | 241 | if (size < 1) |
| 242 | return -EINVAL; |
| 243 | |
David Herrmann | a4d1919 | 2011-07-05 13:45:15 +0200 | [diff] [blame] | 244 | for (i = 0; handlers[i].id; ++i) { |
| 245 | h = &handlers[i]; |
| 246 | if (h->id == raw_data[0] && h->size < size) |
| 247 | h->func(wdata, &raw_data[1]); |
| 248 | } |
| 249 | |
David Herrmann | 02fb72a | 2011-07-05 13:45:09 +0200 | [diff] [blame] | 250 | return 0; |
| 251 | } |
| 252 | |
David Herrmann | e894d0e | 2011-07-05 13:45:10 +0200 | [diff] [blame] | 253 | static struct wiimote_data *wiimote_create(struct hid_device *hdev) |
| 254 | { |
| 255 | struct wiimote_data *wdata; |
David Herrmann | 1abb9ad | 2011-07-05 13:45:16 +0200 | [diff] [blame] | 256 | int i; |
David Herrmann | e894d0e | 2011-07-05 13:45:10 +0200 | [diff] [blame] | 257 | |
| 258 | wdata = kzalloc(sizeof(*wdata), GFP_KERNEL); |
| 259 | if (!wdata) |
| 260 | return NULL; |
| 261 | |
David Herrmann | 672bc4e | 2011-07-05 13:45:11 +0200 | [diff] [blame] | 262 | wdata->input = input_allocate_device(); |
| 263 | if (!wdata->input) { |
| 264 | kfree(wdata); |
| 265 | return NULL; |
| 266 | } |
| 267 | |
David Herrmann | e894d0e | 2011-07-05 13:45:10 +0200 | [diff] [blame] | 268 | wdata->hdev = hdev; |
| 269 | hid_set_drvdata(hdev, wdata); |
| 270 | |
David Herrmann | 672bc4e | 2011-07-05 13:45:11 +0200 | [diff] [blame] | 271 | input_set_drvdata(wdata->input, wdata); |
| 272 | wdata->input->event = wiimote_input_event; |
| 273 | wdata->input->dev.parent = &wdata->hdev->dev; |
| 274 | wdata->input->id.bustype = wdata->hdev->bus; |
| 275 | wdata->input->id.vendor = wdata->hdev->vendor; |
| 276 | wdata->input->id.product = wdata->hdev->product; |
| 277 | wdata->input->id.version = wdata->hdev->version; |
| 278 | wdata->input->name = WIIMOTE_NAME; |
| 279 | |
David Herrmann | 1abb9ad | 2011-07-05 13:45:16 +0200 | [diff] [blame] | 280 | set_bit(EV_KEY, wdata->input->evbit); |
| 281 | for (i = 0; i < WIIPROTO_KEY_COUNT; ++i) |
| 282 | set_bit(wiiproto_keymap[i], wdata->input->keybit); |
| 283 | |
David Herrmann | 23c063c | 2011-07-05 13:45:14 +0200 | [diff] [blame] | 284 | spin_lock_init(&wdata->qlock); |
| 285 | INIT_WORK(&wdata->worker, wiimote_worker); |
| 286 | |
David Herrmann | e894d0e | 2011-07-05 13:45:10 +0200 | [diff] [blame] | 287 | return wdata; |
| 288 | } |
| 289 | |
| 290 | static void wiimote_destroy(struct wiimote_data *wdata) |
| 291 | { |
| 292 | kfree(wdata); |
| 293 | } |
| 294 | |
David Herrmann | 02fb72a | 2011-07-05 13:45:09 +0200 | [diff] [blame] | 295 | static int wiimote_hid_probe(struct hid_device *hdev, |
| 296 | const struct hid_device_id *id) |
| 297 | { |
David Herrmann | e894d0e | 2011-07-05 13:45:10 +0200 | [diff] [blame] | 298 | struct wiimote_data *wdata; |
David Herrmann | 02fb72a | 2011-07-05 13:45:09 +0200 | [diff] [blame] | 299 | int ret; |
| 300 | |
David Herrmann | e894d0e | 2011-07-05 13:45:10 +0200 | [diff] [blame] | 301 | wdata = wiimote_create(hdev); |
| 302 | if (!wdata) { |
| 303 | hid_err(hdev, "Can't alloc device\n"); |
| 304 | return -ENOMEM; |
| 305 | } |
| 306 | |
David Herrmann | 02fb72a | 2011-07-05 13:45:09 +0200 | [diff] [blame] | 307 | ret = hid_parse(hdev); |
| 308 | if (ret) { |
| 309 | hid_err(hdev, "HID parse failed\n"); |
David Herrmann | e894d0e | 2011-07-05 13:45:10 +0200 | [diff] [blame] | 310 | goto err; |
David Herrmann | 02fb72a | 2011-07-05 13:45:09 +0200 | [diff] [blame] | 311 | } |
| 312 | |
| 313 | ret = hid_hw_start(hdev, HID_CONNECT_HIDRAW); |
| 314 | if (ret) { |
| 315 | hid_err(hdev, "HW start failed\n"); |
David Herrmann | e894d0e | 2011-07-05 13:45:10 +0200 | [diff] [blame] | 316 | goto err; |
David Herrmann | 02fb72a | 2011-07-05 13:45:09 +0200 | [diff] [blame] | 317 | } |
| 318 | |
David Herrmann | 672bc4e | 2011-07-05 13:45:11 +0200 | [diff] [blame] | 319 | ret = input_register_device(wdata->input); |
| 320 | if (ret) { |
| 321 | hid_err(hdev, "Cannot register input device\n"); |
| 322 | goto err_stop; |
| 323 | } |
| 324 | |
David Herrmann | 4d36e97 | 2011-07-05 13:45:12 +0200 | [diff] [blame] | 325 | /* smp_wmb: Write wdata->xy first before wdata->ready is set to 1 */ |
| 326 | smp_wmb(); |
| 327 | atomic_set(&wdata->ready, 1); |
David Herrmann | 02fb72a | 2011-07-05 13:45:09 +0200 | [diff] [blame] | 328 | hid_info(hdev, "New device registered\n"); |
David Herrmann | db30834 | 2011-07-05 13:45:17 +0200 | [diff] [blame^] | 329 | wiiproto_req_leds(wdata, WIIPROTO_FLAG_LED1); |
David Herrmann | 02fb72a | 2011-07-05 13:45:09 +0200 | [diff] [blame] | 330 | return 0; |
David Herrmann | e894d0e | 2011-07-05 13:45:10 +0200 | [diff] [blame] | 331 | |
David Herrmann | 672bc4e | 2011-07-05 13:45:11 +0200 | [diff] [blame] | 332 | err_stop: |
| 333 | hid_hw_stop(hdev); |
David Herrmann | e894d0e | 2011-07-05 13:45:10 +0200 | [diff] [blame] | 334 | err: |
David Herrmann | 672bc4e | 2011-07-05 13:45:11 +0200 | [diff] [blame] | 335 | input_free_device(wdata->input); |
David Herrmann | e894d0e | 2011-07-05 13:45:10 +0200 | [diff] [blame] | 336 | wiimote_destroy(wdata); |
| 337 | return ret; |
David Herrmann | 02fb72a | 2011-07-05 13:45:09 +0200 | [diff] [blame] | 338 | } |
| 339 | |
| 340 | static void wiimote_hid_remove(struct hid_device *hdev) |
| 341 | { |
David Herrmann | e894d0e | 2011-07-05 13:45:10 +0200 | [diff] [blame] | 342 | struct wiimote_data *wdata = hid_get_drvdata(hdev); |
| 343 | |
David Herrmann | 02fb72a | 2011-07-05 13:45:09 +0200 | [diff] [blame] | 344 | hid_info(hdev, "Device removed\n"); |
David Herrmann | 23c063c | 2011-07-05 13:45:14 +0200 | [diff] [blame] | 345 | |
David Herrmann | 02fb72a | 2011-07-05 13:45:09 +0200 | [diff] [blame] | 346 | hid_hw_stop(hdev); |
David Herrmann | 672bc4e | 2011-07-05 13:45:11 +0200 | [diff] [blame] | 347 | input_unregister_device(wdata->input); |
David Herrmann | 23c063c | 2011-07-05 13:45:14 +0200 | [diff] [blame] | 348 | |
| 349 | cancel_work_sync(&wdata->worker); |
David Herrmann | e894d0e | 2011-07-05 13:45:10 +0200 | [diff] [blame] | 350 | wiimote_destroy(wdata); |
David Herrmann | 02fb72a | 2011-07-05 13:45:09 +0200 | [diff] [blame] | 351 | } |
| 352 | |
| 353 | static const struct hid_device_id wiimote_hid_devices[] = { |
| 354 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_NINTENDO, |
| 355 | USB_DEVICE_ID_NINTENDO_WIIMOTE) }, |
| 356 | { } |
| 357 | }; |
| 358 | MODULE_DEVICE_TABLE(hid, wiimote_hid_devices); |
| 359 | |
| 360 | static struct hid_driver wiimote_hid_driver = { |
| 361 | .name = "wiimote", |
| 362 | .id_table = wiimote_hid_devices, |
| 363 | .probe = wiimote_hid_probe, |
| 364 | .remove = wiimote_hid_remove, |
| 365 | .raw_event = wiimote_hid_event, |
| 366 | }; |
| 367 | |
David Herrmann | fb51b44 | 2011-07-05 13:45:08 +0200 | [diff] [blame] | 368 | static int __init wiimote_init(void) |
| 369 | { |
David Herrmann | 02fb72a | 2011-07-05 13:45:09 +0200 | [diff] [blame] | 370 | int ret; |
| 371 | |
| 372 | ret = hid_register_driver(&wiimote_hid_driver); |
| 373 | if (ret) |
| 374 | pr_err("Can't register wiimote hid driver\n"); |
| 375 | |
| 376 | return ret; |
David Herrmann | fb51b44 | 2011-07-05 13:45:08 +0200 | [diff] [blame] | 377 | } |
| 378 | |
| 379 | static void __exit wiimote_exit(void) |
| 380 | { |
David Herrmann | 02fb72a | 2011-07-05 13:45:09 +0200 | [diff] [blame] | 381 | hid_unregister_driver(&wiimote_hid_driver); |
David Herrmann | fb51b44 | 2011-07-05 13:45:08 +0200 | [diff] [blame] | 382 | } |
| 383 | |
| 384 | module_init(wiimote_init); |
| 385 | module_exit(wiimote_exit); |
| 386 | MODULE_LICENSE("GPL"); |
| 387 | MODULE_AUTHOR("David Herrmann <dh.herrmann@gmail.com>"); |
| 388 | MODULE_DESCRIPTION(WIIMOTE_NAME " Device Driver"); |
| 389 | MODULE_VERSION(WIIMOTE_VERSION); |