Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1662317 > unrolled thread
| Started by | Linus Walleij <linus.walleij@linaro.org> |
|---|---|
| First post | 2017-06-09 13:20 +0200 |
| Last post | 2017-06-12 02:20 +0200 |
| Articles | 3 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: [PATCH v1 2/3] gpio: Add support for TPS68470 GPIOs Linus Walleij <linus.walleij@linaro.org> - 2017-06-09 13:20 +0200
RE: [PATCH v1 2/3] gpio: Add support for TPS68470 GPIOs "Mani, Rajmohan" <rajmohan.mani@intel.com> - 2017-06-11 07:10 +0200
RE: [PATCH v1 2/3] gpio: Add support for TPS68470 GPIOs "Mani, Rajmohan" <rajmohan.mani@intel.com> - 2017-06-12 02:20 +0200
| From | Linus Walleij <linus.walleij@linaro.org> |
|---|---|
| Date | 2017-06-09 13:20 +0200 |
| Subject | Re: [PATCH v1 2/3] gpio: Add support for TPS68470 GPIOs |
| Message-ID | <tQq7o-OU-21@gated-at.bofh.it> |
On Tue, Jun 6, 2017 at 1:55 PM, Rajmohan Mani <rajmohan.mani@intel.com> wrote:
> This patch adds support for TPS68470 GPIOs.
> There are 7 GPIOs and a few sensor related GPIOs.
> These GPIOs can be requested and configured as
> appropriate.
>
> Signed-off-by: Rajmohan Mani <rajmohan.mani@intel.com>
Same comments as Andy already sent, plus:
> +static inline struct tps68470_gpio_data *to_gpio_data(struct gpio_chip *gpiochp)
> +{
> + return container_of(gpiochp, struct tps68470_gpio_data, gc);
> +}
Please use the data pointe inside gpio_chip.
struct tps68470_gpio_data *foo = gpiochip_get_data(gc);
> + ret = tps68470_reg_read(tps, reg, &val);
(...)
> + tps68470_update_bits(tps, reg, BIT(offset), value ? BIT(offset) : 0);
(...)
> + return tps68470_update_bits(tps, TPS68470_GPIO_CTL_REG_A(offset),
> + TPS68470_GPIO_MODE_MASK,
> + TPS68470_GPIO_MODE_OUT_CMOS);
(...)
> + return tps68470_update_bits(tps, TPS68470_GPIO_CTL_REG_A(offset),
> + TPS68470_GPIO_MODE_MASK, 0x00);
This looks like a reimplementation of regmap. Is it not possible
to create a regmap in the MFD driver and pass that around instead?
> +struct gpiod_lookup_table gpios_table = {
> + .dev_id = NULL,
> + .table = {
> + GPIO_LOOKUP("tps68470-gpio", 0, "gpio.0", GPIO_ACTIVE_HIGH),
> + GPIO_LOOKUP("tps68470-gpio", 1, "gpio.1", GPIO_ACTIVE_HIGH),
> + GPIO_LOOKUP("tps68470-gpio", 2, "gpio.2", GPIO_ACTIVE_HIGH),
> + GPIO_LOOKUP("tps68470-gpio", 3, "gpio.3", GPIO_ACTIVE_HIGH),
> + GPIO_LOOKUP("tps68470-gpio", 4, "gpio.4", GPIO_ACTIVE_HIGH),
> + GPIO_LOOKUP("tps68470-gpio", 5, "gpio.5", GPIO_ACTIVE_HIGH),
> + GPIO_LOOKUP("tps68470-gpio", 6, "gpio.6", GPIO_ACTIVE_HIGH),
> + GPIO_LOOKUP("tps68470-gpio", 7, "s_enable", GPIO_ACTIVE_HIGH),
> + GPIO_LOOKUP("tps68470-gpio", 8, "s_idle", GPIO_ACTIVE_HIGH),
> + GPIO_LOOKUP("tps68470-gpio", 9, "s_resetn", GPIO_ACTIVE_HIGH),
> + {},
> + },
> +};
Hm that's why you include <linux/gpio/machine.h> I guess.
This warrants a big comment above it explaining why this is done like
that and what the use is inside any system with this chip mounted.
> + tps68470_gpio->gc.label = "tps68470-gpio";
> + tps68470_gpio->gc.owner = THIS_MODULE;
> + tps68470_gpio->gc.direction_input = tps68470_gpio_input;
> + tps68470_gpio->gc.direction_output = tps68470_gpio_output;
Please implement .get_direction()
> + tps68470_gpio->gc.get = tps68470_gpio_get;
> + tps68470_gpio->gc.set = tps68470_gpio_set;
> + tps68470_gpio->gc.can_sleep = true;
> + tps68470_gpio->gc.ngpio = TPS68470_N_GPIO;
> + tps68470_gpio->gc.base = -1;
> + tps68470_gpio->gc.parent = &pdev->dev;
Consider assigning the .names() array some sensible line names.
> +static int tps68470_gpio_remove(struct platform_device *pdev)
> +{
> + struct tps68470_gpio_data *tps68470_gpio = platform_get_drvdata(pdev);
> +
> + gpiod_remove_lookup_table(&gpios_table);
> + gpiochip_remove(&tps68470_gpio->gc);
You can't use devm_gpiochip_add()?
Yours,
Linus Walleij
[toc] | [next] | [standalone]
| From | "Mani, Rajmohan" <rajmohan.mani@intel.com> |
|---|---|
| Date | 2017-06-11 07:10 +0200 |
| Message-ID | <tR3ip-Vy-1@gated-at.bofh.it> |
| In reply to | #1662317 |
Hi Linus,
Thanks for the reviews.
> -----Original Message-----
> From: Linus Walleij [mailto:linus.walleij@linaro.org]
> Sent: Friday, June 09, 2017 4:15 AM
> To: Mani, Rajmohan <rajmohan.mani@intel.com>
> Cc: linux-kernel@vger.kernel.org; linux-gpio@vger.kernel.org; ACPI Devel
> Maling List <linux-acpi@vger.kernel.org>; Lee Jones <lee.jones@linaro.org>;
> Alexandre Courbot <gnurou@gmail.com>; Rafael J. Wysocki
> <rjw@rjwysocki.net>; Len Brown <lenb@kernel.org>
> Subject: Re: [PATCH v1 2/3] gpio: Add support for TPS68470 GPIOs
>
> On Tue, Jun 6, 2017 at 1:55 PM, Rajmohan Mani <rajmohan.mani@intel.com>
> wrote:
>
> > This patch adds support for TPS68470 GPIOs.
> > There are 7 GPIOs and a few sensor related GPIOs.
> > These GPIOs can be requested and configured as appropriate.
> >
> > Signed-off-by: Rajmohan Mani <rajmohan.mani@intel.com>
>
> Same comments as Andy already sent, plus:
>
> > +static inline struct tps68470_gpio_data *to_gpio_data(struct
> > +gpio_chip *gpiochp) {
> > + return container_of(gpiochp, struct tps68470_gpio_data, gc); }
>
> Please use the data pointe inside gpio_chip.
>
This is not clear to me.
The driver already gets the data pointer inside gpio_chip (which is gpiochp)
Is the name gpiochp misleading?
I had to get rid of "i" in gpiochip, to meet 80 char limit.
> struct tps68470_gpio_data *foo = gpiochip_get_data(gc);
>
> > + ret = tps68470_reg_read(tps, reg, &val);
> (...)
> > + tps68470_update_bits(tps, reg, BIT(offset), value ?
> > + BIT(offset) : 0);
> (...)
> > + return tps68470_update_bits(tps, TPS68470_GPIO_CTL_REG_A(offset),
> > + TPS68470_GPIO_MODE_MASK,
> > + TPS68470_GPIO_MODE_OUT_CMOS);
> (...)
> > + return tps68470_update_bits(tps, TPS68470_GPIO_CTL_REG_A(offset),
> > + TPS68470_GPIO_MODE_MASK, 0x00);
>
> This looks like a reimplementation of regmap. Is it not possible to create a
> regmap in the MFD driver and pass that around instead?
>
Ack
Will be addressed in v2 of this patch series.
> > +struct gpiod_lookup_table gpios_table = {
> > + .dev_id = NULL,
> > + .table = {
> > + GPIO_LOOKUP("tps68470-gpio", 0, "gpio.0", GPIO_ACTIVE_HIGH),
> > + GPIO_LOOKUP("tps68470-gpio", 1, "gpio.1", GPIO_ACTIVE_HIGH),
> > + GPIO_LOOKUP("tps68470-gpio", 2, "gpio.2", GPIO_ACTIVE_HIGH),
> > + GPIO_LOOKUP("tps68470-gpio", 3, "gpio.3", GPIO_ACTIVE_HIGH),
> > + GPIO_LOOKUP("tps68470-gpio", 4, "gpio.4", GPIO_ACTIVE_HIGH),
> > + GPIO_LOOKUP("tps68470-gpio", 5, "gpio.5", GPIO_ACTIVE_HIGH),
> > + GPIO_LOOKUP("tps68470-gpio", 6, "gpio.6", GPIO_ACTIVE_HIGH),
> > + GPIO_LOOKUP("tps68470-gpio", 7, "s_enable",
> GPIO_ACTIVE_HIGH),
> > + GPIO_LOOKUP("tps68470-gpio", 8, "s_idle", GPIO_ACTIVE_HIGH),
> > + GPIO_LOOKUP("tps68470-gpio", 9, "s_resetn",
> GPIO_ACTIVE_HIGH),
> > + {},
> > + },
> > +};
>
> Hm that's why you include <linux/gpio/machine.h> I guess.
>
Ack
> This warrants a big comment above it explaining why this is done like that and
> what the use is inside any system with this chip mounted.
>
Ack
I have added comments in the MFD driver, inside which the lookup table has moved.
> > + tps68470_gpio->gc.label = "tps68470-gpio";
> > + tps68470_gpio->gc.owner = THIS_MODULE;
> > + tps68470_gpio->gc.direction_input = tps68470_gpio_input;
> > + tps68470_gpio->gc.direction_output = tps68470_gpio_output;
>
> Please implement .get_direction()
>
Ack
> > + tps68470_gpio->gc.get = tps68470_gpio_get;
> > + tps68470_gpio->gc.set = tps68470_gpio_set;
> > + tps68470_gpio->gc.can_sleep = true;
> > + tps68470_gpio->gc.ngpio = TPS68470_N_GPIO;
> > + tps68470_gpio->gc.base = -1;
> > + tps68470_gpio->gc.parent = &pdev->dev;
>
> Consider assigning the .names() array some sensible line names.
>
Ack
> > +static int tps68470_gpio_remove(struct platform_device *pdev) {
> > + struct tps68470_gpio_data *tps68470_gpio =
> > +platform_get_drvdata(pdev);
> > +
> > + gpiod_remove_lookup_table(&gpios_table);
> > + gpiochip_remove(&tps68470_gpio->gc);
>
> You can't use devm_gpiochip_add()?
>
Originally I couldn't, because the driver can not remove the lookup table upon exit/removal. I moved this code inside the MFD driver, which is modified to use .shutdown() to remove the lookup table, so it can use dev_mfd_* call.
[toc] | [prev] | [next] | [standalone]
| From | "Mani, Rajmohan" <rajmohan.mani@intel.com> |
|---|---|
| Date | 2017-06-12 02:20 +0200 |
| Message-ID | <tRlfj-3lg-5@gated-at.bofh.it> |
| In reply to | #1662317 |
Hi Linus,
> Subject: Re: [PATCH v1 2/3] gpio: Add support for TPS68470 GPIOs
> > +static inline struct tps68470_gpio_data *to_gpio_data(struct
> > +gpio_chip *gpiochp) {
> > + return container_of(gpiochp, struct tps68470_gpio_data, gc); }
>
> Please use the data pointe inside gpio_chip.
>
My bad. I completely missed the following line. Will fix it v3.
> struct tps68470_gpio_data *foo = gpiochip_get_data(gc);
>
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web