From: Raag Jadav <raag.jadav@intel.com>
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 <raag.jadav@intel.com>
Subject: [PATCH v1 2/4] pinctrl: intel: optimize irq_set_type hook
Date: Thu, 8 Jun 2023 12:30:15 +0530 [thread overview]
Message-ID: <20230608070017.28072-3-raag.jadav@intel.com> (raw)
In-Reply-To: <20230608070017.28072-1-raag.jadav@intel.com>
Utilize a temporary variable for common shift operation
inside ->irq_set_type() hook and save a few bytes.
While at it, simplify if-else-if chain.
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 <raag.jadav@intel.com>
---
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)
--
2.17.1
next prev parent reply other threads:[~2023-06-08 7:01 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-08 7:00 [PATCH v1 0/4] Minor optimizations for Intel pinctrl Raag Jadav
2023-06-08 7:00 ` [PATCH v1 1/4] pinctrl: intel: optimize set_mux hook Raag Jadav
2023-06-08 8:08 ` Mika Westerberg
2023-06-08 10:20 ` Jadav, Raag
2023-06-08 10:56 ` Mika Westerberg
2023-06-08 7:00 ` Raag Jadav [this message]
2023-06-08 7:00 ` [PATCH v1 3/4] pinctrl: intel: simplify exit path of " Raag Jadav
2023-06-08 8:09 ` Mika Westerberg
2023-06-08 7:00 ` [PATCH v1 4/4] pinctrl: intel: simplify exit path of gpio_request_enable hook Raag Jadav
2023-06-08 8:10 ` Mika Westerberg
2023-06-08 14:30 ` [PATCH v1 0/4] Minor optimizations for Intel pinctrl Andy Shevchenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230608070017.28072-3-raag.jadav@intel.com \
--to=raag.jadav@intel.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mallikarjunappa.sangannavar@intel.com \
--cc=mika.westerberg@linux.intel.com \
--cc=pandith.n@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).