aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2015-03-10 18:08:57 -0400
committerLinus Walleij <linus.walleij@linaro.org>2015-03-19 04:46:04 -0400
commit4d8440b93ce8a8544199804dbcf997b2ab3dad11 (patch)
tree77458cfa065d39cc50c3be2801463d830fd07d36 /drivers
parent964cb341882f920a1a1043864178f22def3193e4 (diff)
gpio / ACPI: Avoid unnecessary checks in __gpiod_get_index()
If dev is NULL in __gpiod_get_index() and both ACPI and OF are enabled, it will be checked twice before the code decides to give up with DT/ACPI lookup, so avoid that. Also use the observation that ACPI_COMPANION() is much more efficient than ACPI_HANDLE(), because the latter uses the former and carries out a check and a pointer dereference on top of it, so replace the ACPI_HANDLE() check with an ACPI_COMPANION() one which does not require the additional IS_ENABLED(CONFIG_ACPI) check too. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Reviewed-by: Hanjun Guo <hanjun.guo@linaro.org> Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gpio/gpiolib.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 3d5b85a7dcdf..59eaa23767d8 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -1971,13 +1971,15 @@ struct gpio_desc *__must_check __gpiod_get_index(struct device *dev,
1971 1971
1972 dev_dbg(dev, "GPIO lookup for consumer %s\n", con_id); 1972 dev_dbg(dev, "GPIO lookup for consumer %s\n", con_id);
1973 1973
1974 /* Using device tree? */ 1974 if (dev) {
1975 if (IS_ENABLED(CONFIG_OF) && dev && dev->of_node) { 1975 /* Using device tree? */
1976 dev_dbg(dev, "using device tree for GPIO lookup\n"); 1976 if (IS_ENABLED(CONFIG_OF) && dev->of_node) {
1977 desc = of_find_gpio(dev, con_id, idx, &lookupflags); 1977 dev_dbg(dev, "using device tree for GPIO lookup\n");
1978 } else if (IS_ENABLED(CONFIG_ACPI) && dev && ACPI_HANDLE(dev)) { 1978 desc = of_find_gpio(dev, con_id, idx, &lookupflags);
1979 dev_dbg(dev, "using ACPI for GPIO lookup\n"); 1979 } else if (ACPI_COMPANION(dev)) {
1980 desc = acpi_find_gpio(dev, con_id, idx, &lookupflags); 1980 dev_dbg(dev, "using ACPI for GPIO lookup\n");
1981 desc = acpi_find_gpio(dev, con_id, idx, &lookupflags);
1982 }
1981 } 1983 }
1982 1984
1983 /* 1985 /*