Re: [PATCH] gpio: crystalcove: Do not write regular gpio registers for virtual GPIOs

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

 



On Sat, May 13, 2017 at 2:39 PM, Hans de Goede <hdegoede@xxxxxxxxxx> wrote:

> The Crystal Cove PMIC has 16 real GPIOs but the ACPI code for devices
> with this PMIC may address up to 95 GPIOs, these extra GPIOs are
> called virtual GPIOs and are used by the ACPI code as a method of
> accessing various non GPIO bits of PMIC.
>
> Commit dcdc3018d635 ("gpio: crystalcove: support virtual GPIO") added
> dummy support for these to avoid a bunch of ACPI errors, but instead of
> ignoring writes / reads to them by doing:
>
> if (gpio >= CRYSTALCOVE_GPIO_NUM)
>         return 0;
>
> It accidentally introduced the following wrong check:
>
> if (gpio > CRYSTALCOVE_VGPIO_NUM)
>         return 0;
>
> Which means that attempts by the ACPI code to access these gpios
> causes some arbitrary gpio to get touched through for example
> GPIO1P0CTLO + gpionr % 8.
>
> Since we do support input/output (but not interrupts) on the 0x5e
> virtual GPIO, this commit makes to_reg return -ENOTSUPP for unsupported
> virtual GPIOs so as to not have to check for (gpio >= CRYSTALCOVE_GPIO_NUM
> && gpio != 0x5e) everywhere and to make it easier to add support for more
> virtual GPIOs in the future.
>
> It then adds a check for to_reg returning an error to all callers where
> this may happen fixing the ACPI code accessing virtual GPIOs accidentally
> causing changes to real GPIOs.
>
> Cc: Aaron Lu <aaron.lu@xxxxxxxxx>
> Signed-off-by: Hans de Goede <hdegoede@xxxxxxxxxx>

Patch applied for fixes with Andy's review tag and
the suggested Fixes: tag.

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[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