Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'input-for-v6.11-rc0' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input

Pull input updates from Dmitry Torokhov:

- streamlined logic in input core for handling normal input handlers vs
input filters

- updates to input drivers to allocate memory with sizeof(*pointer)
instead of sizeof(type)

- change to ads7846 touchscreen driver to use hsync GPIO instead of
requiring platform data with special method (which is not compatible
with boards using device tree)

- update to adc-joystick driver to handle inverted axes

- cleanups in various drivers switching them to use the new "guard" and
"__free()" facilities

- changes to several drivers (adxl34x, atmel_mxt_ts, ati-remote2,
omap-keypad, yealink) to stop creating driver-specific device
attributes manually and use driver core facilities for this

- update to Cypress PS/2 protocol driver to properly handle errors from
the PS/2 transport as well as other cleanups

- update to edt-ft5x06 driver to support ft5426 variant

- update to ektf2127 driver to support ektf2232 variant

- update to exc3000 driver to support EXC81W32 variant

- update to imagis driver to support IST3038 variant

- other assorted driver cleanups.

* tag 'input-for-v6.11-rc0' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input: (71 commits)
Input: yealink - simplify locking in sysfs attribute handling
Input: yealink - use driver core to instantiate device attributes
Input: ati-remote2 - use driver core to instantiate device attributes
Input: omap-keypad - use driver core to instantiate device attributes
Input: atmel_mxt_ts - use driver core to instantiate device attributes
Input: exc3000 - add EXC81W32 support
dt-bindings: input: touchscreen: exc3000: add EXC81W32
Input: twl4030-pwrbutton - fix kernel-doc warning
Input: himax_hx83112b - add support for HX83100A
Input: himax_hx83112b - add himax_chip struct for multi-chip support
Input: himax_hx83112b - implement MCU register reading
Input: himax_hx83112b - use more descriptive register defines
dt-bindings: input: touchscreen: himax,hx83112b: add HX83100A
Input: do not check number of events in input_pass_values()
Input: preallocate memory to hold event values
Input: rearrange input_alloc_device() to prepare for preallocating of vals
Input: simplify event handling logic
Input: make events() method return number of events processed
Input: make sure input handlers define only one processing method
Input: evdev - remove ->event() method
...

