From patchwork Tue Jun 13 08:50:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raag Jadav X-Patchwork-Id: 692819 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6416AC7EE29 for ; Tue, 13 Jun 2023 08:51:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240691AbjFMIvd (ORCPT ); Tue, 13 Jun 2023 04:51:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57794 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235447AbjFMIvc (ORCPT ); Tue, 13 Jun 2023 04:51:32 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C8D5C0; Tue, 13 Jun 2023 01:51:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1686646291; x=1718182291; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=lRlqrIOLlgszhQgiQp5cTIQBBj7DVYDQjqPLzSvJfg0=; b=FvGdOigcrxES0oRfCfYyXapHzpsPlEZUT9HJOyfSxjVYICBRNkFF43GY 90Ep0esb4IwQU0MX9DOXDFbVGlKeGXM8Y1TtwoDhzrnUtOEKD5eFP128l pnHYGHxyIhxJ1M7afeJcfP9Ny0+8/srFCk+3P2iycpNCPn2JBSxHbfS7w 5N3DNkaPPAyaRITbHXba+xv8HE6/OtyQ7J8v1FamsudBwFiVOrpobQH6z 8fJegQthz4dLmPMYydu9K6fgdiGiedEL4TqaJNd6NJnyBENu2JLIHaXBC N8qxVpbjgcQPRWAZnN5bPNvhXFZeg+Ua+RKW0Zlm5heeOKbNksZ4s8hmv A==; X-IronPort-AV: E=McAfee;i="6600,9927,10739"; a="386664945" X-IronPort-AV: E=Sophos;i="6.00,239,1681196400"; d="scan'208";a="386664945" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Jun 2023 01:51:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10739"; a="824305094" X-IronPort-AV: E=Sophos;i="6.00,239,1681196400"; d="scan'208";a="824305094" Received: from inesxmail01.iind.intel.com ([10.223.154.20]) by fmsmga002.fm.intel.com with ESMTP; 13 Jun 2023 01:51:29 -0700 Received: from inlubt0316.iind.intel.com (inlubt0316.iind.intel.com [10.191.20.213]) by inesxmail01.iind.intel.com (Postfix) with ESMTP id 6CAF21973E; Tue, 13 Jun 2023 14:21:28 +0530 (IST) Received: by inlubt0316.iind.intel.com (Postfix, from userid 12101951) id 680C6196; Tue, 13 Jun 2023 14:21:28 +0530 (IST) From: Raag Jadav To: linus.walleij@linaro.org, mika.westerberg@linux.intel.com, andriy.shevchenko@linux.intel.com Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, mallikarjunappa.sangannavar@intel.com, pandith.n@intel.com, Raag Jadav Subject: [PATCH v3 1/3] pinctrl: intel: refine ->set_mux() hook Date: Tue, 13 Jun 2023 14:20:52 +0530 Message-Id: <20230613085054.10976-2-raag.jadav@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230613085054.10976-1-raag.jadav@intel.com> References: <20230613085054.10976-1-raag.jadav@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org Utilize a temporary variable for common shift operation in ->set_mux() hook and improve readability while saving a few bytes. add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-3 (-3) Function old new delta intel_pinmux_set_mux 245 242 -3 Total: Before=10472, After=10469, chg -0.03% Signed-off-by: Raag Jadav --- drivers/pinctrl/intel/pinctrl-intel.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/pinctrl/intel/pinctrl-intel.c b/drivers/pinctrl/intel/pinctrl-intel.c index c7a71c49df0a..e8adf2580321 100644 --- a/drivers/pinctrl/intel/pinctrl-intel.c +++ b/drivers/pinctrl/intel/pinctrl-intel.c @@ -411,18 +411,19 @@ static int intel_pinmux_set_mux(struct pinctrl_dev *pctldev, /* Now enable the mux setting for each pin in the group */ for (i = 0; i < grp->grp.npins; i++) { void __iomem *padcfg0; - u32 value; + u32 value, pmode; padcfg0 = intel_get_padcfg(pctrl, grp->grp.pins[i], PADCFG0); - value = readl(padcfg0); + value = readl(padcfg0); value &= ~PADCFG0_PMODE_MASK; if (grp->modes) - value |= grp->modes[i] << PADCFG0_PMODE_SHIFT; + pmode = grp->modes[i]; else - value |= grp->mode << PADCFG0_PMODE_SHIFT; + pmode = grp->mode; + value |= pmode << PADCFG0_PMODE_SHIFT; writel(value, padcfg0); } From patchwork Tue Jun 13 08:50:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raag Jadav X-Patchwork-Id: 692818 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 484D8C7EE29 for ; Tue, 13 Jun 2023 08:51:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241744AbjFMIvh (ORCPT ); Tue, 13 Jun 2023 04:51:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57814 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240755AbjFMIve (ORCPT ); Tue, 13 Jun 2023 04:51:34 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 93A0CC0; Tue, 13 Jun 2023 01:51:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1686646293; x=1718182293; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=QsnfKD0vrMxrGMgDPsYUSV+TjEAJfQkDBuxj7dIOTYA=; b=dd2Zf4/S7gvLJ3WcHarlrFW9x3M0OnUnrd+ExJNjjtxJZfK1iW/D7fYo 6wlMBznzWvAR25rGlUHZh0dheVIzUCE0YOdB5OrZGNA/HZ4TSZyCOgMg2 wzkLmLb7Y/gJk5OT3a5nzfRQWYTnSvGZ+0oD3v9T+ImgNIx7f4S05X1CL wVy1/R6QN8lmTNz4WRfktIhQbdqp7Jm9DC1YtE6KQ5RY693gKM6JJA6qq VS3wcHqbsMZtRzG4be+F8ZV1Uhomd9ZJAw8O39r+8azKl1hLAFImH6mU2 7DhBNmvXkPVpYS3q5mn07YqvNyxM2ZQwEB+DnCLGMIsxLFluGiLehQMWW Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10739"; a="386664947" X-IronPort-AV: E=Sophos;i="6.00,239,1681196400"; d="scan'208";a="386664947" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Jun 2023 01:51:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10739"; a="824305096" X-IronPort-AV: E=Sophos;i="6.00,239,1681196400"; d="scan'208";a="824305096" Received: from inesxmail01.iind.intel.com ([10.223.154.20]) by fmsmga002.fm.intel.com with ESMTP; 13 Jun 2023 01:51:29 -0700 Received: from inlubt0316.iind.intel.com (inlubt0316.iind.intel.com [10.191.20.213]) by inesxmail01.iind.intel.com (Postfix) with ESMTP id 7123C19742; Tue, 13 Jun 2023 14:21:28 +0530 (IST) Received: by inlubt0316.iind.intel.com (Postfix, from userid 12101951) id 6C1E01C6; Tue, 13 Jun 2023 14:21:28 +0530 (IST) From: Raag Jadav To: linus.walleij@linaro.org, mika.westerberg@linux.intel.com, andriy.shevchenko@linux.intel.com Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, mallikarjunappa.sangannavar@intel.com, pandith.n@intel.com, Raag Jadav Subject: [PATCH v3 2/3] pinctrl: intel: refine ->irq_set_type() hook Date: Tue, 13 Jun 2023 14:20:53 +0530 Message-Id: <20230613085054.10976-3-raag.jadav@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230613085054.10976-1-raag.jadav@intel.com> References: <20230613085054.10976-1-raag.jadav@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org Utilize a temporary variable for common shift operation in ->irq_set_type() hook and improve readability. While at it, simplify if-else-if chain and save a few bytes. add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-16 (-16) Function old new delta intel_gpio_irq_type 317 301 -16 Total: Before=10469, After=10453, chg -0.15% Signed-off-by: Raag Jadav --- drivers/pinctrl/intel/pinctrl-intel.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/drivers/pinctrl/intel/pinctrl-intel.c b/drivers/pinctrl/intel/pinctrl-intel.c index e8adf2580321..3f78066b1837 100644 --- a/drivers/pinctrl/intel/pinctrl-intel.c +++ b/drivers/pinctrl/intel/pinctrl-intel.c @@ -1128,8 +1128,8 @@ static int intel_gpio_irq_type(struct irq_data *d, unsigned int type) struct intel_pinctrl *pctrl = gpiochip_get_data(gc); unsigned int pin = intel_gpio_to_pin(pctrl, irqd_to_hwirq(d), NULL, NULL); unsigned long flags; + u32 value, rxevcfg; void __iomem *reg; - u32 value; reg = intel_get_padcfg(pctrl, pin, PADCFG0); if (!reg) @@ -1150,23 +1150,24 @@ static int intel_gpio_irq_type(struct irq_data *d, unsigned int type) intel_gpio_set_gpio_mode(reg); value = readl(reg); - value &= ~(PADCFG0_RXEVCFG_MASK | PADCFG0_RXINV); if ((type & IRQ_TYPE_EDGE_BOTH) == IRQ_TYPE_EDGE_BOTH) { - value |= PADCFG0_RXEVCFG_EDGE_BOTH << PADCFG0_RXEVCFG_SHIFT; + rxevcfg = PADCFG0_RXEVCFG_EDGE_BOTH; } else if (type & IRQ_TYPE_EDGE_FALLING) { - value |= PADCFG0_RXEVCFG_EDGE << PADCFG0_RXEVCFG_SHIFT; - value |= PADCFG0_RXINV; + rxevcfg = PADCFG0_RXEVCFG_EDGE; } else if (type & IRQ_TYPE_EDGE_RISING) { - value |= PADCFG0_RXEVCFG_EDGE << PADCFG0_RXEVCFG_SHIFT; + rxevcfg = PADCFG0_RXEVCFG_EDGE; } else if (type & IRQ_TYPE_LEVEL_MASK) { - if (type & IRQ_TYPE_LEVEL_LOW) - value |= PADCFG0_RXINV; + rxevcfg = PADCFG0_RXEVCFG_LEVEL; } else { - value |= PADCFG0_RXEVCFG_DISABLED << PADCFG0_RXEVCFG_SHIFT; + rxevcfg = PADCFG0_RXEVCFG_DISABLED; } + if (type == IRQ_TYPE_EDGE_FALLING || type == IRQ_TYPE_LEVEL_LOW) + value |= PADCFG0_RXINV; + + value |= rxevcfg << PADCFG0_RXEVCFG_SHIFT; writel(value, reg); if (type & IRQ_TYPE_EDGE_BOTH) From patchwork Tue Jun 13 08:50:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raag Jadav X-Patchwork-Id: 692330 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 32FF2C88CB6 for ; Tue, 13 Jun 2023 08:51:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241745AbjFMIvh (ORCPT ); Tue, 13 Jun 2023 04:51:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241090AbjFMIve (ORCPT ); Tue, 13 Jun 2023 04:51:34 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB166CA; Tue, 13 Jun 2023 01:51:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1686646293; x=1718182293; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=f8fpX7WbHtQPgDSMHUPqyQBZ/trkXyouBY/M9suBHRw=; b=EHLqwVGIoRISkzonk1xYeHlaaVRhuGv+vSZS4ZYke8V78rXQokJm1fi2 RJ/oonUeHLHq/FUxnxOqv6IOIBhYQT4su97Ogm54+RElwNIfIeI8IFlKR q/h6zu4/4Iz6GIGB3CGu11a6uV1lfh2+uodTfRPfb0mOWPMsN3yISBugB XSsXu/m1Rl+CaSN3vPOUf2FjE8NsTiZeDWzYLGhe0DOOHmCjU679MZ5FN o0LoPZM/dfFKVAkigQoNaNQDV4ar/zxJvKjlgE8RsrkQgJFdxlX/jNXhG R/EpbCzmjNv5RGvUSQ1nLfbJpMLnaJOzWwxOqG9Xp7Y6h4SqohmuLMpQD w==; X-IronPort-AV: E=McAfee;i="6600,9927,10739"; a="386664949" X-IronPort-AV: E=Sophos;i="6.00,239,1681196400"; d="scan'208";a="386664949" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Jun 2023 01:51:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10739"; a="824305098" X-IronPort-AV: E=Sophos;i="6.00,239,1681196400"; d="scan'208";a="824305098" Received: from inesxmail01.iind.intel.com ([10.223.154.20]) by fmsmga002.fm.intel.com with ESMTP; 13 Jun 2023 01:51:29 -0700 Received: from inlubt0316.iind.intel.com (inlubt0316.iind.intel.com [10.191.20.213]) by inesxmail01.iind.intel.com (Postfix) with ESMTP id 731BD19746; Tue, 13 Jun 2023 14:21:28 +0530 (IST) Received: by inlubt0316.iind.intel.com (Postfix, from userid 12101951) id 70262104; Tue, 13 Jun 2023 14:21:28 +0530 (IST) From: Raag Jadav To: linus.walleij@linaro.org, mika.westerberg@linux.intel.com, andriy.shevchenko@linux.intel.com Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, mallikarjunappa.sangannavar@intel.com, pandith.n@intel.com, Raag Jadav Subject: [PATCH v3 3/3] pinctrl: intel: simplify exit path of ->gpio_request_enable() hook Date: Tue, 13 Jun 2023 14:20:54 +0530 Message-Id: <20230613085054.10976-4-raag.jadav@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230613085054.10976-1-raag.jadav@intel.com> References: <20230613085054.10976-1-raag.jadav@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org Simplify exit path of ->gpio_request_enable() hook and save a few bytes. add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-36 (-36) Function old new delta intel_gpio_request_enable 186 150 -36 Total: Before=10453, After=10417, chg -0.34% Signed-off-by: Raag Jadav --- drivers/pinctrl/intel/pinctrl-intel.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/drivers/pinctrl/intel/pinctrl-intel.c b/drivers/pinctrl/intel/pinctrl-intel.c index 3f78066b1837..43e17bc177d0 100644 --- a/drivers/pinctrl/intel/pinctrl-intel.c +++ b/drivers/pinctrl/intel/pinctrl-intel.c @@ -485,20 +485,19 @@ static int intel_gpio_request_enable(struct pinctrl_dev *pctldev, struct intel_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev); void __iomem *padcfg0; unsigned long flags; + int ret = 0; padcfg0 = intel_get_padcfg(pctrl, pin, PADCFG0); raw_spin_lock_irqsave(&pctrl->lock, flags); if (!intel_pad_owned_by_host(pctrl, pin)) { - raw_spin_unlock_irqrestore(&pctrl->lock, flags); - return -EBUSY; + ret = -EBUSY; + goto out_unlock; } - if (!intel_pad_is_unlocked(pctrl, pin)) { - raw_spin_unlock_irqrestore(&pctrl->lock, flags); - return 0; - } + if (!intel_pad_is_unlocked(pctrl, pin)) + goto out_unlock; /* * If pin is already configured in GPIO mode, we assume that @@ -506,16 +505,15 @@ static int intel_gpio_request_enable(struct pinctrl_dev *pctldev, * potential glitches on the pin. Otherwise, for the pin in * alternative mode, consumer has to supply respective flags. */ - if (intel_gpio_get_gpio_mode(padcfg0) == PADCFG0_PMODE_GPIO) { - raw_spin_unlock_irqrestore(&pctrl->lock, flags); - return 0; - } + if (intel_gpio_get_gpio_mode(padcfg0) == PADCFG0_PMODE_GPIO) + goto out_unlock; intel_gpio_set_gpio_mode(padcfg0); +out_unlock: raw_spin_unlock_irqrestore(&pctrl->lock, flags); - return 0; + return ret; } static int intel_gpio_set_direction(struct pinctrl_dev *pctldev,