Input updates for v6.11-rc0

- 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.
 -----BEGIN PGP SIGNATURE-----
 
 iHUEABYIAB0WIQST2eWILY88ieB2DOtAj56VGEWXnAUCZpWmqQAKCRBAj56VGEWX
 nE00AQDsikkxIpF5GJo3mhHLHQc5noEB/zwwLNTqEmV/ThdffwD/bQmr0C0M1dhz
 fOM9NqeyhwKkgGd389AIzv/dV7KIGwI=
 =rQCl
 -----END PGP SIGNATURE-----

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
  ...
This commit is contained in:
Linus Torvalds 2024-07-19 16:51:39 -07:00
commit 8e5c0abfa0
146 changed files with 1235 additions and 1051 deletions

View File

@ -1,60 +0,0 @@
TI-NSPIRE Keypad
Required properties:
- compatible: Compatible property value should be "ti,nspire-keypad".
- reg: Physical base address of the peripheral and length of memory mapped
region.
- interrupts: The interrupt number for the peripheral.
- scan-interval: How often to scan in us. Based on a APB speed of 33MHz, the
maximum and minimum delay time is ~2000us and ~500us respectively
- row-delay: How long to wait before scanning each row.
- clocks: The clock this peripheral is attached to.
- linux,keymap: The keymap to use
(see Documentation/devicetree/bindings/input/matrix-keymap.txt)
Optional properties:
- active-low: Specify that the keypad is active low (i.e. logical low signifies
a key press).
Example:
input {
compatible = "ti,nspire-keypad";
reg = <0x900E0000 0x1000>;
interrupts = <16>;
scan-interval = <1000>;
row-delay = <200>;
clocks = <&apb_pclk>;
linux,keymap = <
0x0000001c 0x0001001c 0x00040039
0x0005002c 0x00060015 0x0007000b
0x0008000f 0x0100002d 0x01010011
0x0102002f 0x01030004 0x01040016
0x01050014 0x0106001f 0x01070002
0x010a006a 0x02000013 0x02010010
0x02020019 0x02030007 0x02040018
0x02050031 0x02060032 0x02070005
0x02080028 0x0209006c 0x03000026
0x03010025 0x03020024 0x0303000a
0x03040017 0x03050023 0x03060022
0x03070008 0x03080035 0x03090069
0x04000021 0x04010012 0x04020020
0x0404002e 0x04050030 0x0406001e
0x0407000d 0x04080037 0x04090067
0x05010038 0x0502000c 0x0503001b
0x05040034 0x0505001a 0x05060006
0x05080027 0x0509000e 0x050a006f
0x0600002b 0x0602004e 0x06030068
0x06040003 0x0605006d 0x06060009
0x06070001 0x0609000f 0x0708002a
0x0709001d 0x070a0033 >;
};

View File

@ -0,0 +1,74 @@
# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/input/ti,nspire-keypad.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#
title: TI-NSPIRE Keypad
maintainers:
- Andrew Davis <afd@ti.com>
allOf:
- $ref: input.yaml#
- $ref: matrix-keymap.yaml#
properties:
compatible:
enum:
- ti,nspire-keypad
reg:
maxItems: 1
interrupts:
maxItems: 1
clocks:
maxItems: 1
scan-interval:
$ref: /schemas/types.yaml#/definitions/uint32
description: How often to scan in us. Based on a APB speed of 33MHz, the
maximum and minimum delay time is ~2000us and ~500us respectively
row-delay:
$ref: /schemas/types.yaml#/definitions/uint32
description: How long to wait between scanning each row in us.
active-low:
description: Specify that the keypad is active low.
required:
- compatible
- reg
- interrupts
- clocks
- scan-interval
- row-delay
- linux,keymap
unevaluatedProperties: false
examples:
- |
#include <dt-bindings/input/input.h>
keypad@900e0000 {
compatible = "ti,nspire-keypad";
reg = <0x900e0000 0x1000>;
interrupts = <16>;
clocks = <&apb_pclk>;
scan-interval = <1000>;
row-delay = <200>;
linux,keymap = <
MATRIX_KEY(0, 0, KEY_ENTER)
MATRIX_KEY(0, 1, KEY_ENTER)
MATRIX_KEY(0, 4, KEY_SPACE)
MATRIX_KEY(0, 5, KEY_Z)
MATRIX_KEY(0, 6, KEY_Y)
MATRIX_KEY(0, 7, KEY_0)
>;
};

View File

@ -57,6 +57,7 @@ Optional properties:
pendown-gpio (u32). pendown-gpio (u32).
pendown-gpio GPIO handle describing the pin the !PENIRQ pendown-gpio GPIO handle describing the pin the !PENIRQ
line is connected to. line is connected to.
ti,hsync-gpios GPIO line to poll for hsync
wakeup-source use any event on touchscreen as wakeup event. wakeup-source use any event on touchscreen as wakeup event.
(Legacy property support: "linux,wakeup") (Legacy property support: "linux,wakeup")
touchscreen-size-x General touchscreen binding, see [1]. touchscreen-size-x General touchscreen binding, see [1].

View File

@ -39,6 +39,7 @@ properties:
- edt,edt-ft5406 - edt,edt-ft5406
- edt,edt-ft5506 - edt,edt-ft5506
- evervision,ev-ft5726 - evervision,ev-ft5726
- focaltech,ft5426
- focaltech,ft5452 - focaltech,ft5452
- focaltech,ft6236 - focaltech,ft6236
- focaltech,ft8719 - focaltech,ft8719

View File

@ -14,10 +14,14 @@ allOf:
properties: properties:
compatible: compatible:
enum: oneOf:
- eeti,exc3000 - const: eeti,exc3000
- eeti,exc80h60 - const: eeti,exc80h60
- eeti,exc80h84 - const: eeti,exc80h84
- items:
- enum:
- eeti,exc81w32
- const: eeti,exc80h84
reg: reg:
const: 0x2a const: 0x2a
interrupts: interrupts:

View File

@ -1,25 +0,0 @@
* Elan eKTF2127 I2C touchscreen controller
Required properties:
- compatible : "elan,ektf2127" or "elan,ektf2132"
- reg : I2C slave address of the chip (0x40)
- interrupts : interrupt specification for the ektf2127 interrupt
- power-gpios : GPIO specification for the pin connected to the
ektf2127's wake input. This needs to be driven high
to take ektf2127 out of its low power state
For additional optional properties see: touchscreen.txt
Example:
i2c@00000000 {
ektf2127: touchscreen@15 {
compatible = "elan,ektf2127";
reg = <0x15>;
interrupt-parent = <&pio>;
interrupts = <6 11 IRQ_TYPE_EDGE_FALLING>
power-gpios = <&pio 1 3 GPIO_ACTIVE_HIGH>;
touchscreen-inverted-x;
touchscreen-swapped-x-y;
};
};

View File

@ -0,0 +1,58 @@
# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
%YAML 1.2
---
$id: http://devicetree.org/schemas/input/touchscreen/elan,ektf2127.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#
title: Elan eKTF2127 I2C touchscreen controller
maintainers:
- Siebren Vroegindeweij <siebren.vroegindeweij@hotmail.com>
allOf:
- $ref: touchscreen.yaml#
properties:
compatible:
enum:
- elan,ektf2127
- elan,ektf2132
- elan,ektf2232
reg:
maxItems: 1
interrupts:
maxItems: 1
power-gpios:
maxItems: 1
required:
- compatible
- reg
- interrupts
- power-gpios
unevaluatedProperties: false
examples:
- |
#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/interrupt-controller/irq.h>
i2c {
#address-cells = <1>;
#size-cells = <0>;
touchscreen@15 {
compatible = "elan,ektf2127";
reg = <0x15>;
interrupt-parent = <&pio>;
interrupts = <6 11 IRQ_TYPE_EDGE_FALLING>;
power-gpios = <&pio 1 3 GPIO_ACTIVE_HIGH>;
touchscreen-inverted-x;
touchscreen-swapped-x-y;
};
};
...

View File

@ -15,6 +15,7 @@ allOf:
properties: properties:
compatible: compatible:
enum: enum:
- himax,hx83100a
- himax,hx83112b - himax,hx83112b
reg: reg:

View File

@ -16,6 +16,7 @@ properties:
compatible: compatible:
enum: enum:
- imagis,ist3032c - imagis,ist3032c
- imagis,ist3038
- imagis,ist3038b - imagis,ist3038b
- imagis,ist3038c - imagis,ist3038c

View File

