From: Hans Zhang <18255117159@163.com>
To: linusw@kernel.org, unicorn_wang@outlook.com, inochiama@gmail.com,
dlan@kernel.org
Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
Hans Zhang <18255117159@163.com>
Subject: [PATCH 1/2] pinctrl: sophgo: Use FIELD_MODIFY()
Date: Fri, 1 May 2026 01:01:03 +0800 [thread overview]
Message-ID: <20260430170104.53854-2-18255117159@163.com> (raw)
In-Reply-To: <20260430170104.53854-1-18255117159@163.com>
Use FIELD_MODIFY() to remove open-coded bit manipulation.
No functional change intended.
Signed-off-by: Hans Zhang <18255117159@163.com>
---
drivers/pinctrl/sophgo/pinctrl-cv18xx.c | 18 ++++++------------
1 file changed, 6 insertions(+), 12 deletions(-)
diff --git a/drivers/pinctrl/sophgo/pinctrl-cv18xx.c b/drivers/pinctrl/sophgo/pinctrl-cv18xx.c
index c3a2dcf71f2a..40a85d93b52e 100644
--- a/drivers/pinctrl/sophgo/pinctrl-cv18xx.c
+++ b/drivers/pinctrl/sophgo/pinctrl-cv18xx.c
@@ -333,13 +333,11 @@ static int cv1800_pinconf_compute_config(struct sophgo_pinctrl *pctrl,
switch (param) {
case PIN_CONFIG_BIAS_PULL_DOWN:
- v &= ~PIN_IO_PULLDOWN;
- v |= FIELD_PREP(PIN_IO_PULLDOWN, arg);
+ FIELD_MODIFY(PIN_IO_PULLDOWN, &v, arg);
m |= PIN_IO_PULLDOWN;
break;
case PIN_CONFIG_BIAS_PULL_UP:
- v &= ~PIN_IO_PULLUP;
- v |= FIELD_PREP(PIN_IO_PULLUP, arg);
+ FIELD_MODIFY(PIN_IO_PULLUP, &v, arg);
m |= PIN_IO_PULLUP;
break;
case PIN_CONFIG_DRIVE_STRENGTH_UA:
@@ -347,8 +345,7 @@ static int cv1800_pinconf_compute_config(struct sophgo_pinctrl *pctrl,
priv->power_cfg, arg);
if (ret < 0)
return ret;
- v &= ~PIN_IO_DRIVE;
- v |= FIELD_PREP(PIN_IO_DRIVE, ret);
+ FIELD_MODIFY(PIN_IO_DRIVE, &v, ret);
m |= PIN_IO_DRIVE;
break;
case PIN_CONFIG_INPUT_SCHMITT_UV:
@@ -356,21 +353,18 @@ static int cv1800_pinconf_compute_config(struct sophgo_pinctrl *pctrl,
priv->power_cfg, arg);
if (ret < 0)
return ret;
- v &= ~PIN_IO_SCHMITT;
- v |= FIELD_PREP(PIN_IO_SCHMITT, ret);
+ FIELD_MODIFY(PIN_IO_SCHMITT, &v, ret);
m |= PIN_IO_SCHMITT;
break;
case PIN_CONFIG_POWER_SOURCE:
/* Ignore power source as it is always fixed */
break;
case PIN_CONFIG_SLEW_RATE:
- v &= ~PIN_IO_OUT_FAST_SLEW;
- v |= FIELD_PREP(PIN_IO_OUT_FAST_SLEW, arg);
+ FIELD_MODIFY(PIN_IO_OUT_FAST_SLEW, &v, arg);
m |= PIN_IO_OUT_FAST_SLEW;
break;
case PIN_CONFIG_BIAS_BUS_HOLD:
- v &= ~PIN_IO_BUS_HOLD;
- v |= FIELD_PREP(PIN_IO_BUS_HOLD, arg);
+ FIELD_MODIFY(PIN_IO_BUS_HOLD, &v, arg);
m |= PIN_IO_BUS_HOLD;
break;
default:
--
2.34.1
next prev parent reply other threads:[~2026-04-30 17:01 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-30 17:01 [PATCH 0/2] pinctrl: Use FIELD_MODIFY() to simplify bit manipulation Hans Zhang
2026-04-30 17:01 ` Hans Zhang [this message]
2026-04-30 17:01 ` [PATCH 2/2] pinctrl: spacemit: Use FIELD_MODIFY() Hans Zhang
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=20260430170104.53854-2-18255117159@163.com \
--to=18255117159@163.com \
--cc=dlan@kernel.org \
--cc=inochiama@gmail.com \
--cc=linusw@kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=unicorn_wang@outlook.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