diff options
author | Johannes Berg <johannes@sipsolutions.net> | 2008-05-05 23:56:55 -0400 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2008-05-16 14:50:16 -0400 |
commit | 7dce869f120cd7500e83850a6036dfeffcf77c57 (patch) | |
tree | d6cbf6871d537ede28b73d17c22f3d47f5d2ef9e /drivers/input | |
parent | 5b7c407baa9501e49ebd3b6eac30cd4bcb60ca9d (diff) |
Input: appletouch - miscellaneous code cleanups
This patch does some code cleanups in appletouch:
* useless comment removal
* make almost checkpatch clean
* make sparse clean
Signed-off-by: Sven Anders <anders@anduras.de>
[jberg: most of the changes including removing much of the original patch]
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers/input')
-rw-r--r-- | drivers/input/mouse/appletouch.c | 173 |
1 files changed, 100 insertions, 73 deletions
diff --git a/drivers/input/mouse/appletouch.c b/drivers/input/mouse/appletouch.c index 32c29400f872..814e90459b3b 100644 --- a/drivers/input/mouse/appletouch.c +++ b/drivers/input/mouse/appletouch.c | |||
@@ -2,12 +2,13 @@ | |||
2 | * Apple USB Touchpad (for post-February 2005 PowerBooks and MacBooks) driver | 2 | * Apple USB Touchpad (for post-February 2005 PowerBooks and MacBooks) driver |
3 | * | 3 | * |
4 | * Copyright (C) 2001-2004 Greg Kroah-Hartman (greg@kroah.com) | 4 | * Copyright (C) 2001-2004 Greg Kroah-Hartman (greg@kroah.com) |
5 | * Copyright (C) 2005 Johannes Berg (johannes@sipsolutions.net) | 5 | * Copyright (C) 2005-2008 Johannes Berg (johannes@sipsolutions.net) |
6 | * Copyright (C) 2005 Stelian Pop (stelian@popies.net) | 6 | * Copyright (C) 2005 Stelian Pop (stelian@popies.net) |
7 | * Copyright (C) 2005 Frank Arnold (frank@scirocco-5v-turbo.de) | 7 | * Copyright (C) 2005 Frank Arnold (frank@scirocco-5v-turbo.de) |
8 | * Copyright (C) 2005 Peter Osterlund (petero2@telia.com) | 8 | * Copyright (C) 2005 Peter Osterlund (petero2@telia.com) |
9 | * Copyright (C) 2005 Michael Hanselmann (linux-kernel@hansmi.ch) | 9 | * Copyright (C) 2005 Michael Hanselmann (linux-kernel@hansmi.ch) |
10 | * Copyright (C) 2006 Nicolas Boichat (nicolas@boichat.ch) | 10 | * Copyright (C) 2006 Nicolas Boichat (nicolas@boichat.ch) |
11 | * Copyright (C) 2007-2008 Sven Anders (anders@anduras.de) | ||
11 | * | 12 | * |
12 | * Thanks to Alex Harper <basilisk@foobox.net> for his inputs. | 13 | * Thanks to Alex Harper <basilisk@foobox.net> for his inputs. |
13 | * | 14 | * |
@@ -38,6 +39,8 @@ | |||
38 | #define APPLE_VENDOR_ID 0x05AC | 39 | #define APPLE_VENDOR_ID 0x05AC |
39 | 40 | ||
40 | /* These names come from Info.plist in AppleUSBTrackpad.kext */ | 41 | /* These names come from Info.plist in AppleUSBTrackpad.kext */ |
42 | |||
43 | /* PowerBooks Feb 2005 / iBooks */ | ||
41 | #define FOUNTAIN_ANSI_PRODUCT_ID 0x020E | 44 | #define FOUNTAIN_ANSI_PRODUCT_ID 0x020E |
42 | #define FOUNTAIN_ISO_PRODUCT_ID 0x020F | 45 | #define FOUNTAIN_ISO_PRODUCT_ID 0x020F |
43 | 46 | ||
@@ -45,9 +48,10 @@ | |||
45 | 48 | ||
46 | #define GEYSER1_TP_ONLY_PRODUCT_ID 0x030B | 49 | #define GEYSER1_TP_ONLY_PRODUCT_ID 0x030B |
47 | 50 | ||
48 | #define GEYSER_ANSI_PRODUCT_ID 0x0214 | 51 | /* PowerBooks Oct 2005 */ |
49 | #define GEYSER_ISO_PRODUCT_ID 0x0215 | 52 | #define GEYSER2_ANSI_PRODUCT_ID 0x0214 |
50 | #define GEYSER_JIS_PRODUCT_ID 0x0216 | 53 | #define GEYSER2_ISO_PRODUCT_ID 0x0215 |
54 | #define GEYSER2_JIS_PRODUCT_ID 0x0216 | ||
51 | 55 | ||
52 | /* MacBook devices */ | 56 | /* MacBook devices */ |
53 | #define GEYSER3_ANSI_PRODUCT_ID 0x0217 | 57 | #define GEYSER3_ANSI_PRODUCT_ID 0x0217 |
@@ -55,13 +59,15 @@ | |||
55 | #define GEYSER3_JIS_PRODUCT_ID 0x0219 | 59 | #define GEYSER3_JIS_PRODUCT_ID 0x0219 |
56 | 60 | ||
57 | /* | 61 | /* |
58 | * Geyser IV: same as Geyser III according to Info.plist in AppleUSBTrackpad.kext | 62 | * Geyser IV: same as Geyser III according to Info.plist in OSX's |
63 | * AppleUSBTrackpad.kext | ||
59 | * -> same IOClass (AppleUSBGrIIITrackpad), same acceleration tables | 64 | * -> same IOClass (AppleUSBGrIIITrackpad), same acceleration tables |
60 | */ | 65 | */ |
61 | #define GEYSER4_ANSI_PRODUCT_ID 0x021A | 66 | #define GEYSER4_ANSI_PRODUCT_ID 0x021A |
62 | #define GEYSER4_ISO_PRODUCT_ID 0x021B | 67 | #define GEYSER4_ISO_PRODUCT_ID 0x021B |
63 | #define GEYSER4_JIS_PRODUCT_ID 0x021C | 68 | #define GEYSER4_JIS_PRODUCT_ID 0x021C |
64 | 69 | ||
70 | /* Macbook3,1 devices */ | ||
65 | #define GEYSER4_HF_ANSI_PRODUCT_ID 0x0229 | 71 | #define GEYSER4_HF_ANSI_PRODUCT_ID 0x0229 |
66 | #define GEYSER4_HF_ISO_PRODUCT_ID 0x022A | 72 | #define GEYSER4_HF_ISO_PRODUCT_ID 0x022A |
67 | #define GEYSER4_HF_JIS_PRODUCT_ID 0x022B | 73 | #define GEYSER4_HF_JIS_PRODUCT_ID 0x022B |
@@ -77,15 +83,16 @@ | |||
77 | 83 | ||
78 | /* table of devices that work with this driver */ | 84 | /* table of devices that work with this driver */ |
79 | static struct usb_device_id atp_table [] = { | 85 | static struct usb_device_id atp_table [] = { |
86 | /* PowerBooks Feb 2005, iBooks G4 */ | ||
80 | { ATP_DEVICE(FOUNTAIN_ANSI_PRODUCT_ID) }, | 87 | { ATP_DEVICE(FOUNTAIN_ANSI_PRODUCT_ID) }, |
81 | { ATP_DEVICE(FOUNTAIN_ISO_PRODUCT_ID) }, | 88 | { ATP_DEVICE(FOUNTAIN_ISO_PRODUCT_ID) }, |
82 | { ATP_DEVICE(FOUNTAIN_TP_ONLY_PRODUCT_ID) }, | 89 | { ATP_DEVICE(FOUNTAIN_TP_ONLY_PRODUCT_ID) }, |
83 | { ATP_DEVICE(GEYSER1_TP_ONLY_PRODUCT_ID) }, | 90 | { ATP_DEVICE(GEYSER1_TP_ONLY_PRODUCT_ID) }, |
84 | 91 | ||
85 | /* PowerBooks Oct 2005 */ | 92 | /* PowerBooks Oct 2005 */ |
86 | { ATP_DEVICE(GEYSER_ANSI_PRODUCT_ID) }, | 93 | { ATP_DEVICE(GEYSER2_ANSI_PRODUCT_ID) }, |
87 | { ATP_DEVICE(GEYSER_ISO_PRODUCT_ID) }, | 94 | { ATP_DEVICE(GEYSER2_ISO_PRODUCT_ID) }, |
88 | { ATP_DEVICE(GEYSER_JIS_PRODUCT_ID) }, | 95 | { ATP_DEVICE(GEYSER2_JIS_PRODUCT_ID) }, |
89 | 96 | ||
90 | /* Core Duo MacBook & MacBook Pro */ | 97 | /* Core Duo MacBook & MacBook Pro */ |
91 | { ATP_DEVICE(GEYSER3_ANSI_PRODUCT_ID) }, | 98 | { ATP_DEVICE(GEYSER3_ANSI_PRODUCT_ID) }, |
@@ -97,6 +104,7 @@ static struct usb_device_id atp_table [] = { | |||
97 | { ATP_DEVICE(GEYSER4_ISO_PRODUCT_ID) }, | 104 | { ATP_DEVICE(GEYSER4_ISO_PRODUCT_ID) }, |
98 | { ATP_DEVICE(GEYSER4_JIS_PRODUCT_ID) }, | 105 | { ATP_DEVICE(GEYSER4_JIS_PRODUCT_ID) }, |
99 | 106 | ||
107 | /* Core2 Duo MacBook3,1 */ | ||
100 | { ATP_DEVICE(GEYSER4_HF_ANSI_PRODUCT_ID) }, | 108 | { ATP_DEVICE(GEYSER4_HF_ANSI_PRODUCT_ID) }, |
101 | { ATP_DEVICE(GEYSER4_HF_ISO_PRODUCT_ID) }, | 109 | { ATP_DEVICE(GEYSER4_HF_ISO_PRODUCT_ID) }, |
102 | { ATP_DEVICE(GEYSER4_HF_JIS_PRODUCT_ID) }, | 110 | { ATP_DEVICE(GEYSER4_HF_JIS_PRODUCT_ID) }, |
@@ -104,7 +112,7 @@ static struct usb_device_id atp_table [] = { | |||
104 | /* Terminating entry */ | 112 | /* Terminating entry */ |
105 | { } | 113 | { } |
106 | }; | 114 | }; |
107 | MODULE_DEVICE_TABLE (usb, atp_table); | 115 | MODULE_DEVICE_TABLE(usb, atp_table); |
108 | 116 | ||
109 | /* | 117 | /* |
110 | * number of sensors. Note that only 16 instead of 26 X (horizontal) | 118 | * number of sensors. Note that only 16 instead of 26 X (horizontal) |
@@ -147,43 +155,45 @@ MODULE_DEVICE_TABLE (usb, atp_table); | |||
147 | /* Structure to hold all of our device specific stuff */ | 155 | /* Structure to hold all of our device specific stuff */ |
148 | struct atp { | 156 | struct atp { |
149 | char phys[64]; | 157 | char phys[64]; |
150 | struct usb_device * udev; /* usb device */ | 158 | struct usb_device *udev; /* usb device */ |
151 | struct urb * urb; /* usb request block */ | 159 | struct urb *urb; /* usb request block */ |
152 | signed char * data; /* transferred data */ | 160 | signed char *data; /* transferred data */ |
153 | struct input_dev * input; /* input dev */ | 161 | struct input_dev *input; /* input dev */ |
154 | unsigned char open; /* non-zero if opened */ | 162 | bool open; |
155 | unsigned char valid; /* are the sensors valid ? */ | 163 | bool valid; /* are the samples valid? */ |
156 | unsigned char size_detect_done; | 164 | bool size_detect_done; |
157 | unsigned char overflowwarn; /* overflow warning printed? */ | 165 | bool overflow_warned; |
158 | int x_old; /* last reported x/y, */ | 166 | int x_old; /* last reported x/y, */ |
159 | int y_old; /* used for smoothing */ | 167 | int y_old; /* used for smoothing */ |
160 | /* current value of the sensors */ | ||
161 | signed char xy_cur[ATP_XSENSORS + ATP_YSENSORS]; | 168 | signed char xy_cur[ATP_XSENSORS + ATP_YSENSORS]; |
162 | /* last value of the sensors */ | ||
163 | signed char xy_old[ATP_XSENSORS + ATP_YSENSORS]; | 169 | signed char xy_old[ATP_XSENSORS + ATP_YSENSORS]; |
164 | /* accumulated sensors */ | ||
165 | int xy_acc[ATP_XSENSORS + ATP_YSENSORS]; | 170 | int xy_acc[ATP_XSENSORS + ATP_YSENSORS]; |
166 | int datalen; /* size of an USB urb transfer */ | 171 | int datalen; /* size of USB transfer */ |
167 | int idlecount; /* number of empty packets */ | 172 | int idlecount; /* number of empty packets */ |
168 | struct work_struct work; | 173 | struct work_struct work; |
169 | }; | 174 | }; |
170 | 175 | ||
171 | #define dbg_dump(msg, tab) \ | 176 | #define dbg_dump(msg, tab) \ |
172 | if (debug > 1) { \ | 177 | if (debug > 1) { \ |
173 | int i; \ | 178 | int __i; \ |
174 | printk("appletouch: %s %lld", msg, (long long)jiffies); \ | 179 | printk(KERN_DEBUG "appletouch: %s", msg); \ |
175 | for (i = 0; i < ATP_XSENSORS + ATP_YSENSORS; i++) \ | 180 | for (__i = 0; __i < ATP_XSENSORS + ATP_YSENSORS; __i++) \ |
176 | printk(" %02x", tab[i]); \ | 181 | printk(" %02x", tab[__i]); \ |
177 | printk("\n"); \ | 182 | printk("\n"); \ |
178 | } | 183 | } |
179 | 184 | ||
180 | #define dprintk(format, a...) \ | 185 | #define dprintk(format, a...) \ |
181 | do { \ | 186 | do { \ |
182 | if (debug) printk(KERN_DEBUG format, ##a); \ | 187 | if (debug) \ |
188 | printk(KERN_DEBUG format, ##a); \ | ||
183 | } while (0) | 189 | } while (0) |
184 | 190 | ||
185 | MODULE_AUTHOR("Johannes Berg, Stelian Pop, Frank Arnold, Michael Hanselmann"); | 191 | MODULE_AUTHOR("Johannes Berg"); |
186 | MODULE_DESCRIPTION("Apple PowerBooks USB touchpad driver"); | 192 | MODULE_AUTHOR("Stelian Pop"); |
193 | MODULE_AUTHOR("Frank Arnold"); | ||
194 | MODULE_AUTHOR("Michael Hanselmann"); | ||
195 | MODULE_AUTHOR("Sven Anders"); | ||
196 | MODULE_DESCRIPTION("Apple PowerBook and MacBook USB touchpad driver"); | ||
187 | MODULE_LICENSE("GPL"); | 197 | MODULE_LICENSE("GPL"); |
188 | 198 | ||
189 | /* | 199 | /* |
@@ -191,9 +201,11 @@ MODULE_LICENSE("GPL"); | |||
191 | */ | 201 | */ |
192 | static int threshold = ATP_THRESHOLD; | 202 | static int threshold = ATP_THRESHOLD; |
193 | module_param(threshold, int, 0644); | 203 | module_param(threshold, int, 0644); |
194 | MODULE_PARM_DESC(threshold, "Discards any change in data from a sensor (trackpad has hundreds of these sensors) less than this value"); | 204 | MODULE_PARM_DESC(threshold, "Discard any change in data from a sensor" |
205 | " (the trackpad has many of these sensors)" | ||
206 | " less than this value."); | ||
195 | 207 | ||
196 | static int debug = 1; | 208 | static int debug; |
197 | module_param(debug, int, 0644); | 209 | module_param(debug, int, 0644); |
198 | MODULE_PARM_DESC(debug, "Activate debugging output"); | 210 | MODULE_PARM_DESC(debug, "Activate debugging output"); |
199 | 211 | ||
@@ -211,9 +223,9 @@ static inline int atp_is_geyser_2(struct atp *dev) | |||
211 | { | 223 | { |
212 | u16 productId = le16_to_cpu(dev->udev->descriptor.idProduct); | 224 | u16 productId = le16_to_cpu(dev->udev->descriptor.idProduct); |
213 | 225 | ||
214 | return (productId == GEYSER_ANSI_PRODUCT_ID) || | 226 | return (productId == GEYSER2_ANSI_PRODUCT_ID) || |
215 | (productId == GEYSER_ISO_PRODUCT_ID) || | 227 | (productId == GEYSER2_ISO_PRODUCT_ID) || |
216 | (productId == GEYSER_JIS_PRODUCT_ID); | 228 | (productId == GEYSER2_JIS_PRODUCT_ID); |
217 | } | 229 | } |
218 | 230 | ||
219 | static inline int atp_is_geyser_3(struct atp *dev) | 231 | static inline int atp_is_geyser_3(struct atp *dev) |
@@ -240,6 +252,7 @@ static int atp_geyser_init(struct usb_device *udev) | |||
240 | { | 252 | { |
241 | char data[8]; | 253 | char data[8]; |
242 | int size; | 254 | int size; |
255 | int i; | ||
243 | 256 | ||
244 | size = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), | 257 | size = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), |
245 | ATP_GEYSER_MODE_READ_REQUEST_ID, | 258 | ATP_GEYSER_MODE_READ_REQUEST_ID, |
@@ -248,8 +261,11 @@ static int atp_geyser_init(struct usb_device *udev) | |||
248 | ATP_GEYSER_MODE_REQUEST_INDEX, &data, 8, 5000); | 261 | ATP_GEYSER_MODE_REQUEST_INDEX, &data, 8, 5000); |
249 | 262 | ||
250 | if (size != 8) { | 263 | if (size != 8) { |
251 | err("Could not do mode read request from device" | 264 | dprintk("atp_geyser_init: read error\n"); |
252 | " (Geyser Raw mode)"); | 265 | for (i = 0; i < 8; i++) |
266 | dprintk("appletouch[%d]: %d\n", i, data[i]); | ||
267 | |||
268 | err("Failed to read mode from device."); | ||
253 | return -EIO; | 269 | return -EIO; |
254 | } | 270 | } |
255 | 271 | ||
@@ -263,8 +279,11 @@ static int atp_geyser_init(struct usb_device *udev) | |||
263 | ATP_GEYSER_MODE_REQUEST_INDEX, &data, 8, 5000); | 279 | ATP_GEYSER_MODE_REQUEST_INDEX, &data, 8, 5000); |
264 | 280 | ||
265 | if (size != 8) { | 281 | if (size != 8) { |
266 | err("Could not do mode write request to device" | 282 | dprintk("atp_geyser_init: write error\n"); |
267 | " (Geyser Raw mode)"); | 283 | for (i = 0; i < 8; i++) |
284 | dprintk("appletouch[%d]: %d\n", i, data[i]); | ||
285 | |||
286 | err("Failed to request geyser raw mode"); | ||
268 | return -EIO; | 287 | return -EIO; |
269 | } | 288 | } |
270 | return 0; | 289 | return 0; |
@@ -280,15 +299,15 @@ static void atp_reinit(struct work_struct *work) | |||
280 | struct usb_device *udev = dev->udev; | 299 | struct usb_device *udev = dev->udev; |
281 | int retval; | 300 | int retval; |
282 | 301 | ||
302 | dprintk("appletouch: putting appletouch to sleep (reinit)\n"); | ||
283 | dev->idlecount = 0; | 303 | dev->idlecount = 0; |
284 | 304 | ||
285 | atp_geyser_init(udev); | 305 | atp_geyser_init(udev); |
286 | 306 | ||
287 | retval = usb_submit_urb(dev->urb, GFP_ATOMIC); | 307 | retval = usb_submit_urb(dev->urb, GFP_ATOMIC); |
288 | if (retval) { | 308 | if (retval) |
289 | err("%s - usb_submit_urb failed with result %d", | 309 | err("atp_reinit: usb_submit_urb failed with error %d", |
290 | __func__, retval); | 310 | retval); |
291 | } | ||
292 | } | 311 | } |
293 | 312 | ||
294 | static int atp_calculate_abs(int *xy_sensors, int nb_sensors, int fact, | 313 | static int atp_calculate_abs(int *xy_sensors, int nb_sensors, int fact, |
@@ -323,7 +342,8 @@ static int atp_calculate_abs(int *xy_sensors, int nb_sensors, int fact, | |||
323 | * | 342 | * |
324 | * - Jason Parekh <jasonparekh@gmail.com> | 343 | * - Jason Parekh <jasonparekh@gmail.com> |
325 | */ | 344 | */ |
326 | if (i < 1 || (!is_increasing && xy_sensors[i - 1] < xy_sensors[i])) { | 345 | if (i < 1 || |
346 | (!is_increasing && xy_sensors[i - 1] < xy_sensors[i])) { | ||
327 | (*fingers)++; | 347 | (*fingers)++; |
328 | is_increasing = 1; | 348 | is_increasing = 1; |
329 | } else if (i > 0 && xy_sensors[i - 1] >= xy_sensors[i]) { | 349 | } else if (i > 0 && xy_sensors[i - 1] >= xy_sensors[i]) { |
@@ -331,11 +351,11 @@ static int atp_calculate_abs(int *xy_sensors, int nb_sensors, int fact, | |||
331 | } | 351 | } |
332 | 352 | ||
333 | /* | 353 | /* |
334 | * Subtracts threshold so a high sensor that just passes the threshold | 354 | * Subtracts threshold so a high sensor that just passes the |
335 | * won't skew the calculated absolute coordinate. Fixes an issue | 355 | * threshold won't skew the calculated absolute coordinate. |
336 | * where slowly moving the mouse would occassionaly jump a number of | 356 | * Fixes an issue where slowly moving the mouse would |
337 | * pixels (let me restate--slowly moving the mouse makes this issue | 357 | * occasionally jump a number of pixels (slowly moving the |
338 | * most apparent). | 358 | * finger makes this issue most apparent.) |
339 | */ | 359 | */ |
340 | pcum += (xy_sensors[i] - threshold) * i; | 360 | pcum += (xy_sensors[i] - threshold) * i; |
341 | psum += (xy_sensors[i] - threshold); | 361 | psum += (xy_sensors[i] - threshold); |
@@ -356,7 +376,7 @@ static inline void atp_report_fingers(struct input_dev *input, int fingers) | |||
356 | input_report_key(input, BTN_TOOL_TRIPLETAP, fingers > 2); | 376 | input_report_key(input, BTN_TOOL_TRIPLETAP, fingers > 2); |
357 | } | 377 | } |
358 | 378 | ||
359 | static void atp_complete(struct urb* urb) | 379 | static void atp_complete(struct urb *urb) |
360 | { | 380 | { |
361 | int x, y, x_z, y_z, x_f, y_f; | 381 | int x, y, x_z, y_z, x_f, y_f; |
362 | int retval, i, j; | 382 | int retval, i, j; |
@@ -368,22 +388,22 @@ static void atp_complete(struct urb* urb) | |||
368 | /* success */ | 388 | /* success */ |
369 | break; | 389 | break; |
370 | case -EOVERFLOW: | 390 | case -EOVERFLOW: |
371 | if(!dev->overflowwarn) { | 391 | if (!dev->overflow_warned) { |
372 | printk(KERN_WARNING "appletouch: OVERFLOW with data " | 392 | printk(KERN_WARNING "appletouch: OVERFLOW with data " |
373 | "length %d, actual length is %d\n", | 393 | "length %d, actual length is %d\n", |
374 | dev->datalen, dev->urb->actual_length); | 394 | dev->datalen, dev->urb->actual_length); |
375 | dev->overflowwarn = 1; | 395 | dev->overflow_warned = true; |
376 | } | 396 | } |
377 | case -ECONNRESET: | 397 | case -ECONNRESET: |
378 | case -ENOENT: | 398 | case -ENOENT: |
379 | case -ESHUTDOWN: | 399 | case -ESHUTDOWN: |
380 | /* This urb is terminated, clean up */ | 400 | /* This urb is terminated, clean up */ |
381 | dbg("%s - urb shutting down with status: %d", | 401 | dbg("atp_complete: urb shutting down with status: %d", |
382 | __func__, urb->status); | 402 | urb->status); |
383 | return; | 403 | return; |
384 | default: | 404 | default: |
385 | dbg("%s - nonzero urb status received: %d", | 405 | dbg("atp_complete: nonzero urb status received: %d", |
386 | __func__, urb->status); | 406 | urb->status); |
387 | goto exit; | 407 | goto exit; |
388 | } | 408 | } |
389 | 409 | ||
@@ -438,7 +458,7 @@ static void atp_complete(struct urb* urb) | |||
438 | } else { | 458 | } else { |
439 | for (i = 0; i < 8; i++) { | 459 | for (i = 0; i < 8; i++) { |
440 | /* X values */ | 460 | /* X values */ |
441 | dev->xy_cur[i ] = dev->data[5 * i + 2]; | 461 | dev->xy_cur[i + 0] = dev->data[5 * i + 2]; |
442 | dev->xy_cur[i + 8] = dev->data[5 * i + 4]; | 462 | dev->xy_cur[i + 8] = dev->data[5 * i + 4]; |
443 | dev->xy_cur[i + 16] = dev->data[5 * i + 42]; | 463 | dev->xy_cur[i + 16] = dev->data[5 * i + 42]; |
444 | if (i < 2) | 464 | if (i < 2) |
@@ -454,7 +474,7 @@ static void atp_complete(struct urb* urb) | |||
454 | 474 | ||
455 | if (!dev->valid) { | 475 | if (!dev->valid) { |
456 | /* first sample */ | 476 | /* first sample */ |
457 | dev->valid = 1; | 477 | dev->valid = true; |
458 | dev->x_old = dev->y_old = -1; | 478 | dev->x_old = dev->y_old = -1; |
459 | memcpy(dev->xy_old, dev->xy_cur, sizeof(dev->xy_old)); | 479 | memcpy(dev->xy_old, dev->xy_cur, sizeof(dev->xy_old)); |
460 | 480 | ||
@@ -463,7 +483,8 @@ static void atp_complete(struct urb* urb) | |||
463 | goto exit; | 483 | goto exit; |
464 | 484 | ||
465 | /* 17" Powerbooks have extra X sensors */ | 485 | /* 17" Powerbooks have extra X sensors */ |
466 | for (i = (atp_is_geyser_2(dev) ? 15 : 16); i < ATP_XSENSORS; i++) { | 486 | for (i = (atp_is_geyser_2(dev) ? 15 : 16); |
487 | i < ATP_XSENSORS; i++) { | ||
467 | if (!dev->xy_cur[i]) | 488 | if (!dev->xy_cur[i]) |
468 | continue; | 489 | continue; |
469 | 490 | ||
@@ -549,10 +570,14 @@ static void atp_complete(struct urb* urb) | |||
549 | * work on Fountain touchpads. | 570 | * work on Fountain touchpads. |
550 | */ | 571 | */ |
551 | if (!atp_is_fountain(dev)) { | 572 | if (!atp_is_fountain(dev)) { |
573 | /* | ||
574 | * Button must not be pressed when entering suspend, | ||
575 | * otherwise we will never release the button. | ||
576 | */ | ||
552 | if (!x && !y && !key) { | 577 | if (!x && !y && !key) { |
553 | dev->idlecount++; | 578 | dev->idlecount++; |
554 | if (dev->idlecount == 10) { | 579 | if (dev->idlecount == 10) { |
555 | dev->valid = 0; | 580 | dev->valid = false; |
556 | schedule_work(&dev->work); | 581 | schedule_work(&dev->work); |
557 | /* Don't resubmit urb here, wait for reinit */ | 582 | /* Don't resubmit urb here, wait for reinit */ |
558 | return; | 583 | return; |
@@ -561,12 +586,11 @@ static void atp_complete(struct urb* urb) | |||
561 | dev->idlecount = 0; | 586 | dev->idlecount = 0; |
562 | } | 587 | } |
563 | 588 | ||
564 | exit: | 589 | exit: |
565 | retval = usb_submit_urb(dev->urb, GFP_ATOMIC); | 590 | retval = usb_submit_urb(dev->urb, GFP_ATOMIC); |
566 | if (retval) { | 591 | if (retval) |
567 | err("%s - usb_submit_urb failed with result %d", | 592 | err("atp_complete: usb_submit_urb failed with result %d", |
568 | __func__, retval); | 593 | retval); |
569 | } | ||
570 | } | 594 | } |
571 | 595 | ||
572 | static int atp_open(struct input_dev *input) | 596 | static int atp_open(struct input_dev *input) |
@@ -589,7 +613,8 @@ static void atp_close(struct input_dev *input) | |||
589 | dev->open = 0; | 613 | dev->open = 0; |
590 | } | 614 | } |
591 | 615 | ||
592 | static int atp_probe(struct usb_interface *iface, const struct usb_device_id *id) | 616 | static int atp_probe(struct usb_interface *iface, |
617 | const struct usb_device_id *id) | ||
593 | { | 618 | { |
594 | struct atp *dev; | 619 | struct atp *dev; |
595 | struct input_dev *input_dev; | 620 | struct input_dev *input_dev; |
@@ -625,7 +650,7 @@ static int atp_probe(struct usb_interface *iface, const struct usb_device_id *id | |||
625 | 650 | ||
626 | dev->udev = udev; | 651 | dev->udev = udev; |
627 | dev->input = input_dev; | 652 | dev->input = input_dev; |
628 | dev->overflowwarn = 0; | 653 | dev->overflow_warned = false; |
629 | if (atp_is_geyser_3(dev)) | 654 | if (atp_is_geyser_3(dev)) |
630 | dev->datalen = 64; | 655 | dev->datalen = 64; |
631 | else if (atp_is_geyser_2(dev)) | 656 | else if (atp_is_geyser_2(dev)) |
@@ -692,9 +717,11 @@ static int atp_probe(struct usb_interface *iface, const struct usb_device_id *id | |||
692 | * 17" models are detected later. | 717 | * 17" models are detected later. |
693 | */ | 718 | */ |
694 | input_set_abs_params(input_dev, ABS_X, 0, | 719 | input_set_abs_params(input_dev, ABS_X, 0, |
695 | (16 - 1) * ATP_XFACT - 1, ATP_FUZZ, 0); | 720 | (16 - 1) * ATP_XFACT - 1, |
721 | ATP_FUZZ, 0); | ||
696 | input_set_abs_params(input_dev, ABS_Y, 0, | 722 | input_set_abs_params(input_dev, ABS_Y, 0, |
697 | (ATP_YSENSORS - 1) * ATP_YFACT - 1, ATP_FUZZ, 0); | 723 | (ATP_YSENSORS - 1) * ATP_YFACT - 1, |
724 | ATP_FUZZ, 0); | ||
698 | } | 725 | } |
699 | input_set_abs_params(input_dev, ABS_PRESSURE, 0, ATP_PRESSURE, 0, 0); | 726 | input_set_abs_params(input_dev, ABS_PRESSURE, 0, ATP_PRESSURE, 0, 0); |
700 | 727 | ||
@@ -749,7 +776,7 @@ static int atp_suspend(struct usb_interface *iface, pm_message_t message) | |||
749 | struct atp *dev = usb_get_intfdata(iface); | 776 | struct atp *dev = usb_get_intfdata(iface); |
750 | 777 | ||
751 | usb_kill_urb(dev->urb); | 778 | usb_kill_urb(dev->urb); |
752 | dev->valid = 0; | 779 | dev->valid = false; |
753 | 780 | ||
754 | return 0; | 781 | return 0; |
755 | } | 782 | } |