Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751809AbdFKFEc (ORCPT ); Sun, 11 Jun 2017 01:04:32 -0400 Received: from mga04.intel.com ([192.55.52.120]:18052 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751675AbdFKFEa (ORCPT ); Sun, 11 Jun 2017 01:04:30 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.39,327,1493708400"; d="scan'208";a="979324965" From: "Mani, Rajmohan" To: Linus Walleij CC: "linux-kernel@vger.kernel.org" , "linux-gpio@vger.kernel.org" , "ACPI Devel Maling List" , Lee Jones , Alexandre Courbot , "Rafael J. Wysocki" , Len Brown Subject: RE: [PATCH v1 2/3] gpio: Add support for TPS68470 GPIOs Thread-Topic: [PATCH v1 2/3] gpio: Add support for TPS68470 GPIOs Thread-Index: AQHS3rzDQNsvvqbo1U++AaPgtQosjaIc2zyAgAIyxRA= Date: Sun, 11 Jun 2017 05:04:27 +0000 Message-ID: <6F87890CF0F5204F892DEA1EF0D77A59725BF127@FMSMSX114.amr.corp.intel.com> References: <1496750118-5570-1-git-send-email-rajmohan.mani@intel.com> <1496750118-5570-3-git-send-email-rajmohan.mani@intel.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 10.0.102.7 dlp-reaction: no-action x-originating-ip: [10.1.200.106] Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by mail.home.local id v5B54a6U028643 Content-Length: 4602 Lines: 123 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 > Cc: linux-kernel@vger.kernel.org; linux-gpio@vger.kernel.org; ACPI Devel > Maling List ; Lee Jones ; > Alexandre Courbot ; Rafael J. Wysocki > ; Len Brown > Subject: Re: [PATCH v1 2/3] gpio: Add support for TPS68470 GPIOs > > On Tue, Jun 6, 2017 at 1:55 PM, Rajmohan Mani > 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 > > 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 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.