From: Mika Westerberg <mika.westerberg@linux.intel.com>
To: Raag Jadav <raag.jadav@intel.com>
Cc: linus.walleij@linaro.org, andriy.shevchenko@linux.intel.com,
linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
mallikarjunappa.sangannavar@intel.com, pandith.n@intel.com
Subject: Re: [PATCH v1 1/4] pinctrl: intel: optimize set_mux hook
Date: Thu, 8 Jun 2023 11:08:21 +0300 [thread overview]
Message-ID: <20230608080821.GF45886@black.fi.intel.com> (raw)
In-Reply-To: <20230608070017.28072-2-raag.jadav@intel.com>
On Thu, Jun 08, 2023 at 12:30:14PM +0530, Raag Jadav wrote:
> Utilize a temporary variable for common shift operation
> inside ->set_mux() hook and save 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%
Shouldn't the compiler be able to optimize this if you ask with the -Ox
options?
I don't really see much benefit for "optimizations" like this. That said
using temporary variable here improves readability so this one is
acceptable by me. As long as you change the commit message accordingly.
> Signed-off-by: Raag Jadav <raag.jadav@intel.com>
> ---
> 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);
> }
>
> --
> 2.17.1
next prev parent reply other threads:[~2023-06-08 8:08 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 [this message]
2023-06-08 10:20 ` Jadav, Raag
2023-06-08 10:56 ` Mika Westerberg
2023-06-08 7:00 ` [PATCH v1 2/4] pinctrl: intel: optimize irq_set_type hook Raag Jadav
2023-06-08 7:00 ` [PATCH v1 3/4] pinctrl: intel: simplify exit path of set_mux hook 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=20230608080821.GF45886@black.fi.intel.com \
--to=mika.westerberg@linux.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=pandith.n@intel.com \
--cc=raag.jadav@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).