@ -288,8 +288,8 @@ static void evdev_pass_values(struct evdev_client *client,
/* /*
* Pass incoming events to all connected clients. * Pass incoming events to all connected clients.
*/ */
static void evdev_events(struct input_handle *handle, static unsigned int evdev_events(struct input_handle *handle,
const struct input_value *vals, unsigned int count) struct input_value *vals, unsigned int count)
{ {
struct evdev *evdev = handle->private; struct evdev *evdev = handle->private;
struct evdev_client *client; struct evdev_client *client;
@ -306,17 +306,8 @@ static void evdev_events(struct input_handle *handle,
evdev_pass_values(client, vals, count, ev_time); evdev_pass_values(client, vals, count, ev_time);
rcu_read_unlock(); rcu_read_unlock();
}
/* return count;
* Pass incoming event to all connected clients.
*/
static void evdev_event(struct input_handle *handle,
unsigned int type, unsigned int code, int value)
{
struct input_value vals[] = { { type, code, value } };
evdev_events(handle, vals, 1);
} }
static int evdev_fasync(int fd, struct file *file, int on) static int evdev_fasync(int fd, struct file *file, int on)
@ -1418,7 +1409,6 @@ static const struct input_device_id evdev_ids[] = {
MODULE_DEVICE_TABLE(input, evdev_ids); MODULE_DEVICE_TABLE(input, evdev_ids);
static struct input_handler evdev_handler = { static struct input_handler evdev_handler = {
.event = evdev_event,
.events = evdev_events, .events = evdev_events,
.connect = evdev_connect, .connect = evdev_connect,
.disconnect = evdev_disconnect, .disconnect = evdev_disconnect,

View File

@ -43,7 +43,7 @@ static int emu_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
struct gameport *port; struct gameport *port;
int error; int error;
emu = kzalloc(sizeof(struct emu), GFP_KERNEL); emu = kzalloc(sizeof(*emu), GFP_KERNEL);
port = gameport_allocate_port(); port = gameport_allocate_port();
if (!emu || !port) { if (!emu || !port) {
printk(KERN_ERR "emu10k1-gp: Memory allocation failed\n"); printk(KERN_ERR "emu10k1-gp: Memory allocation failed\n");

View File

@ -68,7 +68,7 @@ static int fm801_gp_probe(struct pci_dev *pci, const struct pci_device_id *id)
struct gameport *port; struct gameport *port;
int error; int error;
gp = kzalloc(sizeof(struct fm801_gp), GFP_KERNEL); gp = kzalloc(sizeof(*gp), GFP_KERNEL);
port = gameport_allocate_port(); port = gameport_allocate_port();
if (!gp || !port) { if (!gp || !port) {
printk(KERN_ERR "fm801-gp: Memory allocation failed\n"); printk(KERN_ERR "fm801-gp: Memory allocation failed\n");

View File

@ -372,7 +372,7 @@ static int gameport_queue_event(void *object, struct module *owner,
} }
} }
event = kmalloc(sizeof(struct gameport_event), GFP_ATOMIC); event = kmalloc(sizeof(*event), GFP_ATOMIC);
if (!event) { if (!event) {
pr_err("Not enough memory to queue event %d\n", event_type); pr_err("Not enough memory to queue event %d\n", event_type);
retval = -ENOMEM; retval = -ENOMEM;

View File

@ -120,7 +120,7 @@ static int ns558_isa_probe(int io)
return -EBUSY; return -EBUSY;
} }
ns558 = kzalloc(sizeof(struct ns558), GFP_KERNEL); ns558 = kzalloc(sizeof(*ns558), GFP_KERNEL);
port = gameport_allocate_port(); port = gameport_allocate_port();
if (!ns558 || !port) { if (!ns558 || !port) {
printk(KERN_ERR "ns558: Memory allocation failed.\n"); printk(KERN_ERR "ns558: Memory allocation failed.\n");
@ -192,7 +192,7 @@ static int ns558_pnp_probe(struct pnp_dev *dev, const struct pnp_device_id *did)
if (!request_region(ioport, iolen, "ns558-pnp")) if (!request_region(ioport, iolen, "ns558-pnp"))
return -EBUSY; return -EBUSY;
ns558 = kzalloc(sizeof(struct ns558), GFP_KERNEL); ns558 = kzalloc(sizeof(*ns558), GFP_KERNEL);
port = gameport_allocate_port(); port = gameport_allocate_port();
if (!ns558 || !port) { if (!ns558 || !port) {
printk(KERN_ERR "ns558: Memory allocation failed\n"); printk(KERN_ERR "ns558: Memory allocation failed\n");

View File

@ -99,45 +99,13 @@ static void input_stop_autorepeat(struct input_dev *dev)
del_timer(&dev->timer); del_timer(&dev->timer);
} }
/*
* Pass event first through all filters and then, if event has not been
* filtered out, through all open handles. This function is called with
* dev->event_lock held and interrupts disabled.
*/
static unsigned int input_to_handler(struct input_handle *handle,
struct input_value *vals, unsigned int count)
{
struct input_handler *handler = handle->handler;
struct input_value *end = vals;
struct input_value *v;
if (handler->filter) {
for (v = vals; v != vals + count; v++) {
if (handler->filter(handle, v->type, v->code, v->value))
continue;
if (end != v)
*end = *v;
end++;
}
count = end - vals;
}
if (!count)
return 0;
if (handler->events)
handler->events(handle, vals, count);
else if (handler->event)
for (v = vals; v != vals + count; v++)
handler->event(handle, v->type, v->code, v->value);
return count;
}
/* /*
* Pass values first through all filters and then, if event has not been * Pass values first through all filters and then, if event has not been
* filtered out, through all open handles. This function is called with * filtered out, through all open handles. This order is achieved by placing
* dev->event_lock held and interrupts disabled. * filters at the head of the list of handles attached to the device, and
* placing regular handles at the tail of the list.
*
* This function is called with dev->event_lock held and interrupts disabled.
*/ */
static void input_pass_values(struct input_dev *dev, static void input_pass_values(struct input_dev *dev,
struct input_value *vals, unsigned int count) struct input_value *vals, unsigned int count)
@ -147,18 +115,16 @@ static void input_pass_values(struct input_dev *dev,
lockdep_assert_held(&dev->event_lock); lockdep_assert_held(&dev->event_lock);
if (!count)
return;
rcu_read_lock(); rcu_read_lock();
handle = rcu_dereference(dev->grab); handle = rcu_dereference(dev->grab);
if (handle) { if (handle) {
count = input_to_handler(handle, vals, count); count = handle->handler->events(handle, vals, count);
} else { } else {
list_for_each_entry_rcu(handle, &dev->h_list, d_node) list_for_each_entry_rcu(handle, &dev->h_list, d_node)
if (handle->open) { if (handle->open) {
count = input_to_handler(handle, vals, count); count = handle->handler->events(handle, vals,
count);
if (!count) if (!count)
break; break;
} }
@ -354,9 +320,6 @@ static void input_event_dispose(struct input_dev *dev, int disposition,
if ((disposition & INPUT_PASS_TO_DEVICE) && dev->event) if ((disposition & INPUT_PASS_TO_DEVICE) && dev->event)
dev->event(dev, type, code, value); dev->event(dev, type, code, value);
if (!dev->vals)
return;
if (disposition & INPUT_PASS_TO_HANDLERS) { if (disposition & INPUT_PASS_TO_HANDLERS) {
struct input_value *v; struct input_value *v;
@ -2013,22 +1976,41 @@ struct input_dev *input_allocate_device(void)
struct input_dev *dev; struct input_dev *dev;
dev = kzalloc(sizeof(*dev), GFP_KERNEL); dev = kzalloc(sizeof(*dev), GFP_KERNEL);
if (dev) { if (!dev)
dev->dev.type = &input_dev_type; return NULL;
dev->dev.class = &input_class;
device_initialize(&dev->dev);
mutex_init(&dev->mutex);
spin_lock_init(&dev->event_lock);
timer_setup(&dev->timer, NULL, 0);
INIT_LIST_HEAD(&dev->h_list);
INIT_LIST_HEAD(&dev->node);
dev_set_name(&dev->dev, "input%lu", /*
(unsigned long)atomic_inc_return(&input_no)); * Start with space for SYN_REPORT + 7 EV_KEY/EV_MSC events + 2 spare,
* see input_estimate_events_per_packet(). We will tune the number
__module_get(THIS_MODULE); * when we register the device.
*/
dev->max_vals = 10;
dev->vals = kcalloc(dev->max_vals, sizeof(*dev->vals), GFP_KERNEL);
if (!dev->vals) {
kfree(dev);
return NULL;
} }
mutex_init(&dev->mutex);
spin_lock_init(&dev->event_lock);
timer_setup(&dev->timer, NULL, 0);
INIT_LIST_HEAD(&dev->h_list);
INIT_LIST_HEAD(&dev->node);
dev->dev.type = &input_dev_type;
dev->dev.class = &input_class;
device_initialize(&dev->dev);
/*
* From this point on we can no longer simply "kfree(dev)", we need
* to use input_free_device() so that device core properly frees its
* resources associated with the input device.
*/
dev_set_name(&dev->dev, "input%lu",
(unsigned long)atomic_inc_return(&input_no));
__module_get(THIS_MODULE);
return dev; return dev;
} }
EXPORT_SYMBOL(input_allocate_device); EXPORT_SYMBOL(input_allocate_device);
@ -2368,6 +2350,35 @@ bool input_device_enabled(struct input_dev *dev)
} }
EXPORT_SYMBOL_GPL(input_device_enabled); EXPORT_SYMBOL_GPL(input_device_enabled);
static int input_device_tune_vals(struct input_dev *dev)
{
struct input_value *vals;
unsigned int packet_size;
unsigned int max_vals;
packet_size = input_estimate_events_per_packet(dev);
if (dev->hint_events_per_packet < packet_size)
dev->hint_events_per_packet = packet_size;
max_vals = dev->hint_events_per_packet + 2;
if (dev->max_vals >= max_vals)
return 0;
vals = kcalloc(max_vals, sizeof(*vals), GFP_KERNEL);
if (!vals)
return -ENOMEM;
spin_lock_irq(&dev->event_lock);
dev->max_vals = max_vals;
swap(dev->vals, vals);
spin_unlock_irq(&dev->event_lock);
/* Because of swap() above, this frees the old vals memory */
kfree(vals);
return 0;
}
/** /**
* input_register_device - register device with input core * input_register_device - register device with input core
* @dev: device to be registered * @dev: device to be registered
@ -2395,7 +2406,6 @@ int input_register_device(struct input_dev *dev)
{ {
struct input_devres *devres = NULL; struct input_devres *devres = NULL;
struct input_handler *handler; struct input_handler *handler;
unsigned int packet_size;
const char *path; const char *path;
int error; int error;
@ -2423,16 +2433,9 @@ int input_register_device(struct input_dev *dev)
/* Make sure that bitmasks not mentioned in dev->evbit are clean. */ /* Make sure that bitmasks not mentioned in dev->evbit are clean. */
input_cleanse_bitmasks(dev); input_cleanse_bitmasks(dev);
packet_size = input_estimate_events_per_packet(dev); error = input_device_tune_vals(dev);
if (dev->hint_events_per_packet < packet_size) if (error)
dev->hint_events_per_packet = packet_size;
dev->max_vals = dev->hint_events_per_packet + 2;
dev->vals = kcalloc(dev->max_vals, sizeof(*dev->vals), GFP_KERNEL);
if (!dev->vals) {
error = -ENOMEM;
goto err_devres_free; goto err_devres_free;
}
/* /*
* If delay and period are pre-set by the driver, then autorepeating * If delay and period are pre-set by the driver, then autorepeating
@ -2452,7 +2455,7 @@ int input_register_device(struct input_dev *dev)
error = device_add(&dev->dev); error = device_add(&dev->dev);
if (error) if (error)
goto err_free_vals; goto err_devres_free;
path = kobject_get_path(&dev->dev.kobj, GFP_KERNEL); path = kobject_get_path(&dev->dev.kobj, GFP_KERNEL);
pr_info("%s as %s\n", pr_info("%s as %s\n",
@ -2482,9 +2485,6 @@ int input_register_device(struct input_dev *dev)
err_device_del: err_device_del:
device_del(&dev->dev); device_del(&dev->dev);
err_free_vals:
kfree(dev->vals);
dev->vals = NULL;
err_devres_free: err_devres_free:
devres_free(devres); devres_free(devres);
return error; return error;
@ -2517,6 +2517,77 @@ void input_unregister_device(struct input_dev *dev)
} }
EXPORT_SYMBOL(input_unregister_device); EXPORT_SYMBOL(input_unregister_device);
static int input_handler_check_methods(const struct input_handler *handler)
{
int count = 0;
if (handler->filter)
count++;
if (handler->events)
count++;
if (handler->event)
count++;
if (count > 1) {
pr_err("%s: only one event processing method can be defined (%s)\n",
__func__, handler->name);
return -EINVAL;
}
return 0;
}
/*
* An implementation of input_handler's events() method that simply
* invokes handler->event() method for each event one by one.
*/
static unsigned int input_handler_events_default(struct input_handle *handle,
struct input_value *vals,
unsigned int count)
{
struct input_handler *handler = handle->handler;
struct input_value *v;
for (v = vals; v != vals + count; v++)
handler->event(handle, v->type, v->code, v->value);
return count;
}
/*
* An implementation of input_handler's events() method that invokes
* handler->filter() method for each event one by one and removes events
* that were filtered out from the "vals" array.
*/
static unsigned int input_handler_events_filter(struct input_handle *handle,
struct input_value *vals,
unsigned int count)
{
struct input_handler *handler = handle->handler;
struct input_value *end = vals;
struct input_value *v;
for (v = vals; v != vals + count; v++) {
if (handler->filter(handle, v->type, v->code, v->value))
continue;
if (end != v)
*end = *v;
end++;
}
return end - vals;
}
/*
* An implementation of input_handler's events() method that does nothing.
*/
static unsigned int input_handler_events_null(struct input_handle *handle,
struct input_value *vals,
unsigned int count)
{
return count;
}
/** /**
* input_register_handler - register a new input handler * input_register_handler - register a new input handler
* @handler: handler to be registered * @handler: handler to be registered
@ -2530,12 +2601,23 @@ int input_register_handler(struct input_handler *handler)
struct input_dev *dev; struct input_dev *dev;
int error; int error;
error = mutex_lock_interruptible(&input_mutex); error = input_handler_check_methods(handler);
if (error) if (error)
return error; return error;
INIT_LIST_HEAD(&handler->h_list); INIT_LIST_HEAD(&handler->h_list);
if (handler->filter)
handler->events = input_handler_events_filter;
else if (handler->event)
handler->events = input_handler_events_default;
else if (!handler->events)
handler->events = input_handler_events_null;
error = mutex_lock_interruptible(&input_mutex);
if (error)
return error;
list_add_tail(&handler->node, &input_handler_list); list_add_tail(&handler->node, &input_handler_list);
list_for_each_entry(dev, &input_dev_list, node) list_for_each_entry(dev, &input_dev_list, node)

View File

@ -249,7 +249,7 @@ static int a3d_connect(struct gameport *gameport, struct gameport_driver *drv)
int i; int i;
int err; int err;
a3d = kzalloc(sizeof(struct a3d), GFP_KERNEL); a3d = kzalloc(sizeof(*a3d), GFP_KERNEL);
input_dev = input_allocate_device(); input_dev = input_allocate_device();
if (!a3d || !input_dev) { if (!a3d || !input_dev) {
err = -ENOMEM; err = -ENOMEM;

View File

@ -15,20 +15,26 @@
struct adc_joystick_axis { struct adc_joystick_axis {
u32 code; u32 code;
s32 range[2]; bool inverted;
s32 fuzz;
s32 flat;
}; };
struct adc_joystick { struct adc_joystick {
struct input_dev *input; struct input_dev *input;
struct iio_cb_buffer *buffer; struct iio_cb_buffer *buffer;
struct adc_joystick_axis *axes;
struct iio_channel *chans; struct iio_channel *chans;
int num_chans; unsigned int num_chans;
bool polled; struct adc_joystick_axis axes[] __counted_by(num_chans);
}; };
static int adc_joystick_invert(struct input_dev *dev,
unsigned int axis, int val)
{
int min = input_abs_get_min(dev, axis);
int max = input_abs_get_max(dev, axis);
return (max + min) - val;
}
static void adc_joystick_poll(struct input_dev *input) static void adc_joystick_poll(struct input_dev *input)
{ {
struct adc_joystick *joy = input_get_drvdata(input); struct adc_joystick *joy = input_get_drvdata(input);
@ -38,6 +44,8 @@ static void adc_joystick_poll(struct input_dev *input)
ret = iio_read_channel_raw(&joy->chans[i], &val); ret = iio_read_channel_raw(&joy->chans[i], &val);
if (ret < 0) if (ret < 0)
return; return;
if (joy->axes[i].inverted)
val = adc_joystick_invert(input, i, val);
input_report_abs(input, joy->axes[i].code, val); input_report_abs(input, joy->axes[i].code, val);
} }
input_sync(input); input_sync(input);
@ -86,6 +94,8 @@ static int adc_joystick_handle(const void *data, void *private)
val = sign_extend32(val, msb); val = sign_extend32(val, msb);
else else
val &= GENMASK(msb, 0); val &= GENMASK(msb, 0);
if (joy->axes[i].inverted)
val = adc_joystick_invert(joy->input, i, val);
input_report_abs(joy->input, joy->axes[i].code, val); input_report_abs(joy->input, joy->axes[i].code, val);
} }
@ -121,9 +131,11 @@ static void adc_joystick_cleanup(void *data)
static int adc_joystick_set_axes(struct device *dev, struct adc_joystick *joy) static int adc_joystick_set_axes(struct device *dev, struct adc_joystick *joy)
{ {
struct adc_joystick_axis *axes; struct adc_joystick_axis *axes = joy->axes;
struct fwnode_handle *child; struct fwnode_handle *child;
int num_axes, error, i; s32 range[2], fuzz, flat;
unsigned int num_axes;
int error, i;
num_axes = device_get_child_node_count(dev); num_axes = device_get_child_node_count(dev);
if (!num_axes) { if (!num_axes) {
@ -137,10 +149,6 @@ static int adc_joystick_set_axes(struct device *dev, struct adc_joystick *joy)
return -EINVAL; return -EINVAL;
} }
axes = devm_kmalloc_array(dev, num_axes, sizeof(*axes), GFP_KERNEL);
if (!axes)
return -ENOMEM;
device_for_each_child_node(dev, child) { device_for_each_child_node(dev, child) {
error = fwnode_property_read_u32(child, "reg", &i); error = fwnode_property_read_u32(child, "reg", &i);
if (error) { if (error) {
@ -162,23 +170,25 @@ static int adc_joystick_set_axes(struct device *dev, struct adc_joystick *joy)
} }
error = fwnode_property_read_u32_array(child, "abs-range", error = fwnode_property_read_u32_array(child, "abs-range",
axes[i].range, 2); range, 2);
if (error) { if (error) {
dev_err(dev, "abs-range invalid or missing\n"); dev_err(dev, "abs-range invalid or missing\n");
goto err_fwnode_put; goto err_fwnode_put;
} }
fwnode_property_read_u32(child, "abs-fuzz", &axes[i].fuzz); if (range[0] > range[1]) {
fwnode_property_read_u32(child, "abs-flat", &axes[i].flat); dev_dbg(dev, "abs-axis %d inverted\n", i);
axes[i].inverted = true;
swap(range[0], range[1]);
}
fwnode_property_read_u32(child, "abs-fuzz", &fuzz);
fwnode_property_read_u32(child, "abs-flat", &flat);
input_set_abs_params(joy->input, axes[i].code, input_set_abs_params(joy->input, axes[i].code,
axes[i].range[0], axes[i].range[1], range[0], range[1], fuzz, flat);
axes[i].fuzz, axes[i].flat);
input_set_capability(joy->input, EV_ABS, axes[i].code);
} }
joy->axes = axes;
return 0; return 0;
err_fwnode_put: err_fwnode_put:
@ -186,23 +196,50 @@ static int adc_joystick_set_axes(struct device *dev, struct adc_joystick *joy)
return error; return error;
} }
static int adc_joystick_count_channels(struct device *dev,
const struct iio_channel *chans,
bool polled,
unsigned int *num_chans)
{
int bits;
int i;
/*
* Count how many channels we got. NULL terminated.
* Do not check the storage size if using polling.
*/
for (i = 0; chans[i].indio_dev; i++) {
if (polled)
continue;
bits = chans[i].channel->scan_type.storagebits;
if (!bits || bits > 16) {
dev_err(dev, "Unsupported channel storage size\n");
return -EINVAL;
}
if (bits != chans[0].channel->scan_type.storagebits) {
dev_err(dev, "Channels must have equal storage size\n");
return -EINVAL;
}
}
*num_chans = i;
return 0;
}
static int adc_joystick_probe(struct platform_device *pdev) static int adc_joystick_probe(struct platform_device *pdev)
{ {
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
struct iio_channel *chans;
struct adc_joystick *joy; struct adc_joystick *joy;
struct input_dev *input; struct input_dev *input;
unsigned int poll_interval = 0;
unsigned int num_chans;
int error; int error;
int bits;
int i;
unsigned int poll_interval;
joy = devm_kzalloc(dev, sizeof(*joy), GFP_KERNEL); chans = devm_iio_channel_get_all(dev);
if (!joy) error = PTR_ERR_OR_ZERO(chans);
return -ENOMEM; if (error) {
joy->chans = devm_iio_channel_get_all(dev);
if (IS_ERR(joy->chans)) {
error = PTR_ERR(joy->chans);
if (error != -EPROBE_DEFER) if (error != -EPROBE_DEFER)
dev_err(dev, "Unable to get IIO channels"); dev_err(dev, "Unable to get IIO channels");
return error; return error;
@ -216,28 +253,19 @@ static int adc_joystick_probe(struct platform_device *pdev)
} else if (poll_interval == 0) { } else if (poll_interval == 0) {
dev_err(dev, "Unable to get poll-interval\n"); dev_err(dev, "Unable to get poll-interval\n");
return -EINVAL; return -EINVAL;
} else {
joy->polled = true;
} }
/* error = adc_joystick_count_channels(dev, chans, poll_interval != 0,
* Count how many channels we got. NULL terminated. &num_chans);
* Do not check the storage size if using polling. if (error)
*/ return error;
for (i = 0; joy->chans[i].indio_dev; i++) {
if (joy->polled) joy = devm_kzalloc(dev, struct_size(joy, axes, num_chans), GFP_KERNEL);
continue; if (!joy)
bits = joy->chans[i].channel->scan_type.storagebits; return -ENOMEM;
if (!bits || bits > 16) {
dev_err(dev, "Unsupported channel storage size\n"); joy->chans = chans;
return -EINVAL; joy->num_chans = num_chans;
}
if (bits != joy->chans[0].channel->scan_type.storagebits) {
dev_err(dev, "Channels must have equal storage size\n");
return -EINVAL;
}
}
joy->num_chans = i;
input = devm_input_allocate_device(dev); input = devm_input_allocate_device(dev);
if (!input) { if (!input) {
@ -253,7 +281,7 @@ static int adc_joystick_probe(struct platform_device *pdev)
if (error) if (error)
return error; return error;
if (joy->polled) { if (poll_interval != 0) {
input_setup_polling(input, adc_joystick_poll); input_setup_polling(input, adc_joystick_poll);
input_set_poll_interval(input, poll_interval); input_set_poll_interval(input, poll_interval);
} else { } else {

View File

@ -456,7 +456,7 @@ static int adi_connect(struct gameport *gameport, struct gameport_driver *drv)
int i; int i;
int err; int err;
port = kzalloc(sizeof(struct adi_port), GFP_KERNEL); port = kzalloc(sizeof(*port), GFP_KERNEL);
if (!port) if (!port)
return -ENOMEM; return -ENOMEM;

View File

@ -582,7 +582,8 @@ static int analog_connect(struct gameport *gameport, struct gameport_driver *drv
int i; int i;
int err; int err;
if (!(port = kzalloc(sizeof(struct analog_port), GFP_KERNEL))) port = kzalloc(sizeof(*port), GFP_KERNEL);
if (!port)
return -ENOMEM; return -ENOMEM;
err = analog_init_port(gameport, drv, port); err = analog_init_port(gameport, drv, port);

View File

@ -237,7 +237,7 @@ static int as5011_probe(struct i2c_client *client)
return -ENODEV; return -ENODEV;
} }
as5011 = kmalloc(sizeof(struct as5011_device), GFP_KERNEL); as5011 = kmalloc(sizeof(*as5011), GFP_KERNEL);
input_dev = input_allocate_device(); input_dev = input_allocate_device();
if (!as5011 || !input_dev) { if (!as5011 || !input_dev) {
dev_err(&client->dev, dev_err(&client->dev,

View File

@ -141,7 +141,7 @@ static int cobra_connect(struct gameport *gameport, struct gameport_driver *drv)
int i, j; int i, j;
int err; int err;
cobra = kzalloc(sizeof(struct cobra), GFP_KERNEL); cobra = kzalloc(sizeof(*cobra), GFP_KERNEL);
if (!cobra) if (!cobra)
return -ENOMEM; return -ENOMEM;

View File

@ -587,7 +587,7 @@ static void db9_attach(struct parport *pp)
return; return;
} }
db9 = kzalloc(sizeof(struct db9), GFP_KERNEL); db9 = kzalloc(sizeof(*db9), GFP_KERNEL);
if (!db9) if (!db9)
goto err_unreg_pardev; goto err_unreg_pardev;

View File

@ -950,7 +950,7 @@ static void gc_attach(struct parport *pp)
return; return;
} }
gc = kzalloc(sizeof(struct gc), GFP_KERNEL); gc = kzalloc(sizeof(*gc), GFP_KERNEL);
if (!gc) { if (!gc) {
pr_err("Not enough memory\n"); pr_err("Not enough memory\n");
goto err_unreg_pardev; goto err_unreg_pardev;

View File

@ -222,7 +222,7 @@ static int gf2k_connect(struct gameport *gameport, struct gameport_driver *drv)
unsigned char data[GF2K_LENGTH]; unsigned char data[GF2K_LENGTH];
int i, err; int i, err;
gf2k = kzalloc(sizeof(struct gf2k), GFP_KERNEL); gf2k = kzalloc(sizeof(*gf2k), GFP_KERNEL);
input_dev = input_allocate_device(); input_dev = input_allocate_device();
if (!gf2k || !input_dev) { if (!gf2k || !input_dev) {
err = -ENOMEM; err = -ENOMEM;

View File

@ -284,7 +284,8 @@ static int grip_connect(struct gameport *gameport, struct gameport_driver *drv)
int i, j, t; int i, j, t;
int err; int err;
if (!(grip = kzalloc(sizeof(struct grip), GFP_KERNEL))) grip = kzalloc(sizeof(*grip), GFP_KERNEL);
if (!grip)
return -ENOMEM; return -ENOMEM;
grip->gameport = gameport; grip->gameport = gameport;

View File

@ -632,7 +632,8 @@ static int grip_connect(struct gameport *gameport, struct gameport_driver *drv)
struct grip_mp *grip; struct grip_mp *grip;
int err; int err;
if (!(grip = kzalloc(sizeof(struct grip_mp), GFP_KERNEL))) grip = kzalloc(sizeof(*grip), GFP_KERNEL);
if (!grip)
return -ENOMEM; return -ENOMEM;
grip->gameport = gameport; grip->gameport = gameport;

View File

@ -163,7 +163,7 @@ static int guillemot_connect(struct gameport *gameport, struct gameport_driver *
int i, t; int i, t;
int err; int err;
guillemot = kzalloc(sizeof(struct guillemot), GFP_KERNEL); guillemot = kzalloc(sizeof(*guillemot), GFP_KERNEL);
input_dev = input_allocate_device(); input_dev = input_allocate_device();
if (!guillemot || !input_dev) { if (!guillemot || !input_dev) {
err = -ENOMEM; err = -ENOMEM;

View File

@ -192,7 +192,7 @@ static int interact_connect(struct gameport *gameport, struct gameport_driver *d
int i, t; int i, t;
int err; int err;
interact = kzalloc(sizeof(struct interact), GFP_KERNEL); interact = kzalloc(sizeof(*interact), GFP_KERNEL);
input_dev = input_allocate_device(); input_dev = input_allocate_device();
if (!interact || !input_dev) { if (!interact || !input_dev) {
err = -ENOMEM; err = -ENOMEM;

View File

@ -132,7 +132,7 @@ static int magellan_connect(struct serio *serio, struct serio_driver *drv)
int err = -ENOMEM; int err = -ENOMEM;
int i; int i;
magellan = kzalloc(sizeof(struct magellan), GFP_KERNEL); magellan = kzalloc(sizeof(*magellan), GFP_KERNEL);
input_dev = input_allocate_device(); input_dev = input_allocate_device();
if (!magellan || !input_dev) if (!magellan || !input_dev)
goto fail1; goto fail1;

View File

@ -102,7 +102,7 @@ static int probe_maple_controller(struct device *dev)
struct input_dev *idev; struct input_dev *idev;
unsigned long data = be32_to_cpu(mdev->devinfo.function_data[0]); unsigned long data = be32_to_cpu(mdev->devinfo.function_data[0]);
pad = kzalloc(sizeof(struct dc_pad), GFP_KERNEL); pad = kzalloc(sizeof(*pad), GFP_KERNEL);
idev = input_allocate_device(); idev = input_allocate_device();
if (!pad || !idev) { if (!pad || !idev) {
error = -ENOMEM; error = -ENOMEM;

View File

@ -246,7 +246,7 @@ static int __init n64joy_probe(struct platform_device *pdev)
int err = 0; int err = 0;
u32 i, j, found = 0; u32 i, j, found = 0;
priv = kzalloc(sizeof(struct n64joy_priv), GFP_KERNEL); priv = kzalloc(sizeof(*priv), GFP_KERNEL);
if (!priv) if (!priv)
return -ENOMEM; return -ENOMEM;
mutex_init(&priv->n64joy_mutex); mutex_init(&priv->n64joy_mutex);

View File

@ -577,7 +577,7 @@ static int sw_connect(struct gameport *gameport, struct gameport_driver *drv)
comment[0] = 0; comment[0] = 0;
sw = kzalloc(sizeof(struct sw), GFP_KERNEL); sw = kzalloc(sizeof(*sw), GFP_KERNEL);
buf = kmalloc(SW_LENGTH, GFP_KERNEL); buf = kmalloc(SW_LENGTH, GFP_KERNEL);
idbuf = kmalloc(SW_LENGTH, GFP_KERNEL); idbuf = kmalloc(SW_LENGTH, GFP_KERNEL);
if (!sw || !buf || !idbuf) { if (!sw || !buf || !idbuf) {

View File

@ -199,7 +199,7 @@ static int spaceball_connect(struct serio *serio, struct serio_driver *drv)
if ((id = serio->id.id) > SPACEBALL_MAX_ID) if ((id = serio->id.id) > SPACEBALL_MAX_ID)
return -ENODEV; return -ENODEV;
spaceball = kmalloc(sizeof(struct spaceball), GFP_KERNEL); spaceball = kmalloc(sizeof(*spaceball), GFP_KERNEL);
input_dev = input_allocate_device(); input_dev = input_allocate_device();
if (!spaceball || !input_dev) if (!spaceball || !input_dev)
goto fail1; goto fail1;

View File

@ -147,7 +147,7 @@ static int spaceorb_connect(struct serio *serio, struct serio_driver *drv)
int err = -ENOMEM; int err = -ENOMEM;
int i; int i;
spaceorb = kzalloc(sizeof(struct spaceorb), GFP_KERNEL); spaceorb = kzalloc(sizeof(*spaceorb), GFP_KERNEL);
input_dev = input_allocate_device(); input_dev = input_allocate_device();
if (!spaceorb || !input_dev) if (!spaceorb || !input_dev)
goto fail1; goto fail1;

View File

@ -118,7 +118,7 @@ static int stinger_connect(struct serio *serio, struct serio_driver *drv)
struct input_dev *input_dev; struct input_dev *input_dev;
int err = -ENOMEM; int err = -ENOMEM;
stinger = kmalloc(sizeof(struct stinger), GFP_KERNEL); stinger = kmalloc(sizeof(*stinger), GFP_KERNEL);
input_dev = input_allocate_device(); input_dev = input_allocate_device();
if (!stinger || !input_dev) if (!stinger || !input_dev)
goto fail1; goto fail1;

View File

@ -348,7 +348,8 @@ static int tmdc_connect(struct gameport *gameport, struct gameport_driver *drv)
int i; int i;
int err; int err;
if (!(tmdc = kzalloc(sizeof(struct tmdc), GFP_KERNEL))) tmdc = kzalloc(sizeof(*tmdc), GFP_KERNEL);
if (!tmdc)
return -ENOMEM; return -ENOMEM;
tmdc->gameport = gameport; tmdc->gameport = gameport;

View File

@ -172,7 +172,7 @@ static void tgfx_attach(struct parport *pp)
return; return;
} }
tgfx = kzalloc(sizeof(struct tgfx), GFP_KERNEL); tgfx = kzalloc(sizeof(*tgfx), GFP_KERNEL);
if (!tgfx) { if (!tgfx) {
printk(KERN_ERR "turbografx.c: Not enough memory\n"); printk(KERN_ERR "turbografx.c: Not enough memory\n");
goto err_unreg_pardev; goto err_unreg_pardev;

View File

@ -171,7 +171,7 @@ static int twidjoy_connect(struct serio *serio, struct serio_driver *drv)
int err = -ENOMEM; int err = -ENOMEM;
int i; int i;
twidjoy = kzalloc(sizeof(struct twidjoy), GFP_KERNEL); twidjoy = kzalloc(sizeof(*twidjoy), GFP_KERNEL);
input_dev = input_allocate_device(); input_dev = input_allocate_device();
if (!twidjoy || !input_dev) if (!twidjoy || !input_dev)
goto fail1; goto fail1;

View File

@ -124,7 +124,7 @@ static int warrior_connect(struct serio *serio, struct serio_driver *drv)
struct input_dev *input_dev; struct input_dev *input_dev;
int err = -ENOMEM; int err = -ENOMEM;
warrior = kzalloc(sizeof(struct warrior), GFP_KERNEL); warrior = kzalloc(sizeof(*warrior), GFP_KERNEL);
input_dev = input_allocate_device(); input_dev = input_allocate_device();
if (!warrior || !input_dev) if (!warrior || !input_dev)
goto fail1; goto fail1;

View File

@ -1687,7 +1687,7 @@ static int xpad_led_probe(struct usb_xpad *xpad)
if (xpad->xtype != XTYPE_XBOX360 && xpad->xtype != XTYPE_XBOX360W) if (xpad->xtype != XTYPE_XBOX360 && xpad->xtype != XTYPE_XBOX360W)
return 0; return 0;
xpad->led = led = kzalloc(sizeof(struct xpad_led), GFP_KERNEL); xpad->led = led = kzalloc(sizeof(*led), GFP_KERNEL);
if (!led) if (!led)
return -ENOMEM; return -ENOMEM;
@ -2023,7 +2023,7 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id
break; break;
} }
xpad = kzalloc(sizeof(struct usb_xpad), GFP_KERNEL); xpad = kzalloc(sizeof(*xpad), GFP_KERNEL);
if (!xpad) if (!xpad)
return -ENOMEM; return -ENOMEM;

View File

@ -131,7 +131,7 @@ static int zhenhua_connect(struct serio *serio, struct serio_driver *drv)
struct input_dev *input_dev; struct input_dev *input_dev;
int err = -ENOMEM; int err = -ENOMEM;
zhenhua = kzalloc(sizeof(struct zhenhua), GFP_KERNEL); zhenhua = kzalloc(sizeof(*zhenhua), GFP_KERNEL);
input_dev = input_allocate_device(); input_dev = input_allocate_device();
if (!zhenhua || !input_dev) if (!zhenhua || !input_dev)
goto fail1; goto fail1;

View File

@ -1279,7 +1279,7 @@ static int atkbd_connect(struct serio *serio, struct serio_driver *drv)
struct input_dev *dev; struct input_dev *dev;
int err = -ENOMEM; int err = -ENOMEM;
atkbd = kzalloc(sizeof(struct atkbd), GFP_KERNEL); atkbd = kzalloc(sizeof(*atkbd), GFP_KERNEL);
dev = input_allocate_device(); dev = input_allocate_device();
if (!atkbd || !dev) if (!atkbd || !dev)
goto fail1; goto fail1;

View File

@ -86,7 +86,6 @@ struct cap11xx_priv {
struct device *dev; struct device *dev;
struct input_dev *idev; struct input_dev *idev;
const struct cap11xx_hw_model *model; const struct cap11xx_hw_model *model;
u8 id;
struct cap11xx_led *leds; struct cap11xx_led *leds;
int num_leds; int num_leds;
@ -104,27 +103,10 @@ struct cap11xx_hw_model {
u8 product_id; u8 product_id;
unsigned int num_channels; unsigned int num_channels;
unsigned int num_leds; unsigned int num_leds;
bool no_gain; bool has_gain;
}; bool has_irq_config;
bool has_sensitivity_control;
enum { bool has_signal_guard;
CAP1106,
CAP1126,
CAP1188,
CAP1203,
CAP1206,
CAP1293,
CAP1298
};
static const struct cap11xx_hw_model cap11xx_devices[] = {
[CAP1106] = { .product_id = 0x55, .num_channels = 6, .num_leds = 0, .no_gain = false },
[CAP1126] = { .product_id = 0x53, .num_channels = 6, .num_leds = 2, .no_gain = false },
[CAP1188] = { .product_id = 0x50, .num_channels = 8, .num_leds = 8, .no_gain = false },
[CAP1203] = { .product_id = 0x6d, .num_channels = 3, .num_leds = 0, .no_gain = true },
[CAP1206] = { .product_id = 0x67, .num_channels = 6, .num_leds = 0, .no_gain = true },
[CAP1293] = { .product_id = 0x6f, .num_channels = 3, .num_leds = 0, .no_gain = false },
[CAP1298] = { .product_id = 0x71, .num_channels = 8, .num_leds = 0, .no_gain = false },
}; };
static const struct reg_default cap11xx_reg_defaults[] = { static const struct reg_default cap11xx_reg_defaults[] = {
@ -224,7 +206,7 @@ static int cap11xx_init_keys(struct cap11xx_priv *priv)
} }
if (!of_property_read_u32(node, "microchip,sensor-gain", &u32_val)) { if (!of_property_read_u32(node, "microchip,sensor-gain", &u32_val)) {
if (priv->model->no_gain) { if (!priv->model->has_gain) {
dev_warn(dev, dev_warn(dev,
"This model doesn't support 'sensor-gain'\n"); "This model doesn't support 'sensor-gain'\n");
} else if (is_power_of_2(u32_val) && u32_val <= 8) { } else if (is_power_of_2(u32_val) && u32_val <= 8) {
@ -243,9 +225,7 @@ static int cap11xx_init_keys(struct cap11xx_priv *priv)
} }
if (of_property_read_bool(node, "microchip,irq-active-high")) { if (of_property_read_bool(node, "microchip,irq-active-high")) {
if (priv->id == CAP1106 || if (priv->model->has_irq_config) {
priv->id == CAP1126 ||
priv->id == CAP1188) {
error = regmap_update_bits(priv->regmap, error = regmap_update_bits(priv->regmap,
CAP11XX_REG_CONFIG2, CAP11XX_REG_CONFIG2,
CAP11XX_REG_CONFIG2_ALT_POL, CAP11XX_REG_CONFIG2_ALT_POL,
@ -296,7 +276,7 @@ static int cap11xx_init_keys(struct cap11xx_priv *priv)
if (!of_property_read_u32_array(node, "microchip,calib-sensitivity", if (!of_property_read_u32_array(node, "microchip,calib-sensitivity",
priv->calib_sensitivities, priv->calib_sensitivities,
priv->model->num_channels)) { priv->model->num_channels)) {
if (priv->id == CAP1293 || priv->id == CAP1298) { if (priv->model->has_sensitivity_control) {
for (i = 0; i < priv->model->num_channels; i++) { for (i = 0; i < priv->model->num_channels; i++) {
if (!is_power_of_2(priv->calib_sensitivities[i]) || if (!is_power_of_2(priv->calib_sensitivities[i]) ||
priv->calib_sensitivities[i] > 4) { priv->calib_sensitivities[i] > 4) {
@ -311,7 +291,7 @@ static int cap11xx_init_keys(struct cap11xx_priv *priv)
if (error) if (error)
return error; return error;
if (priv->id == CAP1298) { if (priv->model->num_channels > 4) {
error = cap11xx_write_calib_sens_config_2(priv); error = cap11xx_write_calib_sens_config_2(priv);
if (error) if (error)
return error; return error;
@ -333,7 +313,7 @@ static int cap11xx_init_keys(struct cap11xx_priv *priv)
} }
if (priv->signal_guard_inputs_mask) { if (priv->signal_guard_inputs_mask) {
if (priv->id == CAP1293 || priv->id == CAP1298) { if (priv->model->has_signal_guard) {
error = regmap_write(priv->regmap, error = regmap_write(priv->regmap,
CAP11XX_REG_SIGNAL_GUARD_ENABLE, CAP11XX_REG_SIGNAL_GUARD_ENABLE,
priv->signal_guard_inputs_mask); priv->signal_guard_inputs_mask);
@ -508,20 +488,16 @@ static int cap11xx_init_leds(struct device *dev,
static int cap11xx_i2c_probe(struct i2c_client *i2c_client) static int cap11xx_i2c_probe(struct i2c_client *i2c_client)
{ {
const struct i2c_device_id *id = i2c_client_get_device_id(i2c_client); const struct i2c_device_id *id;
const struct cap11xx_hw_model *cap;
struct device *dev = &i2c_client->dev; struct device *dev = &i2c_client->dev;
struct cap11xx_priv *priv; struct cap11xx_priv *priv;
const struct cap11xx_hw_model *cap;
int i, error; int i, error;
unsigned int val, rev; unsigned int val, rev;
if (id->driver_data >= ARRAY_SIZE(cap11xx_devices)) { id = i2c_client_get_device_id(i2c_client);
dev_err(dev, "Invalid device ID %lu\n", id->driver_data); cap = i2c_get_match_data(i2c_client);
return -EINVAL; if (!id || !cap || !cap->num_channels) {
}
cap = &cap11xx_devices[id->driver_data];
if (!cap || !cap->num_channels) {
dev_err(dev, "Invalid device configuration\n"); dev_err(dev, "Invalid device configuration\n");
return -EINVAL; return -EINVAL;
} }
@ -566,7 +542,6 @@ static int cap11xx_i2c_probe(struct i2c_client *i2c_client)
id->name, rev); id->name, rev);
priv->model = cap; priv->model = cap;
priv->id = id->driver_data;
dev_info(dev, "CAP11XX device detected, model %s, revision 0x%02x\n", dev_info(dev, "CAP11XX device detected, model %s, revision 0x%02x\n",
id->name, rev); id->name, rev);
@ -627,27 +602,67 @@ static int cap11xx_i2c_probe(struct i2c_client *i2c_client)
return 0; return 0;
} }
static const struct cap11xx_hw_model cap1106_model = {
.product_id = 0x55, .num_channels = 6, .num_leds = 0,
.has_gain = true,
.has_irq_config = true,
};
static const struct cap11xx_hw_model cap1126_model = {
.product_id = 0x53, .num_channels = 6, .num_leds = 2,
.has_gain = true,
.has_irq_config = true,
};
static const struct cap11xx_hw_model cap1188_model = {
.product_id = 0x50, .num_channels = 8, .num_leds = 8,
.has_gain = true,
.has_irq_config = true,
};
static const struct cap11xx_hw_model cap1203_model = {
.product_id = 0x6d, .num_channels = 3, .num_leds = 0,
};
static const struct cap11xx_hw_model cap1206_model = {
.product_id = 0x67, .num_channels = 6, .num_leds = 0,
};
static const struct cap11xx_hw_model cap1293_model = {
.product_id = 0x6f, .num_channels = 3, .num_leds = 0,
.has_gain = true,
.has_sensitivity_control = true,
.has_signal_guard = true,
};
static const struct cap11xx_hw_model cap1298_model = {
.product_id = 0x71, .num_channels = 8, .num_leds = 0,
.has_gain = true,
.has_sensitivity_control = true,
.has_signal_guard = true,
};
static const struct of_device_id cap11xx_dt_ids[] = { static const struct of_device_id cap11xx_dt_ids[] = {
{ .compatible = "microchip,cap1106", }, { .compatible = "microchip,cap1106", .data = &cap1106_model },
{ .compatible = "microchip,cap1126", }, { .compatible = "microchip,cap1126", .data = &cap1126_model },
{ .compatible = "microchip,cap1188", }, { .compatible = "microchip,cap1188", .data = &cap1188_model },
{ .compatible = "microchip,cap1203", }, { .compatible = "microchip,cap1203", .data = &cap1203_model },
{ .compatible = "microchip,cap1206", }, { .compatible = "microchip,cap1206", .data = &cap1206_model },
{ .compatible = "microchip,cap1293", }, { .compatible = "microchip,cap1293", .data = &cap1293_model },
{ .compatible = "microchip,cap1298", }, { .compatible = "microchip,cap1298", .data = &cap1298_model },
{} { }
}; };
MODULE_DEVICE_TABLE(of, cap11xx_dt_ids); MODULE_DEVICE_TABLE(of, cap11xx_dt_ids);
static const struct i2c_device_id cap11xx_i2c_ids[] = { static const struct i2c_device_id cap11xx_i2c_ids[] = {
{ "cap1106", CAP1106 }, { "cap1106", (kernel_ulong_t)&cap1106_model },
{ "cap1126", CAP1126 }, { "cap1126", (kernel_ulong_t)&cap1126_model },
{ "cap1188", CAP1188 }, { "cap1188", (kernel_ulong_t)&cap1188_model },
{ "cap1203", CAP1203 }, { "cap1203", (kernel_ulong_t)&cap1203_model },
{ "cap1206", CAP1206 }, { "cap1206", (kernel_ulong_t)&cap1206_model },
{ "cap1293", CAP1293 }, { "cap1293", (kernel_ulong_t)&cap1293_model },
{ "cap1298", CAP1298 }, { "cap1298", (kernel_ulong_t)&cap1298_model },
{} { }
}; };
MODULE_DEVICE_TABLE(i2c, cap11xx_i2c_ids); MODULE_DEVICE_TABLE(i2c, cap11xx_i2c_ids);

View File

@ -608,7 +608,7 @@ static int lkkbd_connect(struct serio *serio, struct serio_driver *drv)
int i; int i;
int err; int err;
lk = kzalloc(sizeof(struct lkkbd), GFP_KERNEL); lk = kzalloc(sizeof(*lk), GFP_KERNEL);
input_dev = input_allocate_device(); input_dev = input_allocate_device();
if (!lk || !input_dev) { if (!lk || !input_dev) {
err = -ENOMEM; err = -ENOMEM;

View File

@ -227,7 +227,7 @@ static int locomokbd_probe(struct locomo_dev *dev)
struct input_dev *input_dev; struct input_dev *input_dev;
int i, err; int i, err;
locomokbd = kzalloc(sizeof(struct locomokbd), GFP_KERNEL); locomokbd = kzalloc(sizeof(*locomokbd), GFP_KERNEL);
input_dev = input_allocate_device(); input_dev = input_allocate_device();
if (!locomokbd || !input_dev) { if (!locomokbd || !input_dev) {
err = -ENOMEM; err = -ENOMEM;

View File

@ -154,7 +154,7 @@ static int probe_maple_kbd(struct device *dev)
mdev = to_maple_dev(dev); mdev = to_maple_dev(dev);
mdrv = to_maple_driver(dev->driver); mdrv = to_maple_driver(dev->driver);
kbd = kzalloc(sizeof(struct dc_kbd), GFP_KERNEL); kbd = kzalloc(sizeof(*kbd), GFP_KERNEL);
if (!kbd) { if (!kbd) {
error = -ENOMEM; error = -ENOMEM;
goto fail; goto fail;

View File

@ -68,7 +68,7 @@ static int nkbd_connect(struct serio *serio, struct serio_driver *drv)
int err = -ENOMEM; int err = -ENOMEM;
int i; int i;
nkbd = kzalloc(sizeof(struct nkbd), GFP_KERNEL); nkbd = kzalloc(sizeof(*nkbd), GFP_KERNEL);
input_dev = input_allocate_device(); input_dev = input_allocate_device();
if (!nkbd || !input_dev) if (!nkbd || !input_dev)
goto fail1; goto fail1;

View File

@ -171,6 +171,12 @@ static ssize_t omap_kp_enable_store(struct device *dev, struct device_attribute
static DEVICE_ATTR(enable, S_IRUGO | S_IWUSR, omap_kp_enable_show, omap_kp_enable_store); static DEVICE_ATTR(enable, S_IRUGO | S_IWUSR, omap_kp_enable_show, omap_kp_enable_store);
static struct attribute *omap_kp_attrs[] = {
&dev_attr_enable.attr,
NULL
};
ATTRIBUTE_GROUPS(omap_kp);
static int omap_kp_probe(struct platform_device *pdev) static int omap_kp_probe(struct platform_device *pdev)
{ {
struct omap_kp *omap_kp; struct omap_kp *omap_kp;
@ -214,10 +220,6 @@ static int omap_kp_probe(struct platform_device *pdev)
kp_tasklet.data = (unsigned long) omap_kp; kp_tasklet.data = (unsigned long) omap_kp;
tasklet_enable(&kp_tasklet); tasklet_enable(&kp_tasklet);
ret = device_create_file(&pdev->dev, &dev_attr_enable);
if (ret < 0)
goto err2;
/* setup input device */ /* setup input device */
input_dev->name = "omap-keypad"; input_dev->name = "omap-keypad";
input_dev->phys = "omap-keypad/input0"; input_dev->phys = "omap-keypad/input0";
@ -235,12 +237,12 @@ static int omap_kp_probe(struct platform_device *pdev)
pdata->rows, pdata->cols, pdata->rows, pdata->cols,
omap_kp->keymap, input_dev); omap_kp->keymap, input_dev);
if (ret < 0) if (ret < 0)
goto err3; goto err2;
ret = input_register_device(omap_kp->input); ret = input_register_device(omap_kp->input);
if (ret < 0) { if (ret < 0) {
printk(KERN_ERR "Unable to register omap-keypad input device\n"); printk(KERN_ERR "Unable to register omap-keypad input device\n");
goto err3; goto err2;
} }
if (pdata->dbounce) if (pdata->dbounce)
@ -252,17 +254,15 @@ static int omap_kp_probe(struct platform_device *pdev)
if (omap_kp->irq >= 0) { if (omap_kp->irq >= 0) {
if (request_irq(omap_kp->irq, omap_kp_interrupt, 0, if (request_irq(omap_kp->irq, omap_kp_interrupt, 0,
"omap-keypad", omap_kp) < 0) "omap-keypad", omap_kp) < 0)
goto err4; goto err3;
} }
omap_writew(0, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBD_MASKIT); omap_writew(0, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBD_MASKIT);
return 0; return 0;
err4: err3:
input_unregister_device(omap_kp->input); input_unregister_device(omap_kp->input);
input_dev = NULL; input_dev = NULL;
err3:
device_remove_file(&pdev->dev, &dev_attr_enable);
err2: err2:
kfree(omap_kp); kfree(omap_kp);
input_free_device(input_dev); input_free_device(input_dev);
@ -293,6 +293,7 @@ static struct platform_driver omap_kp_driver = {
.remove_new = omap_kp_remove, .remove_new = omap_kp_remove,
.driver = { .driver = {
.name = "omap-keypad", .name = "omap-keypad",
.dev_groups = omap_kp_groups,
}, },
}; };
module_platform_driver(omap_kp_driver); module_platform_driver(omap_kp_driver);

View File

@ -208,7 +208,7 @@ static const struct regmap_access_table qt1050_writeable_table = {
.n_yes_ranges = ARRAY_SIZE(qt1050_writeable_ranges), .n_yes_ranges = ARRAY_SIZE(qt1050_writeable_ranges),
}; };
static struct regmap_config qt1050_regmap_config = { static const struct regmap_config qt1050_regmap_config = {
.reg_bits = 8, .reg_bits = 8,
.val_bits = 8, .val_bits = 8,
.max_register = QT1050_RES_CAL, .max_register = QT1050_RES_CAL,
@ -226,7 +226,12 @@ static bool qt1050_identify(struct qt1050_priv *ts)
int err; int err;
/* Read Chip ID */ /* Read Chip ID */
regmap_read(ts->regmap, QT1050_CHIP_ID, &val); err = regmap_read(ts->regmap, QT1050_CHIP_ID, &val);
if (err) {
dev_err(&ts->client->dev, "Failed to read chip ID: %d\n", err);
return false;
}
if (val != QT1050_CHIP_ID_VER) { if (val != QT1050_CHIP_ID_VER) {
dev_err(&ts->client->dev, "ID %d not supported\n", val); dev_err(&ts->client->dev, "ID %d not supported\n", val);
return false; return false;

View File

@ -72,7 +72,7 @@ static int skbd_connect(struct serio *serio, struct serio_driver *drv)
int err = -ENOMEM; int err = -ENOMEM;
int i; int i;
skbd = kzalloc(sizeof(struct skbd), GFP_KERNEL); skbd = kzalloc(sizeof(*skbd), GFP_KERNEL);
input_dev = input_allocate_device(); input_dev = input_allocate_device();
if (!skbd || !input_dev) if (!skbd || !input_dev)
goto fail1; goto fail1;

View File

@ -263,7 +263,7 @@ static int sunkbd_connect(struct serio *serio, struct serio_driver *drv)
int err = -ENOMEM; int err = -ENOMEM;
int i; int i;
sunkbd = kzalloc(sizeof(struct sunkbd), GFP_KERNEL); sunkbd = kzalloc(sizeof(*sunkbd), GFP_KERNEL);
input_dev = input_allocate_device(); input_dev = input_allocate_device();
if (!sunkbd || !input_dev) if (!sunkbd || !input_dev)
goto fail1; goto fail1;

View File

@ -70,7 +70,7 @@ static int xtkbd_connect(struct serio *serio, struct serio_driver *drv)
int err = -ENOMEM; int err = -ENOMEM;
int i; int i;
xtkbd = kmalloc(sizeof(struct xtkbd), GFP_KERNEL); xtkbd = kmalloc(sizeof(*xtkbd), GFP_KERNEL);
input_dev = input_allocate_device(); input_dev = input_allocate_device();
if (!xtkbd || !input_dev) if (!xtkbd || !input_dev)
goto fail1; goto fail1;

View File

@ -199,4 +199,5 @@ int matrix_keypad_build_keymap(const struct matrix_keymap_data *keymap_data,
} }
EXPORT_SYMBOL(matrix_keypad_build_keymap); EXPORT_SYMBOL(matrix_keypad_build_keymap);
MODULE_DESCRIPTION("Helpers for matrix keyboard bindings");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");

View File

@ -57,7 +57,7 @@ static int pm80x_onkey_probe(struct platform_device *pdev)
struct pm80x_onkey_info *info; struct pm80x_onkey_info *info;
int err; int err;
info = kzalloc(sizeof(struct pm80x_onkey_info), GFP_KERNEL); info = kzalloc(sizeof(*info), GFP_KERNEL);
if (!info) if (!info)
return -ENOMEM; return -ENOMEM;

View File

@ -98,13 +98,6 @@ static int adxl34x_i2c_probe(struct i2c_client *client)
return 0; return 0;
} }
static void adxl34x_i2c_remove(struct i2c_client *client)
{
struct adxl34x *ac = i2c_get_clientdata(client);
adxl34x_remove(ac);
}
static const struct i2c_device_id adxl34x_id[] = { static const struct i2c_device_id adxl34x_id[] = {
{ "adxl34x" }, { "adxl34x" },
{ } { }
@ -132,11 +125,11 @@ MODULE_DEVICE_TABLE(of, adxl34x_of_id);
static struct i2c_driver adxl34x_driver = { static struct i2c_driver adxl34x_driver = {
.driver = { .driver = {
.name = "adxl34x", .name = "adxl34x",
.dev_groups = adxl34x_groups,
.pm = pm_sleep_ptr(&adxl34x_pm), .pm = pm_sleep_ptr(&adxl34x_pm),
.of_match_table = adxl34x_of_id, .of_match_table = adxl34x_of_id,
}, },
.probe = adxl34x_i2c_probe, .probe = adxl34x_i2c_probe,
.remove = adxl34x_i2c_remove,
.id_table = adxl34x_id, .id_table = adxl34x_id,
}; };

View File

@ -87,20 +87,13 @@ static int adxl34x_spi_probe(struct spi_device *spi)
return 0; return 0;
} }
static void adxl34x_spi_remove(struct spi_device *spi)
{
struct adxl34x *ac = spi_get_drvdata(spi);
adxl34x_remove(ac);
}
static struct spi_driver adxl34x_driver = { static struct spi_driver adxl34x_driver = {
.driver = { .driver = {
.name = "adxl34x", .name = "adxl34x",
.dev_groups = adxl34x_groups,
.pm = pm_sleep_ptr(&adxl34x_pm), .pm = pm_sleep_ptr(&adxl34x_pm),
}, },
.probe = adxl34x_spi_probe, .probe = adxl34x_spi_probe,
.remove = adxl34x_spi_remove,
}; };
module_spi_driver(adxl34x_driver); module_spi_driver(adxl34x_driver);

View File

@ -241,7 +241,8 @@ static void adxl34x_get_triple(struct adxl34x *ac, struct axis_triple *axis)
ac->bops->read_block(ac->dev, DATAX0, DATAZ1 - DATAX0 + 1, buf); ac->bops->read_block(ac->dev, DATAX0, DATAZ1 - DATAX0 + 1, buf);
mutex_lock(&ac->mutex); guard(mutex)(&ac->mutex);
ac->saved.x = (s16) le16_to_cpu(buf[0]); ac->saved.x = (s16) le16_to_cpu(buf[0]);
axis->x = ac->saved.x; axis->x = ac->saved.x;
@ -250,7 +251,6 @@ static void adxl34x_get_triple(struct adxl34x *ac, struct axis_triple *axis)
ac->saved.z = (s16) le16_to_cpu(buf[2]); ac->saved.z = (s16) le16_to_cpu(buf[2]);
axis->z = ac->saved.z; axis->z = ac->saved.z;
mutex_unlock(&ac->mutex);
} }
static void adxl34x_service_ev_fifo(struct adxl34x *ac) static void adxl34x_service_ev_fifo(struct adxl34x *ac)
@ -416,15 +416,13 @@ static int adxl34x_suspend(struct device *dev)
{ {
struct adxl34x *ac = dev_get_drvdata(dev); struct adxl34x *ac = dev_get_drvdata(dev);
mutex_lock(&ac->mutex); guard(mutex)(&ac->mutex);
if (!ac->suspended && !ac->disabled && ac->opened) if (!ac->suspended && !ac->disabled && ac->opened)
__adxl34x_disable(ac); __adxl34x_disable(ac);
ac->suspended = true; ac->suspended = true;
mutex_unlock(&ac->mutex);
return 0; return 0;
} }
@ -432,15 +430,13 @@ static int adxl34x_resume(struct device *dev)
{ {
struct adxl34x *ac = dev_get_drvdata(dev); struct adxl34x *ac = dev_get_drvdata(dev);
mutex_lock(&ac->mutex); guard(mutex)(&ac->mutex);
if (ac->suspended && !ac->disabled && ac->opened) if (ac->suspended && !ac->disabled && ac->opened)
__adxl34x_enable(ac); __adxl34x_enable(ac);
ac->suspended = false; ac->suspended = false;
mutex_unlock(&ac->mutex);
return 0; return 0;
} }
@ -464,7 +460,7 @@ static ssize_t adxl34x_disable_store(struct device *dev,
if (error) if (error)
return error; return error;
mutex_lock(&ac->mutex); guard(mutex)(&ac->mutex);
if (!ac->suspended && ac->opened) { if (!ac->suspended && ac->opened) {
if (val) { if (val) {
@ -478,8 +474,6 @@ static ssize_t adxl34x_disable_store(struct device *dev,
ac->disabled = !!val; ac->disabled = !!val;
mutex_unlock(&ac->mutex);
return count; return count;
} }
@ -489,16 +483,13 @@ static ssize_t adxl34x_calibrate_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
struct adxl34x *ac = dev_get_drvdata(dev); struct adxl34x *ac = dev_get_drvdata(dev);
ssize_t count;
mutex_lock(&ac->mutex); guard(mutex)(&ac->mutex);
count = sprintf(buf, "%d,%d,%d\n",
ac->hwcal.x * 4 + ac->swcal.x,
ac->hwcal.y * 4 + ac->swcal.y,
ac->hwcal.z * 4 + ac->swcal.z);
mutex_unlock(&ac->mutex);
return count; return sprintf(buf, "%d,%d,%d\n",
ac->hwcal.x * 4 + ac->swcal.x,
ac->hwcal.y * 4 + ac->swcal.y,
ac->hwcal.z * 4 + ac->swcal.z);
} }
static ssize_t adxl34x_calibrate_store(struct device *dev, static ssize_t adxl34x_calibrate_store(struct device *dev,
@ -512,7 +503,8 @@ static ssize_t adxl34x_calibrate_store(struct device *dev,
* We use HW calibration and handle the remaining bits in SW. (4mg/LSB) * We use HW calibration and handle the remaining bits in SW. (4mg/LSB)
*/ */
mutex_lock(&ac->mutex); guard(mutex)(&ac->mutex);
ac->hwcal.x -= (ac->saved.x / 4); ac->hwcal.x -= (ac->saved.x / 4);
ac->swcal.x = ac->saved.x % 4; ac->swcal.x = ac->saved.x % 4;
@ -525,7 +517,6 @@ static ssize_t adxl34x_calibrate_store(struct device *dev,
AC_WRITE(ac, OFSX, (s8) ac->hwcal.x); AC_WRITE(ac, OFSX, (s8) ac->hwcal.x);
AC_WRITE(ac, OFSY, (s8) ac->hwcal.y); AC_WRITE(ac, OFSY, (s8) ac->hwcal.y);
AC_WRITE(ac, OFSZ, (s8) ac->hwcal.z); AC_WRITE(ac, OFSZ, (s8) ac->hwcal.z);
mutex_unlock(&ac->mutex);
return count; return count;
} }
@ -553,15 +544,13 @@ static ssize_t adxl34x_rate_store(struct device *dev,
if (error) if (error)
return error; return error;
mutex_lock(&ac->mutex); guard(mutex)(&ac->mutex);
ac->pdata.data_rate = RATE(val); ac->pdata.data_rate = RATE(val);
AC_WRITE(ac, BW_RATE, AC_WRITE(ac, BW_RATE,
ac->pdata.data_rate | ac->pdata.data_rate |
(ac->pdata.low_power_mode ? LOW_POWER : 0)); (ac->pdata.low_power_mode ? LOW_POWER : 0));
mutex_unlock(&ac->mutex);
return count; return count;
} }
@ -588,7 +577,7 @@ static ssize_t adxl34x_autosleep_store(struct device *dev,
if (error) if (error)
return error; return error;
mutex_lock(&ac->mutex); guard(mutex)(&ac->mutex);
if (val) if (val)
ac->pdata.power_mode |= (PCTL_AUTO_SLEEP | PCTL_LINK); ac->pdata.power_mode |= (PCTL_AUTO_SLEEP | PCTL_LINK);
@ -598,8 +587,6 @@ static ssize_t adxl34x_autosleep_store(struct device *dev,
if (!ac->disabled && !ac->suspended && ac->opened) if (!ac->disabled && !ac->suspended && ac->opened)
AC_WRITE(ac, POWER_CTL, ac->pdata.power_mode | PCTL_MEASURE); AC_WRITE(ac, POWER_CTL, ac->pdata.power_mode | PCTL_MEASURE);
mutex_unlock(&ac->mutex);
return count; return count;
} }
@ -610,14 +597,11 @@ static ssize_t adxl34x_position_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
struct adxl34x *ac = dev_get_drvdata(dev); struct adxl34x *ac = dev_get_drvdata(dev);
ssize_t count;
mutex_lock(&ac->mutex); guard(mutex)(&ac->mutex);
count = sprintf(buf, "(%d, %d, %d)\n",
ac->saved.x, ac->saved.y, ac->saved.z);
mutex_unlock(&ac->mutex);
return count; return sprintf(buf, "(%d, %d, %d)\n",
ac->saved.x, ac->saved.y, ac->saved.z);
} }
static DEVICE_ATTR(position, S_IRUGO, adxl34x_position_show, NULL); static DEVICE_ATTR(position, S_IRUGO, adxl34x_position_show, NULL);
@ -638,9 +622,8 @@ static ssize_t adxl34x_write_store(struct device *dev,
if (error) if (error)
return error; return error;
mutex_lock(&ac->mutex); guard(mutex)(&ac->mutex);
AC_WRITE(ac, val >> 8, val & 0xFF); AC_WRITE(ac, val >> 8, val & 0xFF);
mutex_unlock(&ac->mutex);
return count; return count;
} }
@ -664,19 +647,23 @@ static const struct attribute_group adxl34x_attr_group = {
.attrs = adxl34x_attributes, .attrs = adxl34x_attributes,
}; };
const struct attribute_group *adxl34x_groups[] = {
&adxl34x_attr_group,
NULL
};
EXPORT_SYMBOL_GPL(adxl34x_groups);
static int adxl34x_input_open(struct input_dev *input) static int adxl34x_input_open(struct input_dev *input)
{ {
struct adxl34x *ac = input_get_drvdata(input); struct adxl34x *ac = input_get_drvdata(input);
mutex_lock(&ac->mutex); guard(mutex)(&ac->mutex);
if (!ac->suspended && !ac->disabled) if (!ac->suspended && !ac->disabled)
__adxl34x_enable(ac); __adxl34x_enable(ac);
ac->opened = true; ac->opened = true;
mutex_unlock(&ac->mutex);
return 0; return 0;
} }
@ -684,14 +671,12 @@ static void adxl34x_input_close(struct input_dev *input)
{ {
struct adxl34x *ac = input_get_drvdata(input); struct adxl34x *ac = input_get_drvdata(input);
mutex_lock(&ac->mutex); guard(mutex)(&ac->mutex);
if (!ac->suspended && !ac->disabled) if (!ac->suspended && !ac->disabled)
__adxl34x_disable(ac); __adxl34x_disable(ac);
ac->opened = false; ac->opened = false;
mutex_unlock(&ac->mutex);
} }
struct adxl34x *adxl34x_probe(struct device *dev, int irq, struct adxl34x *adxl34x_probe(struct device *dev, int irq,
@ -701,21 +686,21 @@ struct adxl34x *adxl34x_probe(struct device *dev, int irq,
struct adxl34x *ac; struct adxl34x *ac;
struct input_dev *input_dev; struct input_dev *input_dev;
const struct adxl34x_platform_data *pdata; const struct adxl34x_platform_data *pdata;
int err, range, i; int error, range, i;
int revid; int revid;
if (!irq) { if (!irq) {
dev_err(dev, "no IRQ?\n"); dev_err(dev, "no IRQ?\n");
err = -ENODEV; return ERR_PTR(-ENODEV);
goto err_out;
} }
ac = kzalloc(sizeof(*ac), GFP_KERNEL); ac = devm_kzalloc(dev, sizeof(*ac), GFP_KERNEL);
input_dev = input_allocate_device(); if (!ac)
if (!ac || !input_dev) { return ERR_PTR(-ENOMEM);
err = -ENOMEM;
goto err_free_mem; input_dev = devm_input_allocate_device(dev);
} if (!input_dev)
return ERR_PTR(-ENOMEM);
ac->fifo_delay = fifo_delay_default; ac->fifo_delay = fifo_delay_default;
@ -748,14 +733,12 @@ struct adxl34x *adxl34x_probe(struct device *dev, int irq,
break; break;
default: default:
dev_err(dev, "Failed to probe %s\n", input_dev->name); dev_err(dev, "Failed to probe %s\n", input_dev->name);
err = -ENODEV; return ERR_PTR(-ENODEV);
goto err_free_mem;
} }
snprintf(ac->phys, sizeof(ac->phys), "%s/input0", dev_name(dev)); snprintf(ac->phys, sizeof(ac->phys), "%s/input0", dev_name(dev));
input_dev->phys = ac->phys; input_dev->phys = ac->phys;
input_dev->dev.parent = dev;
input_dev->id.product = ac->model; input_dev->id.product = ac->model;
input_dev->id.bustype = bops->bustype; input_dev->id.bustype = bops->bustype;
input_dev->open = adxl34x_input_open; input_dev->open = adxl34x_input_open;
@ -763,18 +746,12 @@ struct adxl34x *adxl34x_probe(struct device *dev, int irq,
input_set_drvdata(input_dev, ac); input_set_drvdata(input_dev, ac);
__set_bit(ac->pdata.ev_type, input_dev->evbit);
if (ac->pdata.ev_type == EV_REL) { if (ac->pdata.ev_type == EV_REL) {
__set_bit(REL_X, input_dev->relbit); input_set_capability(input_dev, EV_REL, REL_X);
__set_bit(REL_Y, input_dev->relbit); input_set_capability(input_dev, EV_REL, REL_Y);
__set_bit(REL_Z, input_dev->relbit); input_set_capability(input_dev, EV_REL, REL_Z);
} else { } else {
/* EV_ABS */ /* EV_ABS */
__set_bit(ABS_X, input_dev->absbit);
__set_bit(ABS_Y, input_dev->absbit);
__set_bit(ABS_Z, input_dev->absbit);
if (pdata->data_range & FULL_RES) if (pdata->data_range & FULL_RES)
range = ADXL_FULLRES_MAX_VAL; /* Signed 13-bit */ range = ADXL_FULLRES_MAX_VAL; /* Signed 13-bit */
else else
@ -785,18 +762,18 @@ struct adxl34x *adxl34x_probe(struct device *dev, int irq,
input_set_abs_params(input_dev, ABS_Z, -range, range, 3, 3); input_set_abs_params(input_dev, ABS_Z, -range, range, 3, 3);
} }
__set_bit(EV_KEY, input_dev->evbit); input_set_capability(input_dev, EV_KEY, pdata->ev_code_tap[ADXL_X_AXIS]);
__set_bit(pdata->ev_code_tap[ADXL_X_AXIS], input_dev->keybit); input_set_capability(input_dev, EV_KEY, pdata->ev_code_tap[ADXL_Y_AXIS]);
__set_bit(pdata->ev_code_tap[ADXL_Y_AXIS], input_dev->keybit); input_set_capability(input_dev, EV_KEY, pdata->ev_code_tap[ADXL_Z_AXIS]);
__set_bit(pdata->ev_code_tap[ADXL_Z_AXIS], input_dev->keybit);
if (pdata->ev_code_ff) { if (pdata->ev_code_ff) {
ac->int_mask = FREE_FALL; ac->int_mask = FREE_FALL;
__set_bit(pdata->ev_code_ff, input_dev->keybit); input_set_capability(input_dev, EV_KEY, pdata->ev_code_ff);
} }
if (pdata->ev_code_act_inactivity) if (pdata->ev_code_act_inactivity)
__set_bit(pdata->ev_code_act_inactivity, input_dev->keybit); input_set_capability(input_dev, EV_KEY,
pdata->ev_code_act_inactivity);
ac->int_mask |= ACTIVITY | INACTIVITY; ac->int_mask |= ACTIVITY | INACTIVITY;
@ -816,20 +793,16 @@ struct adxl34x *adxl34x_probe(struct device *dev, int irq,
AC_WRITE(ac, POWER_CTL, 0); AC_WRITE(ac, POWER_CTL, 0);
err = request_threaded_irq(ac->irq, NULL, adxl34x_irq, error = devm_request_threaded_irq(dev, ac->irq, NULL, adxl34x_irq,
IRQF_ONESHOT, dev_name(dev), ac); IRQF_ONESHOT, dev_name(dev), ac);
if (err) { if (error) {
dev_err(dev, "irq %d busy?\n", ac->irq); dev_err(dev, "irq %d busy?\n", ac->irq);
goto err_free_mem; return ERR_PTR(error);
} }
err = sysfs_create_group(&dev->kobj, &adxl34x_attr_group); error = input_register_device(input_dev);
if (err) if (error)
goto err_free_irq; return ERR_PTR(error);
err = input_register_device(input_dev);
if (err)
goto err_remove_attr;
AC_WRITE(ac, OFSX, pdata->x_axis_offset); AC_WRITE(ac, OFSX, pdata->x_axis_offset);
ac->hwcal.x = pdata->x_axis_offset; ac->hwcal.x = pdata->x_axis_offset;
@ -872,13 +845,13 @@ struct adxl34x *adxl34x_probe(struct device *dev, int irq,
if (pdata->orientation_enable & ADXL_EN_ORIENTATION_3D) if (pdata->orientation_enable & ADXL_EN_ORIENTATION_3D)
for (i = 0; i < ARRAY_SIZE(pdata->ev_codes_orient_3d); i++) for (i = 0; i < ARRAY_SIZE(pdata->ev_codes_orient_3d); i++)
__set_bit(pdata->ev_codes_orient_3d[i], input_set_capability(input_dev, EV_KEY,
input_dev->keybit); pdata->ev_codes_orient_3d[i]);
if (pdata->orientation_enable & ADXL_EN_ORIENTATION_2D) if (pdata->orientation_enable & ADXL_EN_ORIENTATION_2D)
for (i = 0; i < ARRAY_SIZE(pdata->ev_codes_orient_2d); i++) for (i = 0; i < ARRAY_SIZE(pdata->ev_codes_orient_2d); i++)
__set_bit(pdata->ev_codes_orient_2d[i], input_set_capability(input_dev, EV_KEY,
input_dev->keybit); pdata->ev_codes_orient_2d[i]);
} else { } else {
ac->pdata.orientation_enable = 0; ac->pdata.orientation_enable = 0;
} }
@ -888,29 +861,9 @@ struct adxl34x *adxl34x_probe(struct device *dev, int irq,
ac->pdata.power_mode &= (PCTL_AUTO_SLEEP | PCTL_LINK); ac->pdata.power_mode &= (PCTL_AUTO_SLEEP | PCTL_LINK);
return ac; return ac;
err_remove_attr:
sysfs_remove_group(&dev->kobj, &adxl34x_attr_group);
err_free_irq:
free_irq(ac->irq, ac);
err_free_mem:
input_free_device(input_dev);
kfree(ac);
err_out:
return ERR_PTR(err);
} }
EXPORT_SYMBOL_GPL(adxl34x_probe); EXPORT_SYMBOL_GPL(adxl34x_probe);
void adxl34x_remove(struct adxl34x *ac)
{
sysfs_remove_group(&ac->dev->kobj, &adxl34x_attr_group);
free_irq(ac->irq, ac);
input_unregister_device(ac->input);
dev_dbg(ac->dev, "unregistered accelerometer\n");
kfree(ac);
}
EXPORT_SYMBOL_GPL(adxl34x_remove);
EXPORT_GPL_SIMPLE_DEV_PM_OPS(adxl34x_pm, adxl34x_suspend, adxl34x_resume); EXPORT_GPL_SIMPLE_DEV_PM_OPS(adxl34x_pm, adxl34x_suspend, adxl34x_resume);
MODULE_AUTHOR("Michael Hennerich <hennerich@blackfin.uclinux.org>"); MODULE_AUTHOR("Michael Hennerich <hennerich@blackfin.uclinux.org>");

View File

@ -23,8 +23,8 @@ struct adxl34x_bus_ops {
struct adxl34x *adxl34x_probe(struct device *dev, int irq, struct adxl34x *adxl34x_probe(struct device *dev, int irq,
bool fifo_delay_default, bool fifo_delay_default,
const struct adxl34x_bus_ops *bops); const struct adxl34x_bus_ops *bops);
void adxl34x_remove(struct adxl34x *ac);
extern const struct dev_pm_ops adxl34x_pm; extern const struct dev_pm_ops adxl34x_pm;
extern const struct attribute_group *adxl34x_groups[];
#endif #endif

View File

@ -204,26 +204,7 @@ struct ati_remote2 {
unsigned int mode_mask; unsigned int mode_mask;
}; };
static int ati_remote2_probe(struct usb_interface *interface, const struct usb_device_id *id); static struct usb_driver ati_remote2_driver;
static void ati_remote2_disconnect(struct usb_interface *interface);
static int ati_remote2_suspend(struct usb_interface *interface, pm_message_t message);
static int ati_remote2_resume(struct usb_interface *interface);
static int ati_remote2_reset_resume(struct usb_interface *interface);
static int ati_remote2_pre_reset(struct usb_interface *interface);
static int ati_remote2_post_reset(struct usb_interface *interface);
static struct usb_driver ati_remote2_driver = {
.name = "ati_remote2",
.probe = ati_remote2_probe,
.disconnect = ati_remote2_disconnect,
.id_table = ati_remote2_id_table,
.suspend = ati_remote2_suspend,
.resume = ati_remote2_resume,
.reset_resume = ati_remote2_reset_resume,
.pre_reset = ati_remote2_pre_reset,
.post_reset = ati_remote2_post_reset,
.supports_autosuspend = 1,
};
static int ati_remote2_submit_urbs(struct ati_remote2 *ar2) static int ati_remote2_submit_urbs(struct ati_remote2 *ar2)
{ {
@ -791,10 +772,7 @@ static struct attribute *ati_remote2_attrs[] = {
&dev_attr_mode_mask.attr, &dev_attr_mode_mask.attr,
NULL, NULL,
}; };
ATTRIBUTE_GROUPS(ati_remote2);
static struct attribute_group ati_remote2_attr_group = {
.attrs = ati_remote2_attrs,
};
static int ati_remote2_probe(struct usb_interface *interface, const struct usb_device_id *id) static int ati_remote2_probe(struct usb_interface *interface, const struct usb_device_id *id)
{ {
@ -861,13 +839,9 @@ static int ati_remote2_probe(struct usb_interface *interface, const struct usb_d
strlcat(ar2->name, "ATI Remote Wonder II", sizeof(ar2->name)); strlcat(ar2->name, "ATI Remote Wonder II", sizeof(ar2->name));
r = sysfs_create_group(&udev->dev.kobj, &ati_remote2_attr_group);
if (r)
goto fail3;
r = ati_remote2_input_init(ar2); r = ati_remote2_input_init(ar2);
if (r) if (r)
goto fail4; goto fail3;
usb_set_intfdata(interface, ar2); usb_set_intfdata(interface, ar2);
@ -875,8 +849,6 @@ static int ati_remote2_probe(struct usb_interface *interface, const struct usb_d
return 0; return 0;
fail4:
sysfs_remove_group(&udev->dev.kobj, &ati_remote2_attr_group);
fail3: fail3:
ati_remote2_urb_cleanup(ar2); ati_remote2_urb_cleanup(ar2);
fail2: fail2:
@ -900,8 +872,6 @@ static void ati_remote2_disconnect(struct usb_interface *interface)
input_unregister_device(ar2->idev); input_unregister_device(ar2->idev);
sysfs_remove_group(&ar2->udev->dev.kobj, &ati_remote2_attr_group);
ati_remote2_urb_cleanup(ar2); ati_remote2_urb_cleanup(ar2);
usb_driver_release_interface(&ati_remote2_driver, ar2->intf[1]); usb_driver_release_interface(&ati_remote2_driver, ar2->intf[1]);
@ -1032,4 +1002,18 @@ static int ati_remote2_post_reset(struct usb_interface *interface)
return r; return r;
} }
static struct usb_driver ati_remote2_driver = {
.name = "ati_remote2",
.probe = ati_remote2_probe,
.disconnect = ati_remote2_disconnect,
.dev_groups = ati_remote2_groups,
.id_table = ati_remote2_id_table,
.suspend = ati_remote2_suspend,
.resume = ati_remote2_resume,
.reset_resume = ati_remote2_reset_resume,
.pre_reset = ati_remote2_pre_reset,
.post_reset = ati_remote2_post_reset,
.supports_autosuspend = 1,
};
module_usb_driver(ati_remote2_driver); module_usb_driver(ati_remote2_driver);

View File

@ -292,7 +292,7 @@ struct cma3000_accl_data *cma3000_init(struct device *dev, int irq,
goto err_out; goto err_out;
} }
data = kzalloc(sizeof(struct cma3000_accl_data), GFP_KERNEL); data = kzalloc(sizeof(*data), GFP_KERNEL);
input_dev = input_allocate_device(); input_dev = input_allocate_device();
if (!data || !input_dev) { if (!data || !input_dev) {
error = -ENOMEM; error = -ENOMEM;

View File

@ -207,8 +207,7 @@ static int ims_pcu_setup_buttons(struct ims_pcu *pcu,
input = input_allocate_device(); input = input_allocate_device();
if (!input) { if (!input) {
dev_err(pcu->dev, dev_err(pcu->dev, "Not enough memory for input device\n");
"Not enough memory for input input device\n");
return -ENOMEM; return -ENOMEM;
} }
@ -287,7 +286,7 @@ static int ims_pcu_setup_gamepad(struct ims_pcu *pcu)
struct input_dev *input; struct input_dev *input;
int error; int error;
gamepad = kzalloc(sizeof(struct ims_pcu_gamepad), GFP_KERNEL); gamepad = kzalloc(sizeof(*gamepad), GFP_KERNEL);
input = input_allocate_device(); input = input_allocate_device();
if (!gamepad || !input) { if (!gamepad || !input) {
dev_err(pcu->dev, dev_err(pcu->dev,
@ -761,7 +760,7 @@ static int ims_pcu_switch_to_bootloader(struct ims_pcu *pcu)
struct ims_pcu_flash_fmt { struct ims_pcu_flash_fmt {
__le32 addr; __le32 addr;
u8 len; u8 len;
u8 data[]; u8 data[] __counted_by(len);
}; };
static unsigned int ims_pcu_count_fw_records(const struct firmware *fw) static unsigned int ims_pcu_count_fw_records(const struct firmware *fw)
@ -928,9 +927,8 @@ static void ims_pcu_process_async_firmware(const struct firmware *fw,
goto out; goto out;
} }
mutex_lock(&pcu->cmd_mutex); scoped_guard(mutex, &pcu->cmd_mutex)
ims_pcu_handle_firmware_update(pcu, fw); ims_pcu_handle_firmware_update(pcu, fw);
mutex_unlock(&pcu->cmd_mutex);
release_firmware(fw); release_firmware(fw);
@ -954,7 +952,7 @@ static int ims_pcu_backlight_set_brightness(struct led_classdev *cdev,
__le16 br_val = cpu_to_le16(value); __le16 br_val = cpu_to_le16(value);
int error; int error;
mutex_lock(&pcu->cmd_mutex); guard(mutex)(&pcu->cmd_mutex);
error = ims_pcu_execute_command(pcu, SET_BRIGHTNESS, error = ims_pcu_execute_command(pcu, SET_BRIGHTNESS,
&br_val, sizeof(br_val)); &br_val, sizeof(br_val));
@ -963,8 +961,6 @@ static int ims_pcu_backlight_set_brightness(struct led_classdev *cdev,
"Failed to set desired brightness %u, error: %d\n", "Failed to set desired brightness %u, error: %d\n",
value, error); value, error);
mutex_unlock(&pcu->cmd_mutex);
return error; return error;
} }
@ -978,7 +974,7 @@ ims_pcu_backlight_get_brightness(struct led_classdev *cdev)
int brightness; int brightness;
int error; int error;
mutex_lock(&pcu->cmd_mutex); guard(mutex)(&pcu->cmd_mutex);
error = ims_pcu_execute_query(pcu, GET_BRIGHTNESS); error = ims_pcu_execute_query(pcu, GET_BRIGHTNESS);
if (error) { if (error) {
@ -992,8 +988,6 @@ ims_pcu_backlight_get_brightness(struct led_classdev *cdev)
get_unaligned_le16(&pcu->cmd_buf[IMS_PCU_DATA_OFFSET]); get_unaligned_le16(&pcu->cmd_buf[IMS_PCU_DATA_OFFSET]);
} }
mutex_unlock(&pcu->cmd_mutex);
return brightness; return brightness;
} }
@ -1073,24 +1067,23 @@ static ssize_t ims_pcu_attribute_store(struct device *dev,
if (data_len > attr->field_length) if (data_len > attr->field_length)
return -EINVAL; return -EINVAL;
error = mutex_lock_interruptible(&pcu->cmd_mutex); scoped_cond_guard(mutex, return -EINTR, &pcu->cmd_mutex) {
if (error) memset(field, 0, attr->field_length);
return error; memcpy(field, buf, data_len);
memset(field, 0, attr->field_length); error = ims_pcu_set_info(pcu);
memcpy(field, buf, data_len);
error = ims_pcu_set_info(pcu); /*
* Even if update failed, let's fetch the info again as we just
* clobbered one of the fields.
*/
ims_pcu_get_info(pcu);
/* if (error)
* Even if update failed, let's fetch the info again as we just return error;
* clobbered one of the fields. }
*/
ims_pcu_get_info(pcu);
mutex_unlock(&pcu->cmd_mutex); return count;
return error < 0 ? error : count;
} }
#define IMS_PCU_ATTR(_field, _mode) \ #define IMS_PCU_ATTR(_field, _mode) \
@ -1153,7 +1146,6 @@ static ssize_t ims_pcu_update_firmware_store(struct device *dev,
{ {
struct usb_interface *intf = to_usb_interface(dev); struct usb_interface *intf = to_usb_interface(dev);
struct ims_pcu *pcu = usb_get_intfdata(intf); struct ims_pcu *pcu = usb_get_intfdata(intf);
const struct firmware *fw = NULL;
int value; int value;
int error; int error;
@ -1164,35 +1156,33 @@ static ssize_t ims_pcu_update_firmware_store(struct device *dev,
if (value != 1) if (value != 1)
return -EINVAL; return -EINVAL;
error = mutex_lock_interruptible(&pcu->cmd_mutex); const struct firmware *fw __free(firmware) = NULL;
if (error)
return error;
error = request_ihex_firmware(&fw, IMS_PCU_FIRMWARE_NAME, pcu->dev); error = request_ihex_firmware(&fw, IMS_PCU_FIRMWARE_NAME, pcu->dev);
if (error) { if (error) {
dev_err(pcu->dev, "Failed to request firmware %s, error: %d\n", dev_err(pcu->dev, "Failed to request firmware %s, error: %d\n",
IMS_PCU_FIRMWARE_NAME, error); IMS_PCU_FIRMWARE_NAME, error);
goto out; return error;
} }
/* scoped_cond_guard(mutex_intr, return -EINTR, &pcu->cmd_mutex) {
* If we are already in bootloader mode we can proceed with /*
* flashing the firmware. * If we are already in bootloader mode we can proceed with
* * flashing the firmware.
* If we are in application mode, then we need to switch into *
* bootloader mode, which will cause the device to disconnect * If we are in application mode, then we need to switch into
* and reconnect as different device. * bootloader mode, which will cause the device to disconnect
*/ * and reconnect as different device.
if (pcu->bootloader_mode) */
error = ims_pcu_handle_firmware_update(pcu, fw); if (pcu->bootloader_mode)
else error = ims_pcu_handle_firmware_update(pcu, fw);
error = ims_pcu_switch_to_bootloader(pcu); else
error = ims_pcu_switch_to_bootloader(pcu);
release_firmware(fw); if (error)
return error;
}
out: return count;
mutex_unlock(&pcu->cmd_mutex);
return error ?: count;
} }
static DEVICE_ATTR(update_firmware, S_IWUSR, static DEVICE_ATTR(update_firmware, S_IWUSR,
@ -1302,12 +1292,11 @@ static ssize_t ims_pcu_ofn_reg_data_show(struct device *dev,
int error; int error;
u8 data; u8 data;
mutex_lock(&pcu->cmd_mutex); scoped_guard(mutex, &pcu->cmd_mutex) {
error = ims_pcu_read_ofn_config(pcu, pcu->ofn_reg_addr, &data); error = ims_pcu_read_ofn_config(pcu, pcu->ofn_reg_addr, &data);
mutex_unlock(&pcu->cmd_mutex); if (error)
return error;
if (error) }
return error;
return sysfs_emit(buf, "%x\n", data); return sysfs_emit(buf, "%x\n", data);
} }
@ -1325,11 +1314,13 @@ static ssize_t ims_pcu_ofn_reg_data_store(struct device *dev,
if (error) if (error)
return error; return error;
mutex_lock(&pcu->cmd_mutex); guard(mutex)(&pcu->cmd_mutex);
error = ims_pcu_write_ofn_config(pcu, pcu->ofn_reg_addr, value);
mutex_unlock(&pcu->cmd_mutex);
return error ?: count; error = ims_pcu_write_ofn_config(pcu, pcu->ofn_reg_addr, value);
if (error)
return error;
return count;
} }
static DEVICE_ATTR(reg_data, S_IRUGO | S_IWUSR, static DEVICE_ATTR(reg_data, S_IRUGO | S_IWUSR,
@ -1341,13 +1332,10 @@ static ssize_t ims_pcu_ofn_reg_addr_show(struct device *dev,
{ {
struct usb_interface *intf = to_usb_interface(dev); struct usb_interface *intf = to_usb_interface(dev);
struct ims_pcu *pcu = usb_get_intfdata(intf); struct ims_pcu *pcu = usb_get_intfdata(intf);
int error;
mutex_lock(&pcu->cmd_mutex); guard(mutex)(&pcu->cmd_mutex);
error = sysfs_emit(buf, "%x\n", pcu->ofn_reg_addr);
mutex_unlock(&pcu->cmd_mutex);
return error; return sysfs_emit(buf, "%x\n", pcu->ofn_reg_addr);
} }
static ssize_t ims_pcu_ofn_reg_addr_store(struct device *dev, static ssize_t ims_pcu_ofn_reg_addr_store(struct device *dev,
@ -1363,9 +1351,9 @@ static ssize_t ims_pcu_ofn_reg_addr_store(struct device *dev,
if (error) if (error)
return error; return error;
mutex_lock(&pcu->cmd_mutex); guard(mutex)(&pcu->cmd_mutex);
pcu->ofn_reg_addr = value; pcu->ofn_reg_addr = value;
mutex_unlock(&pcu->cmd_mutex);
return count; return count;
} }
@ -1390,12 +1378,11 @@ static ssize_t ims_pcu_ofn_bit_show(struct device *dev,
int error; int error;
u8 data; u8 data;
mutex_lock(&pcu->cmd_mutex); scoped_guard(mutex, &pcu->cmd_mutex) {
error = ims_pcu_read_ofn_config(pcu, attr->addr, &data); error = ims_pcu_read_ofn_config(pcu, attr->addr, &data);
mutex_unlock(&pcu->cmd_mutex); if (error)
return error;
if (error) }
return error;
return sysfs_emit(buf, "%d\n", !!(data & (1 << attr->nr))); return sysfs_emit(buf, "%d\n", !!(data & (1 << attr->nr)));
} }
@ -1419,21 +1406,22 @@ static ssize_t ims_pcu_ofn_bit_store(struct device *dev,
if (value > 1) if (value > 1)
return -EINVAL; return -EINVAL;
mutex_lock(&pcu->cmd_mutex); scoped_guard(mutex, &pcu->cmd_mutex) {
error = ims_pcu_read_ofn_config(pcu, attr->addr, &data);
if (error)
return error;
error = ims_pcu_read_ofn_config(pcu, attr->addr, &data);
if (!error) {
if (value) if (value)
data |= 1U << attr->nr; data |= 1U << attr->nr;
else else
data &= ~(1U << attr->nr); data &= ~(1U << attr->nr);
error = ims_pcu_write_ofn_config(pcu, attr->addr, data); error = ims_pcu_write_ofn_config(pcu, attr->addr, data);
if (error)
return error;
} }
mutex_unlock(&pcu->cmd_mutex); return count;
return error ?: count;
} }
#define IMS_PCU_OFN_BIT_ATTR(_field, _addr, _nr) \ #define IMS_PCU_OFN_BIT_ATTR(_field, _addr, _nr) \
@ -1466,9 +1454,27 @@ static struct attribute *ims_pcu_ofn_attrs[] = {
NULL NULL
}; };
static umode_t ims_pcu_ofn_is_attr_visible(struct kobject *kobj,
struct attribute *attr, int n)
{
struct device *dev = kobj_to_dev(kobj);
struct usb_interface *intf = to_usb_interface(dev);
struct ims_pcu *pcu = usb_get_intfdata(intf);
umode_t mode = attr->mode;
/*
* PCU-B devices, both GEN_1 and GEN_2 do not have OFN sensor.
*/
if (pcu->bootloader_mode || pcu->device_id == IMS_PCU_PCU_B_DEVICE_ID)
mode = 0;
return mode;
}
static const struct attribute_group ims_pcu_ofn_attr_group = { static const struct attribute_group ims_pcu_ofn_attr_group = {
.name = "ofn", .name = "ofn",
.attrs = ims_pcu_ofn_attrs, .is_visible = ims_pcu_ofn_is_attr_visible,
.attrs = ims_pcu_ofn_attrs,
}; };
static void ims_pcu_irq(struct urb *urb) static void ims_pcu_irq(struct urb *urb)
@ -1890,16 +1896,6 @@ static int ims_pcu_init_application_mode(struct ims_pcu *pcu)
/* Device appears to be operable, complete initialization */ /* Device appears to be operable, complete initialization */
pcu->device_no = atomic_inc_return(&device_no); pcu->device_no = atomic_inc_return(&device_no);
/*
* PCU-B devices, both GEN_1 and GEN_2 do not have OFN sensor
*/
if (pcu->device_id != IMS_PCU_PCU_B_DEVICE_ID) {
error = sysfs_create_group(&pcu->dev->kobj,
&ims_pcu_ofn_attr_group);
if (error)
return error;
}
error = ims_pcu_setup_backlight(pcu); error = ims_pcu_setup_backlight(pcu);
if (error) if (error)
return error; return error;
@ -1936,10 +1932,6 @@ static void ims_pcu_destroy_application_mode(struct ims_pcu *pcu)
ims_pcu_destroy_gamepad(pcu); ims_pcu_destroy_gamepad(pcu);
ims_pcu_destroy_buttons(pcu); ims_pcu_destroy_buttons(pcu);
ims_pcu_destroy_backlight(pcu); ims_pcu_destroy_backlight(pcu);
if (pcu->device_id != IMS_PCU_PCU_B_DEVICE_ID)
sysfs_remove_group(&pcu->dev->kobj,
&ims_pcu_ofn_attr_group);
} }
} }
@ -1993,7 +1985,7 @@ static int ims_pcu_probe(struct usb_interface *intf,
struct ims_pcu *pcu; struct ims_pcu *pcu;
int error; int error;
pcu = kzalloc(sizeof(struct ims_pcu), GFP_KERNEL); pcu = kzalloc(sizeof(*pcu), GFP_KERNEL);
if (!pcu) if (!pcu)
return -ENOMEM; return -ENOMEM;
@ -2031,20 +2023,14 @@ static int ims_pcu_probe(struct usb_interface *intf,
if (error) if (error)
goto err_stop_io; goto err_stop_io;
error = sysfs_create_group(&intf->dev.kobj, &ims_pcu_attr_group);
if (error)
goto err_stop_io;
error = pcu->bootloader_mode ? error = pcu->bootloader_mode ?
ims_pcu_init_bootloader_mode(pcu) : ims_pcu_init_bootloader_mode(pcu) :
ims_pcu_init_application_mode(pcu); ims_pcu_init_application_mode(pcu);
if (error) if (error)
goto err_remove_sysfs; goto err_stop_io;
return 0; return 0;
err_remove_sysfs:
sysfs_remove_group(&intf->dev.kobj, &ims_pcu_attr_group);
err_stop_io: err_stop_io:
ims_pcu_stop_io(pcu); ims_pcu_stop_io(pcu);
err_free_buffers: err_free_buffers:
@ -2070,8 +2056,6 @@ static void ims_pcu_disconnect(struct usb_interface *intf)
if (alt->desc.bInterfaceClass != USB_CLASS_COMM) if (alt->desc.bInterfaceClass != USB_CLASS_COMM)
return; return;
sysfs_remove_group(&intf->dev.kobj, &ims_pcu_attr_group);
ims_pcu_stop_io(pcu); ims_pcu_stop_io(pcu);
if (pcu->bootloader_mode) if (pcu->bootloader_mode)
@ -2130,9 +2114,16 @@ static const struct usb_device_id ims_pcu_id_table[] = {
{ } { }
}; };
static const struct attribute_group *ims_pcu_sysfs_groups[] = {
&ims_pcu_attr_group,
&ims_pcu_ofn_attr_group,
NULL
};
static struct usb_driver ims_pcu_driver = { static struct usb_driver ims_pcu_driver = {
.name = "ims_pcu", .name = "ims_pcu",
.id_table = ims_pcu_id_table, .id_table = ims_pcu_id_table,
.dev_groups = ims_pcu_sysfs_groups,
.probe = ims_pcu_probe, .probe = ims_pcu_probe,
.disconnect = ims_pcu_disconnect, .disconnect = ims_pcu_disconnect,
#ifdef CONFIG_PM #ifdef CONFIG_PM

View File

@ -249,7 +249,7 @@ static int max8997_haptic_probe(struct platform_device *pdev)
return -EINVAL; return -EINVAL;
} }
chip = kzalloc(sizeof(struct max8997_haptic), GFP_KERNEL); chip = kzalloc(sizeof(*chip), GFP_KERNEL);
input_dev = input_allocate_device(); input_dev = input_allocate_device();
if (!chip || !input_dev) { if (!chip || !input_dev) {
dev_err(&pdev->dev, "unable to allocate memory\n"); dev_err(&pdev->dev, "unable to allocate memory\n");

View File

@ -49,7 +49,7 @@ static int pcap_keys_probe(struct platform_device *pdev)
struct pcap_keys *pcap_keys; struct pcap_keys *pcap_keys;
struct input_dev *input_dev; struct input_dev *input_dev;
pcap_keys = kmalloc(sizeof(struct pcap_keys), GFP_KERNEL); pcap_keys = kmalloc(sizeof(*pcap_keys), GFP_KERNEL);
if (!pcap_keys) if (!pcap_keys)
return err; return err;

View File

@ -320,7 +320,7 @@ static int powermate_probe(struct usb_interface *intf, const struct usb_device_i
0, interface->desc.bInterfaceNumber, NULL, 0, 0, interface->desc.bInterfaceNumber, NULL, 0,
USB_CTRL_SET_TIMEOUT); USB_CTRL_SET_TIMEOUT);
pm = kzalloc(sizeof(struct powermate_device), GFP_KERNEL); pm = kzalloc(sizeof(*pm), GFP_KERNEL);
input_dev = input_allocate_device(); input_dev = input_allocate_device();
if (!pm || !input_dev) if (!pm || !input_dev)
goto fail1; goto fail1;

View File

@ -128,4 +128,5 @@ static struct platform_driver sgi_buttons_driver = {
}; };
module_platform_driver(sgi_buttons_driver); module_platform_driver(sgi_buttons_driver);
MODULE_DESCRIPTION("SGI Indy/O2 volume button interface driver");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");

View File

@ -620,4 +620,5 @@ static struct platform_driver soc_button_driver = {
}; };
module_platform_driver(soc_button_driver); module_platform_driver(soc_button_driver);
MODULE_DESCRIPTION("Windows-compatible SoC Button Array driver");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");

View File

@ -1,5 +1,5 @@
/** /*
* twl4030-pwrbutton.c - TWL4030 Power Button Input Driver * TWL4030 Power Button Input Driver
* *
* Copyright (C) 2008-2009 Nokia Corporation * Copyright (C) 2008-2009 Nokia Corporation
* *

View File

@ -379,7 +379,7 @@ static int uinput_open(struct inode *inode, struct file *file)
{ {
struct uinput_device *newdev; struct uinput_device *newdev;
newdev = kzalloc(sizeof(struct uinput_device), GFP_KERNEL); newdev = kzalloc(sizeof(*newdev), GFP_KERNEL);
if (!newdev) if (!newdev)
return -ENOMEM; return -ENOMEM;

View File

@ -36,7 +36,7 @@
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/rwsem.h> #include <linux/mutex.h>
#include <linux/usb/input.h> #include <linux/usb/input.h>
#include <linux/map_to_7segment.h> #include <linux/map_to_7segment.h>
@ -103,6 +103,8 @@ struct yealink_dev {
u8 lcdMap[ARRAY_SIZE(lcdMap)]; /* state of LCD, LED ... */ u8 lcdMap[ARRAY_SIZE(lcdMap)]; /* state of LCD, LED ... */
int key_code; /* last reported key */ int key_code; /* last reported key */
struct mutex sysfs_mutex;
unsigned int shutdown:1; unsigned int shutdown:1;
int stat_ix; int stat_ix;
@ -548,8 +550,6 @@ static void input_close(struct input_dev *dev)
* sysfs interface * sysfs interface
******************************************************************************/ ******************************************************************************/
static DECLARE_RWSEM(sysfs_rwsema);
/* Interface to the 7-segments translation table aka. char set. /* Interface to the 7-segments translation table aka. char set.
*/ */
static ssize_t show_map(struct device *dev, struct device_attribute *attr, static ssize_t show_map(struct device *dev, struct device_attribute *attr,
@ -580,15 +580,10 @@ static ssize_t store_map(struct device *dev, struct device_attribute *attr,
*/ */
static ssize_t show_line(struct device *dev, char *buf, int a, int b) static ssize_t show_line(struct device *dev, char *buf, int a, int b)
{ {
struct yealink_dev *yld; struct yealink_dev *yld = dev_get_drvdata(dev);
int i; int i;
down_read(&sysfs_rwsema); guard(mutex)(&yld->sysfs_mutex);
yld = dev_get_drvdata(dev);
if (yld == NULL) {
up_read(&sysfs_rwsema);
return -ENODEV;
}
for (i = a; i < b; i++) for (i = a; i < b; i++)
*buf++ = lcdMap[i].type; *buf++ = lcdMap[i].type;
@ -598,7 +593,6 @@ static ssize_t show_line(struct device *dev, char *buf, int a, int b)
*buf++ = '\n'; *buf++ = '\n';
*buf = 0; *buf = 0;
up_read(&sysfs_rwsema);
return 3 + ((b - a) << 1); return 3 + ((b - a) << 1);
} }
@ -630,22 +624,16 @@ static ssize_t show_line3(struct device *dev, struct device_attribute *attr,
static ssize_t store_line(struct device *dev, const char *buf, size_t count, static ssize_t store_line(struct device *dev, const char *buf, size_t count,
int el, size_t len) int el, size_t len)
{ {
struct yealink_dev *yld; struct yealink_dev *yld = dev_get_drvdata(dev);
int i; int i;
down_write(&sysfs_rwsema); guard(mutex)(&yld->sysfs_mutex);
yld = dev_get_drvdata(dev);
if (yld == NULL) {
up_write(&sysfs_rwsema);
return -ENODEV;
}
if (len > count) if (len > count)
len = count; len = count;
for (i = 0; i < len; i++) for (i = 0; i < len; i++)
setChar(yld, el++, buf[i]); setChar(yld, el++, buf[i]);
up_write(&sysfs_rwsema);
return count; return count;
} }
@ -675,15 +663,10 @@ static ssize_t store_line3(struct device *dev, struct device_attribute *attr,
static ssize_t get_icons(struct device *dev, struct device_attribute *attr, static ssize_t get_icons(struct device *dev, struct device_attribute *attr,
char *buf) char *buf)
{ {
struct yealink_dev *yld; struct yealink_dev *yld = dev_get_drvdata(dev);
int i, ret = 1; int i, ret = 1;
down_read(&sysfs_rwsema); guard(mutex)(&yld->sysfs_mutex);
yld = dev_get_drvdata(dev);
if (yld == NULL) {
up_read(&sysfs_rwsema);
return -ENODEV;
}
for (i = 0; i < ARRAY_SIZE(lcdMap); i++) { for (i = 0; i < ARRAY_SIZE(lcdMap); i++) {
if (lcdMap[i].type != '.') if (lcdMap[i].type != '.')
@ -692,7 +675,7 @@ static ssize_t get_icons(struct device *dev, struct device_attribute *attr,
yld->lcdMap[i] == ' ' ? " " : "on", yld->lcdMap[i] == ' ' ? " " : "on",
lcdMap[i].u.p.name); lcdMap[i].u.p.name);
} }
up_read(&sysfs_rwsema);
return ret; return ret;
} }
@ -700,15 +683,10 @@ static ssize_t get_icons(struct device *dev, struct device_attribute *attr,
static ssize_t set_icon(struct device *dev, const char *buf, size_t count, static ssize_t set_icon(struct device *dev, const char *buf, size_t count,
int chr) int chr)
{ {
struct yealink_dev *yld; struct yealink_dev *yld = dev_get_drvdata(dev);
int i; int i;
down_write(&sysfs_rwsema); guard(mutex)(&yld->sysfs_mutex);
yld = dev_get_drvdata(dev);
if (yld == NULL) {
up_write(&sysfs_rwsema);
return -ENODEV;
}
for (i = 0; i < ARRAY_SIZE(lcdMap); i++) { for (i = 0; i < ARRAY_SIZE(lcdMap); i++) {
if (lcdMap[i].type != '.') if (lcdMap[i].type != '.')
@ -719,7 +697,6 @@ static ssize_t set_icon(struct device *dev, const char *buf, size_t count,
} }
} }
up_write(&sysfs_rwsema);
return count; return count;
} }
@ -739,22 +716,16 @@ static ssize_t hide_icon(struct device *dev, struct device_attribute *attr,
*/ */
/* Stores raw ringtone data in the phone */ /* Stores raw ringtone data in the phone */
static ssize_t store_ringtone(struct device *dev, static ssize_t store_ringtone(struct device *dev, struct device_attribute *attr,
struct device_attribute *attr, const char *buf, size_t count)
const char *buf, size_t count)
{ {
struct yealink_dev *yld; struct yealink_dev *yld = dev_get_drvdata(dev);
down_write(&sysfs_rwsema); guard(mutex)(&yld->sysfs_mutex);
yld = dev_get_drvdata(dev);
if (yld == NULL) {
up_write(&sysfs_rwsema);
return -ENODEV;
}
/* TODO locking with async usb control interface??? */ /* TODO locking with async usb control interface??? */
yealink_set_ringtone(yld, (char *)buf, count); yealink_set_ringtone(yld, (char *)buf, count);
up_write(&sysfs_rwsema);
return count; return count;
} }
@ -771,7 +742,7 @@ static DEVICE_ATTR(show_icon , _M220, NULL , show_icon );
static DEVICE_ATTR(hide_icon , _M220, NULL , hide_icon ); static DEVICE_ATTR(hide_icon , _M220, NULL , hide_icon );
static DEVICE_ATTR(ringtone , _M220, NULL , store_ringtone); static DEVICE_ATTR(ringtone , _M220, NULL , store_ringtone);
static struct attribute *yld_attributes[] = { static struct attribute *yld_attrs[] = {
&dev_attr_line1.attr, &dev_attr_line1.attr,
&dev_attr_line2.attr, &dev_attr_line2.attr,
&dev_attr_line3.attr, &dev_attr_line3.attr,
@ -782,10 +753,7 @@ static struct attribute *yld_attributes[] = {
&dev_attr_ringtone.attr, &dev_attr_ringtone.attr,
NULL NULL
}; };
ATTRIBUTE_GROUPS(yld);
static const struct attribute_group yld_attr_group = {
.attrs = yld_attributes
};
/******************************************************************************* /*******************************************************************************
* Linux interface and usb initialisation * Linux interface and usb initialisation
@ -838,15 +806,10 @@ static int usb_cleanup(struct yealink_dev *yld, int err)
static void usb_disconnect(struct usb_interface *intf) static void usb_disconnect(struct usb_interface *intf)
{ {
struct yealink_dev *yld; struct yealink_dev *yld = usb_get_intfdata(intf);
down_write(&sysfs_rwsema);
yld = usb_get_intfdata(intf);
sysfs_remove_group(&intf->dev.kobj, &yld_attr_group);
usb_set_intfdata(intf, NULL);
up_write(&sysfs_rwsema);
usb_cleanup(yld, 0); usb_cleanup(yld, 0);
usb_set_intfdata(intf, NULL);
} }
static int usb_probe(struct usb_interface *intf, const struct usb_device_id *id) static int usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
@ -868,12 +831,13 @@ static int usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
if (!usb_endpoint_is_int_in(endpoint)) if (!usb_endpoint_is_int_in(endpoint))
return -ENODEV; return -ENODEV;
yld = kzalloc(sizeof(struct yealink_dev), GFP_KERNEL); yld = kzalloc(sizeof(*yld), GFP_KERNEL);
if (!yld) if (!yld)
return -ENOMEM; return -ENOMEM;
yld->udev = udev; yld->udev = udev;
yld->intf = intf; yld->intf = intf;
mutex_init(&yld->sysfs_mutex);
yld->idev = input_dev = input_allocate_device(); yld->idev = input_dev = input_allocate_device();
if (!input_dev) if (!input_dev)
@ -975,8 +939,6 @@ static int usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
store_line3(&intf->dev, NULL, store_line3(&intf->dev, NULL,
DRIVER_VERSION, sizeof(DRIVER_VERSION)); DRIVER_VERSION, sizeof(DRIVER_VERSION));
/* Register sysfs hooks (don't care about failure) */
ret = sysfs_create_group(&intf->dev.kobj, &yld_attr_group);
return 0; return 0;
} }
@ -985,6 +947,7 @@ static struct usb_driver yealink_driver = {
.probe = usb_probe, .probe = usb_probe,
.disconnect = usb_disconnect, .disconnect = usb_disconnect,
.id_table = usb_table, .id_table = usb_table,
.dev_groups = yld_groups,
}; };
module_usb_driver(yealink_driver); module_usb_driver(yealink_driver);

View File

@ -3201,7 +3201,7 @@ int alps_detect(struct psmouse *psmouse, bool set_properties)
*/ */
psmouse_reset(psmouse); psmouse_reset(psmouse);
priv = kzalloc(sizeof(struct alps_data), GFP_KERNEL); priv = kzalloc(sizeof(*priv), GFP_KERNEL);
if (!priv) if (!priv)
return -ENOMEM; return -ENOMEM;

View File

@ -855,7 +855,7 @@ static int atp_probe(struct usb_interface *iface,
} }
/* allocate memory for our device state and initialize it */ /* allocate memory for our device state and initialize it */
dev = kzalloc(sizeof(struct atp), GFP_KERNEL); dev = kzalloc(sizeof(*dev), GFP_KERNEL);
input_dev = input_allocate_device(); input_dev = input_allocate_device();
if (!dev || !input_dev) { if (!dev || !input_dev) {
dev_err(&iface->dev, "Out of memory\n"); dev_err(&iface->dev, "Out of memory\n");

View File

@ -904,7 +904,7 @@ static int bcm5974_probe(struct usb_interface *iface,
cfg = bcm5974_get_config(udev); cfg = bcm5974_get_config(udev);
/* allocate memory for our device state and initialize it */ /* allocate memory for our device state and initialize it */
dev = kzalloc(sizeof(struct bcm5974), GFP_KERNEL); dev = kzalloc(sizeof(*dev), GFP_KERNEL);
input_dev = input_allocate_device(); input_dev = input_allocate_device();
if (!dev || !input_dev) { if (!dev || !input_dev) {
dev_err(&iface->dev, "out of memory\n"); dev_err(&iface->dev, "out of memory\n");

View File

@ -32,33 +32,30 @@ static void cypress_set_packet_size(struct psmouse *psmouse, unsigned int n)
cytp->pkt_size = n; cytp->pkt_size = n;
} }
static const unsigned char cytp_rate[] = {10, 20, 40, 60, 100, 200}; static const u8 cytp_rate[] = {10, 20, 40, 60, 100, 200};
static const unsigned char cytp_resolution[] = {0x00, 0x01, 0x02, 0x03}; static const u8 cytp_resolution[] = {0x00, 0x01, 0x02, 0x03};
static int cypress_ps2_sendbyte(struct psmouse *psmouse, int value) static int cypress_ps2_sendbyte(struct psmouse *psmouse, u8 cmd)
{ {
struct ps2dev *ps2dev = &psmouse->ps2dev; struct ps2dev *ps2dev = &psmouse->ps2dev;
int error;
if (ps2_sendbyte(ps2dev, value & 0xff, CYTP_CMD_TIMEOUT) < 0) { error = ps2_sendbyte(ps2dev, cmd, CYTP_CMD_TIMEOUT);
if (error) {
psmouse_dbg(psmouse, psmouse_dbg(psmouse,
"sending command 0x%02x failed, resp 0x%02x\n", "sending command 0x%02x failed, resp 0x%02x, error %d\n",
value & 0xff, ps2dev->nak); cmd, ps2dev->nak, error);
if (ps2dev->nak == CYTP_PS2_RETRY) return error;
return CYTP_PS2_RETRY;
else
return CYTP_PS2_ERROR;
} }
#ifdef CYTP_DEBUG_VERBOSE #ifdef CYTP_DEBUG_VERBOSE
psmouse_dbg(psmouse, "sending command 0x%02x succeeded, resp 0xfa\n", psmouse_dbg(psmouse, "sending command 0x%02x succeeded\n", cmd);
value & 0xff);
#endif #endif
return 0; return 0;
} }
static int cypress_ps2_ext_cmd(struct psmouse *psmouse, unsigned short cmd, static int cypress_ps2_ext_cmd(struct psmouse *psmouse, u8 prefix, u8 nibble)
unsigned char data)
{ {
struct ps2dev *ps2dev = &psmouse->ps2dev; struct ps2dev *ps2dev = &psmouse->ps2dev;
int tries = CYTP_PS2_CMD_TRIES; int tries = CYTP_PS2_CMD_TRIES;
@ -72,22 +69,21 @@ static int cypress_ps2_ext_cmd(struct psmouse *psmouse, unsigned short cmd,
* If sending the command fails, send recovery command * If sending the command fails, send recovery command
* to make the device return to the ready state. * to make the device return to the ready state.
*/ */
rc = cypress_ps2_sendbyte(psmouse, cmd & 0xff); rc = cypress_ps2_sendbyte(psmouse, prefix);
if (rc == CYTP_PS2_RETRY) { if (rc == -EAGAIN) {
rc = cypress_ps2_sendbyte(psmouse, 0x00); rc = cypress_ps2_sendbyte(psmouse, 0x00);
if (rc == CYTP_PS2_RETRY) if (rc == -EAGAIN)
rc = cypress_ps2_sendbyte(psmouse, 0x0a); rc = cypress_ps2_sendbyte(psmouse, 0x0a);
} }
if (rc == CYTP_PS2_ERROR)
continue;
rc = cypress_ps2_sendbyte(psmouse, data); if (!rc) {
if (rc == CYTP_PS2_RETRY) rc = cypress_ps2_sendbyte(psmouse, nibble);
rc = cypress_ps2_sendbyte(psmouse, data); if (rc == -EAGAIN)
if (rc == CYTP_PS2_ERROR) rc = cypress_ps2_sendbyte(psmouse, nibble);
continue;
else if (!rc)
break; break;
}
} while (--tries > 0); } while (--tries > 0);
ps2_end_command(ps2dev); ps2_end_command(ps2dev);
@ -96,13 +92,12 @@ static int cypress_ps2_ext_cmd(struct psmouse *psmouse, unsigned short cmd,
} }
static int cypress_ps2_read_cmd_status(struct psmouse *psmouse, static int cypress_ps2_read_cmd_status(struct psmouse *psmouse,
unsigned char cmd, u8 cmd, u8 *param)
unsigned char *param)
{ {
int rc;
struct ps2dev *ps2dev = &psmouse->ps2dev; struct ps2dev *ps2dev = &psmouse->ps2dev;
enum psmouse_state old_state; enum psmouse_state old_state;
int pktsize; int pktsize;
int rc;
ps2_begin_command(ps2dev); ps2_begin_command(ps2dev);
@ -113,13 +108,16 @@ static int cypress_ps2_read_cmd_status(struct psmouse *psmouse,
pktsize = (cmd == CYTP_CMD_READ_TP_METRICS) ? 8 : 3; pktsize = (cmd == CYTP_CMD_READ_TP_METRICS) ? 8 : 3;
memset(param, 0, pktsize); memset(param, 0, pktsize);
rc = cypress_ps2_sendbyte(psmouse, 0xe9); rc = cypress_ps2_sendbyte(psmouse, PSMOUSE_CMD_GETINFO & 0xff);
if (rc < 0) if (rc)
goto out; goto out;
wait_event_timeout(ps2dev->wait, if (!wait_event_timeout(ps2dev->wait,
(psmouse->pktcnt >= pktsize), psmouse->pktcnt >= pktsize,
msecs_to_jiffies(CYTP_CMD_TIMEOUT)); msecs_to_jiffies(CYTP_CMD_TIMEOUT))) {
rc = -ETIMEDOUT;
goto out;
}
memcpy(param, psmouse->packet, pktsize); memcpy(param, psmouse->packet, pktsize);
@ -135,8 +133,7 @@ static int cypress_ps2_read_cmd_status(struct psmouse *psmouse,
return rc; return rc;
} }
static bool cypress_verify_cmd_state(struct psmouse *psmouse, static bool cypress_verify_cmd_state(struct psmouse *psmouse, u8 cmd, u8* param)
unsigned char cmd, unsigned char *param)
{ {
bool rate_match = false; bool rate_match = false;
bool resolution_match = false; bool resolution_match = false;
@ -166,31 +163,24 @@ static bool cypress_verify_cmd_state(struct psmouse *psmouse,
return false; return false;
} }
static int cypress_send_ext_cmd(struct psmouse *psmouse, unsigned char cmd, static int cypress_send_ext_cmd(struct psmouse *psmouse, u8 cmd, u8 *param)
unsigned char *param)
{ {
u8 cmd_prefix = PSMOUSE_CMD_SETRES & 0xff;
int tries = CYTP_PS2_CMD_TRIES; int tries = CYTP_PS2_CMD_TRIES;
int rc; int error;
psmouse_dbg(psmouse, "send extension cmd 0x%02x, [%d %d %d %d]\n", psmouse_dbg(psmouse, "send extension cmd 0x%02x, [%d %d %d %d]\n",
cmd, DECODE_CMD_AA(cmd), DECODE_CMD_BB(cmd), cmd, DECODE_CMD_AA(cmd), DECODE_CMD_BB(cmd),
DECODE_CMD_CC(cmd), DECODE_CMD_DD(cmd)); DECODE_CMD_CC(cmd), DECODE_CMD_DD(cmd));
do { do {
cypress_ps2_ext_cmd(psmouse, cypress_ps2_ext_cmd(psmouse, cmd_prefix, DECODE_CMD_DD(cmd));
PSMOUSE_CMD_SETRES, DECODE_CMD_DD(cmd)); cypress_ps2_ext_cmd(psmouse, cmd_prefix, DECODE_CMD_CC(cmd));
cypress_ps2_ext_cmd(psmouse, cypress_ps2_ext_cmd(psmouse, cmd_prefix, DECODE_CMD_BB(cmd));
PSMOUSE_CMD_SETRES, DECODE_CMD_CC(cmd)); cypress_ps2_ext_cmd(psmouse, cmd_prefix, DECODE_CMD_AA(cmd));
cypress_ps2_ext_cmd(psmouse,
PSMOUSE_CMD_SETRES, DECODE_CMD_BB(cmd));
cypress_ps2_ext_cmd(psmouse,
PSMOUSE_CMD_SETRES, DECODE_CMD_AA(cmd));
rc = cypress_ps2_read_cmd_status(psmouse, cmd, param); error = cypress_ps2_read_cmd_status(psmouse, cmd, param);
if (rc) if (!error && cypress_verify_cmd_state(psmouse, cmd, param))
continue;
if (cypress_verify_cmd_state(psmouse, cmd, param))
return 0; return 0;
} while (--tries > 0); } while (--tries > 0);
@ -200,7 +190,7 @@ static int cypress_send_ext_cmd(struct psmouse *psmouse, unsigned char cmd,
int cypress_detect(struct psmouse *psmouse, bool set_properties) int cypress_detect(struct psmouse *psmouse, bool set_properties)
{ {
unsigned char param[3]; u8 param[3];
if (cypress_send_ext_cmd(psmouse, CYTP_CMD_READ_CYPRESS_ID, param)) if (cypress_send_ext_cmd(psmouse, CYTP_CMD_READ_CYPRESS_ID, param))
return -ENODEV; return -ENODEV;
@ -220,7 +210,7 @@ int cypress_detect(struct psmouse *psmouse, bool set_properties)
static int cypress_read_fw_version(struct psmouse *psmouse) static int cypress_read_fw_version(struct psmouse *psmouse)
{ {
struct cytp_data *cytp = psmouse->private; struct cytp_data *cytp = psmouse->private;
unsigned char param[3]; u8 param[3];
if (cypress_send_ext_cmd(psmouse, CYTP_CMD_READ_CYPRESS_ID, param)) if (cypress_send_ext_cmd(psmouse, CYTP_CMD_READ_CYPRESS_ID, param))
return -ENODEV; return -ENODEV;
@ -249,7 +239,7 @@ static int cypress_read_fw_version(struct psmouse *psmouse)
static int cypress_read_tp_metrics(struct psmouse *psmouse) static int cypress_read_tp_metrics(struct psmouse *psmouse)
{ {
struct cytp_data *cytp = psmouse->private; struct cytp_data *cytp = psmouse->private;
unsigned char param[8]; u8 param[8];
/* set default values for tp metrics. */ /* set default values for tp metrics. */
cytp->tp_width = CYTP_DEFAULT_WIDTH; cytp->tp_width = CYTP_DEFAULT_WIDTH;
@ -321,15 +311,15 @@ static int cypress_read_tp_metrics(struct psmouse *psmouse)
static int cypress_query_hardware(struct psmouse *psmouse) static int cypress_query_hardware(struct psmouse *psmouse)
{ {
int ret; int error;
ret = cypress_read_fw_version(psmouse); error = cypress_read_fw_version(psmouse);
if (ret) if (error)
return ret; return error;
ret = cypress_read_tp_metrics(psmouse); error = cypress_read_tp_metrics(psmouse);
if (ret) if (error)
return ret; return error;
return 0; return 0;
} }
@ -337,10 +327,13 @@ static int cypress_query_hardware(struct psmouse *psmouse)
static int cypress_set_absolute_mode(struct psmouse *psmouse) static int cypress_set_absolute_mode(struct psmouse *psmouse)
{ {
struct cytp_data *cytp = psmouse->private; struct cytp_data *cytp = psmouse->private;
unsigned char param[3]; u8 param[3];
int error;
if (cypress_send_ext_cmd(psmouse, CYTP_CMD_ABS_WITH_PRESSURE_MODE, param) < 0) error = cypress_send_ext_cmd(psmouse, CYTP_CMD_ABS_WITH_PRESSURE_MODE,
return -1; param);
if (error)
return error;
cytp->mode = (cytp->mode & ~CYTP_BIT_ABS_REL_MASK) cytp->mode = (cytp->mode & ~CYTP_BIT_ABS_REL_MASK)
| CYTP_BIT_ABS_PRESSURE; | CYTP_BIT_ABS_PRESSURE;
@ -365,7 +358,7 @@ static void cypress_reset(struct psmouse *psmouse)
static int cypress_set_input_params(struct input_dev *input, static int cypress_set_input_params(struct input_dev *input,
struct cytp_data *cytp) struct cytp_data *cytp)
{ {
int ret; int error;
if (!cytp->tp_res_x || !cytp->tp_res_y) if (!cytp->tp_res_x || !cytp->tp_res_y)
return -EINVAL; return -EINVAL;
@ -382,10 +375,10 @@ static int cypress_set_input_params(struct input_dev *input,
input_set_abs_params(input, ABS_MT_POSITION_Y, 0, cytp->tp_max_abs_y, 0, 0); input_set_abs_params(input, ABS_MT_POSITION_Y, 0, cytp->tp_max_abs_y, 0, 0);
input_set_abs_params(input, ABS_MT_PRESSURE, 0, 255, 0, 0); input_set_abs_params(input, ABS_MT_PRESSURE, 0, 255, 0, 0);
ret = input_mt_init_slots(input, CYTP_MAX_MT_SLOTS, error = input_mt_init_slots(input, CYTP_MAX_MT_SLOTS,
INPUT_MT_DROP_UNUSED|INPUT_MT_TRACK); INPUT_MT_DROP_UNUSED | INPUT_MT_TRACK);
if (ret < 0) if (error)
return ret; return error;
__set_bit(INPUT_PROP_SEMI_MT, input->propbit); __set_bit(INPUT_PROP_SEMI_MT, input->propbit);
@ -414,9 +407,9 @@ static int cypress_set_input_params(struct input_dev *input,
return 0; return 0;
} }
static int cypress_get_finger_count(unsigned char header_byte) static int cypress_get_finger_count(u8 header_byte)
{ {
unsigned char bits6_7; u8 bits6_7;
int finger_count; int finger_count;
bits6_7 = header_byte >> 6; bits6_7 = header_byte >> 6;
@ -441,10 +434,11 @@ static int cypress_get_finger_count(unsigned char header_byte)
static int cypress_parse_packet(struct psmouse *psmouse, static int cypress_parse_packet(struct psmouse *psmouse,
struct cytp_data *cytp, struct cytp_report_data *report_data) struct cytp_data *cytp,
struct cytp_report_data *report_data)
{ {
unsigned char *packet = psmouse->packet; u8 *packet = psmouse->packet;
unsigned char header_byte = packet[0]; u8 header_byte = packet[0];
memset(report_data, 0, sizeof(struct cytp_report_data)); memset(report_data, 0, sizeof(struct cytp_report_data));
@ -559,7 +553,7 @@ static psmouse_ret_t cypress_validate_byte(struct psmouse *psmouse)
{ {
int contact_cnt; int contact_cnt;
int index = psmouse->pktcnt - 1; int index = psmouse->pktcnt - 1;
unsigned char *packet = psmouse->packet; u8 *packet = psmouse->packet;
struct cytp_data *cytp = psmouse->private; struct cytp_data *cytp = psmouse->private;
if (index < 0 || index > cytp->pkt_size) if (index < 0 || index > cytp->pkt_size)
@ -612,6 +606,7 @@ static psmouse_ret_t cypress_protocol_handler(struct psmouse *psmouse)
static void cypress_set_rate(struct psmouse *psmouse, unsigned int rate) static void cypress_set_rate(struct psmouse *psmouse, unsigned int rate)
{ {
struct cytp_data *cytp = psmouse->private; struct cytp_data *cytp = psmouse->private;
u8 rate_param;
if (rate >= 80) { if (rate >= 80) {
psmouse->rate = 80; psmouse->rate = 80;
@ -621,8 +616,8 @@ static void cypress_set_rate(struct psmouse *psmouse, unsigned int rate)
cytp->mode &= ~CYTP_BIT_HIGH_RATE; cytp->mode &= ~CYTP_BIT_HIGH_RATE;
} }
ps2_command(&psmouse->ps2dev, (unsigned char *)&psmouse->rate, rate_param = (u8)rate;
PSMOUSE_CMD_SETRATE); ps2_command(&psmouse->ps2dev, &rate_param, PSMOUSE_CMD_SETRATE);
} }
static void cypress_disconnect(struct psmouse *psmouse) static void cypress_disconnect(struct psmouse *psmouse)
@ -635,21 +630,22 @@ static void cypress_disconnect(struct psmouse *psmouse)
static int cypress_reconnect(struct psmouse *psmouse) static int cypress_reconnect(struct psmouse *psmouse)
{ {
int tries = CYTP_PS2_CMD_TRIES; int tries = CYTP_PS2_CMD_TRIES;
int rc; int error;
do { do {
cypress_reset(psmouse); cypress_reset(psmouse);
rc = cypress_detect(psmouse, false); error = cypress_detect(psmouse, false);
} while (rc && (--tries > 0)); } while (error && (--tries > 0));
if (rc) { if (error) {
psmouse_err(psmouse, "Reconnect: unable to detect trackpad.\n"); psmouse_err(psmouse, "Reconnect: unable to detect trackpad.\n");
return -1; return error;
} }
if (cypress_set_absolute_mode(psmouse)) { error = cypress_set_absolute_mode(psmouse);
if (error) {
psmouse_err(psmouse, "Reconnect: Unable to initialize Cypress absolute mode.\n"); psmouse_err(psmouse, "Reconnect: Unable to initialize Cypress absolute mode.\n");
return -1; return error;
} }
return 0; return 0;
@ -658,8 +654,9 @@ static int cypress_reconnect(struct psmouse *psmouse)
int cypress_init(struct psmouse *psmouse) int cypress_init(struct psmouse *psmouse)
{ {
struct cytp_data *cytp; struct cytp_data *cytp;
int error;
cytp = kzalloc(sizeof(struct cytp_data), GFP_KERNEL); cytp = kzalloc(sizeof(*cytp), GFP_KERNEL);
if (!cytp) if (!cytp)
return -ENOMEM; return -ENOMEM;
@ -668,17 +665,20 @@ int cypress_init(struct psmouse *psmouse)
cypress_reset(psmouse); cypress_reset(psmouse);
if (cypress_query_hardware(psmouse)) { error = cypress_query_hardware(psmouse);
if (error) {
psmouse_err(psmouse, "Unable to query Trackpad hardware.\n"); psmouse_err(psmouse, "Unable to query Trackpad hardware.\n");
goto err_exit; goto err_exit;
} }
if (cypress_set_absolute_mode(psmouse)) { error = cypress_set_absolute_mode(psmouse);
if (error) {
psmouse_err(psmouse, "init: Unable to initialize Cypress absolute mode.\n"); psmouse_err(psmouse, "init: Unable to initialize Cypress absolute mode.\n");
goto err_exit; goto err_exit;
} }
if (cypress_set_input_params(psmouse->dev, cytp) < 0) { error = cypress_set_input_params(psmouse->dev, cytp);
if (error) {
psmouse_err(psmouse, "init: Unable to set input params.\n"); psmouse_err(psmouse, "init: Unable to set input params.\n");
goto err_exit; goto err_exit;
} }
@ -703,5 +703,5 @@ int cypress_init(struct psmouse *psmouse)
psmouse->private = NULL; psmouse->private = NULL;
kfree(cytp); kfree(cytp);
return -1; return error;
} }

View File

@ -72,12 +72,6 @@
#define CYTP_DATA_TIMEOUT 30 #define CYTP_DATA_TIMEOUT 30
#define CYTP_EXT_CMD 0xe8 #define CYTP_EXT_CMD 0xe8
#define CYTP_PS2_RETRY 0xfe
#define CYTP_PS2_ERROR 0xfc
#define CYTP_RESP_RETRY 0x01
#define CYTP_RESP_ERROR 0xfe
#define CYTP_105001_WIDTH 97 /* Dell XPS 13 */ #define CYTP_105001_WIDTH 97 /* Dell XPS 13 */
#define CYTP_105001_HIGH 59 #define CYTP_105001_HIGH 59

View File

@ -1356,6 +1356,8 @@ static int elan_suspend(struct device *dev)
} }
err: err:
if (ret)
enable_irq(client->irq);
mutex_unlock(&data->sysfs_mutex); mutex_unlock(&data->sysfs_mutex);
return ret; return ret;
} }

View File

@ -408,8 +408,7 @@ int focaltech_init(struct psmouse *psmouse)
struct focaltech_data *priv; struct focaltech_data *priv;
int error; int error;
psmouse->private = priv = kzalloc(sizeof(struct focaltech_data), psmouse->private = priv = kzalloc(sizeof(*priv), GFP_KERNEL);
GFP_KERNEL);
if (!priv) if (!priv)
return -ENOMEM; return -ENOMEM;

View File

@ -981,7 +981,7 @@ int hgpk_init(struct psmouse *psmouse)
struct hgpk_data *priv; struct hgpk_data *priv;
int err; int err;
priv = kzalloc(sizeof(struct hgpk_data), GFP_KERNEL); priv = kzalloc(sizeof(*priv), GFP_KERNEL);
if (!priv) { if (!priv) {
err = -ENOMEM; err = -ENOMEM;
goto alloc_fail; goto alloc_fail;

View File

@ -273,7 +273,7 @@ static int lifebook_create_relative_device(struct psmouse *psmouse)
struct lifebook_data *priv; struct lifebook_data *priv;
int error = -ENOMEM; int error = -ENOMEM;
priv = kzalloc(sizeof(struct lifebook_data), GFP_KERNEL); priv = kzalloc(sizeof(*priv), GFP_KERNEL);
dev2 = input_allocate_device(); dev2 = input_allocate_device();
if (!priv || !dev2) if (!priv || !dev2)
goto err_out; goto err_out;

View File

@ -73,7 +73,7 @@ static int probe_maple_mouse(struct device *dev)
struct input_dev *input_dev; struct input_dev *input_dev;
struct dc_mouse *mse; struct dc_mouse *mse;
mse = kzalloc(sizeof(struct dc_mouse), GFP_KERNEL); mse = kzalloc(sizeof(*mse), GFP_KERNEL);
if (!mse) { if (!mse) {
error = -ENOMEM; error = -ENOMEM;
goto fail; goto fail;

View File

@ -1591,7 +1591,7 @@ static int psmouse_connect(struct serio *serio, struct serio_driver *drv)
psmouse_deactivate(parent); psmouse_deactivate(parent);
} }
psmouse = kzalloc(sizeof(struct psmouse), GFP_KERNEL); psmouse = kzalloc(sizeof(*psmouse), GFP_KERNEL);
input_dev = input_allocate_device(); input_dev = input_allocate_device();
if (!psmouse || !input_dev) if (!psmouse || !input_dev)
goto err_free; goto err_free;

View File

@ -1028,7 +1028,7 @@ int fsp_init(struct psmouse *psmouse)
"Finger Sensing Pad, hw: %d.%d.%d, sn: %x, sw: %s\n", "Finger Sensing Pad, hw: %d.%d.%d, sn: %x, sw: %s\n",
ver >> 4, ver & 0x0F, rev, sn, fsp_drv_ver); ver >> 4, ver & 0x0F, rev, sn, fsp_drv_ver);
psmouse->private = priv = kzalloc(sizeof(struct fsp_data), GFP_KERNEL); psmouse->private = priv = kzalloc(sizeof(*priv), GFP_KERNEL);
if (!priv) if (!priv)
return -ENOMEM; return -ENOMEM;

View File

@ -231,7 +231,7 @@ static int sermouse_connect(struct serio *serio, struct serio_driver *drv)
unsigned char c = serio->id.extra; unsigned char c = serio->id.extra;
int err = -ENOMEM; int err = -ENOMEM;
sermouse = kzalloc(sizeof(struct sermouse), GFP_KERNEL); sermouse = kzalloc(sizeof(*sermouse), GFP_KERNEL);
input_dev = input_allocate_device(); input_dev = input_allocate_device();
if (!sermouse || !input_dev) if (!sermouse || !input_dev)
goto fail1; goto fail1;

View File

@ -708,7 +708,7 @@ static void synaptics_pt_create(struct psmouse *psmouse)
{ {
struct serio *serio; struct serio *serio;
serio = kzalloc(sizeof(struct serio), GFP_KERNEL); serio = kzalloc(sizeof(*serio), GFP_KERNEL);
if (!serio) { if (!serio) {
psmouse_err(psmouse, psmouse_err(psmouse,
"not enough memory for pass-through port\n"); "not enough memory for pass-through port\n");
@ -1563,7 +1563,7 @@ static int synaptics_init_ps2(struct psmouse *psmouse,
synaptics_apply_quirks(psmouse, info); synaptics_apply_quirks(psmouse, info);
psmouse->private = priv = kzalloc(sizeof(struct synaptics_data), GFP_KERNEL); psmouse->private = priv = kzalloc(sizeof(*priv), GFP_KERNEL);
if (!priv) if (!priv)
return -ENOMEM; return -ENOMEM;

View File

@ -508,7 +508,7 @@ static struct synaptics_i2c *synaptics_i2c_touch_create(struct i2c_client *clien
{ {
struct synaptics_i2c *touch; struct synaptics_i2c *touch;
touch = kzalloc(sizeof(struct synaptics_i2c), GFP_KERNEL); touch = kzalloc(sizeof(*touch), GFP_KERNEL);
if (!touch) if (!touch)
return NULL; return NULL;

View File

@ -456,7 +456,7 @@ static int vsxxxaa_connect(struct serio *serio, struct serio_driver *drv)
struct input_dev *input_dev; struct input_dev *input_dev;
int err = -ENOMEM; int err = -ENOMEM;
mouse = kzalloc(sizeof(struct vsxxxaa), GFP_KERNEL); mouse = kzalloc(sizeof(*mouse), GFP_KERNEL);
input_dev = input_allocate_device(); input_dev = input_allocate_device();
if (!mouse || !input_dev) if (!mouse || !input_dev)
goto fail1; goto fail1;

View File

@ -100,7 +100,7 @@ static int altera_ps2_probe(struct platform_device *pdev)
return error; return error;
} }
serio = kzalloc(sizeof(struct serio), GFP_KERNEL); serio = kzalloc(sizeof(*serio), GFP_KERNEL);
if (!serio) if (!serio)
return -ENOMEM; return -ENOMEM;

View File

@ -114,8 +114,8 @@ static int amba_kmi_probe(struct amba_device *dev,
if (ret) if (ret)
return ret; return ret;
kmi = kzalloc(sizeof(struct amba_kmi_port), GFP_KERNEL); kmi = kzalloc(sizeof(*kmi), GFP_KERNEL);
io = kzalloc(sizeof(struct serio), GFP_KERNEL); io = kzalloc(sizeof(*io), GFP_KERNEL);
if (!kmi || !io) { if (!kmi || !io) {
ret = -ENOMEM; ret = -ENOMEM;
goto out; goto out;

View File

@ -165,7 +165,7 @@ static int apbps2_of_probe(struct platform_device *ofdev)
/* Set reload register to core freq in kHz/10 */ /* Set reload register to core freq in kHz/10 */
iowrite32be(freq_hz / 10000, &priv->regs->reload); iowrite32be(freq_hz / 10000, &priv->regs->reload);
priv->io = kzalloc(sizeof(struct serio), GFP_KERNEL); priv->io = kzalloc(sizeof(*priv->io), GFP_KERNEL);
if (!priv->io) if (!priv->io)
return -ENOMEM; return -ENOMEM;

View File

@ -155,7 +155,7 @@ static int arc_ps2_create_port(struct platform_device *pdev,
struct arc_ps2_port *port = &arc_ps2->port[index]; struct arc_ps2_port *port = &arc_ps2->port[index];
struct serio *io; struct serio *io;
io = kzalloc(sizeof(struct serio), GFP_KERNEL); io = kzalloc(sizeof(*io), GFP_KERNEL);
if (!io) if (!io)
return -ENOMEM; return -ENOMEM;

View File

@ -158,7 +158,7 @@ static int __init ct82c710_detect(void)
static int ct82c710_probe(struct platform_device *dev) static int ct82c710_probe(struct platform_device *dev)
{ {
ct82c710_port = kzalloc(sizeof(struct serio), GFP_KERNEL); ct82c710_port = kzalloc(sizeof(*ct82c710_port), GFP_KERNEL);
if (!ct82c710_port) if (!ct82c710_port)
return -ENOMEM; return -ENOMEM;

View File

@ -338,8 +338,8 @@ static int __init gscps2_probe(struct parisc_device *dev)
if (dev->id.sversion == 0x96) if (dev->id.sversion == 0x96)
hpa += GSC_DINO_OFFSET; hpa += GSC_DINO_OFFSET;
ps2port = kzalloc(sizeof(struct gscps2port), GFP_KERNEL); ps2port = kzalloc(sizeof(*ps2port), GFP_KERNEL);
serio = kzalloc(sizeof(struct serio), GFP_KERNEL); serio = kzalloc(sizeof(*serio), GFP_KERNEL);
if (!ps2port || !serio) { if (!ps2port || !serio) {
ret = -ENOMEM; ret = -ENOMEM;
goto fail_nomem; goto fail_nomem;

View File

@ -318,8 +318,8 @@ static int hv_kbd_probe(struct hv_device *hv_dev,
struct serio *hv_serio; struct serio *hv_serio;
int error; int error;
kbd_dev = kzalloc(sizeof(struct hv_kbd_dev), GFP_KERNEL); kbd_dev = kzalloc(sizeof(*kbd_dev), GFP_KERNEL);
hv_serio = kzalloc(sizeof(struct serio), GFP_KERNEL); hv_serio = kzalloc(sizeof(*hv_serio), GFP_KERNEL);
if (!kbd_dev || !hv_serio) { if (!kbd_dev || !hv_serio) {
error = -ENOMEM; error = -ENOMEM;
goto err_free_mem; goto err_free_mem;

View File

@ -1329,7 +1329,7 @@ static int i8042_create_kbd_port(void)
struct serio *serio; struct serio *serio;
struct i8042_port *port = &i8042_ports[I8042_KBD_PORT_NO]; struct i8042_port *port = &i8042_ports[I8042_KBD_PORT_NO];
serio = kzalloc(sizeof(struct serio), GFP_KERNEL); serio = kzalloc(sizeof(*serio), GFP_KERNEL);
if (!serio) if (!serio)
return -ENOMEM; return -ENOMEM;
@ -1359,7 +1359,7 @@ static int i8042_create_aux_port(int idx)
int port_no = idx < 0 ? I8042_AUX_PORT_NO : I8042_MUX_PORT_NO + idx; int port_no = idx < 0 ? I8042_AUX_PORT_NO : I8042_MUX_PORT_NO + idx;
struct i8042_port *port = &i8042_ports[port_no]; struct i8042_port *port = &i8042_ports[port_no];
serio = kzalloc(sizeof(struct serio), GFP_KERNEL); serio = kzalloc(sizeof(*serio), GFP_KERNEL);
if (!serio) if (!serio)
return -ENOMEM; return -ENOMEM;

View File

@ -117,7 +117,7 @@ static struct serio *maceps2_allocate_port(int idx)
{ {
struct serio *serio; struct serio *serio;
serio = kzalloc(sizeof(struct serio), GFP_KERNEL); serio = kzalloc(sizeof(*serio), GFP_KERNEL);
if (serio) { if (serio) {
serio->id.type = SERIO_8042; serio->id.type = SERIO_8042;
serio->write = maceps2_write; serio->write = maceps2_write;

View File

@ -188,7 +188,7 @@ static int olpc_apsp_probe(struct platform_device *pdev)
return priv->irq; return priv->irq;
/* KEYBOARD */ /* KEYBOARD */
kb_serio = kzalloc(sizeof(struct serio), GFP_KERNEL); kb_serio = kzalloc(sizeof(*kb_serio), GFP_KERNEL);
if (!kb_serio) if (!kb_serio)
return -ENOMEM; return -ENOMEM;
kb_serio->id.type = SERIO_8042_XL; kb_serio->id.type = SERIO_8042_XL;
@ -203,7 +203,7 @@ static int olpc_apsp_probe(struct platform_device *pdev)
serio_register_port(kb_serio); serio_register_port(kb_serio);
/* TOUCHPAD */ /* TOUCHPAD */
pad_serio = kzalloc(sizeof(struct serio), GFP_KERNEL); pad_serio = kzalloc(sizeof(*pad_serio), GFP_KERNEL);
if (!pad_serio) { if (!pad_serio) {
error = -ENOMEM; error = -ENOMEM;
goto err_pad; goto err_pad;

View File

@ -165,7 +165,7 @@ static struct serio *parkbd_allocate_serio(void)
{ {
struct serio *serio; struct serio *serio;
serio = kzalloc(sizeof(struct serio), GFP_KERNEL); serio = kzalloc(sizeof(*serio), GFP_KERNEL);
if (serio) { if (serio) {
serio->id.type = parkbd_mode; serio->id.type = parkbd_mode;
serio->write = parkbd_write; serio->write = parkbd_write;

View File

@ -137,8 +137,8 @@ static int pcips2_probe(struct pci_dev *dev, const struct pci_device_id *id)
if (ret) if (ret)
goto disable; goto disable;
ps2if = kzalloc(sizeof(struct pcips2_data), GFP_KERNEL); ps2if = kzalloc(sizeof(*ps2if), GFP_KERNEL);
serio = kzalloc(sizeof(struct serio), GFP_KERNEL); serio = kzalloc(sizeof(*serio), GFP_KERNEL);
if (!ps2if || !serio) { if (!ps2if || !serio) {
ret = -ENOMEM; ret = -ENOMEM;
goto release; goto release;

View File

@ -404,8 +404,8 @@ static int ps2_gpio_probe(struct platform_device *pdev)
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
int error; int error;
drvdata = devm_kzalloc(dev, sizeof(struct ps2_gpio_data), GFP_KERNEL); drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL);
serio = kzalloc(sizeof(struct serio), GFP_KERNEL); serio = kzalloc(sizeof(*serio), GFP_KERNEL);
if (!drvdata || !serio) { if (!drvdata || !serio) {
error = -ENOMEM; error = -ENOMEM;
goto err_free_serio; goto err_free_serio;

View File

@ -127,7 +127,7 @@ static int ps2mult_create_port(struct ps2mult *psm, int i)
struct serio *mx_serio = psm->mx_serio; struct serio *mx_serio = psm->mx_serio;
struct serio *serio; struct serio *serio;
serio = kzalloc(sizeof(struct serio), GFP_KERNEL); serio = kzalloc(sizeof(*serio), GFP_KERNEL);
if (!serio) if (!serio)
return -ENOMEM; return -ENOMEM;

View File

@ -108,8 +108,8 @@ static int q40kbd_probe(struct platform_device *pdev)
struct serio *port; struct serio *port;
int error; int error;
q40kbd = kzalloc(sizeof(struct q40kbd), GFP_KERNEL); q40kbd = kzalloc(sizeof(*q40kbd), GFP_KERNEL);
port = kzalloc(sizeof(struct serio), GFP_KERNEL); port = kzalloc(sizeof(*port), GFP_KERNEL);
if (!q40kbd || !port) { if (!q40kbd || !port) {
error = -ENOMEM; error = -ENOMEM;
goto err_free_mem; goto err_free_mem;

Some files were not shown because too many files have changed in this diff Show More