diff options
author | Geert Uytterhoeven <geert+renesas@glider.be> | 2019-03-29 11:42:29 +0300 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2019-04-08 14:03:26 +0300 |
commit | a71a81e7975843504170e69fe52605478f3c8e04 (patch) | |
tree | 022e8ffc9b19c00d50cc766f46c487d8dad466d0 /drivers/gpio | |
parent | 26af34079f1d8299932303cfd2b376b9cf55a35c (diff) | |
download | linux-a71a81e7975843504170e69fe52605478f3c8e04.tar.xz |
gpio: of: Optimize quirk checks
Simple string comparisons are cheaper than DT lookups, as the latter
involve taking a spinlock and traversing properties.
Hence optimize quirk checks by postponing DT lookups after string
comparisons.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Mukesh Ojha <mojha@codeaurora.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/gpio')
-rw-r--r-- | drivers/gpio/gpiolib-of.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c index 6a3ec575a404..3a6bb53d89df 100644 --- a/drivers/gpio/gpiolib-of.c +++ b/drivers/gpio/gpiolib-of.c @@ -86,9 +86,9 @@ static void of_gpio_flags_quirks(struct device_node *np, if (IS_ENABLED(CONFIG_REGULATOR) && (of_device_is_compatible(np, "regulator-fixed") || of_device_is_compatible(np, "reg-fixed-voltage") || - (of_device_is_compatible(np, "regulator-gpio") && - !(strcmp(propname, "enable-gpio") && - strcmp(propname, "enable-gpios"))))) { + (!(strcmp(propname, "enable-gpio") && + strcmp(propname, "enable-gpios")) && + of_device_is_compatible(np, "regulator-gpio")))) { /* * The regulator GPIO handles are specified such that the * presence or absence of "enable-active-high" solely controls @@ -119,9 +119,8 @@ static void of_gpio_flags_quirks(struct device_node *np, * property named "cs-gpios" we need to inspect the child node * to determine if the flags should have inverted semantics. */ - if (IS_ENABLED(CONFIG_SPI_MASTER) && - of_property_read_bool(np, "cs-gpios") && - !strcmp(propname, "cs-gpios")) { + if (IS_ENABLED(CONFIG_SPI_MASTER) && !strcmp(propname, "cs-gpios") && + of_property_read_bool(np, "cs-gpios")) { struct device_node *child; u32 cs; int ret; |