Re: [PATCH v3 2/2] Input: cros-ec-keyb - Expose function row physical map to userspace
From: Dmitry Torokhov
Date: Thu Jan 07 2021 - 00:21:59 EST
Hi Philip,
On Mon, Jan 04, 2021 at 06:22:34PM -0800, Philip Chen wrote:
> The top-row keys in a keyboard usually have dual functionalities.
> E.g. A function key "F1" is also an action key "Browser back".
>
> Therefore, when an application receives an action key code from
> a top-row key press, the application needs to know how to correlate
> the action key code with the function key code and do the conversion
> whenever necessary.
>
> Since the userpace already knows the key scanlines (row/column)
> associated with a received key code. Essentially, the userspace only
> needs a mapping between the key row/column and the matching physical
> location in the top row.
>
> This patch enhances the cros-ec-keyb driver to create such a mapping
> and expose it to userspace in the form of a function-row-physmap
> attribute. The attribute would be a space separated ordered list of
> row/column codes, for the keys in the function row, in a left-to-right
> order.
>
> The attribute will only be present when the device has a custom design
> for the top-row keys.
>
> Signed-off-by: Philip Chen <philipchen@xxxxxxxxxxxx>
> ---
>
> Changes in v3:
> - parse `function-row-physmap` from DT earlier, when we probe
> cros_ec_keyb, and then store the extracted info in struct cros_ec_keyb.
Thank you for making the changes, much appreciated. Let's wait a bit to
see if Rob has any issues with this.
...
> static int cros_ec_keyb_probe(struct platform_device *pdev)
> {
> struct cros_ec_device *ec = dev_get_drvdata(pdev->dev.parent);
> @@ -617,6 +690,12 @@ static int cros_ec_keyb_probe(struct platform_device *pdev)
> return err;
> }
>
> + err = sysfs_create_group(&dev->kobj, &cros_ec_keyb_attr_group);
> + if (err) {
> + dev_err(dev, "failed to create attributes. err=%d\n", err);
> + return err;
> + }
Let's use devm_device_add_group() so that we do not need to remove it
manually in cros_ec_keyb_remove().
Thanks.
--
Dmitry