Received: by 2002:a25:5b86:0:0:0:0:0 with SMTP id p128csp1307343ybb; Fri, 29 Mar 2019 01:43:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqwqmxSjflQ03mRog212uLHlcHR4PN8+xcveZT1Br5zacAhtFBYB9YQr6RMFhzP/IU/hiA5J X-Received: by 2002:a63:5054:: with SMTP id q20mr44582285pgl.414.1553849020939; Fri, 29 Mar 2019 01:43:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553849020; cv=none; d=google.com; s=arc-20160816; b=ftqtXReyJOE1O/kbpe/qncBq/EReSmnT1j705tNFXSEsGuYPJ4jMjzACCzI2Zz4Ujd 4CxwfNjitQoXIA6q9pQ0Oxx8WfYvAzHajtC+/xIGZm71UKkN7pHSz/9BJOXD1Tx0nOMg Q8h49/lNMlEy/ljZmqJulHvfILhvuY8tlvjy0pu3f1oGz8ZTQR+nRSSSsDQIsFjvMWPJ BwYoCLMZ2h+RA5p0KsdiXJwJaO2fFvaAxEE79syqOUvjgGr84x7kOizoWvyixPnslt+A kZ8QQFFNyrjbqNqAqJDn8Ez2/gyMD4QvGzdN0NGG/yLWSEL227cHLxr0NP7Q4WsQ/glu 1sdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=V6sJZwjuCt8i64xUrCYe3Jpo0H6OhjICmlPdojUCpN4=; b=zoRstpm66yl3Ud0A6vMXyObzSyLhiYiOZcEHvsmXNrBe3bBpr6MFzBu/Tm9/G3x1P7 twxIHX78kyCUQgOqjm9I3RAh4xD16yNnLOrmHAtVdBkIoYctvfkMTEnRcpNojo5ACkQa l6aqmib5agA67uwH47CrguNRyfijiv6Qu4J3ijsRVVVCvQJV4MCrVSr+2BQgecQveqB9 j12a5QYa7qAWHlKmGBdBTMT5WvF+1/NG/JhAR/pveJo62FaXDsmdRED1XSqfYNGaNGMX kX52JzfuQp54ci+9adc3cF32PIf+fJRnY99GQ8GfXHMoZ5LAiVHqjXTpE85gHkWpPzqO 0u1Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x5si1377641pln.220.2019.03.29.01.43.25; Fri, 29 Mar 2019 01:43:40 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729199AbfC2Ime (ORCPT + 99 others); Fri, 29 Mar 2019 04:42:34 -0400 Received: from xavier.telenet-ops.be ([195.130.132.52]:40526 "EHLO xavier.telenet-ops.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729139AbfC2Ime (ORCPT ); Fri, 29 Mar 2019 04:42:34 -0400 Received: from ramsan ([84.194.111.163]) by xavier.telenet-ops.be with bizsmtp id tkiW1z00e3XaVaC01kiWqw; Fri, 29 Mar 2019 09:42:32 +0100 Received: from rox.of.borg ([192.168.97.57]) by ramsan with esmtp (Exim 4.90_1) (envelope-from ) id 1h9n5r-0001QX-39; Fri, 29 Mar 2019 09:42:31 +0100 Received: from geert by rox.of.borg with local (Exim 4.90_1) (envelope-from ) id 1h9n5r-0004RD-27; Fri, 29 Mar 2019 09:42:31 +0100 From: Geert Uytterhoeven To: Linus Walleij , Bartosz Golaszewski Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH] gpio: of: Optimize quirk checks Date: Fri, 29 Mar 2019 09:42:29 +0100 Message-Id: <20190329084229.17018-1-geert+renesas@glider.be> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- drivers/gpio/gpiolib-of.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c index 6a3ec575a404ed9f..3a6bb53d89dfed32 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; -- 2.17.1