Commit graph

9 commits

Author SHA1 Message Date
Kees Cook
0ed2dd03b9 treewide: Use struct_size() for devm_kmalloc() and friends
Replaces open-coded struct size calculations with struct_size() for
devm_*, f2fs_*, and sock_* allocations. Automatically generated (and
manually adjusted) from the following Coccinelle script:

// Direct reference to struct field.
@@
identifier alloc =~ "devm_kmalloc|devm_kzalloc|sock_kmalloc|f2fs_kmalloc|f2fs_kzalloc";
expression HANDLE;
expression GFP;
identifier VAR, ELEMENT;
expression COUNT;
@@

- alloc(HANDLE, sizeof(*VAR) + COUNT * sizeof(*VAR->ELEMENT), GFP)
+ alloc(HANDLE, struct_size(VAR, ELEMENT, COUNT), GFP)

// mr = kzalloc(sizeof(*mr) + m * sizeof(mr->map[0]), GFP_KERNEL);
@@
identifier alloc =~ "devm_kmalloc|devm_kzalloc|sock_kmalloc|f2fs_kmalloc|f2fs_kzalloc";
expression HANDLE;
expression GFP;
identifier VAR, ELEMENT;
expression COUNT;
@@

- alloc(HANDLE, sizeof(*VAR) + COUNT * sizeof(VAR->ELEMENT[0]), GFP)
+ alloc(HANDLE, struct_size(VAR, ELEMENT, COUNT), GFP)

// Same pattern, but can't trivially locate the trailing element name,
// or variable name.
@@
identifier alloc =~ "devm_kmalloc|devm_kzalloc|sock_kmalloc|f2fs_kmalloc|f2fs_kzalloc";
expression HANDLE;
expression GFP;
expression SOMETHING, COUNT, ELEMENT;
@@

- alloc(HANDLE, sizeof(SOMETHING) + COUNT * sizeof(ELEMENT), GFP)
+ alloc(HANDLE, CHECKME_struct_size(&SOMETHING, ELEMENT, COUNT), GFP)

Signed-off-by: Kees Cook <keescook@chromium.org>
2018-06-06 11:15:43 -07:00
Guenter Roeck
666c0b8366 Input: keyboard - drop calls to platform_set_drvdata and i2c_set_clientdata
There is no call to i2c_get_clientdata(), platform_get_drvdata(),
or dev_get_drvdata() in any of the drivers in this patch.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2017-01-21 23:51:49 -08:00
Amitoj Kaur Chawla
497e1b3f6b Input: cap11xx - add missing of_node_put
for_each_child_of_node performs an of_node_get on each iteration, so
to break out of the loop an of_node_put is required.

Found using Coccinelle.

Signed-off-by: Amitoj Kaur Chawla <amitoj1606@gmail.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2016-01-27 15:55:48 -08:00
Matt Ranostay
efe3b616f8 Input: cap11xx - add LED support
Several cap11xx variants have LEDs that be can be controlled; let's plug
the driver into the LED subsystem.

Signed-off-by: Matt Ranostay <mranostay@gmail.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2015-08-16 23:22:01 -07:00
Krzysztof Kozlowski
800e3b9a68 Input: drop owner assignment from i2c_driver
i2c_driver does not need to set an owner because i2c_register_driver()
will set it.

Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2015-07-17 16:57:00 -07:00
Axel Lin
e297d7bbf6 Input: cap11xx - remove wrong and unneeded cap11xx modalias
This is a I2C driver, so it's wrong to use platform prefix for the
modalias.  We have all needed i2c aliases coming form MODULE_DEVICE_TABLE,
so let's remove the wrong and unneeded cap11xx modalias.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Acked-by: Daniel Mack <linux@zonque.org>
Reviewed-by: Matt Ranostay <mranostay@gmail.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2015-02-01 11:21:23 -08:00
Matt Ranostay
6bdd2fd1ed Input: cap11xx - support for irq-active-high option
Some applications need to use the irq-active-high push-pull option.
This allows it be enabled in the device tree child node.

Signed-off-by: Matt Ranostay <mranostay@gmail.com>
Reviewed-by: Daniel Mack <daniel@zonque.org>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2014-11-02 00:09:11 -07:00
Matt Ranostay
7609a5e973 Input: cap11xx - add support for various cap11xx devices
There are variants of the cap11xx device with a varying number of
capacitance detection channels.

Signed-off-by: Matt Ranostay <mranostay@gmail.com>
Reviewed-by: Daniel Mack <daniel@zonque.org>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2014-11-02 00:09:10 -07:00
Matt Ranostay
c77fd0a42b Input: rename cap1106 driver to cap11xx
There are several devices in cap11xx family besides cap1106. The driver can
be made to support all of them, so let's give it more generic name.

Signed-off-by: Matt Ranostay <mranostay@gmail.com>
Reviewed-by: Daniel Mack <daniel@zonque.org>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2014-11-02 00:09:10 -07:00