lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHp75VcXNTxusT5N_8JvYWMhUyY_sAUzTcT3h0hz2bAawv6ThQ@mail.gmail.com>
Date:   Sun, 19 Jun 2022 13:43:59 +0200
From:   Andy Shevchenko <andy.shevchenko@...il.com>
To:     Samuel Holland <samuel@...lland.org>
Cc:     Dmitry Torokhov <dmitry.torokhov@...il.com>,
        linux-input <linux-input@...r.kernel.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        Rob Herring <robh+dt@...nel.org>, Ondrej Jirman <x@....cz>,
        Krzysztof Kozlowski <krzk+dt@...nel.org>,
        devicetree <devicetree@...r.kernel.org>,
        Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
        Chen-Yu Tsai <wens@...e.org>,
        Colin Ian King <colin.king@...el.com>,
        David Gow <davidgow@...gle.com>,
        Jernej Skrabec <jernej.skrabec@...il.com>,
        Krzysztof Kozlowski <krzysztof.kozlowski+dt@...aro.org>,
        Marco Felsch <m.felsch@...gutronix.de>,
        Mattijs Korpershoek <mkorpershoek@...libre.com>,
        Stephen Boyd <swboyd@...omium.org>,
        Yassine Oudjana <y.oudjana@...tonmail.com>,
        "fengping.yu" <fengping.yu@...iatek.com>,
        linux-arm Mailing List <linux-arm-kernel@...ts.infradead.org>,
        linux-sunxi@...ts.linux.dev
Subject: Re: [PATCH v4 2/4] Input: pinephone-keyboard - Add PinePhone keyboard driver

On Sat, Jun 18, 2022 at 7:10 PM Samuel Holland <samuel@...lland.org> wrote:
>
> The official Pine64 PinePhone keyboard case contains a matrix keypad and
> a MCU which runs a libre firmware. Add support for its I2C interface.

...

> +#include <linux/crc8.h>
> +#include <linux/i2c.h>
> +#include <linux/input/matrix_keypad.h>
> +#include <linux/interrupt.h>
> +#include <linux/module.h>
> +#include <linux/regulator/consumer.h>

Missed
types.h

...

> +#define PPKB_ROWS                      6
> +#define PPKB_COLS                      12

...

> +       for (col = 0; col < PPKB_COLS; ++col) {
> +               u8 old = old_buf[1 + col];
> +               u8 new = new_buf[1 + col];
> +               u8 changed = old ^ new;
> +
> +               if (!changed)
> +                       continue;
> +
> +               for (row = 0; row < PPKB_ROWS; ++row) {
> +                       u8 mask = BIT(row);
> +                       u8 value = new & mask;
> +                       unsigned short code;
> +                       bool fn_state;
> +
> +                       if (!(changed & mask))
> +                               continue;
> +
> +                       /*
> +                        * Save off the FN key state when the key was pressed,
> +                        * and use that to determine the code during a release.
> +                        */
> +                       fn_state = value ? ppkb->fn_pressed : ppkb->fn_state[col] & mask;
> +                       if (fn_state)
> +                               ppkb->fn_state[col] ^= mask;

Can't it be converted to use bitmap APIs?

> +               }
> +       }

...

> +static int ppkb_set_scan(struct i2c_client *client, bool enable)
> +{
> +       struct device *dev = &client->dev;
> +       int ret, val;
> +
> +       ret = i2c_smbus_read_byte_data(client, PPKB_SYS_CONFIG);
> +       if (ret < 0) {
> +               dev_err(dev, "Failed to read config: %d\n", ret);
> +               return ret;
> +       }
> +
> +       if (enable)
> +               val = ret & ~PPKB_SYS_CONFIG_DISABLE_SCAN;
> +       else
> +               val = ret | PPKB_SYS_CONFIG_DISABLE_SCAN;
> +       ret = i2c_smbus_write_byte_data(client, PPKB_SYS_CONFIG, val);
> +       if (ret) {
> +               dev_err(dev, "Failed to write config: %d\n", ret);

> +               return ret;
> +       }
> +
> +       return 0;

return ret;

> +}

...

> +static int ppkb_open(struct input_dev *input)
> +{
> +       struct i2c_client *client = input_get_drvdata(input);

> +       int ret;
> +
> +       ret = ppkb_set_scan(client, true);
> +       if (ret)
> +               return ret;
> +
> +       return 0;

  return ppkb_set_scan(...);

> +}

-- 
With Best Regards,
Andy Shevchenko

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