[PATCH] Input: imx6ul_tsc - generalize the averaging property

Rob Herring robh at kernel.org
Tue Dec 13 11:54:54 PST 2016


On Sun, Dec 11, 2016 at 1:06 AM, Guy Shapiro <guy.shapiro at mobi-wize.com> wrote:
> Make the avarage-samples property a general touchscreen property
> rather than imx6ul device specific.
>
> Signed-off-by: Guy Shapiro <guy.shapiro at mobi-wize.com>
> ---
>  .../bindings/input/touchscreen/imx6ul_tsc.txt      | 11 ++----
>  .../bindings/input/touchscreen/touchscreen.txt     |  3 ++
>  drivers/input/touchscreen/imx6ul_tsc.c             | 46 ++++++++++++++++------
>  3 files changed, 41 insertions(+), 19 deletions(-)

[...]

> +       switch (average_samples) {
> +       case 1:
> +               tsc->average_enable = false;
> +               tsc->average_select = 0; /* value unused; initialize anyway */
> +               break;
> +       case 4:
> +               tsc->average_enable = true;
> +               tsc->average_select = 0;
> +               break;
> +       case 8:
> +               tsc->average_enable = true;
> +               tsc->average_select = 1;
> +               break;
> +       case 16:
> +               tsc->average_enable = true;
> +               tsc->average_select = 2;
> +               break;
> +       case 32:
> +               tsc->average_enable = true;
> +               tsc->average_select = 3;
> +               break;

This could be more efficiently written as

tsc->average_select = log2(average_samples) - 2;

Then enable if >=0.

Rob



More information about the linux-arm-kernel mailing list