+1235 -1051
-60
Documentation/devicetree/bindings/input/ti,nspire-keypad.txt
··· 1 - TI-NSPIRE Keypad 2 - 3 - Required properties: 4 - - compatible: Compatible property value should be "ti,nspire-keypad". 5 - 6 - - reg: Physical base address of the peripheral and length of memory mapped 7 - region. 8 - 9 - - interrupts: The interrupt number for the peripheral. 10 - 11 - - scan-interval: How often to scan in us. Based on a APB speed of 33MHz, the 12 - maximum and minimum delay time is ~2000us and ~500us respectively 13 - 14 - - row-delay: How long to wait before scanning each row. 15 - 16 - - clocks: The clock this peripheral is attached to. 17 - 18 - - linux,keymap: The keymap to use 19 - (see Documentation/devicetree/bindings/input/matrix-keymap.txt) 20 - 21 - Optional properties: 22 - - active-low: Specify that the keypad is active low (i.e. logical low signifies 23 - a key press). 24 - 25 - Example: 26 - 27 - input { 28 - compatible = "ti,nspire-keypad"; 29 - reg = <0x900E0000 0x1000>; 30 - interrupts = <16>; 31 - 32 - scan-interval = <1000>; 33 - row-delay = <200>; 34 - 35 - clocks = <&apb_pclk>; 36 - 37 - linux,keymap = < 38 - 0x0000001c 0x0001001c 0x00040039 39 - 0x0005002c 0x00060015 0x0007000b 40 - 0x0008000f 0x0100002d 0x01010011 41 - 0x0102002f 0x01030004 0x01040016 42 - 0x01050014 0x0106001f 0x01070002 43 - 0x010a006a 0x02000013 0x02010010 44 - 0x02020019 0x02030007 0x02040018 45 - 0x02050031 0x02060032 0x02070005 46 - 0x02080028 0x0209006c 0x03000026 47 - 0x03010025 0x03020024 0x0303000a 48 - 0x03040017 0x03050023 0x03060022 49 - 0x03070008 0x03080035 0x03090069 50 - 0x04000021 0x04010012 0x04020020 51 - 0x0404002e 0x04050030 0x0406001e 52 - 0x0407000d 0x04080037 0x04090067 53 - 0x05010038 0x0502000c 0x0503001b 54 - 0x05040034 0x0505001a 0x05060006 55 - 0x05080027 0x0509000e 0x050a006f 56 - 0x0600002b 0x0602004e 0x06030068 57 - 0x06040003 0x0605006d 0x06060009 58 - 0x06070001 0x0609000f 0x0708002a 59 - 0x0709001d 0x070a0033 >; 60 - };
+74
Documentation/devicetree/bindings/input/ti,nspire-keypad.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/input/ti,nspire-keypad.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: TI-NSPIRE Keypad 8 + 9 + maintainers: 10 + - Andrew Davis <afd@ti.com> 11 + 12 + allOf: 13 + - $ref: input.yaml# 14 + - $ref: matrix-keymap.yaml# 15 + 16 + properties: 17 + compatible: 18 + enum: 19 + - ti,nspire-keypad 20 + 21 + reg: 22 + maxItems: 1 23 + 24 + interrupts: 25 + maxItems: 1 26 + 27 + clocks: 28 + maxItems: 1 29 + 30 + scan-interval: 31 + $ref: /schemas/types.yaml#/definitions/uint32 32 + description: How often to scan in us. Based on a APB speed of 33MHz, the 33 + maximum and minimum delay time is ~2000us and ~500us respectively 34 + 35 + row-delay: 36 + $ref: /schemas/types.yaml#/definitions/uint32 37 + description: How long to wait between scanning each row in us. 38 + 39 + active-low: 40 + description: Specify that the keypad is active low. 41 + 42 + required: 43 + - compatible 44 + - reg 45 + - interrupts 46 + - clocks 47 + - scan-interval 48 + - row-delay 49 + - linux,keymap 50 + 51 + unevaluatedProperties: false 52 + 53 + examples: 54 + - | 55 + #include <dt-bindings/input/input.h> 56 + keypad@900e0000 { 57 + compatible = "ti,nspire-keypad"; 58 + reg = <0x900e0000 0x1000>; 59 + interrupts = <16>; 60 + 61 + clocks = <&apb_pclk>; 62 + 63 + scan-interval = <1000>; 64 + row-delay = <200>; 65 + 66 + linux,keymap = < 67 + MATRIX_KEY(0, 0, KEY_ENTER) 68 + MATRIX_KEY(0, 1, KEY_ENTER) 69 + MATRIX_KEY(0, 4, KEY_SPACE) 70 + MATRIX_KEY(0, 5, KEY_Z) 71 + MATRIX_KEY(0, 6, KEY_Y) 72 + MATRIX_KEY(0, 7, KEY_0) 73 + >; 74 + };
+1
Documentation/devicetree/bindings/input/touchscreen/ads7846.txt
··· 57 57 pendown-gpio (u32). 58 58 pendown-gpio GPIO handle describing the pin the !PENIRQ 59 59 line is connected to. 60 + ti,hsync-gpios GPIO line to poll for hsync 60 61 wakeup-source use any event on touchscreen as wakeup event. 61 62 (Legacy property support: "linux,wakeup") 62 63 touchscreen-size-x General touchscreen binding, see [1].
+1
Documentation/devicetree/bindings/input/touchscreen/edt-ft5x06.yaml
··· 39 39 - edt,edt-ft5406 40 40 - edt,edt-ft5506 41 41 - evervision,ev-ft5726 42 + - focaltech,ft5426 42 43 - focaltech,ft5452 43 44 - focaltech,ft6236 44 45 - focaltech,ft8719
+8 -4
Documentation/devicetree/bindings/input/touchscreen/eeti,exc3000.yaml
··· 14 14 15 15 properties: 16 16 compatible: 17 - enum: 18 - - eeti,exc3000 19 - - eeti,exc80h60 20 - - eeti,exc80h84 17 + oneOf: 18 + - const: eeti,exc3000 19 + - const: eeti,exc80h60 20 + - const: eeti,exc80h84 21 + - items: 22 + - enum: 23 + - eeti,exc81w32 24 + - const: eeti,exc80h84 21 25 reg: 22 26 const: 0x2a 23 27 interrupts:
-25
Documentation/devicetree/bindings/input/touchscreen/ektf2127.txt
··· 1 - * Elan eKTF2127 I2C touchscreen controller 2 - 3 - Required properties: 4 - - compatible : "elan,ektf2127" or "elan,ektf2132" 5 - - reg : I2C slave address of the chip (0x40) 6 - - interrupts : interrupt specification for the ektf2127 interrupt 7 - - power-gpios : GPIO specification for the pin connected to the 8 - ektf2127's wake input. This needs to be driven high 9 - to take ektf2127 out of its low power state 10 - 11 - For additional optional properties see: touchscreen.txt 12 - 13 - Example: 14 - 15 - i2c@00000000 { 16 - ektf2127: touchscreen@15 { 17 - compatible = "elan,ektf2127"; 18 - reg = <0x15>; 19 - interrupt-parent = <&pio>; 20 - interrupts = <6 11 IRQ_TYPE_EDGE_FALLING> 21 - power-gpios = <&pio 1 3 GPIO_ACTIVE_HIGH>; 22 - touchscreen-inverted-x; 23 - touchscreen-swapped-x-y; 24 - }; 25 - };
+58
Documentation/devicetree/bindings/input/touchscreen/elan,ektf2127.yaml
··· 1 + # SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/input/touchscreen/elan,ektf2127.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Elan eKTF2127 I2C touchscreen controller 8 + 9 + maintainers: 10 + - Siebren Vroegindeweij <siebren.vroegindeweij@hotmail.com> 11 + 12 + allOf: 13 + - $ref: touchscreen.yaml# 14 + 15 + properties: 16 + compatible: 17 + enum: 18 + - elan,ektf2127 19 + - elan,ektf2132 20 + - elan,ektf2232 21 + 22 + reg: 23 + maxItems: 1 24 + 25 + interrupts: 26 + maxItems: 1 27 + 28 + power-gpios: 29 + maxItems: 1 30 + 31 + required: 32 + - compatible 33 + - reg 34 + - interrupts 35 + - power-gpios 36 + 37 + unevaluatedProperties: false 38 + 39 + examples: 40 + - | 41 + #include <dt-bindings/gpio/gpio.h> 42 + #include <dt-bindings/interrupt-controller/irq.h> 43 + 44 + i2c { 45 + #address-cells = <1>; 46 + #size-cells = <0>; 47 + 48 + touchscreen@15 { 49 + compatible = "elan,ektf2127"; 50 + reg = <0x15>; 51 + interrupt-parent = <&pio>; 52 + interrupts = <6 11 IRQ_TYPE_EDGE_FALLING>; 53 + power-gpios = <&pio 1 3 GPIO_ACTIVE_HIGH>; 54 + touchscreen-inverted-x; 55 + touchscreen-swapped-x-y; 56 + }; 57 + }; 58 + ...
+1
Documentation/devicetree/bindings/input/touchscreen/himax,hx83112b.yaml
··· 15 15 properties: 16 16 compatible: 17 17 enum: 18 + - himax,hx83100a 18 19 - himax,hx83112b 19 20 20 21 reg:
+1
Documentation/devicetree/bindings/input/touchscreen/imagis,ist3038c.yaml
··· 16 16 compatible: 17 17 enum: 18 18 - imagis,ist3032c 19 + - imagis,ist3038 19 20 - imagis,ist3038b 20 21 - imagis,ist3038c 21 22
+3 -13
drivers/input/evdev.c
··· 288 288 /* 289 289 * Pass incoming events to all connected clients. 290 290 */ 291 - static void evdev_events(struct input_handle *handle, 292 - const struct input_value *vals, unsigned int count) 291 + static unsigned int evdev_events(struct input_handle *handle, 292 + struct input_value *vals, unsigned int count) 293 293 { 294 294 struct evdev *evdev = handle->private; 295 295 struct evdev_client *client; ··· 306 306 evdev_pass_values(client, vals, count, ev_time); 307 307 308 308 rcu_read_unlock(); 309 - } 310 309 311 - /* 312 - * Pass incoming event to all connected clients. 313 - */ 314 - static void evdev_event(struct input_handle *handle, 315 - unsigned int type, unsigned int code, int value) 316 - { 317 - struct input_value vals[] = { { type, code, value } }; 318 - 319 - evdev_events(handle, vals, 1); 310 + return count; 320 311 } 321 312 322 313 static int evdev_fasync(int fd, struct file *file, int on) ··· 1409 1418 MODULE_DEVICE_TABLE(input, evdev_ids); 1410 1419 1411 1420 static struct input_handler evdev_handler = { 1412 - .event = evdev_event, 1413 1421 .events = evdev_events, 1414 1422 .connect = evdev_connect, 1415 1423 .disconnect = evdev_disconnect,
+1 -1
drivers/input/gameport/emu10k1-gp.c
··· 43 43 struct gameport *port; 44 44 int error; 45 45 46 - emu = kzalloc(sizeof(struct emu), GFP_KERNEL); 46 + emu = kzalloc(sizeof(*emu), GFP_KERNEL); 47 47 port = gameport_allocate_port(); 48 48 if (!emu || !port) { 49 49 printk(KERN_ERR "emu10k1-gp: Memory allocation failed\n");
+1 -1
drivers/input/gameport/fm801-gp.c
··· 68 68 struct gameport *port; 69 69 int error; 70 70 71 - gp = kzalloc(sizeof(struct fm801_gp), GFP_KERNEL); 71 + gp = kzalloc(sizeof(*gp), GFP_KERNEL); 72 72 port = gameport_allocate_port(); 73 73 if (!gp || !port) { 74 74 printk(KERN_ERR "fm801-gp: Memory allocation failed\n");
+1 -1
drivers/input/gameport/gameport.c
··· 372 372 } 373 373 } 374 374 375 - event = kmalloc(sizeof(struct gameport_event), GFP_ATOMIC); 375 + event = kmalloc(sizeof(*event), GFP_ATOMIC); 376 376 if (!event) { 377 377 pr_err("Not enough memory to queue event %d\n", event_type); 378 378 retval = -ENOMEM;
+2 -2
drivers/input/gameport/ns558.c
··· 120 120 return -EBUSY; 121 121 } 122 122 123 - ns558 = kzalloc(sizeof(struct ns558), GFP_KERNEL); 123 + ns558 = kzalloc(sizeof(*ns558), GFP_KERNEL); 124 124 port = gameport_allocate_port(); 125 125 if (!ns558 || !port) { 126 126 printk(KERN_ERR "ns558: Memory allocation failed.\n"); ··· 192 192 if (!request_region(ioport, iolen, "ns558-pnp")) 193 193 return -EBUSY; 194 194 195 - ns558 = kzalloc(sizeof(struct ns558), GFP_KERNEL); 195 + ns558 = kzalloc(sizeof(*ns558), GFP_KERNEL); 196 196 port = gameport_allocate_port(); 197 197 if (!ns558 || !port) { 198 198 printk(KERN_ERR "ns558: Memory allocation failed\n");
+155 -73
drivers/input/input.c
··· 100 100 } 101 101 102 102 /* 103 - * Pass event first through all filters and then, if event has not been 104 - * filtered out, through all open handles. This function is called with 105 - * dev->event_lock held and interrupts disabled. 106 - */ 107 - static unsigned int input_to_handler(struct input_handle *handle, 108 - struct input_value *vals, unsigned int count) 109 - { 110 - struct input_handler *handler = handle->handler; 111 - struct input_value *end = vals; 112 - struct input_value *v; 113 - 114 - if (handler->filter) { 115 - for (v = vals; v != vals + count; v++) { 116 - if (handler->filter(handle, v->type, v->code, v->value)) 117 - continue; 118 - if (end != v) 119 - *end = *v; 120 - end++; 121 - } 122 - count = end - vals; 123 - } 124 - 125 - if (!count) 126 - return 0; 127 - 128 - if (handler->events) 129 - handler->events(handle, vals, count); 130 - else if (handler->event) 131 - for (v = vals; v != vals + count; v++) 132 - handler->event(handle, v->type, v->code, v->value); 133 - 134 - return count; 135 - } 136 - 137 - /* 138 103 * Pass values first through all filters and then, if event has not been 139 - * filtered out, through all open handles. This function is called with 140 - * dev->event_lock held and interrupts disabled. 104 + * filtered out, through all open handles. This order is achieved by placing 105 + * filters at the head of the list of handles attached to the device, and 106 + * placing regular handles at the tail of the list. 107 + * 108 + * This function is called with dev->event_lock held and interrupts disabled. 141 109 */ 142 110 static void input_pass_values(struct input_dev *dev, 143 111 struct input_value *vals, unsigned int count) ··· 115 147 116 148 lockdep_assert_held(&dev->event_lock); 117 149 118 - if (!count) 119 - return; 120 - 121 150 rcu_read_lock(); 122 151 123 152 handle = rcu_dereference(dev->grab); 124 153 if (handle) { 125 - count = input_to_handler(handle, vals, count); 154 + count = handle->handler->events(handle, vals, count); 126 155 } else { 127 156 list_for_each_entry_rcu(handle, &dev->h_list, d_node) 128 157 if (handle->open) { 129 - count = input_to_handler(handle, vals, count); 158 + count = handle->handler->events(handle, vals, 159 + count); 130 160 if (!count) 131 161 break; 132 162 } ··· 319 353 { 320 354 if ((disposition & INPUT_PASS_TO_DEVICE) && dev->event) 321 355 dev->event(dev, type, code, value); 322 - 323 - if (!dev->vals) 324 - return; 325 356 326 357 if (disposition & INPUT_PASS_TO_HANDLERS) { 327 358 struct input_value *v; ··· 1976 2013 struct input_dev *dev; 1977 2014 1978 2015 dev = kzalloc(sizeof(*dev), GFP_KERNEL); 1979 - if (dev) { 1980 - dev->dev.type = &input_dev_type; 1981 - dev->dev.class = &input_class; 1982 - device_initialize(&dev->dev); 1983 - mutex_init(&dev->mutex); 1984 - spin_lock_init(&dev->event_lock); 1985 - timer_setup(&dev->timer, NULL, 0); 1986 - INIT_LIST_HEAD(&dev->h_list); 1987 - INIT_LIST_HEAD(&dev->node); 2016 + if (!dev) 2017 + return NULL; 1988 2018 1989 - dev_set_name(&dev->dev, "input%lu", 1990 - (unsigned long)atomic_inc_return(&input_no)); 1991 - 1992 - __module_get(THIS_MODULE); 2019 + /* 2020 + * Start with space for SYN_REPORT + 7 EV_KEY/EV_MSC events + 2 spare, 2021 + * see input_estimate_events_per_packet(). We will tune the number 2022 + * when we register the device. 2023 + */ 2024 + dev->max_vals = 10; 2025 + dev->vals = kcalloc(dev->max_vals, sizeof(*dev->vals), GFP_KERNEL); 2026 + if (!dev->vals) { 2027 + kfree(dev); 2028 + return NULL; 1993 2029 } 2030 + 2031 + mutex_init(&dev->mutex); 2032 + spin_lock_init(&dev->event_lock); 2033 + timer_setup(&dev->timer, NULL, 0); 2034 + INIT_LIST_HEAD(&dev->h_list); 2035 + INIT_LIST_HEAD(&dev->node); 2036 + 2037 + dev->dev.type = &input_dev_type; 2038 + dev->dev.class = &input_class; 2039 + device_initialize(&dev->dev); 2040 + /* 2041 + * From this point on we can no longer simply "kfree(dev)", we need 2042 + * to use input_free_device() so that device core properly frees its 2043 + * resources associated with the input device. 2044 + */ 2045 + 2046 + dev_set_name(&dev->dev, "input%lu", 2047 + (unsigned long)atomic_inc_return(&input_no)); 2048 + 2049 + __module_get(THIS_MODULE); 1994 2050 1995 2051 return dev; 1996 2052 } ··· 2350 2368 } 2351 2369 EXPORT_SYMBOL_GPL(input_device_enabled); 2352 2370 2371 + static int input_device_tune_vals(struct input_dev *dev) 2372 + { 2373 + struct input_value *vals; 2374 + unsigned int packet_size; 2375 + unsigned int max_vals; 2376 + 2377 + packet_size = input_estimate_events_per_packet(dev); 2378 + if (dev->hint_events_per_packet < packet_size) 2379 + dev->hint_events_per_packet = packet_size; 2380 + 2381 + max_vals = dev->hint_events_per_packet + 2; 2382 + if (dev->max_vals >= max_vals) 2383 + return 0; 2384 + 2385 + vals = kcalloc(max_vals, sizeof(*vals), GFP_KERNEL); 2386 + if (!vals) 2387 + return -ENOMEM; 2388 + 2389 + spin_lock_irq(&dev->event_lock); 2390 + dev->max_vals = max_vals; 2391 + swap(dev->vals, vals); 2392 + spin_unlock_irq(&dev->event_lock); 2393 + 2394 + /* Because of swap() above, this frees the old vals memory */ 2395 + kfree(vals); 2396 + 2397 + return 0; 2398 + } 2399 + 2353 2400 /** 2354 2401 * input_register_device - register device with input core 2355 2402 * @dev: device to be registered ··· 2406 2395 { 2407 2396 struct input_devres *devres = NULL; 2408 2397 struct input_handler *handler; 2409 - unsigned int packet_size; 2410 2398 const char *path; 2411 2399 int error; 2412 2400 ··· 2433 2423 /* Make sure that bitmasks not mentioned in dev->evbit are clean. */ 2434 2424 input_cleanse_bitmasks(dev); 2435 2425 2436 - packet_size = input_estimate_events_per_packet(dev); 2437 - if (dev->hint_events_per_packet < packet_size) 2438 - dev->hint_events_per_packet = packet_size; 2439 - 2440 - dev->max_vals = dev->hint_events_per_packet + 2; 2441 - dev->vals = kcalloc(dev->max_vals, sizeof(*dev->vals), GFP_KERNEL); 2442 - if (!dev->vals) { 2443 - error = -ENOMEM; 2426 + error = input_device_tune_vals(dev); 2427 + if (error) 2444 2428 goto err_devres_free; 2445 - } 2446 2429 2447 2430 /* 2448 2431 * If delay and period are pre-set by the driver, then autorepeating ··· 2455 2452 2456 2453 error = device_add(&dev->dev); 2457 2454 if (error) 2458 - goto err_free_vals; 2455 + goto err_devres_free; 2459 2456 2460 2457 path = kobject_get_path(&dev->dev.kobj, GFP_KERNEL); 2461 2458 pr_info("%s as %s\n", ··· 2485 2482 2486 2483 err_device_del: 2487 2484 device_del(&dev->dev); 2488 - err_free_vals: 2489 - kfree(dev->vals); 2490 - dev->vals = NULL; 2491 2485 err_devres_free: 2492 2486 devres_free(devres); 2493 2487 return error; ··· 2517 2517 } 2518 2518 EXPORT_SYMBOL(input_unregister_device); 2519 2519 2520 + static int input_handler_check_methods(const struct input_handler *handler) 2521 + { 2522 + int count = 0; 2523 + 2524 + if (handler->filter) 2525 + count++; 2526 + if (handler->events) 2527 + count++; 2528 + if (handler->event) 2529 + count++; 2530 + 2531 + if (count > 1) { 2532 + pr_err("%s: only one event processing method can be defined (%s)\n", 2533 + __func__, handler->name); 2534 + return -EINVAL; 2535 + } 2536 + 2537 + return 0; 2538 + } 2539 + 2540 + /* 2541 + * An implementation of input_handler's events() method that simply 2542 + * invokes handler->event() method for each event one by one. 2543 + */ 2544 + static unsigned int input_handler_events_default(struct input_handle *handle, 2545 + struct input_value *vals, 2546 + unsigned int count) 2547 + { 2548 + struct input_handler *handler = handle->handler; 2549 + struct input_value *v; 2550 + 2551 + for (v = vals; v != vals + count; v++) 2552 + handler->event(handle, v->type, v->code, v->value); 2553 + 2554 + return count; 2555 + } 2556 + 2557 + /* 2558 + * An implementation of input_handler's events() method that invokes 2559 + * handler->filter() method for each event one by one and removes events 2560 + * that were filtered out from the "vals" array. 2561 + */ 2562 + static unsigned int input_handler_events_filter(struct input_handle *handle, 2563 + struct input_value *vals, 2564 + unsigned int count) 2565 + { 2566 + struct input_handler *handler = handle->handler; 2567 + struct input_value *end = vals; 2568 + struct input_value *v; 2569 + 2570 + for (v = vals; v != vals + count; v++) { 2571 + if (handler->filter(handle, v->type, v->code, v->value)) 2572 + continue; 2573 + if (end != v) 2574 + *end = *v; 2575 + end++; 2576 + } 2577 + 2578 + return end - vals; 2579 + } 2580 + 2581 + /* 2582 + * An implementation of input_handler's events() method that does nothing. 2583 + */ 2584 + static unsigned int input_handler_events_null(struct input_handle *handle, 2585 + struct input_value *vals, 2586 + unsigned int count) 2587 + { 2588 + return count; 2589 + } 2590 + 2520 2591 /** 2521 2592 * input_register_handler - register a new input handler 2522 2593 * @handler: handler to be registered ··· 2601 2530 struct input_dev *dev; 2602 2531 int error; 2603 2532 2604 - error = mutex_lock_interruptible(&input_mutex); 2533 + error = input_handler_check_methods(handler); 2605 2534 if (error) 2606 2535 return error; 2607 2536 2608 2537 INIT_LIST_HEAD(&handler->h_list); 2538 + 2539 + if (handler->filter) 2540 + handler->events = input_handler_events_filter; 2541 + else if (handler->event) 2542 + handler->events = input_handler_events_default; 2543 + else if (!handler->events) 2544 + handler->events = input_handler_events_null; 2545 + 2546 + error = mutex_lock_interruptible(&input_mutex); 2547 + if (error) 2548 + return error; 2609 2549 2610 2550 list_add_tail(&handler->node, &input_handler_list); 2611 2551
+1 -1
drivers/input/joystick/a3d.c
··· 249 249 int i; 250 250 int err; 251 251 252 - a3d = kzalloc(sizeof(struct a3d), GFP_KERNEL); 252 + a3d = kzalloc(sizeof(*a3d), GFP_KERNEL); 253 253 input_dev = input_allocate_device(); 254 254 if (!a3d || !input_dev) { 255 255 err = -ENOMEM;
+79 -51
drivers/input/joystick/adc-joystick.c
··· 15 15 16 16 struct adc_joystick_axis { 17 17 u32 code; 18 - s32 range[2]; 19 - s32 fuzz; 20 - s32 flat; 18 + bool inverted; 21 19 }; 22 20 23 21 struct adc_joystick { 24 22 struct input_dev *input; 25 23 struct iio_cb_buffer *buffer; 26 - struct adc_joystick_axis *axes; 27 24 struct iio_channel *chans; 28 - int num_chans; 29 - bool polled; 25 + unsigned int num_chans; 26 + struct adc_joystick_axis axes[] __counted_by(num_chans); 30 27 }; 28 + 29 + static int adc_joystick_invert(struct input_dev *dev, 30 + unsigned int axis, int val) 31 + { 32 + int min = input_abs_get_min(dev, axis); 33 + int max = input_abs_get_max(dev, axis); 34 + 35 + return (max + min) - val; 36 + } 31 37 32 38 static void adc_joystick_poll(struct input_dev *input) 33 39 { ··· 44 38 ret = iio_read_channel_raw(&joy->chans[i], &val); 45 39 if (ret < 0) 46 40 return; 41 + if (joy->axes[i].inverted) 42 + val = adc_joystick_invert(input, i, val); 47 43 input_report_abs(input, joy->axes[i].code, val); 48 44 } 49 45 input_sync(input); ··· 94 86 val = sign_extend32(val, msb); 95 87 else 96 88 val &= GENMASK(msb, 0); 89 + if (joy->axes[i].inverted) 90 + val = adc_joystick_invert(joy->input, i, val); 97 91 input_report_abs(joy->input, joy->axes[i].code, val); 98 92 } 99 93 ··· 131 121 132 122 static int adc_joystick_set_axes(struct device *dev, struct adc_joystick *joy) 133 123 { 134 - struct adc_joystick_axis *axes; 124 + struct adc_joystick_axis *axes = joy->axes; 135 125 struct fwnode_handle *child; 136 - int num_axes, error, i; 126 + s32 range[2], fuzz, flat; 127 + unsigned int num_axes; 128 + int error, i; 137 129 138 130 num_axes = device_get_child_node_count(dev); 139 131 if (!num_axes) { ··· 148 136 num_axes, joy->num_chans); 149 137 return -EINVAL; 150 138 } 151 - 152 - axes = devm_kmalloc_array(dev, num_axes, sizeof(*axes), GFP_KERNEL); 153 - if (!axes) 154 - return -ENOMEM; 155 139 156 140 device_for_each_child_node(dev, child) { 157 141 error = fwnode_property_read_u32(child, "reg", &i); ··· 170 162 } 171 163 172 164 error = fwnode_property_read_u32_array(child, "abs-range", 173 - axes[i].range, 2); 165 + range, 2); 174 166 if (error) { 175 167 dev_err(dev, "abs-range invalid or missing\n"); 176 168 goto err_fwnode_put; 177 169 } 178 170 179 - fwnode_property_read_u32(child, "abs-fuzz", &axes[i].fuzz); 180 - fwnode_property_read_u32(child, "abs-flat", &axes[i].flat); 171 + if (range[0] > range[1]) { 172 + dev_dbg(dev, "abs-axis %d inverted\n", i); 173 + axes[i].inverted = true; 174 + swap(range[0], range[1]); 175 + } 176 + 177 + fwnode_property_read_u32(child, "abs-fuzz", &fuzz); 178 + fwnode_property_read_u32(child, "abs-flat", &flat); 181 179 182 180 input_set_abs_params(joy->input, axes[i].code, 183 - axes[i].range[0], axes[i].range[1], 184 - axes[i].fuzz, axes[i].flat); 185 - input_set_capability(joy->input, EV_ABS, axes[i].code); 181 + range[0], range[1], fuzz, flat); 186 182 } 187 - 188 - joy->axes = axes; 189 183 190 184 return 0; 191 185 ··· 196 186 return error; 197 187 } 198 188 189 + 190 + static int adc_joystick_count_channels(struct device *dev, 191 + const struct iio_channel *chans, 192 + bool polled, 193 + unsigned int *num_chans) 194 + { 195 + int bits; 196 + int i; 197 + 198 + /* 199 + * Count how many channels we got. NULL terminated. 200 + * Do not check the storage size if using polling. 201 + */ 202 + for (i = 0; chans[i].indio_dev; i++) { 203 + if (polled) 204 + continue; 205 + bits = chans[i].channel->scan_type.storagebits; 206 + if (!bits || bits > 16) { 207 + dev_err(dev, "Unsupported channel storage size\n"); 208 + return -EINVAL; 209 + } 210 + if (bits != chans[0].channel->scan_type.storagebits) { 211 + dev_err(dev, "Channels must have equal storage size\n"); 212 + return -EINVAL; 213 + } 214 + } 215 + 216 + *num_chans = i; 217 + return 0; 218 + } 219 + 199 220 static int adc_joystick_probe(struct platform_device *pdev) 200 221 { 201 222 struct device *dev = &pdev->dev; 223 + struct iio_channel *chans; 202 224 struct adc_joystick *joy; 203 225 struct input_dev *input; 226 + unsigned int poll_interval = 0; 227 + unsigned int num_chans; 204 228 int error; 205 - int bits; 206 - int i; 207 - unsigned int poll_interval; 208 229 209 - joy = devm_kzalloc(dev, sizeof(*joy), GFP_KERNEL); 210 - if (!joy) 211 - return -ENOMEM; 212 - 213 - joy->chans = devm_iio_channel_get_all(dev); 214 - if (IS_ERR(joy->chans)) { 215 - error = PTR_ERR(joy->chans); 230 + chans = devm_iio_channel_get_all(dev); 231 + error = PTR_ERR_OR_ZERO(chans); 232 + if (error) { 216 233 if (error != -EPROBE_DEFER) 217 234 dev_err(dev, "Unable to get IIO channels"); 218 235 return error; ··· 253 216 } else if (poll_interval == 0) { 254 217 dev_err(dev, "Unable to get poll-interval\n"); 255 218 return -EINVAL; 256 - } else { 257 - joy->polled = true; 258 219 } 259 220 260 - /* 261 - * Count how many channels we got. NULL terminated. 262 - * Do not check the storage size if using polling. 263 - */ 264 - for (i = 0; joy->chans[i].indio_dev; i++) { 265 - if (joy->polled) 266 - continue; 267 - bits = joy->chans[i].channel->scan_type.storagebits; 268 - if (!bits || bits > 16) { 269 - dev_err(dev, "Unsupported channel storage size\n"); 270 - return -EINVAL; 271 - } 272 - if (bits != joy->chans[0].channel->scan_type.storagebits) { 273 - dev_err(dev, "Channels must have equal storage size\n"); 274 - return -EINVAL; 275 - } 276 - } 277 - joy->num_chans = i; 221 + error = adc_joystick_count_channels(dev, chans, poll_interval != 0, 222 + &num_chans); 223 + if (error) 224 + return error; 225 + 226 + joy = devm_kzalloc(dev, struct_size(joy, axes, num_chans), GFP_KERNEL); 227 + if (!joy) 228 + return -ENOMEM; 229 + 230 + joy->chans = chans; 231 + joy->num_chans = num_chans; 278 232 279 233 input = devm_input_allocate_device(dev); 280 234 if (!input) { ··· 281 253 if (error) 282 254 return error; 283 255 284 - if (joy->polled) { 256 + if (poll_interval != 0) { 285 257 input_setup_polling(input, adc_joystick_poll); 286 258 input_set_poll_interval(input, poll_interval); 287 259 } else {
+1 -1
drivers/input/joystick/adi.c
··· 456 456 int i; 457 457 int err; 458 458 459 - port = kzalloc(sizeof(struct adi_port), GFP_KERNEL); 459 + port = kzalloc(sizeof(*port), GFP_KERNEL); 460 460 if (!port) 461 461 return -ENOMEM; 462 462
+2 -1
drivers/input/joystick/analog.c
··· 582 582 int i; 583 583 int err; 584 584 585 - if (!(port = kzalloc(sizeof(struct analog_port), GFP_KERNEL))) 585 + port = kzalloc(sizeof(*port), GFP_KERNEL); 586 + if (!port) 586 587 return -ENOMEM; 587 588 588 589 err = analog_init_port(gameport, drv, port);
+1 -1
drivers/input/joystick/as5011.c
··· 237 237 return -ENODEV; 238 238 } 239 239 240 - as5011 = kmalloc(sizeof(struct as5011_device), GFP_KERNEL); 240 + as5011 = kmalloc(sizeof(*as5011), GFP_KERNEL); 241 241 input_dev = input_allocate_device(); 242 242 if (!as5011 || !input_dev) { 243 243 dev_err(&client->dev,
+1 -1
drivers/input/joystick/cobra.c
··· 141 141 int i, j; 142 142 int err; 143 143 144 - cobra = kzalloc(sizeof(struct cobra), GFP_KERNEL); 144 + cobra = kzalloc(sizeof(*cobra), GFP_KERNEL); 145 145 if (!cobra) 146 146 return -ENOMEM; 147 147
+1 -1
drivers/input/joystick/db9.c
··· 587 587 return; 588 588 } 589 589 590 - db9 = kzalloc(sizeof(struct db9), GFP_KERNEL); 590 + db9 = kzalloc(sizeof(*db9), GFP_KERNEL); 591 591 if (!db9) 592 592 goto err_unreg_pardev; 593 593
+1 -1
drivers/input/joystick/gamecon.c
··· 950 950 return; 951 951 } 952 952 953 - gc = kzalloc(sizeof(struct gc), GFP_KERNEL); 953 + gc = kzalloc(sizeof(*gc), GFP_KERNEL); 954 954 if (!gc) { 955 955 pr_err("Not enough memory\n"); 956 956 goto err_unreg_pardev;
+1 -1
drivers/input/joystick/gf2k.c
··· 222 222 unsigned char data[GF2K_LENGTH]; 223 223 int i, err; 224 224 225 - gf2k = kzalloc(sizeof(struct gf2k), GFP_KERNEL); 225 + gf2k = kzalloc(sizeof(*gf2k), GFP_KERNEL); 226 226 input_dev = input_allocate_device(); 227 227 if (!gf2k || !input_dev) { 228 228 err = -ENOMEM;
+2 -1
drivers/input/joystick/grip.c
··· 284 284 int i, j, t; 285 285 int err; 286 286 287 - if (!(grip = kzalloc(sizeof(struct grip), GFP_KERNEL))) 287 + grip = kzalloc(sizeof(*grip), GFP_KERNEL); 288 + if (!grip) 288 289 return -ENOMEM; 289 290 290 291 grip->gameport = gameport;
+2 -1
drivers/input/joystick/grip_mp.c
··· 632 632 struct grip_mp *grip; 633 633 int err; 634 634 635 - if (!(grip = kzalloc(sizeof(struct grip_mp), GFP_KERNEL))) 635 + grip = kzalloc(sizeof(*grip), GFP_KERNEL); 636 + if (!grip) 636 637 return -ENOMEM; 637 638 638 639 grip->gameport = gameport;
+1 -1
drivers/input/joystick/guillemot.c
··· 163 163 int i, t; 164 164 int err; 165 165 166 - guillemot = kzalloc(sizeof(struct guillemot), GFP_KERNEL); 166 + guillemot = kzalloc(sizeof(*guillemot), GFP_KERNEL); 167 167 input_dev = input_allocate_device(); 168 168 if (!guillemot || !input_dev) { 169 169 err = -ENOMEM;
+1 -1
drivers/input/joystick/interact.c
··· 192 192 int i, t; 193 193 int err; 194 194 195 - interact = kzalloc(sizeof(struct interact), GFP_KERNEL); 195 + interact = kzalloc(sizeof(*interact), GFP_KERNEL); 196 196 input_dev = input_allocate_device(); 197 197 if (!interact || !input_dev) { 198 198 err = -ENOMEM;
+1 -1
drivers/input/joystick/magellan.c
··· 132 132 int err = -ENOMEM; 133 133 int i; 134 134 135 - magellan = kzalloc(sizeof(struct magellan), GFP_KERNEL); 135 + magellan = kzalloc(sizeof(*magellan), GFP_KERNEL); 136 136 input_dev = input_allocate_device(); 137 137 if (!magellan || !input_dev) 138 138 goto fail1;
+1 -1
drivers/input/joystick/maplecontrol.c
··· 102 102 struct input_dev *idev; 103 103 unsigned long data = be32_to_cpu(mdev->devinfo.function_data[0]); 104 104 105 - pad = kzalloc(sizeof(struct dc_pad), GFP_KERNEL); 105 + pad = kzalloc(sizeof(*pad), GFP_KERNEL); 106 106 idev = input_allocate_device(); 107 107 if (!pad || !idev) { 108 108 error = -ENOMEM;
+1 -1
drivers/input/joystick/n64joy.c
··· 246 246 int err = 0; 247 247 u32 i, j, found = 0; 248 248 249 - priv = kzalloc(sizeof(struct n64joy_priv), GFP_KERNEL); 249 + priv = kzalloc(sizeof(*priv), GFP_KERNEL); 250 250 if (!priv) 251 251 return -ENOMEM; 252 252 mutex_init(&priv->n64joy_mutex);
+1 -1
drivers/input/joystick/sidewinder.c
··· 577 577 578 578 comment[0] = 0; 579 579 580 - sw = kzalloc(sizeof(struct sw), GFP_KERNEL); 580 + sw = kzalloc(sizeof(*sw), GFP_KERNEL); 581 581 buf = kmalloc(SW_LENGTH, GFP_KERNEL); 582 582 idbuf = kmalloc(SW_LENGTH, GFP_KERNEL); 583 583 if (!sw || !buf || !idbuf) {
+1 -1
drivers/input/joystick/spaceball.c
··· 199 199 if ((id = serio->id.id) > SPACEBALL_MAX_ID) 200 200 return -ENODEV; 201 201 202 - spaceball = kmalloc(sizeof(struct spaceball), GFP_KERNEL); 202 + spaceball = kmalloc(sizeof(*spaceball), GFP_KERNEL); 203 203 input_dev = input_allocate_device(); 204 204 if (!spaceball || !input_dev) 205 205 goto fail1;
+1 -1
drivers/input/joystick/spaceorb.c
··· 147 147 int err = -ENOMEM; 148 148 int i; 149 149 150 - spaceorb = kzalloc(sizeof(struct spaceorb), GFP_KERNEL); 150 + spaceorb = kzalloc(sizeof(*spaceorb), GFP_KERNEL); 151 151 input_dev = input_allocate_device(); 152 152 if (!spaceorb || !input_dev) 153 153 goto fail1;
+1 -1
drivers/input/joystick/stinger.c
··· 118 118 struct input_dev *input_dev; 119 119 int err = -ENOMEM; 120 120 121 - stinger = kmalloc(sizeof(struct stinger), GFP_KERNEL); 121 + stinger = kmalloc(sizeof(*stinger), GFP_KERNEL); 122 122 input_dev = input_allocate_device(); 123 123 if (!stinger || !input_dev) 124 124 goto fail1;
+2 -1
drivers/input/joystick/tmdc.c
··· 348 348 int i; 349 349 int err; 350 350 351 - if (!(tmdc = kzalloc(sizeof(struct tmdc), GFP_KERNEL))) 351 + tmdc = kzalloc(sizeof(*tmdc), GFP_KERNEL); 352 + if (!tmdc) 352 353 return -ENOMEM; 353 354 354 355 tmdc->gameport = gameport;
+1 -1
drivers/input/joystick/turbografx.c
··· 172 172 return; 173 173 } 174 174 175 - tgfx = kzalloc(sizeof(struct tgfx), GFP_KERNEL); 175 + tgfx = kzalloc(sizeof(*tgfx), GFP_KERNEL); 176 176 if (!tgfx) { 177 177 printk(KERN_ERR "turbografx.c: Not enough memory\n"); 178 178 goto err_unreg_pardev;
+1 -1
drivers/input/joystick/twidjoy.c
··· 171 171 int err = -ENOMEM; 172 172 int i; 173 173 174 - twidjoy = kzalloc(sizeof(struct twidjoy), GFP_KERNEL); 174 + twidjoy = kzalloc(sizeof(*twidjoy), GFP_KERNEL); 175 175 input_dev = input_allocate_device(); 176 176 if (!twidjoy || !input_dev) 177 177 goto fail1;
+1 -1
drivers/input/joystick/warrior.c
··· 124 124 struct input_dev *input_dev; 125 125 int err = -ENOMEM; 126 126 127 - warrior = kzalloc(sizeof(struct warrior), GFP_KERNEL); 127 + warrior = kzalloc(sizeof(*warrior), GFP_KERNEL); 128 128 input_dev = input_allocate_device(); 129 129 if (!warrior || !input_dev) 130 130 goto fail1;
+2 -2
drivers/input/joystick/xpad.c
··· 1687 1687 if (xpad->xtype != XTYPE_XBOX360 && xpad->xtype != XTYPE_XBOX360W) 1688 1688 return 0; 1689 1689 1690 - xpad->led = led = kzalloc(sizeof(struct xpad_led), GFP_KERNEL); 1690 + xpad->led = led = kzalloc(sizeof(*led), GFP_KERNEL); 1691 1691 if (!led) 1692 1692 return -ENOMEM; 1693 1693 ··· 2023 2023 break; 2024 2024 } 2025 2025 2026 - xpad = kzalloc(sizeof(struct usb_xpad), GFP_KERNEL); 2026 + xpad = kzalloc(sizeof(*xpad), GFP_KERNEL); 2027 2027 if (!xpad) 2028 2028 return -ENOMEM; 2029 2029
+1 -1
drivers/input/joystick/zhenhua.c
··· 131 131 struct input_dev *input_dev; 132 132 int err = -ENOMEM; 133 133 134 - zhenhua = kzalloc(sizeof(struct zhenhua), GFP_KERNEL); 134 + zhenhua = kzalloc(sizeof(*zhenhua), GFP_KERNEL); 135 135 input_dev = input_allocate_device(); 136 136 if (!zhenhua || !input_dev) 137 137 goto fail1;
+1 -1
drivers/input/keyboard/atkbd.c
··· 1279 1279 struct input_dev *dev; 1280 1280 int err = -ENOMEM; 1281 1281 1282 - atkbd = kzalloc(sizeof(struct atkbd), GFP_KERNEL); 1282 + atkbd = kzalloc(sizeof(*atkbd), GFP_KERNEL); 1283 1283 dev = input_allocate_device(); 1284 1284 if (!atkbd || !dev) 1285 1285 goto fail1;
+70 -55
drivers/input/keyboard/cap11xx.c
··· 86 86 struct device *dev; 87 87 struct input_dev *idev; 88 88 const struct cap11xx_hw_model *model; 89 - u8 id; 90 89 91 90 struct cap11xx_led *leds; 92 91 int num_leds; ··· 103 104 u8 product_id; 104 105 unsigned int num_channels; 105 106 unsigned int num_leds; 106 - bool no_gain; 107 - }; 108 - 109 - enum { 110 - CAP1106, 111 - CAP1126, 112 - CAP1188, 113 - CAP1203, 114 - CAP1206, 115 - CAP1293, 116 - CAP1298 117 - }; 118 - 119 - static const struct cap11xx_hw_model cap11xx_devices[] = { 120 - [CAP1106] = { .product_id = 0x55, .num_channels = 6, .num_leds = 0, .no_gain = false }, 121 - [CAP1126] = { .product_id = 0x53, .num_channels = 6, .num_leds = 2, .no_gain = false }, 122 - [CAP1188] = { .product_id = 0x50, .num_channels = 8, .num_leds = 8, .no_gain = false }, 123 - [CAP1203] = { .product_id = 0x6d, .num_channels = 3, .num_leds = 0, .no_gain = true }, 124 - [CAP1206] = { .product_id = 0x67, .num_channels = 6, .num_leds = 0, .no_gain = true }, 125 - [CAP1293] = { .product_id = 0x6f, .num_channels = 3, .num_leds = 0, .no_gain = false }, 126 - [CAP1298] = { .product_id = 0x71, .num_channels = 8, .num_leds = 0, .no_gain = false }, 107 + bool has_gain; 108 + bool has_irq_config; 109 + bool has_sensitivity_control; 110 + bool has_signal_guard; 127 111 }; 128 112 129 113 static const struct reg_default cap11xx_reg_defaults[] = { ··· 206 224 } 207 225 208 226 if (!of_property_read_u32(node, "microchip,sensor-gain", &u32_val)) { 209 - if (priv->model->no_gain) { 227 + if (!priv->model->has_gain) { 210 228 dev_warn(dev, 211 229 "This model doesn't support 'sensor-gain'\n"); 212 230 } else if (is_power_of_2(u32_val) && u32_val <= 8) { ··· 225 243 } 226 244 227 245 if (of_property_read_bool(node, "microchip,irq-active-high")) { 228 - if (priv->id == CAP1106 || 229 - priv->id == CAP1126 || 230 - priv->id == CAP1188) { 246 + if (priv->model->has_irq_config) { 231 247 error = regmap_update_bits(priv->regmap, 232 248 CAP11XX_REG_CONFIG2, 233 249 CAP11XX_REG_CONFIG2_ALT_POL, ··· 276 296 if (!of_property_read_u32_array(node, "microchip,calib-sensitivity", 277 297 priv->calib_sensitivities, 278 298 priv->model->num_channels)) { 279 - if (priv->id == CAP1293 || priv->id == CAP1298) { 299 + if (priv->model->has_sensitivity_control) { 280 300 for (i = 0; i < priv->model->num_channels; i++) { 281 301 if (!is_power_of_2(priv->calib_sensitivities[i]) || 282 302 priv->calib_sensitivities[i] > 4) { ··· 291 311 if (error) 292 312 return error; 293 313 294 - if (priv->id == CAP1298) { 314 + if (priv->model->num_channels > 4) { 295 315 error = cap11xx_write_calib_sens_config_2(priv); 296 316 if (error) 297 317 return error; ··· 313 333 } 314 334 315 335 if (priv->signal_guard_inputs_mask) { 316 - if (priv->id == CAP1293 || priv->id == CAP1298) { 336 + if (priv->model->has_signal_guard) { 317 337 error = regmap_write(priv->regmap, 318 338 CAP11XX_REG_SIGNAL_GUARD_ENABLE, 319 339 priv->signal_guard_inputs_mask); ··· 488 508 489 509 static int cap11xx_i2c_probe(struct i2c_client *i2c_client) 490 510 { 491 - const struct i2c_device_id *id = i2c_client_get_device_id(i2c_client); 511 + const struct i2c_device_id *id; 512 + const struct cap11xx_hw_model *cap; 492 513 struct device *dev = &i2c_client->dev; 493 514 struct cap11xx_priv *priv; 494 - const struct cap11xx_hw_model *cap; 495 515 int i, error; 496 516 unsigned int val, rev; 497 517 498 - if (id->driver_data >= ARRAY_SIZE(cap11xx_devices)) { 499 - dev_err(dev, "Invalid device ID %lu\n", id->driver_data); 500 - return -EINVAL; 501 - } 502 - 503 - cap = &cap11xx_devices[id->driver_data]; 504 - if (!cap || !cap->num_channels) { 518 + id = i2c_client_get_device_id(i2c_client); 519 + cap = i2c_get_match_data(i2c_client); 520 + if (!id || !cap || !cap->num_channels) { 505 521 dev_err(dev, "Invalid device configuration\n"); 506 522 return -EINVAL; 507 523 } ··· 542 566 id->name, rev); 543 567 544 568 priv->model = cap; 545 - priv->id = id->driver_data; 546 569 547 570 dev_info(dev, "CAP11XX device detected, model %s, revision 0x%02x\n", 548 571 id->name, rev); ··· 602 627 return 0; 603 628 } 604 629 630 + static const struct cap11xx_hw_model cap1106_model = { 631 + .product_id = 0x55, .num_channels = 6, .num_leds = 0, 632 + .has_gain = true, 633 + .has_irq_config = true, 634 + }; 635 + 636 + static const struct cap11xx_hw_model cap1126_model = { 637 + .product_id = 0x53, .num_channels = 6, .num_leds = 2, 638 + .has_gain = true, 639 + .has_irq_config = true, 640 + }; 641 + 642 + static const struct cap11xx_hw_model cap1188_model = { 643 + .product_id = 0x50, .num_channels = 8, .num_leds = 8, 644 + .has_gain = true, 645 + .has_irq_config = true, 646 + }; 647 + 648 + static const struct cap11xx_hw_model cap1203_model = { 649 + .product_id = 0x6d, .num_channels = 3, .num_leds = 0, 650 + }; 651 + 652 + static const struct cap11xx_hw_model cap1206_model = { 653 + .product_id = 0x67, .num_channels = 6, .num_leds = 0, 654 + }; 655 + 656 + static const struct cap11xx_hw_model cap1293_model = { 657 + .product_id = 0x6f, .num_channels = 3, .num_leds = 0, 658 + .has_gain = true, 659 + .has_sensitivity_control = true, 660 + .has_signal_guard = true, 661 + }; 662 + 663 + static const struct cap11xx_hw_model cap1298_model = { 664 + .product_id = 0x71, .num_channels = 8, .num_leds = 0, 665 + .has_gain = true, 666 + .has_sensitivity_control = true, 667 + .has_signal_guard = true, 668 + }; 669 + 605 670 static const struct of_device_id cap11xx_dt_ids[] = { 606 - { .compatible = "microchip,cap1106", }, 607 - { .compatible = "microchip,cap1126", }, 608 - { .compatible = "microchip,cap1188", }, 609 - { .compatible = "microchip,cap1203", }, 610 - { .compatible = "microchip,cap1206", }, 611 - { .compatible = "microchip,cap1293", }, 612 - { .compatible = "microchip,cap1298", }, 613 - {} 671 + { .compatible = "microchip,cap1106", .data = &cap1106_model }, 672 + { .compatible = "microchip,cap1126", .data = &cap1126_model }, 673 + { .compatible = "microchip,cap1188", .data = &cap1188_model }, 674 + { .compatible = "microchip,cap1203", .data = &cap1203_model }, 675 + { .compatible = "microchip,cap1206", .data = &cap1206_model }, 676 + { .compatible = "microchip,cap1293", .data = &cap1293_model }, 677 + { .compatible = "microchip,cap1298", .data = &cap1298_model }, 678 + { } 614 679 }; 615 680 MODULE_DEVICE_TABLE(of, cap11xx_dt_ids); 616 681 617 682 static const struct i2c_device_id cap11xx_i2c_ids[] = { 618 - { "cap1106", CAP1106 }, 619 - { "cap1126", CAP1126 }, 620 - { "cap1188", CAP1188 }, 621 - { "cap1203", CAP1203 }, 622 - { "cap1206", CAP1206 }, 623 - { "cap1293", CAP1293 }, 624 - { "cap1298", CAP1298 }, 625 - {} 683 + { "cap1106", (kernel_ulong_t)&cap1106_model }, 684 + { "cap1126", (kernel_ulong_t)&cap1126_model }, 685 + { "cap1188", (kernel_ulong_t)&cap1188_model }, 686 + { "cap1203", (kernel_ulong_t)&cap1203_model }, 687 + { "cap1206", (kernel_ulong_t)&cap1206_model }, 688 + { "cap1293", (kernel_ulong_t)&cap1293_model }, 689 + { "cap1298", (kernel_ulong_t)&cap1298_model }, 690 + { } 626 691 }; 627 692 MODULE_DEVICE_TABLE(i2c, cap11xx_i2c_ids); 628 693
+1 -1
drivers/input/keyboard/lkkbd.c
··· 608 608 int i; 609 609 int err; 610 610 611 - lk = kzalloc(sizeof(struct lkkbd), GFP_KERNEL); 611 + lk = kzalloc(sizeof(*lk), GFP_KERNEL); 612 612 input_dev = input_allocate_device(); 613 613 if (!lk || !input_dev) { 614 614 err = -ENOMEM;
+1 -1
drivers/input/keyboard/locomokbd.c
··· 227 227 struct input_dev *input_dev; 228 228 int i, err; 229 229 230 - locomokbd = kzalloc(sizeof(struct locomokbd), GFP_KERNEL); 230 + locomokbd = kzalloc(sizeof(*locomokbd), GFP_KERNEL); 231 231 input_dev = input_allocate_device(); 232 232 if (!locomokbd || !input_dev) { 233 233 err = -ENOMEM;
+1 -1
drivers/input/keyboard/maple_keyb.c
··· 154 154 mdev = to_maple_dev(dev); 155 155 mdrv = to_maple_driver(dev->driver); 156 156 157 - kbd = kzalloc(sizeof(struct dc_kbd), GFP_KERNEL); 157 + kbd = kzalloc(sizeof(*kbd), GFP_KERNEL); 158 158 if (!kbd) { 159 159 error = -ENOMEM; 160 160 goto fail;
+1 -1
drivers/input/keyboard/newtonkbd.c
··· 68 68 int err = -ENOMEM; 69 69 int i; 70 70 71 - nkbd = kzalloc(sizeof(struct nkbd), GFP_KERNEL); 71 + nkbd = kzalloc(sizeof(*nkbd), GFP_KERNEL); 72 72 input_dev = input_allocate_device(); 73 73 if (!nkbd || !input_dev) 74 74 goto fail1;
+11 -10
drivers/input/keyboard/omap-keypad.c
··· 171 171 172 172 static DEVICE_ATTR(enable, S_IRUGO | S_IWUSR, omap_kp_enable_show, omap_kp_enable_store); 173 173 174 + static struct attribute *omap_kp_attrs[] = { 175 + &dev_attr_enable.attr, 176 + NULL 177 + }; 178 + ATTRIBUTE_GROUPS(omap_kp); 179 + 174 180 static int omap_kp_probe(struct platform_device *pdev) 175 181 { 176 182 struct omap_kp *omap_kp; ··· 220 214 kp_tasklet.data = (unsigned long) omap_kp; 221 215 tasklet_enable(&kp_tasklet); 222 216 223 - ret = device_create_file(&pdev->dev, &dev_attr_enable); 224 - if (ret < 0) 225 - goto err2; 226 - 227 217 /* setup input device */ 228 218 input_dev->name = "omap-keypad"; 229 219 input_dev->phys = "omap-keypad/input0"; ··· 237 235 pdata->rows, pdata->cols, 238 236 omap_kp->keymap, input_dev); 239 237 if (ret < 0) 240 - goto err3; 238 + goto err2; 241 239 242 240 ret = input_register_device(omap_kp->input); 243 241 if (ret < 0) { 244 242 printk(KERN_ERR "Unable to register omap-keypad input device\n"); 245 - goto err3; 243 + goto err2; 246 244 } 247 245 248 246 if (pdata->dbounce) ··· 254 252 if (omap_kp->irq >= 0) { 255 253 if (request_irq(omap_kp->irq, omap_kp_interrupt, 0, 256 254 "omap-keypad", omap_kp) < 0) 257 - goto err4; 255 + goto err3; 258 256 } 259 257 omap_writew(0, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBD_MASKIT); 260 258 261 259 return 0; 262 260 263 - err4: 261 + err3: 264 262 input_unregister_device(omap_kp->input); 265 263 input_dev = NULL; 266 - err3: 267 - device_remove_file(&pdev->dev, &dev_attr_enable); 268 264 err2: 269 265 kfree(omap_kp); 270 266 input_free_device(input_dev); ··· 293 293 .remove_new = omap_kp_remove, 294 294 .driver = { 295 295 .name = "omap-keypad", 296 + .dev_groups = omap_kp_groups, 296 297 }, 297 298 }; 298 299 module_platform_driver(omap_kp_driver);
+7 -2
drivers/input/keyboard/qt1050.c
··· 208 208 .n_yes_ranges = ARRAY_SIZE(qt1050_writeable_ranges), 209 209 }; 210 210 211 - static struct regmap_config qt1050_regmap_config = { 211 + static const struct regmap_config qt1050_regmap_config = { 212 212 .reg_bits = 8, 213 213 .val_bits = 8, 214 214 .max_register = QT1050_RES_CAL, ··· 226 226 int err; 227 227 228 228 /* Read Chip ID */ 229 - regmap_read(ts->regmap, QT1050_CHIP_ID, &val); 229 + err = regmap_read(ts->regmap, QT1050_CHIP_ID, &val); 230 + if (err) { 231 + dev_err(&ts->client->dev, "Failed to read chip ID: %d\n", err); 232 + return false; 233 + } 234 + 230 235 if (val != QT1050_CHIP_ID_VER) { 231 236 dev_err(&ts->client->dev, "ID %d not supported\n", val); 232 237 return false;
+1 -1
drivers/input/keyboard/stowaway.c
··· 72 72 int err = -ENOMEM; 73 73 int i; 74 74 75 - skbd = kzalloc(sizeof(struct skbd), GFP_KERNEL); 75 + skbd = kzalloc(sizeof(*skbd), GFP_KERNEL); 76 76 input_dev = input_allocate_device(); 77 77 if (!skbd || !input_dev) 78 78 goto fail1;
+1 -1
drivers/input/keyboard/sunkbd.c
··· 263 263 int err = -ENOMEM; 264 264 int i; 265 265 266 - sunkbd = kzalloc(sizeof(struct sunkbd), GFP_KERNEL); 266 + sunkbd = kzalloc(sizeof(*sunkbd), GFP_KERNEL); 267 267 input_dev = input_allocate_device(); 268 268 if (!sunkbd || !input_dev) 269 269 goto fail1;
+1 -1
drivers/input/keyboard/xtkbd.c
··· 70 70 int err = -ENOMEM; 71 71 int i; 72 72 73 - xtkbd = kmalloc(sizeof(struct xtkbd), GFP_KERNEL); 73 + xtkbd = kmalloc(sizeof(*xtkbd), GFP_KERNEL); 74 74 input_dev = input_allocate_device(); 75 75 if (!xtkbd || !input_dev) 76 76 goto fail1;
+1
drivers/input/matrix-keymap.c
··· 199 199 } 200 200 EXPORT_SYMBOL(matrix_keypad_build_keymap); 201 201 202 + MODULE_DESCRIPTION("Helpers for matrix keyboard bindings"); 202 203 MODULE_LICENSE("GPL");
+1 -1
drivers/input/misc/88pm80x_onkey.c
··· 57 57 struct pm80x_onkey_info *info; 58 58 int err; 59 59 60 - info = kzalloc(sizeof(struct pm80x_onkey_info), GFP_KERNEL); 60 + info = kzalloc(sizeof(*info), GFP_KERNEL); 61 61 if (!info) 62 62 return -ENOMEM; 63 63
+1 -8
drivers/input/misc/adxl34x-i2c.c
··· 98 98 return 0; 99 99 } 100 100 101 - static void adxl34x_i2c_remove(struct i2c_client *client) 102 - { 103 - struct adxl34x *ac = i2c_get_clientdata(client); 104 - 105 - adxl34x_remove(ac); 106 - } 107 - 108 101 static const struct i2c_device_id adxl34x_id[] = { 109 102 { "adxl34x" }, 110 103 { } ··· 125 132 static struct i2c_driver adxl34x_driver = { 126 133 .driver = { 127 134 .name = "adxl34x", 135 + .dev_groups = adxl34x_groups, 128 136 .pm = pm_sleep_ptr(&adxl34x_pm), 129 137 .of_match_table = adxl34x_of_id, 130 138 }, 131 139 .probe = adxl34x_i2c_probe, 132 - .remove = adxl34x_i2c_remove, 133 140 .id_table = adxl34x_id, 134 141 }; 135 142
+1 -8
drivers/input/misc/adxl34x-spi.c
··· 87 87 return 0; 88 88 } 89 89 90 - static void adxl34x_spi_remove(struct spi_device *spi) 91 - { 92 - struct adxl34x *ac = spi_get_drvdata(spi); 93 - 94 - adxl34x_remove(ac); 95 - } 96 - 97 90 static struct spi_driver adxl34x_driver = { 98 91 .driver = { 99 92 .name = "adxl34x", 93 + .dev_groups = adxl34x_groups, 100 94 .pm = pm_sleep_ptr(&adxl34x_pm), 101 95 }, 102 96 .probe = adxl34x_spi_probe, 103 - .remove = adxl34x_spi_remove, 104 97 }; 105 98 106 99 module_spi_driver(adxl34x_driver);
+56 -103
drivers/input/misc/adxl34x.c
··· 241 241 242 242 ac->bops->read_block(ac->dev, DATAX0, DATAZ1 - DATAX0 + 1, buf); 243 243 244 - mutex_lock(&ac->mutex); 244 + guard(mutex)(&ac->mutex); 245 + 245 246 ac->saved.x = (s16) le16_to_cpu(buf[0]); 246 247 axis->x = ac->saved.x; 247 248 ··· 251 250 252 251 ac->saved.z = (s16) le16_to_cpu(buf[2]); 253 252 axis->z = ac->saved.z; 254 - mutex_unlock(&ac->mutex); 255 253 } 256 254 257 255 static void adxl34x_service_ev_fifo(struct adxl34x *ac) ··· 416 416 { 417 417 struct adxl34x *ac = dev_get_drvdata(dev); 418 418 419 - mutex_lock(&ac->mutex); 419 + guard(mutex)(&ac->mutex); 420 420 421 421 if (!ac->suspended && !ac->disabled && ac->opened) 422 422 __adxl34x_disable(ac); 423 423 424 424 ac->suspended = true; 425 - 426 - mutex_unlock(&ac->mutex); 427 425 428 426 return 0; 429 427 } ··· 430 432 { 431 433 struct adxl34x *ac = dev_get_drvdata(dev); 432 434 433 - mutex_lock(&ac->mutex); 435 + guard(mutex)(&ac->mutex); 434 436 435 437 if (ac->suspended && !ac->disabled && ac->opened) 436 438 __adxl34x_enable(ac); 437 439 438 440 ac->suspended = false; 439 - 440 - mutex_unlock(&ac->mutex); 441 441 442 442 return 0; 443 443 } ··· 460 464 if (error) 461 465 return error; 462 466 463 - mutex_lock(&ac->mutex); 467 + guard(mutex)(&ac->mutex); 464 468 465 469 if (!ac->suspended && ac->opened) { 466 470 if (val) { ··· 474 478 475 479 ac->disabled = !!val; 476 480 477 - mutex_unlock(&ac->mutex); 478 - 479 481 return count; 480 482 } 481 483 ··· 483 489 struct device_attribute *attr, char *buf) 484 490 { 485 491 struct adxl34x *ac = dev_get_drvdata(dev); 486 - ssize_t count; 487 492 488 - mutex_lock(&ac->mutex); 489 - count = sprintf(buf, "%d,%d,%d\n", 490 - ac->hwcal.x * 4 + ac->swcal.x, 491 - ac->hwcal.y * 4 + ac->swcal.y, 492 - ac->hwcal.z * 4 + ac->swcal.z); 493 - mutex_unlock(&ac->mutex); 493 + guard(mutex)(&ac->mutex); 494 494 495 - return count; 495 + return sprintf(buf, "%d,%d,%d\n", 496 + ac->hwcal.x * 4 + ac->swcal.x, 497 + ac->hwcal.y * 4 + ac->swcal.y, 498 + ac->hwcal.z * 4 + ac->swcal.z); 496 499 } 497 500 498 501 static ssize_t adxl34x_calibrate_store(struct device *dev, ··· 503 512 * We use HW calibration and handle the remaining bits in SW. (4mg/LSB) 504 513 */ 505 514 506 - mutex_lock(&ac->mutex); 515 + guard(mutex)(&ac->mutex); 516 + 507 517 ac->hwcal.x -= (ac->saved.x / 4); 508 518 ac->swcal.x = ac->saved.x % 4; 509 519 ··· 517 525 AC_WRITE(ac, OFSX, (s8) ac->hwcal.x); 518 526 AC_WRITE(ac, OFSY, (s8) ac->hwcal.y); 519 527 AC_WRITE(ac, OFSZ, (s8) ac->hwcal.z); 520 - mutex_unlock(&ac->mutex); 521 528 522 529 return count; 523 530 } ··· 544 553 if (error) 545 554 return error; 546 555 547 - mutex_lock(&ac->mutex); 556 + guard(mutex)(&ac->mutex); 548 557 549 558 ac->pdata.data_rate = RATE(val); 550 559 AC_WRITE(ac, BW_RATE, 551 560 ac->pdata.data_rate | 552 561 (ac->pdata.low_power_mode ? LOW_POWER : 0)); 553 - 554 - mutex_unlock(&ac->mutex); 555 562 556 563 return count; 557 564 } ··· 577 588 if (error) 578 589 return error; 579 590 580 - mutex_lock(&ac->mutex); 591 + guard(mutex)(&ac->mutex); 581 592 582 593 if (val) 583 594 ac->pdata.power_mode |= (PCTL_AUTO_SLEEP | PCTL_LINK); ··· 586 597 587 598 if (!ac->disabled && !ac->suspended && ac->opened) 588 599 AC_WRITE(ac, POWER_CTL, ac->pdata.power_mode | PCTL_MEASURE); 589 - 590 - mutex_unlock(&ac->mutex); 591 600 592 601 return count; 593 602 } ··· 597 610 struct device_attribute *attr, char *buf) 598 611 { 599 612 struct adxl34x *ac = dev_get_drvdata(dev); 600 - ssize_t count; 601 613 602 - mutex_lock(&ac->mutex); 603 - count = sprintf(buf, "(%d, %d, %d)\n", 604 - ac->saved.x, ac->saved.y, ac->saved.z); 605 - mutex_unlock(&ac->mutex); 614 + guard(mutex)(&ac->mutex); 606 615 607 - return count; 616 + return sprintf(buf, "(%d, %d, %d)\n", 617 + ac->saved.x, ac->saved.y, ac->saved.z); 608 618 } 609 619 610 620 static DEVICE_ATTR(position, S_IRUGO, adxl34x_position_show, NULL); ··· 622 638 if (error) 623 639 return error; 624 640 625 - mutex_lock(&ac->mutex); 641 + guard(mutex)(&ac->mutex); 626 642 AC_WRITE(ac, val >> 8, val & 0xFF); 627 - mutex_unlock(&ac->mutex); 628 643 629 644 return count; 630 645 } ··· 647 664 .attrs = adxl34x_attributes, 648 665 }; 649 666 667 + const struct attribute_group *adxl34x_groups[] = { 668 + &adxl34x_attr_group, 669 + NULL 670 + }; 671 + EXPORT_SYMBOL_GPL(adxl34x_groups); 672 + 650 673 static int adxl34x_input_open(struct input_dev *input) 651 674 { 652 675 struct adxl34x *ac = input_get_drvdata(input); 653 676 654 - mutex_lock(&ac->mutex); 677 + guard(mutex)(&ac->mutex); 655 678 656 679 if (!ac->suspended && !ac->disabled) 657 680 __adxl34x_enable(ac); 658 681 659 682 ac->opened = true; 660 - 661 - mutex_unlock(&ac->mutex); 662 683 663 684 return 0; 664 685 } ··· 671 684 { 672 685 struct adxl34x *ac = input_get_drvdata(input); 673 686 674 - mutex_lock(&ac->mutex); 687 + guard(mutex)(&ac->mutex); 675 688 676 689 if (!ac->suspended && !ac->disabled) 677 690 __adxl34x_disable(ac); 678 691 679 692 ac->opened = false; 680 - 681 - mutex_unlock(&ac->mutex); 682 693 } 683 694 684 695 struct adxl34x *adxl34x_probe(struct device *dev, int irq, ··· 686 701 struct adxl34x *ac; 687 702 struct input_dev *input_dev; 688 703 const struct adxl34x_platform_data *pdata; 689 - int err, range, i; 704 + int error, range, i; 690 705 int revid; 691 706 692 707 if (!irq) { 693 708 dev_err(dev, "no IRQ?\n"); 694 - err = -ENODEV; 695 - goto err_out; 709 + return ERR_PTR(-ENODEV); 696 710 } 697 711 698 - ac = kzalloc(sizeof(*ac), GFP_KERNEL); 699 - input_dev = input_allocate_device(); 700 - if (!ac || !input_dev) { 701 - err = -ENOMEM; 702 - goto err_free_mem; 703 - } 712 + ac = devm_kzalloc(dev, sizeof(*ac), GFP_KERNEL); 713 + if (!ac) 714 + return ERR_PTR(-ENOMEM); 715 + 716 + input_dev = devm_input_allocate_device(dev); 717 + if (!input_dev) 718 + return ERR_PTR(-ENOMEM); 704 719 705 720 ac->fifo_delay = fifo_delay_default; 706 721 ··· 733 748 break; 734 749 default: 735 750 dev_err(dev, "Failed to probe %s\n", input_dev->name); 736 - err = -ENODEV; 737 - goto err_free_mem; 751 + return ERR_PTR(-ENODEV); 738 752 } 739 753 740 754 snprintf(ac->phys, sizeof(ac->phys), "%s/input0", dev_name(dev)); 741 755 742 756 input_dev->phys = ac->phys; 743 - input_dev->dev.parent = dev; 744 757 input_dev->id.product = ac->model; 745 758 input_dev->id.bustype = bops->bustype; 746 759 input_dev->open = adxl34x_input_open; ··· 746 763 747 764 input_set_drvdata(input_dev, ac); 748 765 749 - __set_bit(ac->pdata.ev_type, input_dev->evbit); 750 - 751 766 if (ac->pdata.ev_type == EV_REL) { 752 - __set_bit(REL_X, input_dev->relbit); 753 - __set_bit(REL_Y, input_dev->relbit); 754 - __set_bit(REL_Z, input_dev->relbit); 767 + input_set_capability(input_dev, EV_REL, REL_X); 768 + input_set_capability(input_dev, EV_REL, REL_Y); 769 + input_set_capability(input_dev, EV_REL, REL_Z); 755 770 } else { 756 771 /* EV_ABS */ 757 - __set_bit(ABS_X, input_dev->absbit); 758 - __set_bit(ABS_Y, input_dev->absbit); 759 - __set_bit(ABS_Z, input_dev->absbit); 760 - 761 772 if (pdata->data_range & FULL_RES) 762 773 range = ADXL_FULLRES_MAX_VAL; /* Signed 13-bit */ 763 774 else ··· 762 785 input_set_abs_params(input_dev, ABS_Z, -range, range, 3, 3); 763 786 } 764 787 765 - __set_bit(EV_KEY, input_dev->evbit); 766 - __set_bit(pdata->ev_code_tap[ADXL_X_AXIS], input_dev->keybit); 767 - __set_bit(pdata->ev_code_tap[ADXL_Y_AXIS], input_dev->keybit); 768 - __set_bit(pdata->ev_code_tap[ADXL_Z_AXIS], input_dev->keybit); 788 + input_set_capability(input_dev, EV_KEY, pdata->ev_code_tap[ADXL_X_AXIS]); 789 + input_set_capability(input_dev, EV_KEY, pdata->ev_code_tap[ADXL_Y_AXIS]); 790 + input_set_capability(input_dev, EV_KEY, pdata->ev_code_tap[ADXL_Z_AXIS]); 769 791 770 792 if (pdata->ev_code_ff) { 771 793 ac->int_mask = FREE_FALL; 772 - __set_bit(pdata->ev_code_ff, input_dev->keybit); 794 + input_set_capability(input_dev, EV_KEY, pdata->ev_code_ff); 773 795 } 774 796 775 797 if (pdata->ev_code_act_inactivity) 776 - __set_bit(pdata->ev_code_act_inactivity, input_dev->keybit); 798 + input_set_capability(input_dev, EV_KEY, 799 + pdata->ev_code_act_inactivity); 777 800 778 801 ac->int_mask |= ACTIVITY | INACTIVITY; 779 802 ··· 793 816 794 817 AC_WRITE(ac, POWER_CTL, 0); 795 818 796 - err = request_threaded_irq(ac->irq, NULL, adxl34x_irq, 797 - IRQF_ONESHOT, dev_name(dev), ac); 798 - if (err) { 819 + error = devm_request_threaded_irq(dev, ac->irq, NULL, adxl34x_irq, 820 + IRQF_ONESHOT, dev_name(dev), ac); 821 + if (error) { 799 822 dev_err(dev, "irq %d busy?\n", ac->irq); 800 - goto err_free_mem; 823 + return ERR_PTR(error); 801 824 } 802 825 803 - err = sysfs_create_group(&dev->kobj, &adxl34x_attr_group); 804 - if (err) 805 - goto err_free_irq; 806 - 807 - err = input_register_device(input_dev); 808 - if (err) 809 - goto err_remove_attr; 826 + error = input_register_device(input_dev); 827 + if (error) 828 + return ERR_PTR(error); 810 829 811 830 AC_WRITE(ac, OFSX, pdata->x_axis_offset); 812 831 ac->hwcal.x = pdata->x_axis_offset; ··· 845 872 846 873 if (pdata->orientation_enable & ADXL_EN_ORIENTATION_3D) 847 874 for (i = 0; i < ARRAY_SIZE(pdata->ev_codes_orient_3d); i++) 848 - __set_bit(pdata->ev_codes_orient_3d[i], 849 - input_dev->keybit); 875 + input_set_capability(input_dev, EV_KEY, 876 + pdata->ev_codes_orient_3d[i]); 850 877 851 878 if (pdata->orientation_enable & ADXL_EN_ORIENTATION_2D) 852 879 for (i = 0; i < ARRAY_SIZE(pdata->ev_codes_orient_2d); i++) 853 - __set_bit(pdata->ev_codes_orient_2d[i], 854 - input_dev->keybit); 880 + input_set_capability(input_dev, EV_KEY, 881 + pdata->ev_codes_orient_2d[i]); 855 882 } else { 856 883 ac->pdata.orientation_enable = 0; 857 884 } ··· 861 888 ac->pdata.power_mode &= (PCTL_AUTO_SLEEP | PCTL_LINK); 862 889 863 890 return ac; 864 - 865 - err_remove_attr: 866 - sysfs_remove_group(&dev->kobj, &adxl34x_attr_group); 867 - err_free_irq: 868 - free_irq(ac->irq, ac); 869 - err_free_mem: 870 - input_free_device(input_dev); 871 - kfree(ac); 872 - err_out: 873 - return ERR_PTR(err); 874 891 } 875 892 EXPORT_SYMBOL_GPL(adxl34x_probe); 876 - 877 - void adxl34x_remove(struct adxl34x *ac) 878 - { 879 - sysfs_remove_group(&ac->dev->kobj, &adxl34x_attr_group); 880 - free_irq(ac->irq, ac); 881 - input_unregister_device(ac->input); 882 - dev_dbg(ac->dev, "unregistered accelerometer\n"); 883 - kfree(ac); 884 - } 885 - EXPORT_SYMBOL_GPL(adxl34x_remove); 886 893 887 894 EXPORT_GPL_SIMPLE_DEV_PM_OPS(adxl34x_pm, adxl34x_suspend, adxl34x_resume); 888 895
+1 -1
drivers/input/misc/adxl34x.h
··· 23 23 struct adxl34x *adxl34x_probe(struct device *dev, int irq, 24 24 bool fifo_delay_default, 25 25 const struct adxl34x_bus_ops *bops); 26 - void adxl34x_remove(struct adxl34x *ac); 27 26 28 27 extern const struct dev_pm_ops adxl34x_pm; 28 + extern const struct attribute_group *adxl34x_groups[]; 29 29 30 30 #endif
+17 -33
drivers/input/misc/ati_remote2.c
··· 204 204 unsigned int mode_mask; 205 205 }; 206 206 207 - static int ati_remote2_probe(struct usb_interface *interface, const struct usb_device_id *id); 208 - static void ati_remote2_disconnect(struct usb_interface *interface); 209 - static int ati_remote2_suspend(struct usb_interface *interface, pm_message_t message); 210 - static int ati_remote2_resume(struct usb_interface *interface); 211 - static int ati_remote2_reset_resume(struct usb_interface *interface); 212 - static int ati_remote2_pre_reset(struct usb_interface *interface); 213 - static int ati_remote2_post_reset(struct usb_interface *interface); 214 - 215 - static struct usb_driver ati_remote2_driver = { 216 - .name = "ati_remote2", 217 - .probe = ati_remote2_probe, 218 - .disconnect = ati_remote2_disconnect, 219 - .id_table = ati_remote2_id_table, 220 - .suspend = ati_remote2_suspend, 221 - .resume = ati_remote2_resume, 222 - .reset_resume = ati_remote2_reset_resume, 223 - .pre_reset = ati_remote2_pre_reset, 224 - .post_reset = ati_remote2_post_reset, 225 - .supports_autosuspend = 1, 226 - }; 207 + static struct usb_driver ati_remote2_driver; 227 208 228 209 static int ati_remote2_submit_urbs(struct ati_remote2 *ar2) 229 210 { ··· 772 791 &dev_attr_mode_mask.attr, 773 792 NULL, 774 793 }; 775 - 776 - static struct attribute_group ati_remote2_attr_group = { 777 - .attrs = ati_remote2_attrs, 778 - }; 794 + ATTRIBUTE_GROUPS(ati_remote2); 779 795 780 796 static int ati_remote2_probe(struct usb_interface *interface, const struct usb_device_id *id) 781 797 { ··· 839 861 840 862 strlcat(ar2->name, "ATI Remote Wonder II", sizeof(ar2->name)); 841 863 842 - r = sysfs_create_group(&udev->dev.kobj, &ati_remote2_attr_group); 843 - if (r) 844 - goto fail3; 845 - 846 864 r = ati_remote2_input_init(ar2); 847 865 if (r) 848 - goto fail4; 866 + goto fail3; 849 867 850 868 usb_set_intfdata(interface, ar2); 851 869 ··· 849 875 850 876 return 0; 851 877 852 - fail4: 853 - sysfs_remove_group(&udev->dev.kobj, &ati_remote2_attr_group); 854 878 fail3: 855 879 ati_remote2_urb_cleanup(ar2); 856 880 fail2: ··· 871 899 usb_set_intfdata(interface, NULL); 872 900 873 901 input_unregister_device(ar2->idev); 874 - 875 - sysfs_remove_group(&ar2->udev->dev.kobj, &ati_remote2_attr_group); 876 902 877 903 ati_remote2_urb_cleanup(ar2); 878 904 ··· 1001 1031 1002 1032 return r; 1003 1033 } 1034 + 1035 + static struct usb_driver ati_remote2_driver = { 1036 + .name = "ati_remote2", 1037 + .probe = ati_remote2_probe, 1038 + .disconnect = ati_remote2_disconnect, 1039 + .dev_groups = ati_remote2_groups, 1040 + .id_table = ati_remote2_id_table, 1041 + .suspend = ati_remote2_suspend, 1042 + .resume = ati_remote2_resume, 1043 + .reset_resume = ati_remote2_reset_resume, 1044 + .pre_reset = ati_remote2_pre_reset, 1045 + .post_reset = ati_remote2_post_reset, 1046 + .supports_autosuspend = 1, 1047 + }; 1004 1048 1005 1049 module_usb_driver(ati_remote2_driver);
+1 -1
drivers/input/misc/cma3000_d0x.c
··· 292 292 goto err_out; 293 293 } 294 294 295 - data = kzalloc(sizeof(struct cma3000_accl_data), GFP_KERNEL); 295 + data = kzalloc(sizeof(*data), GFP_KERNEL); 296 296 input_dev = input_allocate_device(); 297 297 if (!data || !input_dev) { 298 298 error = -ENOMEM;
+95 -104
drivers/input/misc/ims-pcu.c
··· 207 207 208 208 input = input_allocate_device(); 209 209 if (!input) { 210 - dev_err(pcu->dev, 211 - "Not enough memory for input input device\n"); 210 + dev_err(pcu->dev, "Not enough memory for input device\n"); 212 211 return -ENOMEM; 213 212 } 214 213 ··· 286 287 struct input_dev *input; 287 288 int error; 288 289 289 - gamepad = kzalloc(sizeof(struct ims_pcu_gamepad), GFP_KERNEL); 290 + gamepad = kzalloc(sizeof(*gamepad), GFP_KERNEL); 290 291 input = input_allocate_device(); 291 292 if (!gamepad || !input) { 292 293 dev_err(pcu->dev, ··· 760 761 struct ims_pcu_flash_fmt { 761 762 __le32 addr; 762 763 u8 len; 763 - u8 data[]; 764 + u8 data[] __counted_by(len); 764 765 }; 765 766 766 767 static unsigned int ims_pcu_count_fw_records(const struct firmware *fw) ··· 927 928 goto out; 928 929 } 929 930 930 - mutex_lock(&pcu->cmd_mutex); 931 - ims_pcu_handle_firmware_update(pcu, fw); 932 - mutex_unlock(&pcu->cmd_mutex); 931 + scoped_guard(mutex, &pcu->cmd_mutex) 932 + ims_pcu_handle_firmware_update(pcu, fw); 933 933 934 934 release_firmware(fw); 935 935 ··· 952 954 __le16 br_val = cpu_to_le16(value); 953 955 int error; 954 956 955 - mutex_lock(&pcu->cmd_mutex); 957 + guard(mutex)(&pcu->cmd_mutex); 956 958 957 959 error = ims_pcu_execute_command(pcu, SET_BRIGHTNESS, 958 960 &br_val, sizeof(br_val)); ··· 960 962 dev_warn(pcu->dev, 961 963 "Failed to set desired brightness %u, error: %d\n", 962 964 value, error); 963 - 964 - mutex_unlock(&pcu->cmd_mutex); 965 965 966 966 return error; 967 967 } ··· 974 978 int brightness; 975 979 int error; 976 980 977 - mutex_lock(&pcu->cmd_mutex); 981 + guard(mutex)(&pcu->cmd_mutex); 978 982 979 983 error = ims_pcu_execute_query(pcu, GET_BRIGHTNESS); 980 984 if (error) { ··· 987 991 brightness = 988 992 get_unaligned_le16(&pcu->cmd_buf[IMS_PCU_DATA_OFFSET]); 989 993 } 990 - 991 - mutex_unlock(&pcu->cmd_mutex); 992 994 993 995 return brightness; 994 996 } ··· 1067 1073 if (data_len > attr->field_length) 1068 1074 return -EINVAL; 1069 1075 1070 - error = mutex_lock_interruptible(&pcu->cmd_mutex); 1071 - if (error) 1072 - return error; 1076 + scoped_cond_guard(mutex, return -EINTR, &pcu->cmd_mutex) { 1077 + memset(field, 0, attr->field_length); 1078 + memcpy(field, buf, data_len); 1073 1079 1074 - memset(field, 0, attr->field_length); 1075 - memcpy(field, buf, data_len); 1080 + error = ims_pcu_set_info(pcu); 1076 1081 1077 - error = ims_pcu_set_info(pcu); 1082 + /* 1083 + * Even if update failed, let's fetch the info again as we just 1084 + * clobbered one of the fields. 1085 + */ 1086 + ims_pcu_get_info(pcu); 1078 1087 1079 - /* 1080 - * Even if update failed, let's fetch the info again as we just 1081 - * clobbered one of the fields. 1082 - */ 1083 - ims_pcu_get_info(pcu); 1088 + if (error) 1089 + return error; 1090 + } 1084 1091 1085 - mutex_unlock(&pcu->cmd_mutex); 1086 - 1087 - return error < 0 ? error : count; 1092 + return count; 1088 1093 } 1089 1094 1090 1095 #define IMS_PCU_ATTR(_field, _mode) \ ··· 1146 1153 { 1147 1154 struct usb_interface *intf = to_usb_interface(dev); 1148 1155 struct ims_pcu *pcu = usb_get_intfdata(intf); 1149 - const struct firmware *fw = NULL; 1150 1156 int value; 1151 1157 int error; 1152 1158 ··· 1156 1164 if (value != 1) 1157 1165 return -EINVAL; 1158 1166 1159 - error = mutex_lock_interruptible(&pcu->cmd_mutex); 1160 - if (error) 1161 - return error; 1162 - 1167 + const struct firmware *fw __free(firmware) = NULL; 1163 1168 error = request_ihex_firmware(&fw, IMS_PCU_FIRMWARE_NAME, pcu->dev); 1164 1169 if (error) { 1165 1170 dev_err(pcu->dev, "Failed to request firmware %s, error: %d\n", 1166 1171 IMS_PCU_FIRMWARE_NAME, error); 1167 - goto out; 1172 + return error; 1168 1173 } 1169 1174 1170 - /* 1171 - * If we are already in bootloader mode we can proceed with 1172 - * flashing the firmware. 1173 - * 1174 - * If we are in application mode, then we need to switch into 1175 - * bootloader mode, which will cause the device to disconnect 1176 - * and reconnect as different device. 1177 - */ 1178 - if (pcu->bootloader_mode) 1179 - error = ims_pcu_handle_firmware_update(pcu, fw); 1180 - else 1181 - error = ims_pcu_switch_to_bootloader(pcu); 1175 + scoped_cond_guard(mutex_intr, return -EINTR, &pcu->cmd_mutex) { 1176 + /* 1177 + * If we are already in bootloader mode we can proceed with 1178 + * flashing the firmware. 1179 + * 1180 + * If we are in application mode, then we need to switch into 1181 + * bootloader mode, which will cause the device to disconnect 1182 + * and reconnect as different device. 1183 + */ 1184 + if (pcu->bootloader_mode) 1185 + error = ims_pcu_handle_firmware_update(pcu, fw); 1186 + else 1187 + error = ims_pcu_switch_to_bootloader(pcu); 1182 1188 1183 - release_firmware(fw); 1189 + if (error) 1190 + return error; 1191 + } 1184 1192 1185 - out: 1186 - mutex_unlock(&pcu->cmd_mutex); 1187 - return error ?: count; 1193 + return count; 1188 1194 } 1189 1195 1190 1196 static DEVICE_ATTR(update_firmware, S_IWUSR, ··· 1292 1302 int error; 1293 1303 u8 data; 1294 1304 1295 - mutex_lock(&pcu->cmd_mutex); 1296 - error = ims_pcu_read_ofn_config(pcu, pcu->ofn_reg_addr, &data); 1297 - mutex_unlock(&pcu->cmd_mutex); 1298 - 1299 - if (error) 1300 - return error; 1305 + scoped_guard(mutex, &pcu->cmd_mutex) { 1306 + error = ims_pcu_read_ofn_config(pcu, pcu->ofn_reg_addr, &data); 1307 + if (error) 1308 + return error; 1309 + } 1301 1310 1302 1311 return sysfs_emit(buf, "%x\n", data); 1303 1312 } ··· 1314 1325 if (error) 1315 1326 return error; 1316 1327 1317 - mutex_lock(&pcu->cmd_mutex); 1318 - error = ims_pcu_write_ofn_config(pcu, pcu->ofn_reg_addr, value); 1319 - mutex_unlock(&pcu->cmd_mutex); 1328 + guard(mutex)(&pcu->cmd_mutex); 1320 1329 1321 - return error ?: count; 1330 + error = ims_pcu_write_ofn_config(pcu, pcu->ofn_reg_addr, value); 1331 + if (error) 1332 + return error; 1333 + 1334 + return count; 1322 1335 } 1323 1336 1324 1337 static DEVICE_ATTR(reg_data, S_IRUGO | S_IWUSR, ··· 1332 1341 { 1333 1342 struct usb_interface *intf = to_usb_interface(dev); 1334 1343 struct ims_pcu *pcu = usb_get_intfdata(intf); 1335 - int error; 1336 1344 1337 - mutex_lock(&pcu->cmd_mutex); 1338 - error = sysfs_emit(buf, "%x\n", pcu->ofn_reg_addr); 1339 - mutex_unlock(&pcu->cmd_mutex); 1345 + guard(mutex)(&pcu->cmd_mutex); 1340 1346 1341 - return error; 1347 + return sysfs_emit(buf, "%x\n", pcu->ofn_reg_addr); 1342 1348 } 1343 1349 1344 1350 static ssize_t ims_pcu_ofn_reg_addr_store(struct device *dev, ··· 1351 1363 if (error) 1352 1364 return error; 1353 1365 1354 - mutex_lock(&pcu->cmd_mutex); 1366 + guard(mutex)(&pcu->cmd_mutex); 1367 + 1355 1368 pcu->ofn_reg_addr = value; 1356 - mutex_unlock(&pcu->cmd_mutex); 1357 1369 1358 1370 return count; 1359 1371 } ··· 1378 1390 int error; 1379 1391 u8 data; 1380 1392 1381 - mutex_lock(&pcu->cmd_mutex); 1382 - error = ims_pcu_read_ofn_config(pcu, attr->addr, &data); 1383 - mutex_unlock(&pcu->cmd_mutex); 1384 - 1385 - if (error) 1386 - return error; 1393 + scoped_guard(mutex, &pcu->cmd_mutex) { 1394 + error = ims_pcu_read_ofn_config(pcu, attr->addr, &data); 1395 + if (error) 1396 + return error; 1397 + } 1387 1398 1388 1399 return sysfs_emit(buf, "%d\n", !!(data & (1 << attr->nr))); 1389 1400 } ··· 1406 1419 if (value > 1) 1407 1420 return -EINVAL; 1408 1421 1409 - mutex_lock(&pcu->cmd_mutex); 1422 + scoped_guard(mutex, &pcu->cmd_mutex) { 1423 + error = ims_pcu_read_ofn_config(pcu, attr->addr, &data); 1424 + if (error) 1425 + return error; 1410 1426 1411 - error = ims_pcu_read_ofn_config(pcu, attr->addr, &data); 1412 - if (!error) { 1413 1427 if (value) 1414 1428 data |= 1U << attr->nr; 1415 1429 else 1416 1430 data &= ~(1U << attr->nr); 1417 1431 1418 1432 error = ims_pcu_write_ofn_config(pcu, attr->addr, data); 1433 + if (error) 1434 + return error; 1419 1435 } 1420 1436 1421 - mutex_unlock(&pcu->cmd_mutex); 1422 - 1423 - return error ?: count; 1437 + return count; 1424 1438 } 1425 1439 1426 1440 #define IMS_PCU_OFN_BIT_ATTR(_field, _addr, _nr) \ ··· 1454 1466 NULL 1455 1467 }; 1456 1468 1469 + static umode_t ims_pcu_ofn_is_attr_visible(struct kobject *kobj, 1470 + struct attribute *attr, int n) 1471 + { 1472 + struct device *dev = kobj_to_dev(kobj); 1473 + struct usb_interface *intf = to_usb_interface(dev); 1474 + struct ims_pcu *pcu = usb_get_intfdata(intf); 1475 + umode_t mode = attr->mode; 1476 + 1477 + /* 1478 + * PCU-B devices, both GEN_1 and GEN_2 do not have OFN sensor. 1479 + */ 1480 + if (pcu->bootloader_mode || pcu->device_id == IMS_PCU_PCU_B_DEVICE_ID) 1481 + mode = 0; 1482 + 1483 + return mode; 1484 + } 1485 + 1457 1486 static const struct attribute_group ims_pcu_ofn_attr_group = { 1458 - .name = "ofn", 1459 - .attrs = ims_pcu_ofn_attrs, 1487 + .name = "ofn", 1488 + .is_visible = ims_pcu_ofn_is_attr_visible, 1489 + .attrs = ims_pcu_ofn_attrs, 1460 1490 }; 1461 1491 1462 1492 static void ims_pcu_irq(struct urb *urb) ··· 1896 1890 /* Device appears to be operable, complete initialization */ 1897 1891 pcu->device_no = atomic_inc_return(&device_no); 1898 1892 1899 - /* 1900 - * PCU-B devices, both GEN_1 and GEN_2 do not have OFN sensor 1901 - */ 1902 - if (pcu->device_id != IMS_PCU_PCU_B_DEVICE_ID) { 1903 - error = sysfs_create_group(&pcu->dev->kobj, 1904 - &ims_pcu_ofn_attr_group); 1905 - if (error) 1906 - return error; 1907 - } 1908 - 1909 1893 error = ims_pcu_setup_backlight(pcu); 1910 1894 if (error) 1911 1895 return error; ··· 1932 1936 ims_pcu_destroy_gamepad(pcu); 1933 1937 ims_pcu_destroy_buttons(pcu); 1934 1938 ims_pcu_destroy_backlight(pcu); 1935 - 1936 - if (pcu->device_id != IMS_PCU_PCU_B_DEVICE_ID) 1937 - sysfs_remove_group(&pcu->dev->kobj, 1938 - &ims_pcu_ofn_attr_group); 1939 1939 } 1940 1940 } 1941 1941 ··· 1985 1993 struct ims_pcu *pcu; 1986 1994 int error; 1987 1995 1988 - pcu = kzalloc(sizeof(struct ims_pcu), GFP_KERNEL); 1996 + pcu = kzalloc(sizeof(*pcu), GFP_KERNEL); 1989 1997 if (!pcu) 1990 1998 return -ENOMEM; 1991 1999 ··· 2023 2031 if (error) 2024 2032 goto err_stop_io; 2025 2033 2026 - error = sysfs_create_group(&intf->dev.kobj, &ims_pcu_attr_group); 2027 - if (error) 2028 - goto err_stop_io; 2029 - 2030 2034 error = pcu->bootloader_mode ? 2031 2035 ims_pcu_init_bootloader_mode(pcu) : 2032 2036 ims_pcu_init_application_mode(pcu); 2033 2037 if (error) 2034 - goto err_remove_sysfs; 2038 + goto err_stop_io; 2035 2039 2036 2040 return 0; 2037 2041 2038 - err_remove_sysfs: 2039 - sysfs_remove_group(&intf->dev.kobj, &ims_pcu_attr_group); 2040 2042 err_stop_io: 2041 2043 ims_pcu_stop_io(pcu); 2042 2044 err_free_buffers: ··· 2055 2069 */ 2056 2070 if (alt->desc.bInterfaceClass != USB_CLASS_COMM) 2057 2071 return; 2058 - 2059 - sysfs_remove_group(&intf->dev.kobj, &ims_pcu_attr_group); 2060 2072 2061 2073 ims_pcu_stop_io(pcu); 2062 2074 ··· 2114 2130 { } 2115 2131 }; 2116 2132 2133 + static const struct attribute_group *ims_pcu_sysfs_groups[] = { 2134 + &ims_pcu_attr_group, 2135 + &ims_pcu_ofn_attr_group, 2136 + NULL 2137 + }; 2138 + 2117 2139 static struct usb_driver ims_pcu_driver = { 2118 2140 .name = "ims_pcu", 2119 2141 .id_table = ims_pcu_id_table, 2142 + .dev_groups = ims_pcu_sysfs_groups, 2120 2143 .probe = ims_pcu_probe, 2121 2144 .disconnect = ims_pcu_disconnect, 2122 2145 #ifdef CONFIG_PM
+1 -1
drivers/input/misc/max8997_haptic.c
··· 249 249 return -EINVAL; 250 250 } 251 251 252 - chip = kzalloc(sizeof(struct max8997_haptic), GFP_KERNEL); 252 + chip = kzalloc(sizeof(*chip), GFP_KERNEL); 253 253 input_dev = input_allocate_device(); 254 254 if (!chip || !input_dev) { 255 255 dev_err(&pdev->dev, "unable to allocate memory\n");
+1 -1
drivers/input/misc/pcap_keys.c
··· 49 49 struct pcap_keys *pcap_keys; 50 50 struct input_dev *input_dev; 51 51 52 - pcap_keys = kmalloc(sizeof(struct pcap_keys), GFP_KERNEL); 52 + pcap_keys = kmalloc(sizeof(*pcap_keys), GFP_KERNEL); 53 53 if (!pcap_keys) 54 54 return err; 55 55
+1 -1
drivers/input/misc/powermate.c
··· 320 320 0, interface->desc.bInterfaceNumber, NULL, 0, 321 321 USB_CTRL_SET_TIMEOUT); 322 322 323 - pm = kzalloc(sizeof(struct powermate_device), GFP_KERNEL); 323 + pm = kzalloc(sizeof(*pm), GFP_KERNEL); 324 324 input_dev = input_allocate_device(); 325 325 if (!pm || !input_dev) 326 326 goto fail1;
+1
drivers/input/misc/sgi_btns.c
··· 128 128 }; 129 129 module_platform_driver(sgi_buttons_driver); 130 130 131 + MODULE_DESCRIPTION("SGI Indy/O2 volume button interface driver"); 131 132 MODULE_LICENSE("GPL");
+1
drivers/input/misc/soc_button_array.c
··· 620 620 }; 621 621 module_platform_driver(soc_button_driver); 622 622 623 + MODULE_DESCRIPTION("Windows-compatible SoC Button Array driver"); 623 624 MODULE_LICENSE("GPL");
+2 -2
drivers/input/misc/twl4030-pwrbutton.c
··· 1 - /** 2 - * twl4030-pwrbutton.c - TWL4030 Power Button Input Driver 1 + /* 2 + * TWL4030 Power Button Input Driver 3 3 * 4 4 * Copyright (C) 2008-2009 Nokia Corporation 5 5 *
+1 -1
drivers/input/misc/uinput.c
··· 379 379 { 380 380 struct uinput_device *newdev; 381 381 382 - newdev = kzalloc(sizeof(struct uinput_device), GFP_KERNEL); 382 + newdev = kzalloc(sizeof(*newdev), GFP_KERNEL); 383 383 if (!newdev) 384 384 return -ENOMEM; 385 385
+24 -61
drivers/input/misc/yealink.c
··· 36 36 #include <linux/kernel.h> 37 37 #include <linux/slab.h> 38 38 #include <linux/module.h> 39 - #include <linux/rwsem.h> 39 + #include <linux/mutex.h> 40 40 #include <linux/usb/input.h> 41 41 #include <linux/map_to_7segment.h> 42 42 ··· 102 102 103 103 u8 lcdMap[ARRAY_SIZE(lcdMap)]; /* state of LCD, LED ... */ 104 104 int key_code; /* last reported key */ 105 + 106 + struct mutex sysfs_mutex; 105 107 106 108 unsigned int shutdown:1; 107 109 ··· 550 548 * sysfs interface 551 549 ******************************************************************************/ 552 550 553 - static DECLARE_RWSEM(sysfs_rwsema); 554 - 555 551 /* Interface to the 7-segments translation table aka. char set. 556 552 */ 557 553 static ssize_t show_map(struct device *dev, struct device_attribute *attr, ··· 580 580 */ 581 581 static ssize_t show_line(struct device *dev, char *buf, int a, int b) 582 582 { 583 - struct yealink_dev *yld; 583 + struct yealink_dev *yld = dev_get_drvdata(dev); 584 584 int i; 585 585 586 - down_read(&sysfs_rwsema); 587 - yld = dev_get_drvdata(dev); 588 - if (yld == NULL) { 589 - up_read(&sysfs_rwsema); 590 - return -ENODEV; 591 - } 586 + guard(mutex)(&yld->sysfs_mutex); 592 587 593 588 for (i = a; i < b; i++) 594 589 *buf++ = lcdMap[i].type; ··· 593 598 *buf++ = '\n'; 594 599 *buf = 0; 595 600 596 - up_read(&sysfs_rwsema); 597 601 return 3 + ((b - a) << 1); 598 602 } 599 603 ··· 624 630 static ssize_t store_line(struct device *dev, const char *buf, size_t count, 625 631 int el, size_t len) 626 632 { 627 - struct yealink_dev *yld; 633 + struct yealink_dev *yld = dev_get_drvdata(dev); 628 634 int i; 629 635 630 - down_write(&sysfs_rwsema); 631 - yld = dev_get_drvdata(dev); 632 - if (yld == NULL) { 633 - up_write(&sysfs_rwsema); 634 - return -ENODEV; 635 - } 636 + guard(mutex)(&yld->sysfs_mutex); 636 637 637 638 if (len > count) 638 639 len = count; 639 640 for (i = 0; i < len; i++) 640 641 setChar(yld, el++, buf[i]); 641 642 642 - up_write(&sysfs_rwsema); 643 643 return count; 644 644 } 645 645 ··· 663 675 static ssize_t get_icons(struct device *dev, struct device_attribute *attr, 664 676 char *buf) 665 677 { 666 - struct yealink_dev *yld; 678 + struct yealink_dev *yld = dev_get_drvdata(dev); 667 679 int i, ret = 1; 668 680 669 - down_read(&sysfs_rwsema); 670 - yld = dev_get_drvdata(dev); 671 - if (yld == NULL) { 672 - up_read(&sysfs_rwsema); 673 - return -ENODEV; 674 - } 681 + guard(mutex)(&yld->sysfs_mutex); 675 682 676 683 for (i = 0; i < ARRAY_SIZE(lcdMap); i++) { 677 684 if (lcdMap[i].type != '.') ··· 675 692 yld->lcdMap[i] == ' ' ? " " : "on", 676 693 lcdMap[i].u.p.name); 677 694 } 678 - up_read(&sysfs_rwsema); 695 + 679 696 return ret; 680 697 } 681 698 ··· 683 700 static ssize_t set_icon(struct device *dev, const char *buf, size_t count, 684 701 int chr) 685 702 { 686 - struct yealink_dev *yld; 703 + struct yealink_dev *yld = dev_get_drvdata(dev); 687 704 int i; 688 705 689 - down_write(&sysfs_rwsema); 690 - yld = dev_get_drvdata(dev); 691 - if (yld == NULL) { 692 - up_write(&sysfs_rwsema); 693 - return -ENODEV; 694 - } 706 + guard(mutex)(&yld->sysfs_mutex); 695 707 696 708 for (i = 0; i < ARRAY_SIZE(lcdMap); i++) { 697 709 if (lcdMap[i].type != '.') ··· 697 719 } 698 720 } 699 721 700 - up_write(&sysfs_rwsema); 701 722 return count; 702 723 } 703 724 ··· 716 739 */ 717 740 718 741 /* Stores raw ringtone data in the phone */ 719 - static ssize_t store_ringtone(struct device *dev, 720 - struct device_attribute *attr, 721 - const char *buf, size_t count) 742 + static ssize_t store_ringtone(struct device *dev, struct device_attribute *attr, 743 + const char *buf, size_t count) 722 744 { 723 - struct yealink_dev *yld; 745 + struct yealink_dev *yld = dev_get_drvdata(dev); 724 746 725 - down_write(&sysfs_rwsema); 726 - yld = dev_get_drvdata(dev); 727 - if (yld == NULL) { 728 - up_write(&sysfs_rwsema); 729 - return -ENODEV; 730 - } 747 + guard(mutex)(&yld->sysfs_mutex); 731 748 732 749 /* TODO locking with async usb control interface??? */ 733 750 yealink_set_ringtone(yld, (char *)buf, count); 734 - up_write(&sysfs_rwsema); 751 + 735 752 return count; 736 753 } 737 754 ··· 742 771 static DEVICE_ATTR(hide_icon , _M220, NULL , hide_icon ); 743 772 static DEVICE_ATTR(ringtone , _M220, NULL , store_ringtone); 744 773 745 - static struct attribute *yld_attributes[] = { 774 + static struct attribute *yld_attrs[] = { 746 775 &dev_attr_line1.attr, 747 776 &dev_attr_line2.attr, 748 777 &dev_attr_line3.attr, ··· 753 782 &dev_attr_ringtone.attr, 754 783 NULL 755 784 }; 756 - 757 - static const struct attribute_group yld_attr_group = { 758 - .attrs = yld_attributes 759 - }; 785 + ATTRIBUTE_GROUPS(yld); 760 786 761 787 /******************************************************************************* 762 788 * Linux interface and usb initialisation ··· 806 838 807 839 static void usb_disconnect(struct usb_interface *intf) 808 840 { 809 - struct yealink_dev *yld; 810 - 811 - down_write(&sysfs_rwsema); 812 - yld = usb_get_intfdata(intf); 813 - sysfs_remove_group(&intf->dev.kobj, &yld_attr_group); 814 - usb_set_intfdata(intf, NULL); 815 - up_write(&sysfs_rwsema); 841 + struct yealink_dev *yld = usb_get_intfdata(intf); 816 842 817 843 usb_cleanup(yld, 0); 844 + usb_set_intfdata(intf, NULL); 818 845 } 819 846 820 847 static int usb_probe(struct usb_interface *intf, const struct usb_device_id *id) ··· 831 868 if (!usb_endpoint_is_int_in(endpoint)) 832 869 return -ENODEV; 833 870 834 - yld = kzalloc(sizeof(struct yealink_dev), GFP_KERNEL); 871 + yld = kzalloc(sizeof(*yld), GFP_KERNEL); 835 872 if (!yld) 836 873 return -ENOMEM; 837 874 838 875 yld->udev = udev; 839 876 yld->intf = intf; 877 + mutex_init(&yld->sysfs_mutex); 840 878 841 879 yld->idev = input_dev = input_allocate_device(); 842 880 if (!input_dev) ··· 939 975 store_line3(&intf->dev, NULL, 940 976 DRIVER_VERSION, sizeof(DRIVER_VERSION)); 941 977 942 - /* Register sysfs hooks (don't care about failure) */ 943 - ret = sysfs_create_group(&intf->dev.kobj, &yld_attr_group); 944 978 return 0; 945 979 } 946 980 ··· 947 985 .probe = usb_probe, 948 986 .disconnect = usb_disconnect, 949 987 .id_table = usb_table, 988 + .dev_groups = yld_groups, 950 989 }; 951 990 952 991 module_usb_driver(yealink_driver);
+1 -1
drivers/input/mouse/alps.c
··· 3201 3201 */ 3202 3202 psmouse_reset(psmouse); 3203 3203 3204 - priv = kzalloc(sizeof(struct alps_data), GFP_KERNEL); 3204 + priv = kzalloc(sizeof(*priv), GFP_KERNEL); 3205 3205 if (!priv) 3206 3206 return -ENOMEM; 3207 3207
+1 -1
drivers/input/mouse/appletouch.c
··· 855 855 } 856 856 857 857 /* allocate memory for our device state and initialize it */ 858 - dev = kzalloc(sizeof(struct atp), GFP_KERNEL); 858 + dev = kzalloc(sizeof(*dev), GFP_KERNEL); 859 859 input_dev = input_allocate_device(); 860 860 if (!dev || !input_dev) { 861 861 dev_err(&iface->dev, "Out of memory\n");
+1 -1
drivers/input/mouse/bcm5974.c
··· 904 904 cfg = bcm5974_get_config(udev); 905 905 906 906 /* allocate memory for our device state and initialize it */ 907 - dev = kzalloc(sizeof(struct bcm5974), GFP_KERNEL); 907 + dev = kzalloc(sizeof(*dev), GFP_KERNEL); 908 908 input_dev = input_allocate_device(); 909 909 if (!dev || !input_dev) { 910 910 dev_err(&iface->dev, "out of memory\n");
+90 -90
drivers/input/mouse/cypress_ps2.c
··· 32 32 cytp->pkt_size = n; 33 33 } 34 34 35 - static const unsigned char cytp_rate[] = {10, 20, 40, 60, 100, 200}; 36 - static const unsigned char cytp_resolution[] = {0x00, 0x01, 0x02, 0x03}; 35 + static const u8 cytp_rate[] = {10, 20, 40, 60, 100, 200}; 36 + static const u8 cytp_resolution[] = {0x00, 0x01, 0x02, 0x03}; 37 37 38 - static int cypress_ps2_sendbyte(struct psmouse *psmouse, int value) 38 + static int cypress_ps2_sendbyte(struct psmouse *psmouse, u8 cmd) 39 39 { 40 40 struct ps2dev *ps2dev = &psmouse->ps2dev; 41 + int error; 41 42 42 - if (ps2_sendbyte(ps2dev, value & 0xff, CYTP_CMD_TIMEOUT) < 0) { 43 + error = ps2_sendbyte(ps2dev, cmd, CYTP_CMD_TIMEOUT); 44 + if (error) { 43 45 psmouse_dbg(psmouse, 44 - "sending command 0x%02x failed, resp 0x%02x\n", 45 - value & 0xff, ps2dev->nak); 46 - if (ps2dev->nak == CYTP_PS2_RETRY) 47 - return CYTP_PS2_RETRY; 48 - else 49 - return CYTP_PS2_ERROR; 46 + "sending command 0x%02x failed, resp 0x%02x, error %d\n", 47 + cmd, ps2dev->nak, error); 48 + return error; 50 49 } 51 50 52 51 #ifdef CYTP_DEBUG_VERBOSE 53 - psmouse_dbg(psmouse, "sending command 0x%02x succeeded, resp 0xfa\n", 54 - value & 0xff); 52 + psmouse_dbg(psmouse, "sending command 0x%02x succeeded\n", cmd); 55 53 #endif 56 54 57 55 return 0; 58 56 } 59 57 60 - static int cypress_ps2_ext_cmd(struct psmouse *psmouse, unsigned short cmd, 61 - unsigned char data) 58 + static int cypress_ps2_ext_cmd(struct psmouse *psmouse, u8 prefix, u8 nibble) 62 59 { 63 60 struct ps2dev *ps2dev = &psmouse->ps2dev; 64 61 int tries = CYTP_PS2_CMD_TRIES; ··· 69 72 * If sending the command fails, send recovery command 70 73 * to make the device return to the ready state. 71 74 */ 72 - rc = cypress_ps2_sendbyte(psmouse, cmd & 0xff); 73 - if (rc == CYTP_PS2_RETRY) { 75 + rc = cypress_ps2_sendbyte(psmouse, prefix); 76 + if (rc == -EAGAIN) { 74 77 rc = cypress_ps2_sendbyte(psmouse, 0x00); 75 - if (rc == CYTP_PS2_RETRY) 78 + if (rc == -EAGAIN) 76 79 rc = cypress_ps2_sendbyte(psmouse, 0x0a); 77 80 } 78 - if (rc == CYTP_PS2_ERROR) 79 - continue; 80 81 81 - rc = cypress_ps2_sendbyte(psmouse, data); 82 - if (rc == CYTP_PS2_RETRY) 83 - rc = cypress_ps2_sendbyte(psmouse, data); 84 - if (rc == CYTP_PS2_ERROR) 85 - continue; 86 - else 87 - break; 82 + if (!rc) { 83 + rc = cypress_ps2_sendbyte(psmouse, nibble); 84 + if (rc == -EAGAIN) 85 + rc = cypress_ps2_sendbyte(psmouse, nibble); 86 + 87 + if (!rc) 88 + break; 89 + } 88 90 } while (--tries > 0); 89 91 90 92 ps2_end_command(ps2dev); ··· 92 96 } 93 97 94 98 static int cypress_ps2_read_cmd_status(struct psmouse *psmouse, 95 - unsigned char cmd, 96 - unsigned char *param) 99 + u8 cmd, u8 *param) 97 100 { 98 - int rc; 99 101 struct ps2dev *ps2dev = &psmouse->ps2dev; 100 102 enum psmouse_state old_state; 101 103 int pktsize; 104 + int rc; 102 105 103 106 ps2_begin_command(ps2dev); 104 107 ··· 108 113 pktsize = (cmd == CYTP_CMD_READ_TP_METRICS) ? 8 : 3; 109 114 memset(param, 0, pktsize); 110 115 111 - rc = cypress_ps2_sendbyte(psmouse, 0xe9); 112 - if (rc < 0) 116 + rc = cypress_ps2_sendbyte(psmouse, PSMOUSE_CMD_GETINFO & 0xff); 117 + if (rc) 113 118 goto out; 114 119 115 - wait_event_timeout(ps2dev->wait, 116 - (psmouse->pktcnt >= pktsize), 117 - msecs_to_jiffies(CYTP_CMD_TIMEOUT)); 120 + if (!wait_event_timeout(ps2dev->wait, 121 + psmouse->pktcnt >= pktsize, 122 + msecs_to_jiffies(CYTP_CMD_TIMEOUT))) { 123 + rc = -ETIMEDOUT; 124 + goto out; 125 + } 118 126 119 127 memcpy(param, psmouse->packet, pktsize); 120 128 ··· 133 135 return rc; 134 136 } 135 137 136 - static bool cypress_verify_cmd_state(struct psmouse *psmouse, 137 - unsigned char cmd, unsigned char *param) 138 + static bool cypress_verify_cmd_state(struct psmouse *psmouse, u8 cmd, u8* param) 138 139 { 139 140 bool rate_match = false; 140 141 bool resolution_match = false; ··· 163 166 return false; 164 167 } 165 168 166 - static int cypress_send_ext_cmd(struct psmouse *psmouse, unsigned char cmd, 167 - unsigned char *param) 169 + static int cypress_send_ext_cmd(struct psmouse *psmouse, u8 cmd, u8 *param) 168 170 { 171 + u8 cmd_prefix = PSMOUSE_CMD_SETRES & 0xff; 169 172 int tries = CYTP_PS2_CMD_TRIES; 170 - int rc; 173 + int error; 171 174 172 175 psmouse_dbg(psmouse, "send extension cmd 0x%02x, [%d %d %d %d]\n", 173 176 cmd, DECODE_CMD_AA(cmd), DECODE_CMD_BB(cmd), 174 177 DECODE_CMD_CC(cmd), DECODE_CMD_DD(cmd)); 175 178 176 179 do { 177 - cypress_ps2_ext_cmd(psmouse, 178 - PSMOUSE_CMD_SETRES, DECODE_CMD_DD(cmd)); 179 - cypress_ps2_ext_cmd(psmouse, 180 - PSMOUSE_CMD_SETRES, DECODE_CMD_CC(cmd)); 181 - cypress_ps2_ext_cmd(psmouse, 182 - PSMOUSE_CMD_SETRES, DECODE_CMD_BB(cmd)); 183 - cypress_ps2_ext_cmd(psmouse, 184 - PSMOUSE_CMD_SETRES, DECODE_CMD_AA(cmd)); 180 + cypress_ps2_ext_cmd(psmouse, cmd_prefix, DECODE_CMD_DD(cmd)); 181 + cypress_ps2_ext_cmd(psmouse, cmd_prefix, DECODE_CMD_CC(cmd)); 182 + cypress_ps2_ext_cmd(psmouse, cmd_prefix, DECODE_CMD_BB(cmd)); 183 + cypress_ps2_ext_cmd(psmouse, cmd_prefix, DECODE_CMD_AA(cmd)); 185 184 186 - rc = cypress_ps2_read_cmd_status(psmouse, cmd, param); 187 - if (rc) 188 - continue; 189 - 190 - if (cypress_verify_cmd_state(psmouse, cmd, param)) 185 + error = cypress_ps2_read_cmd_status(psmouse, cmd, param); 186 + if (!error && cypress_verify_cmd_state(psmouse, cmd, param)) 191 187 return 0; 192 188 193 189 } while (--tries > 0); ··· 190 200 191 201 int cypress_detect(struct psmouse *psmouse, bool set_properties) 192 202 { 193 - unsigned char param[3]; 203 + u8 param[3]; 194 204 195 205 if (cypress_send_ext_cmd(psmouse, CYTP_CMD_READ_CYPRESS_ID, param)) 196 206 return -ENODEV; ··· 210 220 static int cypress_read_fw_version(struct psmouse *psmouse) 211 221 { 212 222 struct cytp_data *cytp = psmouse->private; 213 - unsigned char param[3]; 223 + u8 param[3]; 214 224 215 225 if (cypress_send_ext_cmd(psmouse, CYTP_CMD_READ_CYPRESS_ID, param)) 216 226 return -ENODEV; ··· 239 249 static int cypress_read_tp_metrics(struct psmouse *psmouse) 240 250 { 241 251 struct cytp_data *cytp = psmouse->private; 242 - unsigned char param[8]; 252 + u8 param[8]; 243 253 244 254 /* set default values for tp metrics. */ 245 255 cytp->tp_width = CYTP_DEFAULT_WIDTH; ··· 311 321 312 322 static int cypress_query_hardware(struct psmouse *psmouse) 313 323 { 314 - int ret; 324 + int error; 315 325 316 - ret = cypress_read_fw_version(psmouse); 317 - if (ret) 318 - return ret; 326 + error = cypress_read_fw_version(psmouse); 327 + if (error) 328 + return error; 319 329 320 - ret = cypress_read_tp_metrics(psmouse); 321 - if (ret) 322 - return ret; 330 + error = cypress_read_tp_metrics(psmouse); 331 + if (error) 332 + return error; 323 333 324 334 return 0; 325 335 } ··· 327 337 static int cypress_set_absolute_mode(struct psmouse *psmouse) 328 338 { 329 339 struct cytp_data *cytp = psmouse->private; 330 - unsigned char param[3]; 340 + u8 param[3]; 341 + int error; 331 342 332 - if (cypress_send_ext_cmd(psmouse, CYTP_CMD_ABS_WITH_PRESSURE_MODE, param) < 0) 333 - return -1; 343 + error = cypress_send_ext_cmd(psmouse, CYTP_CMD_ABS_WITH_PRESSURE_MODE, 344 + param); 345 + if (error) 346 + return error; 334 347 335 348 cytp->mode = (cytp->mode & ~CYTP_BIT_ABS_REL_MASK) 336 349 | CYTP_BIT_ABS_PRESSURE; ··· 358 365 static int cypress_set_input_params(struct input_dev *input, 359 366 struct cytp_data *cytp) 360 367 { 361 - int ret; 368 + int error; 362 369 363 370 if (!cytp->tp_res_x || !cytp->tp_res_y) 364 371 return -EINVAL; ··· 375 382 input_set_abs_params(input, ABS_MT_POSITION_Y, 0, cytp->tp_max_abs_y, 0, 0); 376 383 input_set_abs_params(input, ABS_MT_PRESSURE, 0, 255, 0, 0); 377 384 378 - ret = input_mt_init_slots(input, CYTP_MAX_MT_SLOTS, 379 - INPUT_MT_DROP_UNUSED|INPUT_MT_TRACK); 380 - if (ret < 0) 381 - return ret; 385 + error = input_mt_init_slots(input, CYTP_MAX_MT_SLOTS, 386 + INPUT_MT_DROP_UNUSED | INPUT_MT_TRACK); 387 + if (error) 388 + return error; 382 389 383 390 __set_bit(INPUT_PROP_SEMI_MT, input->propbit); 384 391 ··· 407 414 return 0; 408 415 } 409 416 410 - static int cypress_get_finger_count(unsigned char header_byte) 417 + static int cypress_get_finger_count(u8 header_byte) 411 418 { 412 - unsigned char bits6_7; 419 + u8 bits6_7; 413 420 int finger_count; 414 421 415 422 bits6_7 = header_byte >> 6; ··· 434 441 435 442 436 443 static int cypress_parse_packet(struct psmouse *psmouse, 437 - struct cytp_data *cytp, struct cytp_report_data *report_data) 444 + struct cytp_data *cytp, 445 + struct cytp_report_data *report_data) 438 446 { 439 - unsigned char *packet = psmouse->packet; 440 - unsigned char header_byte = packet[0]; 447 + u8 *packet = psmouse->packet; 448 + u8 header_byte = packet[0]; 441 449 442 450 memset(report_data, 0, sizeof(struct cytp_report_data)); 443 451 ··· 553 559 { 554 560 int contact_cnt; 555 561 int index = psmouse->pktcnt - 1; 556 - unsigned char *packet = psmouse->packet; 562 + u8 *packet = psmouse->packet; 557 563 struct cytp_data *cytp = psmouse->private; 558 564 559 565 if (index < 0 || index > cytp->pkt_size) ··· 606 612 static void cypress_set_rate(struct psmouse *psmouse, unsigned int rate) 607 613 { 608 614 struct cytp_data *cytp = psmouse->private; 615 + u8 rate_param; 609 616 610 617 if (rate >= 80) { 611 618 psmouse->rate = 80; ··· 616 621 cytp->mode &= ~CYTP_BIT_HIGH_RATE; 617 622 } 618 623 619 - ps2_command(&psmouse->ps2dev, (unsigned char *)&psmouse->rate, 620 - PSMOUSE_CMD_SETRATE); 624 + rate_param = (u8)rate; 625 + ps2_command(&psmouse->ps2dev, &rate_param, PSMOUSE_CMD_SETRATE); 621 626 } 622 627 623 628 static void cypress_disconnect(struct psmouse *psmouse) ··· 630 635 static int cypress_reconnect(struct psmouse *psmouse) 631 636 { 632 637 int tries = CYTP_PS2_CMD_TRIES; 633 - int rc; 638 + int error; 634 639 635 640 do { 636 641 cypress_reset(psmouse); 637 - rc = cypress_detect(psmouse, false); 638 - } while (rc && (--tries > 0)); 642 + error = cypress_detect(psmouse, false); 643 + } while (error && (--tries > 0)); 639 644 640 - if (rc) { 645 + if (error) { 641 646 psmouse_err(psmouse, "Reconnect: unable to detect trackpad.\n"); 642 - return -1; 647 + return error; 643 648 } 644 649 645 - if (cypress_set_absolute_mode(psmouse)) { 650 + error = cypress_set_absolute_mode(psmouse); 651 + if (error) { 646 652 psmouse_err(psmouse, "Reconnect: Unable to initialize Cypress absolute mode.\n"); 647 - return -1; 653 + return error; 648 654 } 649 655 650 656 return 0; ··· 654 658 int cypress_init(struct psmouse *psmouse) 655 659 { 656 660 struct cytp_data *cytp; 661 + int error; 657 662 658 - cytp = kzalloc(sizeof(struct cytp_data), GFP_KERNEL); 663 + cytp = kzalloc(sizeof(*cytp), GFP_KERNEL); 659 664 if (!cytp) 660 665 return -ENOMEM; 661 666 ··· 665 668 666 669 cypress_reset(psmouse); 667 670 668 - if (cypress_query_hardware(psmouse)) { 671 + error = cypress_query_hardware(psmouse); 672 + if (error) { 669 673 psmouse_err(psmouse, "Unable to query Trackpad hardware.\n"); 670 674 goto err_exit; 671 675 } 672 676 673 - if (cypress_set_absolute_mode(psmouse)) { 677 + error = cypress_set_absolute_mode(psmouse); 678 + if (error) { 674 679 psmouse_err(psmouse, "init: Unable to initialize Cypress absolute mode.\n"); 675 680 goto err_exit; 676 681 } 677 682 678 - if (cypress_set_input_params(psmouse->dev, cytp) < 0) { 683 + error = cypress_set_input_params(psmouse->dev, cytp); 684 + if (error) { 679 685 psmouse_err(psmouse, "init: Unable to set input params.\n"); 680 686 goto err_exit; 681 687 } ··· 703 703 psmouse->private = NULL; 704 704 kfree(cytp); 705 705 706 - return -1; 706 + return error; 707 707 }
-6
drivers/input/mouse/cypress_ps2.h
··· 72 72 #define CYTP_DATA_TIMEOUT 30 73 73 74 74 #define CYTP_EXT_CMD 0xe8 75 - #define CYTP_PS2_RETRY 0xfe 76 - #define CYTP_PS2_ERROR 0xfc 77 - 78 - #define CYTP_RESP_RETRY 0x01 79 - #define CYTP_RESP_ERROR 0xfe 80 - 81 75 82 76 #define CYTP_105001_WIDTH 97 /* Dell XPS 13 */ 83 77 #define CYTP_105001_HIGH 59
+2
drivers/input/mouse/elan_i2c_core.c
··· 1356 1356 } 1357 1357 1358 1358 err: 1359 + if (ret) 1360 + enable_irq(client->irq); 1359 1361 mutex_unlock(&data->sysfs_mutex); 1360 1362 return ret; 1361 1363 }
+1 -2
drivers/input/mouse/focaltech.c
··· 408 408 struct focaltech_data *priv; 409 409 int error; 410 410 411 - psmouse->private = priv = kzalloc(sizeof(struct focaltech_data), 412 - GFP_KERNEL); 411 + psmouse->private = priv = kzalloc(sizeof(*priv), GFP_KERNEL); 413 412 if (!priv) 414 413 return -ENOMEM; 415 414
+1 -1
drivers/input/mouse/hgpk.c
··· 981 981 struct hgpk_data *priv; 982 982 int err; 983 983 984 - priv = kzalloc(sizeof(struct hgpk_data), GFP_KERNEL); 984 + priv = kzalloc(sizeof(*priv), GFP_KERNEL); 985 985 if (!priv) { 986 986 err = -ENOMEM; 987 987 goto alloc_fail;
+1 -1
drivers/input/mouse/lifebook.c
··· 273 273 struct lifebook_data *priv; 274 274 int error = -ENOMEM; 275 275 276 - priv = kzalloc(sizeof(struct lifebook_data), GFP_KERNEL); 276 + priv = kzalloc(sizeof(*priv), GFP_KERNEL); 277 277 dev2 = input_allocate_device(); 278 278 if (!priv || !dev2) 279 279 goto err_out;
+1 -1
drivers/input/mouse/maplemouse.c
··· 73 73 struct input_dev *input_dev; 74 74 struct dc_mouse *mse; 75 75 76 - mse = kzalloc(sizeof(struct dc_mouse), GFP_KERNEL); 76 + mse = kzalloc(sizeof(*mse), GFP_KERNEL); 77 77 if (!mse) { 78 78 error = -ENOMEM; 79 79 goto fail;
+1 -1
drivers/input/mouse/psmouse-base.c
··· 1591 1591 psmouse_deactivate(parent); 1592 1592 } 1593 1593 1594 - psmouse = kzalloc(sizeof(struct psmouse), GFP_KERNEL); 1594 + psmouse = kzalloc(sizeof(*psmouse), GFP_KERNEL); 1595 1595 input_dev = input_allocate_device(); 1596 1596 if (!psmouse || !input_dev) 1597 1597 goto err_free;
+1 -1
drivers/input/mouse/sentelic.c
··· 1028 1028 "Finger Sensing Pad, hw: %d.%d.%d, sn: %x, sw: %s\n", 1029 1029 ver >> 4, ver & 0x0F, rev, sn, fsp_drv_ver); 1030 1030 1031 - psmouse->private = priv = kzalloc(sizeof(struct fsp_data), GFP_KERNEL); 1031 + psmouse->private = priv = kzalloc(sizeof(*priv), GFP_KERNEL); 1032 1032 if (!priv) 1033 1033 return -ENOMEM; 1034 1034
+1 -1
drivers/input/mouse/sermouse.c
··· 231 231 unsigned char c = serio->id.extra; 232 232 int err = -ENOMEM; 233 233 234 - sermouse = kzalloc(sizeof(struct sermouse), GFP_KERNEL); 234 + sermouse = kzalloc(sizeof(*sermouse), GFP_KERNEL); 235 235 input_dev = input_allocate_device(); 236 236 if (!sermouse || !input_dev) 237 237 goto fail1;
+2 -2
drivers/input/mouse/synaptics.c
··· 708 708 { 709 709 struct serio *serio; 710 710 711 - serio = kzalloc(sizeof(struct serio), GFP_KERNEL); 711 + serio = kzalloc(sizeof(*serio), GFP_KERNEL); 712 712 if (!serio) { 713 713 psmouse_err(psmouse, 714 714 "not enough memory for pass-through port\n"); ··· 1563 1563 1564 1564 synaptics_apply_quirks(psmouse, info); 1565 1565 1566 - psmouse->private = priv = kzalloc(sizeof(struct synaptics_data), GFP_KERNEL); 1566 + psmouse->private = priv = kzalloc(sizeof(*priv), GFP_KERNEL); 1567 1567 if (!priv) 1568 1568 return -ENOMEM; 1569 1569
+1 -1
drivers/input/mouse/synaptics_i2c.c
··· 508 508 { 509 509 struct synaptics_i2c *touch; 510 510 511 - touch = kzalloc(sizeof(struct synaptics_i2c), GFP_KERNEL); 511 + touch = kzalloc(sizeof(*touch), GFP_KERNEL); 512 512 if (!touch) 513 513 return NULL; 514 514
+1 -1
drivers/input/mouse/vsxxxaa.c
··· 456 456 struct input_dev *input_dev; 457 457 int err = -ENOMEM; 458 458 459 - mouse = kzalloc(sizeof(struct vsxxxaa), GFP_KERNEL); 459 + mouse = kzalloc(sizeof(*mouse), GFP_KERNEL); 460 460 input_dev = input_allocate_device(); 461 461 if (!mouse || !input_dev) 462 462 goto fail1;
+1 -1
drivers/input/serio/altera_ps2.c
··· 100 100 return error; 101 101 } 102 102 103 - serio = kzalloc(sizeof(struct serio), GFP_KERNEL); 103 + serio = kzalloc(sizeof(*serio), GFP_KERNEL); 104 104 if (!serio) 105 105 return -ENOMEM; 106 106
+2 -2
drivers/input/serio/ambakmi.c
··· 114 114 if (ret) 115 115 return ret; 116 116 117 - kmi = kzalloc(sizeof(struct amba_kmi_port), GFP_KERNEL); 118 - io = kzalloc(sizeof(struct serio), GFP_KERNEL); 117 + kmi = kzalloc(sizeof(*kmi), GFP_KERNEL); 118 + io = kzalloc(sizeof(*io), GFP_KERNEL); 119 119 if (!kmi || !io) { 120 120 ret = -ENOMEM; 121 121 goto out;
+1 -1
drivers/input/serio/apbps2.c
··· 165 165 /* Set reload register to core freq in kHz/10 */ 166 166 iowrite32be(freq_hz / 10000, &priv->regs->reload); 167 167 168 - priv->io = kzalloc(sizeof(struct serio), GFP_KERNEL); 168 + priv->io = kzalloc(sizeof(*priv->io), GFP_KERNEL); 169 169 if (!priv->io) 170 170 return -ENOMEM; 171 171
+1 -1
drivers/input/serio/arc_ps2.c
··· 155 155 struct arc_ps2_port *port = &arc_ps2->port[index]; 156 156 struct serio *io; 157 157 158 - io = kzalloc(sizeof(struct serio), GFP_KERNEL); 158 + io = kzalloc(sizeof(*io), GFP_KERNEL); 159 159 if (!io) 160 160 return -ENOMEM; 161 161
+1 -1
drivers/input/serio/ct82c710.c
··· 158 158 159 159 static int ct82c710_probe(struct platform_device *dev) 160 160 { 161 - ct82c710_port = kzalloc(sizeof(struct serio), GFP_KERNEL); 161 + ct82c710_port = kzalloc(sizeof(*ct82c710_port), GFP_KERNEL); 162 162 if (!ct82c710_port) 163 163 return -ENOMEM; 164 164
+2 -2
drivers/input/serio/gscps2.c
··· 338 338 if (dev->id.sversion == 0x96) 339 339 hpa += GSC_DINO_OFFSET; 340 340 341 - ps2port = kzalloc(sizeof(struct gscps2port), GFP_KERNEL); 342 - serio = kzalloc(sizeof(struct serio), GFP_KERNEL); 341 + ps2port = kzalloc(sizeof(*ps2port), GFP_KERNEL); 342 + serio = kzalloc(sizeof(*serio), GFP_KERNEL); 343 343 if (!ps2port || !serio) { 344 344 ret = -ENOMEM; 345 345 goto fail_nomem;
+2 -2
drivers/input/serio/hyperv-keyboard.c
··· 318 318 struct serio *hv_serio; 319 319 int error; 320 320 321 - kbd_dev = kzalloc(sizeof(struct hv_kbd_dev), GFP_KERNEL); 322 - hv_serio = kzalloc(sizeof(struct serio), GFP_KERNEL); 321 + kbd_dev = kzalloc(sizeof(*kbd_dev), GFP_KERNEL); 322 + hv_serio = kzalloc(sizeof(*hv_serio), GFP_KERNEL); 323 323 if (!kbd_dev || !hv_serio) { 324 324 error = -ENOMEM; 325 325 goto err_free_mem;
+2 -2
drivers/input/serio/i8042.c
··· 1329 1329 struct serio *serio; 1330 1330 struct i8042_port *port = &i8042_ports[I8042_KBD_PORT_NO]; 1331 1331 1332 - serio = kzalloc(sizeof(struct serio), GFP_KERNEL); 1332 + serio = kzalloc(sizeof(*serio), GFP_KERNEL); 1333 1333 if (!serio) 1334 1334 return -ENOMEM; 1335 1335 ··· 1359 1359 int port_no = idx < 0 ? I8042_AUX_PORT_NO : I8042_MUX_PORT_NO + idx; 1360 1360 struct i8042_port *port = &i8042_ports[port_no]; 1361 1361 1362 - serio = kzalloc(sizeof(struct serio), GFP_KERNEL); 1362 + serio = kzalloc(sizeof(*serio), GFP_KERNEL); 1363 1363 if (!serio) 1364 1364 return -ENOMEM; 1365 1365
+1 -1
drivers/input/serio/maceps2.c
··· 117 117 { 118 118 struct serio *serio; 119 119 120 - serio = kzalloc(sizeof(struct serio), GFP_KERNEL); 120 + serio = kzalloc(sizeof(*serio), GFP_KERNEL); 121 121 if (serio) { 122 122 serio->id.type = SERIO_8042; 123 123 serio->write = maceps2_write;
+2 -2
drivers/input/serio/olpc_apsp.c
··· 188 188 return priv->irq; 189 189 190 190 /* KEYBOARD */ 191 - kb_serio = kzalloc(sizeof(struct serio), GFP_KERNEL); 191 + kb_serio = kzalloc(sizeof(*kb_serio), GFP_KERNEL); 192 192 if (!kb_serio) 193 193 return -ENOMEM; 194 194 kb_serio->id.type = SERIO_8042_XL; ··· 203 203 serio_register_port(kb_serio); 204 204 205 205 /* TOUCHPAD */ 206 - pad_serio = kzalloc(sizeof(struct serio), GFP_KERNEL); 206 + pad_serio = kzalloc(sizeof(*pad_serio), GFP_KERNEL); 207 207 if (!pad_serio) { 208 208 error = -ENOMEM; 209 209 goto err_pad;
+1 -1
drivers/input/serio/parkbd.c
··· 165 165 { 166 166 struct serio *serio; 167 167 168 - serio = kzalloc(sizeof(struct serio), GFP_KERNEL); 168 + serio = kzalloc(sizeof(*serio), GFP_KERNEL); 169 169 if (serio) { 170 170 serio->id.type = parkbd_mode; 171 171 serio->write = parkbd_write;
+2 -2
drivers/input/serio/pcips2.c
··· 137 137 if (ret) 138 138 goto disable; 139 139 140 - ps2if = kzalloc(sizeof(struct pcips2_data), GFP_KERNEL); 141 - serio = kzalloc(sizeof(struct serio), GFP_KERNEL); 140 + ps2if = kzalloc(sizeof(*ps2if), GFP_KERNEL); 141 + serio = kzalloc(sizeof(*serio), GFP_KERNEL); 142 142 if (!ps2if || !serio) { 143 143 ret = -ENOMEM; 144 144 goto release;
+2 -2
drivers/input/serio/ps2-gpio.c
··· 404 404 struct device *dev = &pdev->dev; 405 405 int error; 406 406 407 - drvdata = devm_kzalloc(dev, sizeof(struct ps2_gpio_data), GFP_KERNEL); 408 - serio = kzalloc(sizeof(struct serio), GFP_KERNEL); 407 + drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL); 408 + serio = kzalloc(sizeof(*serio), GFP_KERNEL); 409 409 if (!drvdata || !serio) { 410 410 error = -ENOMEM; 411 411 goto err_free_serio;
+1 -1
drivers/input/serio/ps2mult.c
··· 127 127 struct serio *mx_serio = psm->mx_serio; 128 128 struct serio *serio; 129 129 130 - serio = kzalloc(sizeof(struct serio), GFP_KERNEL); 130 + serio = kzalloc(sizeof(*serio), GFP_KERNEL); 131 131 if (!serio) 132 132 return -ENOMEM; 133 133
+2 -2
drivers/input/serio/q40kbd.c
··· 108 108 struct serio *port; 109 109 int error; 110 110 111 - q40kbd = kzalloc(sizeof(struct q40kbd), GFP_KERNEL); 112 - port = kzalloc(sizeof(struct serio), GFP_KERNEL); 111 + q40kbd = kzalloc(sizeof(*q40kbd), GFP_KERNEL); 112 + port = kzalloc(sizeof(*port), GFP_KERNEL); 113 113 if (!q40kbd || !port) { 114 114 error = -ENOMEM; 115 115 goto err_free_mem;
+1 -1
drivers/input/serio/rpckbd.c
··· 108 108 if (tx_irq < 0) 109 109 return tx_irq; 110 110 111 - serio = kzalloc(sizeof(struct serio), GFP_KERNEL); 111 + serio = kzalloc(sizeof(*serio), GFP_KERNEL); 112 112 rpckbd = kzalloc(sizeof(*rpckbd), GFP_KERNEL); 113 113 if (!serio || !rpckbd) { 114 114 kfree(rpckbd);
+2 -2
drivers/input/serio/sa1111ps2.c
··· 256 256 struct serio *serio; 257 257 int ret; 258 258 259 - ps2if = kzalloc(sizeof(struct ps2if), GFP_KERNEL); 260 - serio = kzalloc(sizeof(struct serio), GFP_KERNEL); 259 + ps2if = kzalloc(sizeof(*ps2if), GFP_KERNEL); 260 + serio = kzalloc(sizeof(*serio), GFP_KERNEL); 261 261 if (!ps2if || !serio) { 262 262 ret = -ENOMEM; 263 263 goto free;
+1 -1
drivers/input/serio/serio.c
··· 258 258 } 259 259 } 260 260 261 - event = kmalloc(sizeof(struct serio_event), GFP_ATOMIC); 261 + event = kmalloc(sizeof(*event), GFP_ATOMIC); 262 262 if (!event) { 263 263 pr_err("Not enough memory to queue event %d\n", event_type); 264 264 retval = -ENOMEM;
+2 -2
drivers/input/serio/serio_raw.c
··· 92 92 goto out; 93 93 } 94 94 95 - client = kzalloc(sizeof(struct serio_raw_client), GFP_KERNEL); 95 + client = kzalloc(sizeof(*client), GFP_KERNEL); 96 96 if (!client) { 97 97 retval = -ENOMEM; 98 98 goto out; ··· 293 293 struct serio_raw *serio_raw; 294 294 int err; 295 295 296 - serio_raw = kzalloc(sizeof(struct serio_raw), GFP_KERNEL); 296 + serio_raw = kzalloc(sizeof(*serio_raw), GFP_KERNEL); 297 297 if (!serio_raw) { 298 298 dev_dbg(&serio->dev, "can't allocate memory for a device\n"); 299 299 return -ENOMEM;
+2 -2
drivers/input/serio/serport.c
··· 82 82 if (!capable(CAP_SYS_ADMIN)) 83 83 return -EPERM; 84 84 85 - serport = kzalloc(sizeof(struct serport), GFP_KERNEL); 85 + serport = kzalloc(sizeof(*serport), GFP_KERNEL); 86 86 if (!serport) 87 87 return -ENOMEM; 88 88 ··· 167 167 if (test_and_set_bit(SERPORT_BUSY, &serport->flags)) 168 168 return -EBUSY; 169 169 170 - serport->serio = serio = kzalloc(sizeof(struct serio), GFP_KERNEL); 170 + serport->serio = serio = kzalloc(sizeof(*serio), GFP_KERNEL); 171 171 if (!serio) 172 172 return -ENOMEM; 173 173
+2 -2
drivers/input/serio/sun4i-ps2.c
··· 213 213 struct device *dev = &pdev->dev; 214 214 int error; 215 215 216 - drvdata = kzalloc(sizeof(struct sun4i_ps2data), GFP_KERNEL); 217 - serio = kzalloc(sizeof(struct serio), GFP_KERNEL); 216 + drvdata = kzalloc(sizeof(*drvdata), GFP_KERNEL); 217 + serio = kzalloc(sizeof(*serio), GFP_KERNEL); 218 218 if (!drvdata || !serio) { 219 219 error = -ENOMEM; 220 220 goto err_free_mem;
+2 -2
drivers/input/serio/userio.c
··· 77 77 { 78 78 struct userio_device *userio; 79 79 80 - userio = kzalloc(sizeof(struct userio_device), GFP_KERNEL); 80 + userio = kzalloc(sizeof(*userio), GFP_KERNEL); 81 81 if (!userio) 82 82 return -ENOMEM; 83 83 ··· 85 85 spin_lock_init(&userio->buf_lock); 86 86 init_waitqueue_head(&userio->waitq); 87 87 88 - userio->serio = kzalloc(sizeof(struct serio), GFP_KERNEL); 88 + userio->serio = kzalloc(sizeof(*userio->serio), GFP_KERNEL); 89 89 if (!userio->serio) { 90 90 kfree(userio); 91 91 return -ENOMEM;
+2 -2
drivers/input/serio/xilinx_ps2.c
··· 252 252 return -ENODEV; 253 253 } 254 254 255 - drvdata = kzalloc(sizeof(struct xps2data), GFP_KERNEL); 256 - serio = kzalloc(sizeof(struct serio), GFP_KERNEL); 255 + drvdata = kzalloc(sizeof(*drvdata), GFP_KERNEL); 256 + serio = kzalloc(sizeof(*serio), GFP_KERNEL); 257 257 if (!drvdata || !serio) { 258 258 error = -ENOMEM; 259 259 goto failed1;
+1 -1
drivers/input/tablet/acecad.c
··· 129 129 pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress); 130 130 maxp = usb_maxpacket(dev, pipe); 131 131 132 - acecad = kzalloc(sizeof(struct usb_acecad), GFP_KERNEL); 132 + acecad = kzalloc(sizeof(*acecad), GFP_KERNEL); 133 133 input_dev = input_allocate_device(); 134 134 if (!acecad || !input_dev) { 135 135 err = -ENOMEM;
+1 -1
drivers/input/tablet/aiptek.c
··· 1673 1673 */ 1674 1674 speeds[0] = programmableDelay; 1675 1675 1676 - aiptek = kzalloc(sizeof(struct aiptek), GFP_KERNEL); 1676 + aiptek = kzalloc(sizeof(*aiptek), GFP_KERNEL); 1677 1677 inputdev = input_allocate_device(); 1678 1678 if (!aiptek || !inputdev) { 1679 1679 dev_warn(&intf->dev,
+1 -1
drivers/input/tablet/hanwang.c
··· 322 322 if (intf->cur_altsetting->desc.bNumEndpoints < 1) 323 323 return -ENODEV; 324 324 325 - hanwang = kzalloc(sizeof(struct hanwang), GFP_KERNEL); 325 + hanwang = kzalloc(sizeof(*hanwang), GFP_KERNEL); 326 326 input_dev = input_allocate_device(); 327 327 if (!hanwang || !input_dev) { 328 328 error = -ENOMEM;
+1 -1
drivers/input/tablet/kbtab.c
··· 121 121 if (!usb_endpoint_is_int_in(endpoint)) 122 122 return -ENODEV; 123 123 124 - kbtab = kzalloc(sizeof(struct kbtab), GFP_KERNEL); 124 + kbtab = kzalloc(sizeof(*kbtab), GFP_KERNEL); 125 125 input_dev = input_allocate_device(); 126 126 if (!kbtab || !input_dev) 127 127 goto fail1;
+1 -1
drivers/input/tablet/wacom_serial4.c
··· 521 521 struct input_dev *input_dev; 522 522 int err = -ENOMEM; 523 523 524 - wacom = kzalloc(sizeof(struct wacom), GFP_KERNEL); 524 + wacom = kzalloc(sizeof(*wacom), GFP_KERNEL); 525 525 input_dev = input_allocate_device(); 526 526 if (!wacom || !input_dev) 527 527 goto free_device;
+1
drivers/input/tests/input_test.c
··· 179 179 kunit_test_suite(input_test_suite); 180 180 181 181 MODULE_AUTHOR("Javier Martinez Canillas <javierm@redhat.com>"); 182 + MODULE_DESCRIPTION("KUnit test for the input core"); 182 183 MODULE_LICENSE("GPL");
+29 -6
drivers/input/touchscreen/ads7846.c
··· 138 138 void *filter_data; 139 139 int (*get_pendown_state)(void); 140 140 struct gpio_desc *gpio_pendown; 141 + struct gpio_desc *gpio_hsync; 141 142 142 143 void (*wait_for_sync)(void); 143 144 }; ··· 635 634 636 635 /*--------------------------------------------------------------------------*/ 637 636 638 - static void null_wait_for_sync(void) 639 - { 640 - } 641 - 642 637 static int ads7846_debounce_filter(void *ads, int data_idx, int *val) 643 638 { 644 639 struct ads7846 *ts = ads; ··· 787 790 return 0; 788 791 } 789 792 793 + static void ads7846_wait_for_hsync(struct ads7846 *ts) 794 + { 795 + if (ts->wait_for_sync) { 796 + ts->wait_for_sync(); 797 + return; 798 + } 799 + 800 + if (!ts->gpio_hsync) 801 + return; 802 + 803 + /* 804 + * Wait for HSYNC to assert the line should be flagged 805 + * as active low so here we are waiting for it to assert 806 + */ 807 + while (!gpiod_get_value(ts->gpio_hsync)) 808 + cpu_relax(); 809 + 810 + /* Then we wait for it do de-assert */ 811 + while (gpiod_get_value(ts->gpio_hsync)) 812 + cpu_relax(); 813 + } 814 + 790 815 static void ads7846_read_state(struct ads7846 *ts) 791 816 { 792 817 struct ads7846_packet *packet = ts->packet; ··· 819 800 packet->last_cmd_idx = 0; 820 801 821 802 while (true) { 822 - ts->wait_for_sync(); 803 + ads7846_wait_for_hsync(ts); 823 804 824 805 m = &ts->msg[msg_idx]; 825 806 error = spi_sync(ts->spi, m); ··· 1287 1268 ts->penirq_recheck_delay_usecs = 1288 1269 pdata->penirq_recheck_delay_usecs; 1289 1270 1290 - ts->wait_for_sync = pdata->wait_for_sync ? : null_wait_for_sync; 1271 + ts->wait_for_sync = pdata->wait_for_sync; 1272 + 1273 + ts->gpio_hsync = devm_gpiod_get_optional(dev, "ti,hsync", GPIOD_IN); 1274 + if (IS_ERR(ts->gpio_hsync)) 1275 + return PTR_ERR(ts->gpio_hsync); 1291 1276 1292 1277 snprintf(ts->phys, sizeof(ts->phys), "%s/input0", dev_name(dev)); 1293 1278 snprintf(ts->name, sizeof(ts->name), "ADS%d Touchscreen", ts->model);
+2 -14
drivers/input/touchscreen/atmel_mxt_ts.c
··· 3069 3069 NULL 3070 3070 }; 3071 3071 3072 - static const struct attribute_group mxt_attr_group = { 3073 - .attrs = mxt_attrs, 3074 - }; 3072 + ATTRIBUTE_GROUPS(mxt); 3075 3073 3076 3074 static void mxt_start(struct mxt_data *data) 3077 3075 { ··· 3346 3348 if (error) 3347 3349 goto err_disable_regulators; 3348 3350 3349 - error = sysfs_create_group(&client->dev.kobj, &mxt_attr_group); 3350 - if (error) { 3351 - dev_err(&client->dev, "Failure %d creating sysfs group\n", 3352 - error); 3353 - goto err_free_object; 3354 - } 3355 - 3356 3351 return 0; 3357 3352 3358 - err_free_object: 3359 - mxt_free_input_device(data); 3360 - mxt_free_object_table(data); 3361 3353 err_disable_regulators: 3362 3354 regulator_bulk_disable(ARRAY_SIZE(data->regulators), 3363 3355 data->regulators); ··· 3359 3371 struct mxt_data *data = i2c_get_clientdata(client); 3360 3372 3361 3373 disable_irq(data->irq); 3362 - sysfs_remove_group(&client->dev.kobj, &mxt_attr_group); 3363 3374 mxt_free_input_device(data); 3364 3375 mxt_free_object_table(data); 3365 3376 regulator_bulk_disable(ARRAY_SIZE(data->regulators), ··· 3442 3455 static struct i2c_driver mxt_driver = { 3443 3456 .driver = { 3444 3457 .name = "atmel_mxt_ts", 3458 + .dev_groups = mxt_groups, 3445 3459 .of_match_table = mxt_of_match, 3446 3460 .acpi_match_table = ACPI_PTR(mxt_acpi_id), 3447 3461 .pm = pm_sleep_ptr(&mxt_pm_ops),
+1
drivers/input/touchscreen/cyttsp_i2c_common.c
··· 81 81 EXPORT_SYMBOL_GPL(cyttsp_i2c_write_block_data); 82 82 83 83 84 + MODULE_DESCRIPTION("Cypress TrueTouch(TM) Standard Product (TTSP) I2C touchscreen driver"); 84 85 MODULE_LICENSE("GPL"); 85 86 MODULE_AUTHOR("Cypress");
+1 -1
drivers/input/touchscreen/da9052_tsi.c
··· 232 232 if (!da9052) 233 233 return -EINVAL; 234 234 235 - tsi = kzalloc(sizeof(struct da9052_tsi), GFP_KERNEL); 235 + tsi = kzalloc(sizeof(*tsi), GFP_KERNEL); 236 236 input_dev = input_allocate_device(); 237 237 if (!tsi || !input_dev) { 238 238 error = -ENOMEM;
+1 -1
drivers/input/touchscreen/dynapro.c
··· 110 110 struct input_dev *input_dev; 111 111 int err; 112 112 113 - pdynapro = kzalloc(sizeof(struct dynapro), GFP_KERNEL); 113 + pdynapro = kzalloc(sizeof(*pdynapro), GFP_KERNEL); 114 114 input_dev = input_allocate_device(); 115 115 if (!pdynapro || !input_dev) { 116 116 err = -ENOMEM;
+1
drivers/input/touchscreen/edt-ft5x06.c
··· 1496 1496 { .compatible = "edt,edt-ft5406", .data = &edt_ft5x06_data }, 1497 1497 { .compatible = "edt,edt-ft5506", .data = &edt_ft5506_data }, 1498 1498 { .compatible = "evervision,ev-ft5726", .data = &edt_ft5506_data }, 1499 + { .compatible = "focaltech,ft5426", .data = &edt_ft5506_data }, 1499 1500 { .compatible = "focaltech,ft5452", .data = &edt_ft5452_data }, 1500 1501 /* Note focaltech vendor prefix for compatibility with ft6236.c */ 1501 1502 { .compatible = "focaltech,ft6236", .data = &edt_ft6236_data },
+1 -1
drivers/input/touchscreen/egalax_ts_serial.c
··· 99 99 struct input_dev *input_dev; 100 100 int error; 101 101 102 - egalax = kzalloc(sizeof(struct egalax), GFP_KERNEL); 102 + egalax = kzalloc(sizeof(*egalax), GFP_KERNEL); 103 103 input_dev = input_allocate_device(); 104 104 if (!egalax || !input_dev) { 105 105 error = -ENOMEM;
+30 -6
drivers/input/touchscreen/ektf2127.c
··· 13 13 * Hans de Goede <hdegoede@redhat.com> 14 14 */ 15 15 16 + #include <linux/bits.h> 16 17 #include <linux/gpio/consumer.h> 17 18 #include <linux/interrupt.h> 18 19 #include <linux/i2c.h> ··· 47 46 struct input_dev *input; 48 47 struct gpio_desc *power_gpios; 49 48 struct touchscreen_properties prop; 49 + int status_shift; 50 + }; 51 + 52 + struct ektf2127_i2c_chip_data { 53 + int status_shift; 50 54 }; 51 55 52 56 static void ektf2127_parse_coordinates(const u8 *buf, unsigned int touch_count, ··· 118 112 119 113 static void ektf2127_report2_event(struct ektf2127_ts *ts, const u8 *buf) 120 114 { 121 - ektf2127_report2_contact(ts, 0, &buf[1], !!(buf[7] & 2)); 122 - ektf2127_report2_contact(ts, 1, &buf[4], !!(buf[7] & 4)); 115 + ektf2127_report2_contact(ts, 0, &buf[1], !!(buf[7] & BIT(ts->status_shift))); 116 + ektf2127_report2_contact(ts, 1, &buf[4], !!(buf[7] & BIT(ts->status_shift + 1))); 123 117 124 118 input_mt_sync_frame(ts->input); 125 119 input_sync(ts->input); ··· 253 247 static int ektf2127_probe(struct i2c_client *client) 254 248 { 255 249 struct device *dev = &client->dev; 250 + const struct ektf2127_i2c_chip_data *chip_data; 256 251 struct ektf2127_ts *ts; 257 252 struct input_dev *input; 258 253 u8 buf[4]; ··· 310 303 return error; 311 304 312 305 ts->input = input; 306 + 307 + chip_data = i2c_get_match_data(client); 308 + if (!chip_data) 309 + return dev_err_probe(&client->dev, -EINVAL, "missing chip data\n"); 310 + 311 + ts->status_shift = chip_data->status_shift; 312 + 313 313 input_set_drvdata(input, ts); 314 314 315 315 error = devm_request_threaded_irq(dev, client->irq, ··· 339 325 return 0; 340 326 } 341 327 328 + static const struct ektf2127_i2c_chip_data ektf2127_data = { 329 + .status_shift = 1, 330 + }; 331 + 332 + static const struct ektf2127_i2c_chip_data ektf2232_data = { 333 + .status_shift = 0, 334 + }; 335 + 342 336 #ifdef CONFIG_OF 343 337 static const struct of_device_id ektf2127_of_match[] = { 344 - { .compatible = "elan,ektf2127" }, 345 - { .compatible = "elan,ektf2132" }, 338 + { .compatible = "elan,ektf2127", .data = &ektf2127_data}, 339 + { .compatible = "elan,ektf2132", .data = &ektf2127_data}, 340 + { .compatible = "elan,ektf2232", .data = &ektf2232_data}, 346 341 {} 347 342 }; 348 343 MODULE_DEVICE_TABLE(of, ektf2127_of_match); 349 344 #endif 350 345 351 346 static const struct i2c_device_id ektf2127_i2c_id[] = { 352 - { "ektf2127" }, 353 - { "ektf2132" }, 347 + { .name = "ektf2127", .driver_data = (long)&ektf2127_data }, 348 + { .name = "ektf2132", .driver_data = (long)&ektf2127_data }, 349 + { .name = "ektf2232", .driver_data = (long)&ektf2232_data }, 354 350 {} 355 351 }; 356 352 MODULE_DEVICE_TABLE(i2c, ektf2127_i2c_id);
+1 -1
drivers/input/touchscreen/elo.c
··· 307 307 struct input_dev *input_dev; 308 308 int err; 309 309 310 - elo = kzalloc(sizeof(struct elo), GFP_KERNEL); 310 + elo = kzalloc(sizeof(*elo), GFP_KERNEL); 311 311 input_dev = input_allocate_device(); 312 312 if (!elo || !input_dev) { 313 313 err = -ENOMEM;
+7
drivers/input/touchscreen/exc3000.c
··· 53 53 EETI_EXC3000, 54 54 EETI_EXC80H60, 55 55 EETI_EXC80H84, 56 + EETI_EXC81W32, 56 57 }; 57 58 58 59 static struct eeti_dev_info exc3000_info[] = { ··· 67 66 }, 68 67 [EETI_EXC80H84] = { 69 68 .name = "EETI EXC80H84 Touch Screen", 69 + .max_xy = SZ_16K - 1, 70 + }, 71 + [EETI_EXC81W32] = { 72 + .name = "EETI EXC81W32 Touch Screen", 70 73 .max_xy = SZ_16K - 1, 71 74 }, 72 75 }; ··· 446 441 { "exc3000", EETI_EXC3000 }, 447 442 { "exc80h60", EETI_EXC80H60 }, 448 443 { "exc80h84", EETI_EXC80H84 }, 444 + { "exc81w32", EETI_EXC81W32 }, 449 445 { } 450 446 }; 451 447 MODULE_DEVICE_TABLE(i2c, exc3000_id); ··· 456 450 { .compatible = "eeti,exc3000", .data = &exc3000_info[EETI_EXC3000] }, 457 451 { .compatible = "eeti,exc80h60", .data = &exc3000_info[EETI_EXC80H60] }, 458 452 { .compatible = "eeti,exc80h84", .data = &exc3000_info[EETI_EXC80H84] }, 453 + { .compatible = "eeti,exc81w32", .data = &exc3000_info[EETI_EXC81W32] }, 459 454 { } 460 455 }; 461 456 MODULE_DEVICE_TABLE(of, exc3000_of_match);
+1 -1
drivers/input/touchscreen/fsl-imx25-tcq.c
··· 38 38 struct device *dev; 39 39 }; 40 40 41 - static struct regmap_config mx25_tcq_regconfig = { 41 + static const struct regmap_config mx25_tcq_regconfig = { 42 42 .fast_io = true, 43 43 .max_register = 0x5c, 44 44 .reg_bits = 32,
+1 -1
drivers/input/touchscreen/fujitsu_ts.c
··· 99 99 struct input_dev *input_dev; 100 100 int err; 101 101 102 - fujitsu = kzalloc(sizeof(struct fujitsu), GFP_KERNEL); 102 + fujitsu = kzalloc(sizeof(*fujitsu), GFP_KERNEL); 103 103 input_dev = input_allocate_device(); 104 104 if (!fujitsu || !input_dev) { 105 105 err = -ENOMEM;
+13 -11
drivers/input/touchscreen/goodix_berlin_spi.c
··· 36 36 struct spi_transfer xfers; 37 37 struct spi_message spi_msg; 38 38 const u32 *reg = reg_buf; /* reg is stored as native u32 at start of buffer */ 39 - u8 *buf; 40 39 int error; 41 40 42 41 if (reg_size != GOODIX_BERLIN_REGISTER_WIDTH) 43 42 return -EINVAL; 44 43 45 - buf = kzalloc(GOODIX_BERLIN_SPI_READ_PREFIX_LEN + val_size, GFP_KERNEL); 44 + u8 *buf __free(kfree) = 45 + kzalloc(GOODIX_BERLIN_SPI_READ_PREFIX_LEN + val_size, 46 + GFP_KERNEL); 46 47 if (!buf) 47 48 return -ENOMEM; 48 49 ··· 63 62 spi_message_add_tail(&xfers, &spi_msg); 64 63 65 64 error = spi_sync(spi, &spi_msg); 66 - if (error < 0) 65 + if (error < 0) { 67 66 dev_err(&spi->dev, "spi transfer error, %d", error); 68 - else 69 - memcpy(val_buf, buf + GOODIX_BERLIN_SPI_READ_PREFIX_LEN, val_size); 67 + return error; 68 + } 70 69 71 - kfree(buf); 70 + memcpy(val_buf, buf + GOODIX_BERLIN_SPI_READ_PREFIX_LEN, val_size); 72 71 return error; 73 72 } 74 73 ··· 80 79 struct spi_transfer xfers; 81 80 struct spi_message spi_msg; 82 81 const u32 *reg = data; /* reg is stored as native u32 at start of buffer */ 83 - u8 *buf; 84 82 int error; 85 83 86 - buf = kzalloc(GOODIX_BERLIN_SPI_WRITE_PREFIX_LEN + len, GFP_KERNEL); 84 + u8 *buf __free(kfree) = 85 + kzalloc(GOODIX_BERLIN_SPI_WRITE_PREFIX_LEN + len, GFP_KERNEL); 87 86 if (!buf) 88 87 return -ENOMEM; 89 88 ··· 101 100 spi_message_add_tail(&xfers, &spi_msg); 102 101 103 102 error = spi_sync(spi, &spi_msg); 104 - if (error < 0) 103 + if (error < 0) { 105 104 dev_err(&spi->dev, "spi transfer error, %d", error); 105 + return error; 106 + } 106 107 107 - kfree(buf); 108 - return error; 108 + return 0; 109 109 } 110 110 111 111 static const struct regmap_config goodix_berlin_spi_regmap_conf = {
+1 -1
drivers/input/touchscreen/gunze.c
··· 97 97 struct input_dev *input_dev; 98 98 int err; 99 99 100 - gunze = kzalloc(sizeof(struct gunze), GFP_KERNEL); 100 + gunze = kzalloc(sizeof(*gunze), GFP_KERNEL); 101 101 input_dev = input_allocate_device(); 102 102 if (!gunze || !input_dev) { 103 103 err = -ENOMEM;
+1 -1
drivers/input/touchscreen/hampshire.c
··· 109 109 struct input_dev *input_dev; 110 110 int err; 111 111 112 - phampshire = kzalloc(sizeof(struct hampshire), GFP_KERNEL); 112 + phampshire = kzalloc(sizeof(*phampshire), GFP_KERNEL); 113 113 input_dev = input_allocate_device(); 114 114 if (!phampshire || !input_dev) { 115 115 err = -ENOMEM;
+109 -26
drivers/input/touchscreen/himax_hx83112b.c
··· 4 4 * 5 5 * Copyright (C) 2022 Job Noorman <job@noorman.info> 6 6 * 7 + * HX83100A support 8 + * Copyright (C) 2024 Felix Kaechele <felix@kaechele.ca> 9 + * 7 10 * This code is based on "Himax Android Driver Sample Code for QCT platform": 8 11 * 9 12 * Copyright (C) 2017 Himax Corporation. ··· 23 20 #include <linux/kernel.h> 24 21 #include <linux/regmap.h> 25 22 26 - #define HIMAX_ID_83112B 0x83112b 27 - 28 23 #define HIMAX_MAX_POINTS 10 29 24 30 - #define HIMAX_REG_CFG_SET_ADDR 0x00 31 - #define HIMAX_REG_CFG_INIT_READ 0x0c 32 - #define HIMAX_REG_CFG_READ_VALUE 0x08 33 - #define HIMAX_REG_READ_EVENT 0x30 25 + #define HIMAX_AHB_ADDR_BYTE_0 0x00 26 + #define HIMAX_AHB_ADDR_RDATA_BYTE_0 0x08 27 + #define HIMAX_AHB_ADDR_ACCESS_DIRECTION 0x0c 28 + #define HIMAX_AHB_ADDR_INCR4 0x0d 29 + #define HIMAX_AHB_ADDR_CONTI 0x13 30 + #define HIMAX_AHB_ADDR_EVENT_STACK 0x30 34 31 35 - #define HIMAX_CFG_PRODUCT_ID 0x900000d0 32 + #define HIMAX_AHB_CMD_ACCESS_DIRECTION_READ 0x00 33 + #define HIMAX_AHB_CMD_INCR4 0x10 34 + #define HIMAX_AHB_CMD_CONTI 0x31 35 + 36 + #define HIMAX_REG_ADDR_ICID 0x900000d0 37 + 38 + #define HX83100A_REG_FW_EVENT_STACK 0x90060000 36 39 37 40 #define HIMAX_INVALID_COORD 0xffff 38 41 ··· 58 49 59 50 static_assert(sizeof(struct himax_event) == 56); 60 51 52 + struct himax_ts_data; 53 + struct himax_chip { 54 + u32 id; 55 + int (*check_id)(struct himax_ts_data *ts); 56 + int (*read_events)(struct himax_ts_data *ts, struct himax_event *event, 57 + size_t length); 58 + }; 59 + 61 60 struct himax_ts_data { 61 + const struct himax_chip *chip; 62 62 struct gpio_desc *gpiod_rst; 63 63 struct input_dev *input_dev; 64 64 struct i2c_client *client; ··· 81 63 .val_format_endian = REGMAP_ENDIAN_LITTLE, 82 64 }; 83 65 84 - static int himax_read_config(struct himax_ts_data *ts, u32 address, u32 *dst) 66 + static int himax_bus_enable_burst(struct himax_ts_data *ts) 85 67 { 86 68 int error; 87 69 88 - error = regmap_write(ts->regmap, HIMAX_REG_CFG_SET_ADDR, address); 70 + error = regmap_write(ts->regmap, HIMAX_AHB_ADDR_CONTI, 71 + HIMAX_AHB_CMD_CONTI); 89 72 if (error) 90 73 return error; 91 74 92 - error = regmap_write(ts->regmap, HIMAX_REG_CFG_INIT_READ, 0x0); 75 + error = regmap_write(ts->regmap, HIMAX_AHB_ADDR_INCR4, 76 + HIMAX_AHB_CMD_INCR4); 93 77 if (error) 94 78 return error; 95 79 96 - error = regmap_read(ts->regmap, HIMAX_REG_CFG_READ_VALUE, dst); 80 + return 0; 81 + } 82 + 83 + static int himax_bus_read(struct himax_ts_data *ts, u32 address, void *dst, 84 + size_t length) 85 + { 86 + int error; 87 + 88 + if (length > 4) { 89 + error = himax_bus_enable_burst(ts); 90 + if (error) 91 + return error; 92 + } 93 + 94 + error = regmap_write(ts->regmap, HIMAX_AHB_ADDR_BYTE_0, address); 95 + if (error) 96 + return error; 97 + 98 + error = regmap_write(ts->regmap, HIMAX_AHB_ADDR_ACCESS_DIRECTION, 99 + HIMAX_AHB_CMD_ACCESS_DIRECTION_READ); 100 + if (error) 101 + return error; 102 + 103 + if (length > 4) 104 + error = regmap_noinc_read(ts->regmap, HIMAX_AHB_ADDR_RDATA_BYTE_0, 105 + dst, length); 106 + else 107 + error = regmap_read(ts->regmap, HIMAX_AHB_ADDR_RDATA_BYTE_0, 108 + dst); 109 + if (error) 110 + return error; 111 + 112 + return 0; 113 + } 114 + 115 + static int himax_read_mcu(struct himax_ts_data *ts, u32 address, u32 *dst) 116 + { 117 + int error; 118 + 119 + error = himax_bus_read(ts, address, dst, sizeof(dst)); 97 120 if (error) 98 121 return error; 99 122 ··· 160 101 { 161 102 int error; 162 103 163 - error = himax_read_config(ts, HIMAX_CFG_PRODUCT_ID, product_id); 104 + error = himax_read_mcu(ts, HIMAX_REG_ADDR_ICID, product_id); 164 105 if (error) 165 106 return error; 166 107 ··· 179 120 180 121 dev_dbg(&ts->client->dev, "Product id: %x\n", product_id); 181 122 182 - switch (product_id) { 183 - case HIMAX_ID_83112B: 123 + if (product_id == ts->chip->id) 184 124 return 0; 185 125 186 - default: 187 - dev_err(&ts->client->dev, 188 - "Unknown product id: %x\n", product_id); 189 - return -EINVAL; 190 - } 126 + dev_err(&ts->client->dev, "Unknown product id: %x\n", 127 + product_id); 128 + return -EINVAL; 191 129 } 192 130 193 131 static int himax_input_register(struct himax_ts_data *ts) ··· 286 230 return true; 287 231 } 288 232 233 + static int himax_read_events(struct himax_ts_data *ts, 234 + struct himax_event *event, size_t length) 235 + { 236 + return regmap_raw_read(ts->regmap, HIMAX_AHB_ADDR_EVENT_STACK, event, 237 + length); 238 + } 239 + 240 + static int hx83100a_read_events(struct himax_ts_data *ts, 241 + struct himax_event *event, size_t length) 242 + { 243 + return himax_bus_read(ts, HX83100A_REG_FW_EVENT_STACK, event, length); 244 + }; 245 + 289 246 static int himax_handle_input(struct himax_ts_data *ts) 290 247 { 291 248 int error; 292 249 struct himax_event event; 293 250 294 - error = regmap_raw_read(ts->regmap, HIMAX_REG_READ_EVENT, &event, 295 - sizeof(event)); 251 + error = ts->chip->read_events(ts, &event, sizeof(event)); 296 252 if (error) { 297 253 dev_err(&ts->client->dev, "Failed to read input event: %d\n", 298 254 error); ··· 350 282 351 283 i2c_set_clientdata(client, ts); 352 284 ts->client = client; 285 + ts->chip = i2c_get_match_data(client); 353 286 354 287 ts->regmap = devm_regmap_init_i2c(client, &himax_regmap_config); 355 288 error = PTR_ERR_OR_ZERO(ts->regmap); ··· 368 299 369 300 himax_reset(ts); 370 301 371 - error = himax_check_product_id(ts); 372 - if (error) 373 - return error; 302 + if (ts->chip->check_id) { 303 + error = himax_check_product_id(ts); 304 + if (error) 305 + return error; 306 + } 374 307 375 308 error = himax_input_register(ts); 376 309 if (error) ··· 405 334 406 335 static DEFINE_SIMPLE_DEV_PM_OPS(himax_pm_ops, himax_suspend, himax_resume); 407 336 337 + static const struct himax_chip hx83100a_chip = { 338 + .read_events = hx83100a_read_events, 339 + }; 340 + 341 + static const struct himax_chip hx83112b_chip = { 342 + .id = 0x83112b, 343 + .check_id = himax_check_product_id, 344 + .read_events = himax_read_events, 345 + }; 346 + 408 347 static const struct i2c_device_id himax_ts_id[] = { 409 - { "hx83112b" }, 348 + { "hx83100a", (kernel_ulong_t)&hx83100a_chip }, 349 + { "hx83112b", (kernel_ulong_t)&hx83112b_chip }, 410 350 { /* sentinel */ } 411 351 }; 412 352 MODULE_DEVICE_TABLE(i2c, himax_ts_id); 413 353 414 354 #ifdef CONFIG_OF 415 355 static const struct of_device_id himax_of_match[] = { 416 - { .compatible = "himax,hx83112b" }, 356 + { .compatible = "himax,hx83100a", .data = &hx83100a_chip }, 357 + { .compatible = "himax,hx83112b", .data = &hx83112b_chip }, 417 358 { /* sentinel */ } 418 359 }; 419 360 MODULE_DEVICE_TABLE(of, himax_of_match);
+64 -63
drivers/input/touchscreen/ili210x.c
··· 582 582 } 583 583 static DEVICE_ATTR(calibrate, S_IWUSR, NULL, ili210x_calibrate); 584 584 585 - static int ili251x_firmware_to_buffer(const struct firmware *fw, 586 - u8 **buf, u16 *ac_end, u16 *df_end) 585 + static const u8 *ili251x_firmware_to_buffer(const struct firmware *fw, 586 + u16 *ac_end, u16 *df_end) 587 587 { 588 588 const struct ihex_binrec *rec; 589 589 u32 fw_addr, fw_last_addr = 0; 590 590 u16 fw_len; 591 - u8 *fw_buf; 592 - int error; 593 591 594 592 /* 595 593 * The firmware ihex blob can never be bigger than 64 kiB, so make this ··· 595 597 * once, copy them all into this buffer at the right locations, and then 596 598 * do all operations on this linear buffer. 597 599 */ 598 - fw_buf = kzalloc(SZ_64K, GFP_KERNEL); 600 + u8* fw_buf __free(kvfree) = kvmalloc(SZ_64K, GFP_KERNEL); 599 601 if (!fw_buf) 600 - return -ENOMEM; 602 + return ERR_PTR(-ENOMEM); 601 603 602 604 rec = (const struct ihex_binrec *)fw->data; 603 605 while (rec) { ··· 605 607 fw_len = be16_to_cpu(rec->len); 606 608 607 609 /* The last 32 Byte firmware block can be 0xffe0 */ 608 - if (fw_addr + fw_len > SZ_64K || fw_addr > SZ_64K - 32) { 609 - error = -EFBIG; 610 - goto err_big; 611 - } 610 + if (fw_addr + fw_len > SZ_64K || fw_addr > SZ_64K - 32) 611 + return ERR_PTR(-EFBIG); 612 612 613 613 /* Find the last address before DF start address, that is AC end */ 614 614 if (fw_addr == 0xf000) ··· 619 623 620 624 /* DF end address is the last address in the firmware blob */ 621 625 *df_end = fw_addr + fw_len; 622 - *buf = fw_buf; 623 - return 0; 624 626 625 - err_big: 626 - kfree(fw_buf); 627 - return error; 627 + return_ptr(fw_buf); 628 628 } 629 629 630 630 /* Switch mode between Application and BootLoader */ ··· 683 691 return 0; 684 692 } 685 693 686 - static int ili251x_firmware_write_to_ic(struct device *dev, u8 *fwbuf, 694 + static int ili251x_firmware_write_to_ic(struct device *dev, const u8 *fwbuf, 687 695 u16 start, u16 end, u8 dataflash) 688 696 { 689 697 struct i2c_client *client = to_i2c_client(dev); ··· 768 776 msleep(300); 769 777 } 770 778 771 - static ssize_t ili210x_firmware_update_store(struct device *dev, 772 - struct device_attribute *attr, 773 - const char *buf, size_t count) 779 + static int ili210x_do_firmware_update(struct ili210x *priv, 780 + const u8 *fwbuf, u16 ac_end, u16 df_end) 774 781 { 775 - struct i2c_client *client = to_i2c_client(dev); 776 - struct ili210x *priv = i2c_get_clientdata(client); 777 - const char *fwname = ILI251X_FW_FILENAME; 778 - const struct firmware *fw; 779 - u16 ac_end, df_end; 780 - u8 *fwbuf; 782 + struct i2c_client *client = priv->client; 783 + struct device *dev = &client->dev; 781 784 int error; 782 785 int i; 783 786 784 - error = request_ihex_firmware(&fw, fwname, dev); 785 - if (error) { 786 - dev_err(dev, "Failed to request firmware %s, error=%d\n", 787 - fwname, error); 788 - return error; 789 - } 790 - 791 - error = ili251x_firmware_to_buffer(fw, &fwbuf, &ac_end, &df_end); 792 - release_firmware(fw); 793 - if (error) 794 - return error; 795 - 796 - /* 797 - * Disable touchscreen IRQ, so that we would not get spurious touch 798 - * interrupt during firmware update, and so that the IRQ handler won't 799 - * trigger and interfere with the firmware update. There is no bit in 800 - * the touch controller to disable the IRQs during update, so we have 801 - * to do it this way here. 802 - */ 803 - disable_irq(client->irq); 804 - 805 - dev_dbg(dev, "Firmware update started, firmware=%s\n", fwname); 806 - 807 - ili210x_hardware_reset(priv->reset_gpio); 808 - 809 787 error = ili251x_firmware_reset(client); 810 788 if (error) 811 - goto exit; 789 + return error; 812 790 813 791 /* This may not succeed on first try, so re-try a few times. */ 814 792 for (i = 0; i < 5; i++) { ··· 788 826 } 789 827 790 828 if (error) 791 - goto exit; 829 + return error; 792 830 793 831 dev_dbg(dev, "IC is now in BootLoader mode\n"); 794 832 ··· 797 835 error = ili251x_firmware_write_to_ic(dev, fwbuf, 0xf000, df_end, 1); 798 836 if (error) { 799 837 dev_err(dev, "DF firmware update failed, error=%d\n", error); 800 - goto exit; 838 + return error; 801 839 } 802 840 803 841 dev_dbg(dev, "DataFlash firmware written\n"); ··· 805 843 error = ili251x_firmware_write_to_ic(dev, fwbuf, 0x2000, ac_end, 0); 806 844 if (error) { 807 845 dev_err(dev, "AC firmware update failed, error=%d\n", error); 808 - goto exit; 846 + return error; 809 847 } 810 848 811 849 dev_dbg(dev, "Application firmware written\n"); ··· 818 856 } 819 857 820 858 if (error) 821 - goto exit; 859 + return error; 822 860 823 861 dev_dbg(dev, "IC is now in Application mode\n"); 824 862 825 863 error = ili251x_firmware_update_cached_state(dev); 826 864 if (error) 827 - goto exit; 865 + return error; 828 866 829 - error = count; 867 + return 0; 868 + } 830 869 831 - exit: 832 - ili210x_hardware_reset(priv->reset_gpio); 833 - dev_dbg(dev, "Firmware update ended, error=%i\n", error); 834 - enable_irq(client->irq); 835 - kfree(fwbuf); 836 - return error; 870 + static ssize_t ili210x_firmware_update_store(struct device *dev, 871 + struct device_attribute *attr, 872 + const char *buf, size_t count) 873 + { 874 + struct i2c_client *client = to_i2c_client(dev); 875 + struct ili210x *priv = i2c_get_clientdata(client); 876 + const char *fwname = ILI251X_FW_FILENAME; 877 + u16 ac_end, df_end; 878 + int error; 879 + 880 + const struct firmware *fw __free(firmware) = NULL; 881 + error = request_ihex_firmware(&fw, fwname, dev); 882 + if (error) { 883 + dev_err(dev, "Failed to request firmware %s, error=%d\n", 884 + fwname, error); 885 + return error; 886 + } 887 + 888 + const u8* fwbuf __free(kvfree) = 889 + ili251x_firmware_to_buffer(fw, &ac_end, &df_end); 890 + error = PTR_ERR_OR_ZERO(fwbuf); 891 + if (error) 892 + return error; 893 + 894 + /* 895 + * Disable touchscreen IRQ, so that we would not get spurious touch 896 + * interrupt during firmware update, and so that the IRQ handler won't 897 + * trigger and interfere with the firmware update. There is no bit in 898 + * the touch controller to disable the IRQs during update, so we have 899 + * to do it this way here. 900 + */ 901 + scoped_guard(disable_irq, &client->irq) { 902 + dev_dbg(dev, "Firmware update started, firmware=%s\n", fwname); 903 + 904 + ili210x_hardware_reset(priv->reset_gpio); 905 + 906 + error = ili210x_do_firmware_update(priv, fwbuf, ac_end, df_end); 907 + 908 + ili210x_hardware_reset(priv->reset_gpio); 909 + 910 + dev_dbg(dev, "Firmware update ended, error=%i\n", error); 911 + } 912 + 913 + return error ?: count; 837 914 } 838 915 839 916 static DEVICE_ATTR(firmware_update, 0200, NULL, ili210x_firmware_update_store);
+26 -9
drivers/input/touchscreen/imagis.c
··· 12 12 #include <linux/property.h> 13 13 #include <linux/regulator/consumer.h> 14 14 15 - #define IST3032C_WHOAMI 0x32c 15 + #define IST30XX_REG_STATUS 0x20 16 + #define IST30XX_REG_CHIPID (0x40000000 | IST3038C_DIRECT_ACCESS) 16 17 17 - #define IST3038B_REG_STATUS 0x20 18 + #define IST30XX_WHOAMI 0x30003000 19 + #define IST30XXA_WHOAMI 0x300a300a 20 + #define IST30XXB_WHOAMI 0x300b300b 21 + #define IST3038_WHOAMI 0x30383038 22 + 23 + #define IST3032C_WHOAMI 0x32c 24 + #define IST3038C_WHOAMI 0x38c 25 + 18 26 #define IST3038B_REG_CHIPID 0x30 19 27 #define IST3038B_WHOAMI 0x30380b 20 28 ··· 33 25 #define IST3038C_REG_TOUCH_STATUS (IST3038C_REG_HIB_BASE | IST3038C_HIB_ACCESS) 34 26 #define IST3038C_REG_TOUCH_COORD (IST3038C_REG_HIB_BASE | IST3038C_HIB_ACCESS | 0x8) 35 27 #define IST3038C_REG_INTR_MESSAGE (IST3038C_REG_HIB_BASE | IST3038C_HIB_ACCESS | 0x4) 36 - #define IST3038C_WHOAMI 0x38c 37 28 #define IST3038C_CHIP_ON_DELAY_MS 60 38 29 #define IST3038C_I2C_RETRY_COUNT 3 39 30 #define IST3038C_MAX_FINGER_NUM 10 ··· 128 121 for (i = 0; i < finger_count; i++) { 129 122 if (ts->tdata->protocol_b) 130 123 error = imagis_i2c_read_reg(ts, 131 - ts->tdata->touch_coord_cmd, &finger_status); 132 - else 133 - error = imagis_i2c_read_reg(ts, 134 124 ts->tdata->touch_coord_cmd + (i * 4), 135 125 &finger_status); 126 + else 127 + error = imagis_i2c_read_reg(ts, 128 + ts->tdata->touch_coord_cmd, &finger_status); 136 129 if (error) { 137 130 dev_err(&ts->client->dev, 138 131 "failed to read coordinates for finger %d: %d\n", ··· 401 394 .whoami_cmd = IST3038C_REG_CHIPID, 402 395 .whoami_val = IST3032C_WHOAMI, 403 396 .touch_keys_supported = true, 397 + .protocol_b = true, 398 + }; 399 + 400 + static const struct imagis_properties imagis_3038_data = { 401 + .interrupt_msg_cmd = IST30XX_REG_STATUS, 402 + .touch_coord_cmd = IST30XX_REG_STATUS, 403 + .whoami_cmd = IST30XX_REG_CHIPID, 404 + .whoami_val = IST3038_WHOAMI, 405 + .touch_keys_supported = true, 404 406 }; 405 407 406 408 static const struct imagis_properties imagis_3038b_data = { 407 - .interrupt_msg_cmd = IST3038B_REG_STATUS, 408 - .touch_coord_cmd = IST3038B_REG_STATUS, 409 + .interrupt_msg_cmd = IST30XX_REG_STATUS, 410 + .touch_coord_cmd = IST30XX_REG_STATUS, 409 411 .whoami_cmd = IST3038B_REG_CHIPID, 410 412 .whoami_val = IST3038B_WHOAMI, 411 - .protocol_b = true, 412 413 }; 413 414 414 415 static const struct imagis_properties imagis_3038c_data = { ··· 424 409 .touch_coord_cmd = IST3038C_REG_TOUCH_COORD, 425 410 .whoami_cmd = IST3038C_REG_CHIPID, 426 411 .whoami_val = IST3038C_WHOAMI, 412 + .protocol_b = true, 427 413 }; 428 414 429 415 #ifdef CONFIG_OF 430 416 static const struct of_device_id imagis_of_match[] = { 431 417 { .compatible = "imagis,ist3032c", .data = &imagis_3032c_data }, 418 + { .compatible = "imagis,ist3038", .data = &imagis_3038_data }, 432 419 { .compatible = "imagis,ist3038b", .data = &imagis_3038b_data }, 433 420 { .compatible = "imagis,ist3038c", .data = &imagis_3038c_data }, 434 421 { },
+1 -1
drivers/input/touchscreen/inexio.c
··· 114 114 struct input_dev *input_dev; 115 115 int err; 116 116 117 - pinexio = kzalloc(sizeof(struct inexio), GFP_KERNEL); 117 + pinexio = kzalloc(sizeof(*pinexio), GFP_KERNEL); 118 118 input_dev = input_allocate_device(); 119 119 if (!pinexio || !input_dev) { 120 120 err = -ENOMEM;
+1 -1
drivers/input/touchscreen/mtouch.c
··· 128 128 struct input_dev *input_dev; 129 129 int err; 130 130 131 - mtouch = kzalloc(sizeof(struct mtouch), GFP_KERNEL); 131 + mtouch = kzalloc(sizeof(*mtouch), GFP_KERNEL); 132 132 input_dev = input_allocate_device(); 133 133 if (!mtouch || !input_dev) { 134 134 err = -ENOMEM;
+1 -1
drivers/input/touchscreen/penmount.c
··· 199 199 int max_x, max_y; 200 200 int err; 201 201 202 - pm = kzalloc(sizeof(struct pm), GFP_KERNEL); 202 + pm = kzalloc(sizeof(*pm), GFP_KERNEL); 203 203 input_dev = input_allocate_device(); 204 204 if (!pm || !input_dev) { 205 205 err = -ENOMEM;
+37 -58
drivers/input/touchscreen/rohm_bu21023.c
··· 643 643 const char *firmware_name) 644 644 { 645 645 struct device *dev = &client->dev; 646 - const struct firmware *fw; 647 646 s32 status; 648 647 unsigned int offset, len, xfer_len; 649 648 unsigned int retry = 0; 650 649 int error, error2; 651 650 651 + const struct firmware *fw __free(firmware) = NULL; 652 652 error = request_firmware(&fw, firmware_name, dev); 653 653 if (error) { 654 654 dev_err(dev, "unable to retrieve firmware %s: %d\n", ··· 722 722 out: 723 723 error2 = i2c_smbus_write_byte_data(client, INT_MASK, INT_ALL); 724 724 725 - release_firmware(fw); 726 - 727 725 return error ? error : error2; 726 + } 727 + 728 + static int rohm_ts_update_setting(struct rohm_ts_data *ts, 729 + unsigned int setting_bit, bool on) 730 + { 731 + int error; 732 + 733 + scoped_cond_guard(mutex_intr, return -EINTR, &ts->input->mutex) { 734 + if (on) 735 + ts->setup2 |= setting_bit; 736 + else 737 + ts->setup2 &= ~setting_bit; 738 + 739 + if (ts->initialized) { 740 + error = i2c_smbus_write_byte_data(ts->client, 741 + COMMON_SETUP2, 742 + ts->setup2); 743 + if (error) 744 + return error; 745 + } 746 + } 747 + 748 + return 0; 728 749 } 729 750 730 751 static ssize_t swap_xy_show(struct device *dev, struct device_attribute *attr, ··· 754 733 struct i2c_client *client = to_i2c_client(dev); 755 734 struct rohm_ts_data *ts = i2c_get_clientdata(client); 756 735 757 - return sprintf(buf, "%d\n", !!(ts->setup2 & SWAP_XY)); 736 + return sysfs_emit(buf, "%d\n", !!(ts->setup2 & SWAP_XY)); 758 737 } 759 738 760 739 static ssize_t swap_xy_store(struct device *dev, struct device_attribute *attr, ··· 769 748 if (error) 770 749 return error; 771 750 772 - error = mutex_lock_interruptible(&ts->input->mutex); 773 - if (error) 774 - return error; 775 - 776 - if (val) 777 - ts->setup2 |= SWAP_XY; 778 - else 779 - ts->setup2 &= ~SWAP_XY; 780 - 781 - if (ts->initialized) 782 - error = i2c_smbus_write_byte_data(ts->client, COMMON_SETUP2, 783 - ts->setup2); 784 - 785 - mutex_unlock(&ts->input->mutex); 786 - 787 - return error ? error : count; 751 + error = rohm_ts_update_setting(ts, SWAP_XY, val); 752 + return error ?: count; 788 753 } 789 754 790 755 static ssize_t inv_x_show(struct device *dev, struct device_attribute *attr, ··· 779 772 struct i2c_client *client = to_i2c_client(dev); 780 773 struct rohm_ts_data *ts = i2c_get_clientdata(client); 781 774 782 - return sprintf(buf, "%d\n", !!(ts->setup2 & INV_X)); 775 + return sysfs_emit(buf, "%d\n", !!(ts->setup2 & INV_X)); 783 776 } 784 777 785 778 static ssize_t inv_x_store(struct device *dev, struct device_attribute *attr, ··· 794 787 if (error) 795 788 return error; 796 789 797 - error = mutex_lock_interruptible(&ts->input->mutex); 798 - if (error) 799 - return error; 800 - 801 - if (val) 802 - ts->setup2 |= INV_X; 803 - else 804 - ts->setup2 &= ~INV_X; 805 - 806 - if (ts->initialized) 807 - error = i2c_smbus_write_byte_data(ts->client, COMMON_SETUP2, 808 - ts->setup2); 809 - 810 - mutex_unlock(&ts->input->mutex); 811 - 812 - return error ? error : count; 790 + error = rohm_ts_update_setting(ts, INV_X, val); 791 + return error ?: count; 813 792 } 814 793 815 794 static ssize_t inv_y_show(struct device *dev, struct device_attribute *attr, ··· 804 811 struct i2c_client *client = to_i2c_client(dev); 805 812 struct rohm_ts_data *ts = i2c_get_clientdata(client); 806 813 807 - return sprintf(buf, "%d\n", !!(ts->setup2 & INV_Y)); 814 + return sysfs_emit(buf, "%d\n", !!(ts->setup2 & INV_Y)); 808 815 } 809 816 810 817 static ssize_t inv_y_store(struct device *dev, struct device_attribute *attr, ··· 819 826 if (error) 820 827 return error; 821 828 822 - error = mutex_lock_interruptible(&ts->input->mutex); 823 - if (error) 824 - return error; 825 - 826 - if (val) 827 - ts->setup2 |= INV_Y; 828 - else 829 - ts->setup2 &= ~INV_Y; 830 - 831 - if (ts->initialized) 832 - error = i2c_smbus_write_byte_data(client, COMMON_SETUP2, 833 - ts->setup2); 834 - 835 - mutex_unlock(&ts->input->mutex); 836 - 837 - return error ? error : count; 829 + error = rohm_ts_update_setting(ts, INV_Y, val); 830 + return error ?: count; 838 831 } 839 832 840 833 static DEVICE_ATTR_RW(swap_xy); ··· 840 861 struct device *dev = &client->dev; 841 862 int error; 842 863 843 - disable_irq(client->irq); 864 + guard(disable_irq)(&client->irq); 844 865 845 866 /* 846 867 * Wait 200usec for reset ··· 1015 1036 /* controller CPU power on */ 1016 1037 error = i2c_smbus_write_byte_data(client, SYSTEM, 1017 1038 ANALOG_POWER_ON | CPU_POWER_ON); 1039 + if (error) 1040 + return error; 1018 1041 1019 - enable_irq(client->irq); 1020 - 1021 - return error; 1042 + return 0; 1022 1043 } 1023 1044 1024 1045 static int rohm_ts_power_off(struct i2c_client *client)
+1 -1
drivers/input/touchscreen/sur40.c
··· 672 672 return -ENODEV; 673 673 674 674 /* Allocate memory for our device state and initialize it. */ 675 - sur40 = kzalloc(sizeof(struct sur40_state), GFP_KERNEL); 675 + sur40 = kzalloc(sizeof(*sur40), GFP_KERNEL); 676 676 if (!sur40) 677 677 return -ENOMEM; 678 678
+1 -1
drivers/input/touchscreen/touchit213.c
··· 139 139 struct input_dev *input_dev; 140 140 int err; 141 141 142 - touchit213 = kzalloc(sizeof(struct touchit213), GFP_KERNEL); 142 + touchit213 = kzalloc(sizeof(*touchit213), GFP_KERNEL); 143 143 input_dev = input_allocate_device(); 144 144 if (!touchit213 || !input_dev) { 145 145 err = -ENOMEM;
+1 -1
drivers/input/touchscreen/touchright.c
··· 102 102 struct input_dev *input_dev; 103 103 int err; 104 104 105 - tr = kzalloc(sizeof(struct tr), GFP_KERNEL); 105 + tr = kzalloc(sizeof(*tr), GFP_KERNEL); 106 106 input_dev = input_allocate_device(); 107 107 if (!tr || !input_dev) { 108 108 err = -ENOMEM;
+1 -1
drivers/input/touchscreen/touchwin.c
··· 109 109 struct input_dev *input_dev; 110 110 int err; 111 111 112 - tw = kzalloc(sizeof(struct tw), GFP_KERNEL); 112 + tw = kzalloc(sizeof(*tw), GFP_KERNEL); 113 113 input_dev = input_allocate_device(); 114 114 if (!tw || !input_dev) { 115 115 err = -ENOMEM;
+1 -1
drivers/input/touchscreen/tsc40.c
··· 83 83 struct input_dev *input_dev; 84 84 int error; 85 85 86 - ptsc = kzalloc(sizeof(struct tsc_ser), GFP_KERNEL); 86 + ptsc = kzalloc(sizeof(*ptsc), GFP_KERNEL); 87 87 input_dev = input_allocate_device(); 88 88 if (!ptsc || !input_dev) { 89 89 error = -ENOMEM;
+8 -7
drivers/input/touchscreen/usbtouchscreen.c
··· 505 505 506 506 static int mtouch_alloc(struct usbtouch_usb *usbtouch) 507 507 { 508 + struct mtouch_priv *priv; 508 509 int ret; 509 510 510 - usbtouch->priv = kmalloc(sizeof(struct mtouch_priv), GFP_KERNEL); 511 - if (!usbtouch->priv) 511 + priv = kmalloc(sizeof(*priv), GFP_KERNEL); 512 + if (!priv) 512 513 return -ENOMEM; 513 514 515 + usbtouch->priv = priv; 514 516 ret = sysfs_create_group(&usbtouch->interface->dev.kobj, 515 517 &mtouch_attr_group); 516 518 if (ret) { ··· 926 924 struct nexio_priv *priv; 927 925 int ret = -ENOMEM; 928 926 929 - usbtouch->priv = kmalloc(sizeof(struct nexio_priv), GFP_KERNEL); 930 - if (!usbtouch->priv) 927 + priv = kmalloc(sizeof(*priv), GFP_KERNEL); 928 + if (!priv) 931 929 goto out_buf; 932 930 933 - priv = usbtouch->priv; 934 - 931 + usbtouch->priv = priv; 935 932 priv->ack_buf = kmemdup(nexio_ack_pkt, sizeof(nexio_ack_pkt), 936 933 GFP_KERNEL); 937 934 if (!priv->ack_buf) ··· 1662 1661 if (!endpoint) 1663 1662 return -ENXIO; 1664 1663 1665 - usbtouch = kzalloc(sizeof(struct usbtouch_usb), GFP_KERNEL); 1664 + usbtouch = kzalloc(sizeof(*usbtouch), GFP_KERNEL); 1666 1665 input_dev = input_allocate_device(); 1667 1666 if (!usbtouch || !input_dev) 1668 1667 goto out_free;
+16 -21
drivers/input/touchscreen/wacom_w8001.c
··· 380 380 struct w8001 *w8001 = input_get_drvdata(dev); 381 381 int err; 382 382 383 - err = mutex_lock_interruptible(&w8001->mutex); 384 - if (err) 385 - return err; 383 + scoped_guard(mutex_intr, &w8001->mutex) { 384 + if (w8001->open_count == 0) { 385 + err = w8001_command(w8001, W8001_CMD_START, false); 386 + if (err) 387 + return err; 388 + } 386 389 387 - if (w8001->open_count++ == 0) { 388 - err = w8001_command(w8001, W8001_CMD_START, false); 389 - if (err) 390 - w8001->open_count--; 390 + w8001->open_count++; 391 + return 0; 391 392 } 392 393 393 - mutex_unlock(&w8001->mutex); 394 - return err; 394 + return -EINTR; 395 395 } 396 396 397 397 static void w8001_close(struct input_dev *dev) 398 398 { 399 399 struct w8001 *w8001 = input_get_drvdata(dev); 400 400 401 - mutex_lock(&w8001->mutex); 401 + guard(mutex)(&w8001->mutex); 402 402 403 403 if (--w8001->open_count == 0) 404 404 w8001_command(w8001, W8001_CMD_STOP, false); 405 - 406 - mutex_unlock(&w8001->mutex); 407 405 } 408 406 409 407 static int w8001_detect(struct w8001 *w8001) ··· 593 595 struct w8001 *w8001; 594 596 struct input_dev *input_dev_pen; 595 597 struct input_dev *input_dev_touch; 596 - char basename[64]; 598 + char basename[64] = "Wacom Serial"; 597 599 int err, err_pen, err_touch; 598 600 599 - w8001 = kzalloc(sizeof(struct w8001), GFP_KERNEL); 601 + w8001 = kzalloc(sizeof(*w8001), GFP_KERNEL); 600 602 input_dev_pen = input_allocate_device(); 601 603 input_dev_touch = input_allocate_device(); 602 604 if (!w8001 || !input_dev_pen || !input_dev_touch) { ··· 623 625 /* For backwards-compatibility we compose the basename based on 624 626 * capabilities and then just append the tool type 625 627 */ 626 - strscpy(basename, "Wacom Serial", sizeof(basename)); 627 - 628 628 err_pen = w8001_setup_pen(w8001, basename, sizeof(basename)); 629 629 err_touch = w8001_setup_touch(w8001, basename, sizeof(basename)); 630 630 if (err_pen && err_touch) { ··· 631 635 } 632 636 633 637 if (!err_pen) { 634 - strscpy(w8001->pen_name, basename, sizeof(w8001->pen_name)); 635 - strlcat(w8001->pen_name, " Pen", sizeof(w8001->pen_name)); 638 + snprintf(w8001->pen_name, sizeof(w8001->pen_name), 639 + "%s Pen", basename); 636 640 input_dev_pen->name = w8001->pen_name; 637 641 638 642 w8001_set_devdata(input_dev_pen, w8001, serio); ··· 647 651 } 648 652 649 653 if (!err_touch) { 650 - strscpy(w8001->touch_name, basename, sizeof(w8001->touch_name)); 651 - strlcat(w8001->touch_name, " Finger", 652 - sizeof(w8001->touch_name)); 654 + snprintf(w8001->touch_name, sizeof(w8001->touch_name), 655 + "%s Finger", basename); 653 656 input_dev_touch->name = w8001->touch_name; 654 657 655 658 w8001_set_devdata(input_dev_touch, w8001, serio);
+1
drivers/input/vivaldi-fmap.c
··· 36 36 } 37 37 EXPORT_SYMBOL_GPL(vivaldi_function_row_physmap_show); 38 38 39 + MODULE_DESCRIPTION("Helpers for ChromeOS Vivaldi keyboard function row mapping"); 39 40 MODULE_LICENSE("GPL");
+4 -3
include/linux/input.h
··· 275 275 * it may not sleep 276 276 * @events: event sequence handler. This method is being called by 277 277 * input core with interrupts disabled and dev->event_lock 278 - * spinlock held and so it may not sleep 278 + * spinlock held and so it may not sleep. The method must return 279 + * number of events passed to it. 279 280 * @filter: similar to @event; separates normal event handlers from 280 281 * "filters". 281 282 * @match: called after comparing device's id with handler's id_table ··· 313 312 void *private; 314 313 315 314 void (*event)(struct input_handle *handle, unsigned int type, unsigned int code, int value); 316 - void (*events)(struct input_handle *handle, 317 - const struct input_value *vals, unsigned int count); 315 + unsigned int (*events)(struct input_handle *handle, 316 + struct input_value *vals, unsigned int count); 318 317 bool (*filter)(struct input_handle *handle, unsigned int type, unsigned int code, int value); 319 318 bool (*match)(struct input_handler *handler, struct input_dev *dev); 320 319 int (*connect)(struct input_handler *handler, struct input_dev *dev, const struct input_device_id *id);
+4
include/linux/interrupt.h
··· 5 5 6 6 #include <linux/kernel.h> 7 7 #include <linux/bitops.h> 8 + #include <linux/cleanup.h> 8 9 #include <linux/cpumask.h> 9 10 #include <linux/irqreturn.h> 10 11 #include <linux/irqnr.h> ··· 235 234 extern void enable_percpu_irq(unsigned int irq, unsigned int type); 236 235 extern bool irq_percpu_is_enabled(unsigned int irq); 237 236 extern void irq_wake_thread(unsigned int irq, void *dev_id); 237 + 238 + DEFINE_LOCK_GUARD_1(disable_irq, int, 239 + disable_irq(*_T->lock), enable_irq(*_T->lock)) 238 240 239 241 extern void disable_nmi_nosync(unsigned int irq); 240 242 extern void disable_percpu_nmi(unsigned int irq);