diff options
author | Mika Westerberg <mika.westerberg@linux.intel.com> | 2014-10-27 12:15:14 +0200 |
---|---|---|
committer | Mihai Serban <mihai.serban@intel.com> | 2016-01-07 17:55:01 +0200 |
commit | 03ca386fa5483fc3fb547ac42a0e83640c2edb2c (patch) | |
tree | 9c49b821c91fa50df96765b621ef894de1d5b796 | |
parent | f24ce5908fd9e2ab427e275ac7bce32cfe7cff8e (diff) | |
download | minnowboard-v3.14-03ca386fa5483fc3fb547ac42a0e83640c2edb2c.tar.gz |
BACKPORT: net: rfkill: gpio: Add default GPIO driver mappings for ACPI
The driver uses devm_gpiod_get_index(..., index) so that the index refers
directly to the GpioIo resource under the ACPI device. The problem with
this is that if the ordering changes we get wrong GPIOs.
With ACPI 5.1 _DSD we can now use names instead to reference GPIOs
analogous to Device Tree. However, we still have systems out there that do
not provide _DSD at all. These systems must be supported as well.
Luckily we now have acpi_dev_add_driver_gpios() that can be used to provide
mappings for systems where _DSD is not provided and still take advantage of
_DSD if it exists.
This patch changes the driver to create default GPIO mappings if we are
running on ACPI system.
While there we can drop the indices completely and use devm_gpiod_get()
with name instead.
Change-Id: I72c28c64a2dcf93075fb2fdf5889564c31b1ddf9
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: Johannes Berg <johannes@sipsolutions.net>
Acked-by: John W. Linville <linville@tuxdriver.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Robert Dolca <robert.dolca@intel.com>
-rw-r--r-- | net/rfkill/rfkill-gpio.c | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/net/rfkill/rfkill-gpio.c b/net/rfkill/rfkill-gpio.c index f8232b94330..ac11117d6e7 100644 --- a/net/rfkill/rfkill-gpio.c +++ b/net/rfkill/rfkill-gpio.c @@ -90,6 +90,15 @@ static const struct rfkill_ops rfkill_gpio_ops = { .set_block = rfkill_gpio_set_power, }; +static const struct acpi_gpio_params reset_gpios = { 0, 0, false }; +static const struct acpi_gpio_params shutdown_gpios = { 1, 0, false }; + +static const struct acpi_gpio_mapping acpi_rfkill_default_gpios[] = { + { "reset-gpios", &reset_gpios, 1 }, + { "shutdown-gpios", &shutdown_gpios, 1 }, + { }, +}; + static irqreturn_t rfkill_gpio_host_wake(int irq, void *dev) { struct rfkill_gpio_data *rfkill = dev; @@ -210,7 +219,8 @@ static int rfkill_gpio_acpi_probe(struct device *dev, rfkill->name = dev_name(dev); rfkill->type = desc->type; - return rfkill_gpio_init(dev, desc); + return acpi_dev_add_driver_gpios(ACPI_COMPANION(dev), + acpi_rfkill_default_gpios); } static int rfkill_gpio_probe(struct platform_device *pdev) @@ -232,13 +242,14 @@ static int rfkill_gpio_probe(struct platform_device *pdev) } else if (pdata) { rfkill->name = pdata->name; rfkill->type = pdata->type; - ret = rfkill_gpio_init(&pdev->dev, NULL); - if (ret) - return ret; } else { return -ENODEV; } + ret = rfkill_gpio_init(&pdev->dev, NULL); + if (ret) + return ret; + rfkill->rfkill_dev = rfkill_alloc(rfkill->name, &pdev->dev, rfkill->type, &rfkill_gpio_ops, rfkill); @@ -299,6 +310,8 @@ static int rfkill_gpio_remove(struct platform_device *pdev) rfkill_unregister(rfkill->rfkill_dev); rfkill_destroy(rfkill->rfkill_dev); + acpi_dev_remove_driver_gpios(ACPI_COMPANION(&pdev->dev)); + return 0; } |