Input: matrix-keypad - switch to using generic device properties
Subsystems (5)
Dmitry Torokhov
maintainerPATCH 1/2 Input: matrix-keypad - switch to using generic device properties
Instead of being OF-specific, let's switch to using generic device properties, which will make this code usable on ACPI, device tree and legacy boards that use property sets.
As part of the change let's rename matrix_keypad_parse_of_params() to matrix_keypad_parse_properties().
--- drivers/input/keyboard/bcm-keypad.c | 2 +- drivers/input/keyboard/cros_ec_keyb.c | 3 +- drivers/input/keyboard/lpc32xx-keys.c | 2 +- drivers/input/keyboard/omap4-keypad.c | 4 +- drivers/input/keyboard/pmic8xxx-keypad.c | 2 +- drivers/input/keyboard/pxa27x_keypad.c | 2 +- drivers/input/keyboard/st-keyscan.c | 4 +- drivers/input/keyboard/stmpe-keypad.c | 2 +- drivers/input/keyboard/tca8418_keypad.c | 2 +- drivers/input/keyboard/twl4030_keypad.c | 4 +- drivers/input/matrix-keymap.c | 109 ++++++++++++++++--------------- include/linux/input/matrix_keypad.h | 21 +----- 12 files changed, 72 insertions(+), 85 deletions(-)
drivers/input/keyboard/bcm-keypad.c +1 -1
@@ -213,7 +213,7 @@ static int bcm_kp_matrix_key_parse_dt(struct bcm_kp *kp)/* Initialize the KPCR Keypad Configuration Register */ kp->kpcr =KPCR_STATUSFILTERENABLE |KPCR_COLFILTERENABLE ; - error =matrix_keypad_parse_of_params (dev, &kp->n_rows, &kp->n_cols); + error =matrix_keypad_parse_properties (dev, &kp->n_rows, &kp->n_cols);if (error) {dev_err (dev,"failed to parse kp params\n" );return error;
drivers/input/keyboard/cros_ec_keyb.c +2 -1
@@ -229,7 +229,8 @@ static int cros_ec_keyb_probe(struct platform_device *pdev) ckdev =devm_kzalloc (dev,sizeof (*ckdev),GFP_KERNEL );if (!ckdev)return -ENOMEM ; - err =matrix_keypad_parse_of_params (dev, &ckdev->rows, &ckdev->cols); + + err =matrix_keypad_parse_properties (dev, &ckdev->rows, &ckdev->cols);if (err)return err;
drivers/input/keyboard/lpc32xx-keys.c +1 -1
@@ -145,7 +145,7 @@ static int lpc32xx_parse_dt(struct device *dev,u32 rows =0 , columns =0 ;int err; - err =matrix_keypad_parse_of_params (dev, &rows, &columns); + err =matrix_keypad_parse_properties (dev, &rows, &columns);if (err)return err;if (rows != columns) {
drivers/input/keyboard/omap4-keypad.c +2 -2
@@ -223,8 +223,8 @@ static int omap4_keypad_parse_dt(struct device *dev,struct device_node *np = dev->of_node;int err; - err =matrix_keypad_parse_of_params (dev, &keypad_data->rows, - &keypad_data->cols); + err =matrix_keypad_parse_properties (dev, &keypad_data->rows, + &keypad_data->cols);if (err)return err;
drivers/input/keyboard/pmic8xxx-keypad.c +1 -1
@@ -515,7 +515,7 @@ static int pmic8xxx_kp_probe(struct platform_device *pdev)int rc;unsigned int ctrl_val; - rc =matrix_keypad_parse_of_params (&pdev->dev, &rows, &cols); + rc =matrix_keypad_parse_properties (&pdev->dev, &rows, &cols);if (rc)return rc;
drivers/input/keyboard/pxa27x_keypad.c +1 -1
@@ -126,7 +126,7 @@ static int pxa27x_keypad_matrix_key_parse_dt(struct pxa27x_keypad *keypad,u32 rows, cols;int error; - error =matrix_keypad_parse_of_params (dev, &rows, &cols); + error =matrix_keypad_parse_properties (dev, &rows, &cols);if (error)return error;
drivers/input/keyboard/st-keyscan.c +2 -2
@@ -106,8 +106,8 @@ static int keypad_matrix_key_parse_dt(struct st_keyscan *keypad_data)struct device_node *np = dev->of_node;int error; - error =matrix_keypad_parse_of_params (dev, &keypad_data->n_rows, - &keypad_data->n_cols); + error =matrix_keypad_parse_properties (dev, &keypad_data->n_rows, + &keypad_data->n_cols);if (error) {dev_err (dev,"failed to parse keypad params\n" );return error;
drivers/input/keyboard/stmpe-keypad.c +1 -1
@@ -354,7 +354,7 @@ static int stmpe_keypad_probe(struct platform_device *pdev) input->id.bustype =BUS_I2C ; input->dev.parent = &pdev->dev; - error =matrix_keypad_parse_of_params (&pdev->dev, &rows, &cols); + error =matrix_keypad_parse_properties (&pdev->dev, &rows, &cols);if (error)return error;
drivers/input/keyboard/tca8418_keypad.c +1 -1
@@ -295,7 +295,7 @@ static int tca8418_keypad_probe(struct i2c_client *client,struct device_node *np = dev->of_node;int err; - err =matrix_keypad_parse_of_params (dev, &rows, &cols); + err =matrix_keypad_parse_properties (dev, &rows, &cols);if (err)return err; rep =of_property_read_bool (np,"keypad,autorepeat" );
drivers/input/keyboard/twl4030_keypad.c +2 -2
@@ -374,8 +374,8 @@ static int twl4030_kp_probe(struct platform_device *pdev) kp->autorepeat = pdata->rep; keymap_data = pdata->keymap_data; }else { - error =matrix_keypad_parse_of_params (&pdev->dev, &kp->n_rows, - &kp->n_cols); + error =matrix_keypad_parse_properties (&pdev->dev, &kp->n_rows, + &kp->n_cols);if (error)return error;
drivers/input/matrix-keymap.c +56 -53
162 lines not on this page · raw message
include/linux/input/matrix_keypad.h +2 -19
@@ -80,24 +80,7 @@ int matrix_keypad_build_keymap(const struct matrix_keymap_data *keymap_data, unsigned int rows, unsigned int cols, unsigned short *keymap, struct input_dev *input_dev); - -#ifdef CONFIG_OF -/** -* matrix_keypad_parse_of_params() - Read parameters from matrix-keypad node -* -* @dev: Device containing of_node -* @rows: Returns number of matrix rows -* @cols: Returns number of matrix columns -* @return 0 if OK, <0 on error -*/ -int matrix_keypad_parse_of_params (struct device *dev, -unsigned int *rows,unsigned int *cols); -#else -static inline int matrix_keypad_parse_of_params (struct device *dev, -unsigned int *rows,unsigned int *cols) -{ -return -ENOSYS ; -} -#endif /* CONFIG_OF */ +int matrix_keypad_parse_properties (struct device *dev, +unsigned int *rows,unsigned int *cols);#endif /* _MATRIX_KEYPAD_H */
Signature · 1 line
2.11.0.483.g087da7b7c-goog
Dmitry Torokhov
maintainerPATCH 2/2 Input: tca8418 - switch to using generic device properties
Let's drop legacy platform data support (there are no users in mainline) and switch to using generic device properties, which will make the driver simpler (non-OF boards can use property sets to describe hardware).
--- drivers/input/keyboard/tca8418_keypad.c | 90 ++++++++++----------------------- include/linux/input/tca8418_keypad.h | 44 ---------------- 2 files changed, 26 insertions(+), 108 deletions(-) delete mode 100644 include/linux/input/tca8418_keypad.h
drivers/input/keyboard/tca8418_keypad.c +26 -64
@@ -24,18 +24,17 @@* alternative licensing inquiries. */ -#include <linux/types.h> -#include <linux/module.h> -#include <linux/init.h> #include <linux/delay.h> -#include <linux/slab.h> -#include <linux/interrupt.h> -#include <linux/workqueue.h> -#include <linux/gpio.h> #include <linux/i2c.h> +#include <linux/init.h> #include <linux/input.h> -#include <linux/input/tca8418_keypad.h> +#include <linux/input/matrix_keypad.h> +#include <linux/interrupt.h> +#include <linux/module.h> #include <linux/of.h> +#include <linux/property.h> +#include <linux/slab.h> +#include <linux/types.h> /* TCA8418 hardware limits */ #define TCA8418_MAX_ROWS 8
@@ -264,43 +263,25 @@ static int tca8418_configure(struct tca8418_keypad *keypad_data, }static int tca8418_keypad_probe (struct i2c_client *client, -const struct i2c_device_id *id) +const struct i2c_device_id *id) {struct device *dev = &client->dev; -const struct tca8418_keypad_platform_data *pdata = -dev_get_platdata (dev);struct tca8418_keypad *keypad_data;struct input_dev *input; -const struct matrix_keymap_data *keymap_data =NULL ;u32 rows =0 , cols =0 ; -bool rep = false; -bool irq_is_gpio = false; -int irq;int error, row_shift, max_keys; -unsigned long trigger =0 ; -/* Copy the platform data */ -if (pdata) { -if (!pdata->keymap_data) { -dev_err (dev,"no keymap data defined\n" ); -return -EINVAL ; - } - keymap_data = pdata->keymap_data; - rows = pdata->rows; - cols = pdata->cols; - rep = pdata->rep; - irq_is_gpio = pdata->irq_is_gpio; - trigger =IRQF_TRIGGER_FALLING ; - }else { -struct device_node *np = dev->of_node; -int err; - - err =matrix_keypad_parse_properties (dev, &rows, &cols); -if (err) -return err; - rep =of_property_read_bool (np,"keypad,autorepeat" ); +/* Check i2c driver capabilities */ +if (!i2c_check_functionality (client->adapter,I2C_FUNC_SMBUS_BYTE )) { +dev_err (dev,"%s adapter not supported\n" , +dev_driver_string (&client->adapter->dev)); +return -ENODEV ; } + error =matrix_keypad_parse_properties (dev, &rows, &cols); +if (error) +return error; +if (!rows || rows >TCA8418_MAX_ROWS ) {dev_err (dev,"invalid rows\n" );return -EINVAL ;
@@ -311,13 +292,6 @@ static int tca8418_keypad_probe(struct i2c_client *client,return -EINVAL ; } -/* Check i2c driver capabilities */ -if (!i2c_check_functionality (client->adapter,I2C_FUNC_SMBUS_BYTE )) { -dev_err (dev,"%s adapter not supported\n" , -dev_driver_string (&client->adapter->dev)); -return -ENODEV ; - } - row_shift =get_count_order (cols); max_keys = rows << row_shift;
@@ -347,25 +321,22 @@ static int tca8418_keypad_probe(struct i2c_client *client, input->id.product =0x001 ; input->id.version =0x0001 ; - error =matrix_keypad_build_keymap (keymap_data,NULL , rows, cols, -NULL , input); + error =matrix_keypad_build_keymap (NULL ,NULL , rows, cols,NULL , input);if (error) {dev_err (dev,"Failed to build keymap\n" );return error; } -if (rep) +if (device_property_read_bool (dev,"keypad,autorepeat" ))__set_bit (EV_REP , input->evbit); +input_set_capability (input,EV_MSC ,MSC_SCAN );input_set_drvdata (input, keypad_data); - irq = client->irq; -if (irq_is_gpio) - irq =gpio_to_irq (irq); - - error =devm_request_threaded_irq (dev, irq,NULL , tca8418_irq_handler, - trigger |IRQF_SHARED |IRQF_ONESHOT , + error =devm_request_threaded_irq (dev, client->irq, +NULL , tca8418_irq_handler, +IRQF_SHARED |IRQF_ONESHOT , client->name, keypad_data);if (error) { dev_err(dev, "Unable to claim irq %d; error %d\n",
@@ -384,30 +355,21 @@ static int tca8418_keypad_probe(struct i2c_client *client, }static const struct i2c_device_id tca8418_id[] = { - {TCA8418_NAME ,8418 , }, + {"tca8418" ,8418 , }, { } };MODULE_DEVICE_TABLE (i2c, tca8418_id); -#ifdef CONFIG_OF static const struct of_device_id tca8418_dt_ids[] = { { .compatible ="ti,tca8418" , }, { } };MODULE_DEVICE_TABLE (of, tca8418_dt_ids); -/* -* The device tree based i2c loader looks for -* "i2c:" + second_component_of(property("compatible")) -* and therefore we need an alias to be found. -*/ -MODULE_ALIAS ("i2c:tca8418" ); -#endif -static struct i2c_driver tca8418_keypad_driver = { .driver = { - .name =TCA8418_NAME , - .of_match_table =of_match_ptr (tca8418_dt_ids), + .name ="tca8418_keypad" , + .of_match_table = tca8418_dt_ids, }, .probe = tca8418_keypad_probe, .id_table = tca8418_id,
include/linux/input/tca8418_keypad.h deleted +0 -44
44 lines not on this page · raw message
Signature · 1 line
2.11.0.483.g087da7b7c-goog
Re: [PATCH 2/2] Input: tca8418 - switch to using generic device properties
Quoted 5 lines · Dmitry Torokhov
Let's drop legacy platform data support (there are no users in mainline) and switch to using generic device properties, which will make the driver simpler (non-OF boards can use property sets to describe hardware).
Signed-off-by Dmitry Torokhov <[email protected]>
Thanks!
Maxime
Signature · 10 lines
Maxime Ripard, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 801 bytes Desc: not available URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20170120/b15164af/attachment.sig>