linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: Bartosz Golaszewski <brgl@bgdev.pl>,
	Mika Westerberg <mika.westerberg@linux.intel.com>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Linus Walleij <linus.walleij@linaro.org>,
	Daniel Scally <djrscally@gmail.com>,
	Mark Gross <markgross@kernel.org>
Cc: linux-gpio@vger.kernel.org, linux-acpi@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	platform-driver-x86@vger.kernel.org,
	Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Subject: Re: [RFT PATCH 2/4] platform/x86: int3472: led: don't use gpiod_toggle_active_low()
Date: Wed, 27 Sep 2023 11:40:40 +0200	[thread overview]
Message-ID: <2b5db794-c00f-e9f5-c0c9-4c5fb4df0802@redhat.com> (raw)
In-Reply-To: <20230926145943.42814-3-brgl@bgdev.pl>

Hi,

On 9/26/23 16:59, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> 
> Instead of acpi_get_and_request_gpiod() + gpiod_toggle_active_low(), use
> temporary lookup tables with appropriate lookup flags.
> 
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> ---
>  drivers/platform/x86/intel/int3472/led.c | 12 ++++--------
>  1 file changed, 4 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/platform/x86/intel/int3472/led.c b/drivers/platform/x86/intel/int3472/led.c
> index bca1ce7d0d0c..62e0cd5207a7 100644
> --- a/drivers/platform/x86/intel/int3472/led.c
> +++ b/drivers/platform/x86/intel/int3472/led.c
> @@ -25,18 +25,14 @@ int skl_int3472_register_pled(struct int3472_discrete_device *int3472,
>  	if (int3472->pled.classdev.dev)
>  		return -EBUSY;
>  
> -	int3472->pled.gpio = acpi_get_and_request_gpiod(path, agpio->pin_table[0],
> -							     "int3472,privacy-led");
> +	int3472->pled.gpio = skl_int3472_gpiod_get_from_temp_lookup(
> +				int3472->dev, path, agpio->pin_table[0],
> +				"int3472,privacy-led", polarity,
> +				GPIOD_OUT_LOW);

Yeah so this is not going to work, path here is an ACPI device path, e.g.
on my laptop (which actually uses the INT3472 glue code) the path-s of
the 2 GPIO controllers are: `\_SB_.GPI0` resp `\_SB_.PC00.XHCI.RHUB.HS08.VGPO`

Where as skl_int3472_gpiod_get_from_temp_lookup() stores the passed in path
in  gpiod_lookup_table.table[0].key, which is the dev_name() of the GPIO
controller's parent dev which are `INTC1055:00` resp. `INTC1096:00` .

So we are going to need to add some code to INT3472 to go from path to
a correct value for gpiod_lookup_table.table[0].key which means partly
reproducing most of acpi_get_gpiod:

        struct gpio_chip *chip;
        acpi_handle handle;
        acpi_status status;

        status = acpi_get_handle(NULL, path, &handle);
        if (ACPI_FAILURE(status))
                return ERR_PTR(-ENODEV);

        chip = gpiochip_find(handle, acpi_gpiochip_find);
        if (!chip)
                return ERR_PTR(-EPROBE_DEFER);

And then get the key from the chip. Which means using gpiochip_find
in the int3472 code now, which does not sound like an improvement.

I think that was is needed instead is adding an active_low flag
to acpi_get_and_request_gpiod() and then have that directly
set the active-low flag on the returned desc.

Regards,

Hans








>  	if (IS_ERR(int3472->pled.gpio))
>  		return dev_err_probe(int3472->dev, PTR_ERR(int3472->pled.gpio),
>  				     "getting privacy LED GPIO\n");
>  
> -	if (polarity == GPIO_ACTIVE_LOW)
> -		gpiod_toggle_active_low(int3472->pled.gpio);
> -
> -	/* Ensure the pin is in output mode and non-active state */
> -	gpiod_direction_output(int3472->pled.gpio, 0);
> -
>  	/* Generate the name, replacing the ':' in the ACPI devname with '_' */
>  	snprintf(int3472->pled.name, sizeof(int3472->pled.name),
>  		 "%s::privacy_led", acpi_dev_name(int3472->sensor));


  parent reply	other threads:[~2023-09-27  9:41 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-26 14:59 [RFT PATCH 0/4] platform/x86: int3472: don't use gpiod_toggle_active_low() Bartosz Golaszewski
2023-09-26 14:59 ` [RFT PATCH 1/4] platform/x86: int3472: provide a helper for getting GPIOs from lookups Bartosz Golaszewski
2023-09-26 15:25   ` Andy Shevchenko
2023-09-26 14:59 ` [RFT PATCH 2/4] platform/x86: int3472: led: don't use gpiod_toggle_active_low() Bartosz Golaszewski
2023-09-26 15:26   ` Andy Shevchenko
2023-09-27  7:02     ` Bartosz Golaszewski
2023-09-27  9:14       ` Hans de Goede
2023-09-27  9:40   ` Hans de Goede [this message]
2023-09-27 10:44     ` Bartosz Golaszewski
2023-09-27 13:08       ` Hans de Goede
2023-09-27 13:17         ` Hans de Goede
2023-09-26 14:59 ` [RFT PATCH 3/4] platform/x86: int3472: clk_and_regulator: use GPIO lookup tables Bartosz Golaszewski
2023-09-26 15:27   ` Andy Shevchenko
2023-09-26 14:59 ` [RFT PATCH 4/4] gpio: acpi: remove acpi_get_and_request_gpiod() Bartosz Golaszewski
2023-09-26 15:27   ` Andy Shevchenko
2023-09-27  7:55     ` Mika Westerberg
2023-10-09 12:49   ` Bartosz Golaszewski
2023-09-26 15:28 ` [RFT PATCH 0/4] platform/x86: int3472: don't use gpiod_toggle_active_low() Andy Shevchenko
2023-09-27  8:38 ` Hans de Goede
2023-09-27  8:41   ` Hans de Goede
2023-09-27  8:48   ` Bartosz Golaszewski
2023-09-27  9:02     ` Hans de Goede
2023-09-27  9:18       ` Bartosz Golaszewski
2023-09-28 12:40 ` [PATCH v2 0/5] " Hans de Goede
2023-09-28 12:41   ` [PATCH v2 1/5] platform/x86: int3472: Add new skl_int3472_fill_gpiod_lookup() helper Hans de Goede
2023-09-28 12:42   ` [PATCH v2 2/5] platform/x86: int3472: Add new skl_int3472_gpiod_get_from_temp_lookup() helper Hans de Goede
2023-10-01  8:42     ` Andy Shevchenko
2023-10-01  8:55       ` Hans de Goede
2023-09-28 12:43   ` [PATCH v2 3/5] platform/x86: int3472: Stop using gpiod_toggle_active_low() Hans de Goede
2023-09-28 12:44   ` [PATCH v2 4/5] platform/x86: int3472: Switch to devm_get_gpiod() Hans de Goede
2023-09-28 12:45   ` [PATCH v2 5/5] gpio: acpi: remove acpi_get_and_request_gpiod() Hans de Goede
2023-10-01  9:16     ` Andy Shevchenko
2023-09-28 18:40   ` [PATCH v2 0/5] platform/x86: int3472: don't use gpiod_toggle_active_low() Bartosz Golaszewski
2023-09-28 21:15     ` Hans de Goede
2023-10-04 16:29     ` Hans de Goede
2023-10-04 18:22       ` Bartosz Golaszewski
2023-10-06 13:27       ` Ilpo Järvinen
2023-10-01  9:17   ` Andy Shevchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2b5db794-c00f-e9f5-c0c9-4c5fb4df0802@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=bartosz.golaszewski@linaro.org \
    --cc=brgl@bgdev.pl \
    --cc=djrscally@gmail.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=markgross@kernel.org \
    --cc=mika.westerberg@linux.intel.com \
    --cc=platform-driver-x86@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).