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>
This commit is contained in:
committed by
Linus Walleij
parent
26af34079f
commit
a71a81e797
@@ -86,9 +86,9 @@ static void of_gpio_flags_quirks(struct device_node *np,
|
|||||||
if (IS_ENABLED(CONFIG_REGULATOR) &&
|
if (IS_ENABLED(CONFIG_REGULATOR) &&
|
||||||
(of_device_is_compatible(np, "regulator-fixed") ||
|
(of_device_is_compatible(np, "regulator-fixed") ||
|
||||||
of_device_is_compatible(np, "reg-fixed-voltage") ||
|
of_device_is_compatible(np, "reg-fixed-voltage") ||
|
||||||
(of_device_is_compatible(np, "regulator-gpio") &&
|
(!(strcmp(propname, "enable-gpio") &&
|
||||||
!(strcmp(propname, "enable-gpio") &&
|
strcmp(propname, "enable-gpios")) &&
|
||||||
strcmp(propname, "enable-gpios"))))) {
|
of_device_is_compatible(np, "regulator-gpio")))) {
|
||||||
/*
|
/*
|
||||||
* The regulator GPIO handles are specified such that the
|
* The regulator GPIO handles are specified such that the
|
||||||
* presence or absence of "enable-active-high" solely controls
|
* 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
|
* property named "cs-gpios" we need to inspect the child node
|
||||||
* to determine if the flags should have inverted semantics.
|
* to determine if the flags should have inverted semantics.
|
||||||
*/
|
*/
|
||||||
if (IS_ENABLED(CONFIG_SPI_MASTER) &&
|
if (IS_ENABLED(CONFIG_SPI_MASTER) && !strcmp(propname, "cs-gpios") &&
|
||||||
of_property_read_bool(np, "cs-gpios") &&
|
of_property_read_bool(np, "cs-gpios")) {
|
||||||
!strcmp(propname, "cs-gpios")) {
|
|
||||||
struct device_node *child;
|
struct device_node *child;
|
||||||
u32 cs;
|
u32 cs;
|
||||||
int ret;
|
int ret;
|
||||||
|
|||||||
Reference in New Issue
Block a user