Re: [PATCH v1 39/63] Input: touchscreen: Atmel: Add device tree support for T15 key array objects

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Aug 16, 2019 at 05:35:01PM +0900, Jiada Wang wrote:
> From: Daniel Gong <Zhanli.Gong@xxxxxxxxxxxx>

This should be with the code adding T15 handling.

> 
> Signed-off-by: Daniel Gong <Zhanli.Gong@xxxxxxxxxxxx>
> Signed-off-by: George G. Davis <george_davis@xxxxxxxxxx>
> Signed-off-by: Jiada Wang <jiada_wang@xxxxxxxxxx>
> ---
>  drivers/input/touchscreen/atmel_mxt_ts.c | 29 ++++++++++++++++++++++++
>  1 file changed, 29 insertions(+)
> 
> diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c
> index be63002c2b31..3b9544c0a209 100644
> --- a/drivers/input/touchscreen/atmel_mxt_ts.c
> +++ b/drivers/input/touchscreen/atmel_mxt_ts.c
> @@ -4143,10 +4143,12 @@ static int mxt_parse_device_properties(struct mxt_data *data)
>  {
>  	static const char keymap_property[] = "linux,gpio-keymap";
>  	static const char gpios_property[] = "atmel,gpios";
> +	static const char buttons_property[] = "atmel,key-buttons";
>  	struct device *dev = &data->client->dev;
>  	struct device_node *np = dev ? dev->of_node : NULL;
>  	struct device_node *np_gpio;
>  	u32 *keymap;
> +	u32 *buttonmap;
>  	int n_keys;
>  	int error;
>  
> @@ -4181,6 +4183,33 @@ static int mxt_parse_device_properties(struct mxt_data *data)
>  		data->t19_num_keys = n_keys;
>  	}
>  
> +	if (device_property_present(dev, buttons_property)) {
> +		n_keys = device_property_read_u32_array(dev, buttons_property,
> +							NULL, 0);
> +		if (n_keys <= 0) {
> +			error = n_keys < 0 ? n_keys : -EINVAL;
> +			dev_err(dev, "invalid/malformed '%s' property: %d\n",
> +				buttons_property, error);
> +			return error;
> +		}
> +
> +		buttonmap = devm_kmalloc_array(dev, n_keys, sizeof(*buttonmap),
> +					       GFP_KERNEL);
> +		if (!buttonmap)
> +			return -ENOMEM;
> +
> +		error = device_property_read_u32_array(dev, buttons_property,
> +						       buttonmap, n_keys);
> +		if (error) {
> +			dev_err(dev, "failed to parse '%s' property: %d\n",
> +				buttons_property, error);
> +			return error;
> +		}
> +
> +		data->t15_keymap = buttonmap;
> +		data->t15_num_keys = n_keys;
> +	}
> +
>  	device_property_read_u32(dev, "atmel,suspend-mode", &data->suspend_mode);
>  
>  	np_gpio = of_get_child_by_name(np, gpios_property);
> -- 
> 2.19.2
> 

-- 
Dmitry



[Index of Archives]     [Linux Media Devel]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Linux Wireless Networking]     [Linux Omap]

  Powered by Linux