Re: [RFT PATCH 2/4] platform/x86: int3472: led: don't use gpiod_toggle_active_low()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Sep 27, 2023 at 11:40 AM Hans de Goede <hdegoede@xxxxxxxxxx> wrote:
>
> Hi,
>
> On 9/26/23 16:59, Bartosz Golaszewski wrote:
> > From: Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxx>
> >
> > 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@xxxxxxxxxx>
> > ---
> >  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.
>

Ultimately I'd like everyone to use gpiod_get() for getting
descriptors but for now I get it's enough. Are you find with this
being done in a single patch across GPIO and this driver?

Bart

> 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));
>




[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux