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: <CAHp75VdCK26wXiw0c=1fc0vKsea4w=tthCBrroLOqqaDbwuMVQ@mail.gmail.com>
Date:   Mon, 13 Apr 2020 23:20:42 +0300
From:   Andy Shevchenko <andy.shevchenko@...il.com>
To:     mani@...nel.org
Cc:     Jonathan Cameron <jic23@...nel.org>,
        Rob Herring <robh+dt@...nel.org>, narcisaanamaria12@...il.com,
        Hartmut Knaack <knaack.h@....de>,
        Lars-Peter Clausen <lars@...afoo.de>,
        Peter Meerwald <pmeerw@...erw.net>,
        linux-iio <linux-iio@...r.kernel.org>,
        devicetree <devicetree@...r.kernel.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 2/3] iio: chemical: Add support for external Reset and
 Wakeup in CCS811

On Mon, Apr 13, 2020 at 8:34 AM <mani@...nel.org> wrote:
>
> From: Manivannan Sadhasivam <mani@...nel.org>
>
> CCS811 VOC sensor exposes nRESET and nWAKE pins which can be connected
> to GPIO pins of the host controller. These pins can be used to externally
> release the device from reset and also to wake it up before any I2C
> transaction. The initial driver support assumed that the nRESET pin is not
> connected and the nWAKE pin is tied to ground.
>
> This commit improves it by adding support for controlling those two pins
> externally using a host controller. For the case of reset, if the hardware
> reset is not available, the mechanism to do software reset is also added.
>
> As a side effect of doing this, the IIO device allocation needs to be
> slightly moved to top of probe to make use of priv data early.

...

> +#define CCS811_SW_RESET                0xFF


> +       reset_gpio = devm_gpiod_get_optional(&client->dev, "reset",
> +                                            GPIOD_OUT_LOW);
> +       if (IS_ERR(reset_gpio)) {
> +               dev_err(&client->dev, "Failed to acquire reset gpio\n");

> +               return -EINVAL;

Do not shadow actual error code.

> +       }
> +
> +       /* Try to reset using nRESET pin if available else do SW reset */
> +       if (reset_gpio) {
> +               gpiod_set_value(reset_gpio, 1);
> +               usleep_range(20, 30);
> +               gpiod_set_value(reset_gpio, 0);
> +       } else {

> +               static const u8 reset_seq[] = {
> +                       0xFF, 0x11, 0xE5, 0x72, 0x8A,
> +               };

Is 0xFF here is CCS811_SW_RESET? If so, can you put it explicitly?

> +               ret = i2c_smbus_write_i2c_block_data(client, CCS811_SW_RESET,
> +                                            sizeof(reset_seq), reset_seq);
> +               if (ret < 0) {
> +                       dev_err(&client->dev, "Failed to reset sensor\n");
> +                       return ret;
> +               }
> +       }

...

> +       data->wakeup_gpio = devm_gpiod_get_optional(&client->dev, "wakeup",
> +                                                   GPIOD_OUT_HIGH);
> +       if (IS_ERR(data->wakeup_gpio)) {
> +               dev_err(&client->dev, "Failed to acquire wakeup gpio\n");

> +               return -EINVAL;

Ditto.

> +       }

-- 
With Best Regards,
Andy Shevchenko

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