Hi Linus, Thanks for the reviews. > -----Original Message----- > From: Linus Walleij [mailto:linus.walleij@xxxxxxxxxx] > Sent: Friday, June 09, 2017 4:15 AM > To: Mani, Rajmohan <rajmohan.mani@xxxxxxxxx> > Cc: linux-kernel@xxxxxxxxxxxxxxx; linux-gpio@xxxxxxxxxxxxxxx; ACPI Devel > Maling List <linux-acpi@xxxxxxxxxxxxxxx>; Lee Jones <lee.jones@xxxxxxxxxx>; > Alexandre Courbot <gnurou@xxxxxxxxx>; Rafael J. Wysocki > <rjw@xxxxxxxxxxxxx>; Len Brown <lenb@xxxxxxxxxx> > 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@xxxxxxxxx> > 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@xxxxxxxxx> > > 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. ��.n��������+%������w��{.n�����{�����ܨ}���Ơz�j:+v�����w����ޙ��&�)ߡ�a����z�ޗ���ݢj��w�f