[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHp75VdSWxcAQzWryKoMfzh8xM_2ZRF6Uk+8pveGhmt=prOAVg@mail.gmail.com>
Date: Thu, 2 Jul 2020 15:36:32 +0300
From: Andy Shevchenko <andy.shevchenko@...il.com>
To: Sungbo Eo <mans0n@...ani.run>
Cc: Linus Walleij <linus.walleij@...aro.org>,
Bartosz Golaszewski <bgolaszewski@...libre.com>,
Michael Walle <michael@...le.cc>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
"open list:GPIO SUBSYSTEM" <linux-gpio@...r.kernel.org>
Subject: Re: [PATCH v4 1/2] gpio: add GPO driver for PCA9570
On Thu, Jul 2, 2020 at 3:18 PM Sungbo Eo <mans0n@...ani.run> wrote:
>
> NXP PCA9570 is 4-bit I2C GPO expander without interrupt functionality.
is a 4-bit
> Its ports are controlled only by a data byte without register address.
>
> As there is no other driver similar enough to be adapted for it, a new
> driver is introduced here.
Can we have a Datasheet: tag with URL attached to it?
...
> +static int pca9570_read(struct pca9570 *gpio, u8 *value)
> +{
> + s32 ret;
> +
> + ret = i2c_smbus_read_byte(gpio->client);
> + if (ret < 0)
> + return ret;
> +
> + *value = (u8)ret;
I doubt casting is needed.
> + return 0;
> +}
...
> +static const struct i2c_device_id pca9570_id_table[] = {
> + { "pca9570", 4 },
> + { /* sentinel */ }
> +};
> +MODULE_DEVICE_TABLE(i2c, pca9570_id_table);
> +
> +static const struct of_device_id pca9570_of_match_table[] = {
> + { .compatible = "nxp,pca9570" },
This driver data should also have 4.
> + { /* sentinel */ }
> +};
...
> + gpio->chip.ngpio = i2c_match_id(pca9570_id_table, client)->driver_data;
Oh, avoid direct access to the table like this. And you may simply use
device_get_match_data().
...
> + /* Read the current output level */
> + (void) pca9570_read(gpio, &gpio->out);
(void) casting is not needed. And I'm not sure hiding an error is a
good idea. But the latter is up to you.
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists