linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Haowen Bai <baihaowen@meizu.com>
To: <lgirdwood@gmail.com>, <broonie@kernel.org>
Cc: <linux-kernel@vger.kernel.org>, Haowen Bai <baihaowen@meizu.com>
Subject: [PATCH] regulator: vctrl: Use min() instead of doing it manually
Date: Tue, 15 Mar 2022 11:33:10 +0800	[thread overview]
Message-ID: <1647315190-16139-1-git-send-email-baihaowen@meizu.com> (raw)

Fix following coccicheck warning:
drivers/regulator/vctrl-regulator.c:188:15-17: WARNING opportunity for max()

Signed-off-by: Haowen Bai <baihaowen@meizu.com>
---
 drivers/regulator/vctrl-regulator.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/regulator/vctrl-regulator.c b/drivers/regulator/vctrl-regulator.c
index d2a3797..c504672 100644
--- a/drivers/regulator/vctrl-regulator.c
+++ b/drivers/regulator/vctrl-regulator.c
@@ -185,10 +185,7 @@ static int vctrl_set_voltage_sel(struct regulator_dev *rdev,
 		unsigned int next_sel;
 		int delay;
 
-		if (selector >= vctrl->vtable[vctrl->sel].ovp_min_sel)
-			next_sel = selector;
-		else
-			next_sel = vctrl->vtable[vctrl->sel].ovp_min_sel;
+		next_sel = max_t(unsigned int, selector, vctrl->vtable[vctrl->sel].ovp_min_sel);
 
 		ret = regulator_set_voltage_rdev(rdev->supply->rdev,
 					    vctrl->vtable[next_sel].ctrl,
-- 
2.7.4


             reply	other threads:[~2022-03-15  3:33 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-15  3:33 Haowen Bai [this message]
2022-03-15 13:40 ` [PATCH] regulator: vctrl: Use min() instead of doing it manually Mark Brown

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=1647315190-16139-1-git-send-email-baihaowen@meizu.com \
    --to=baihaowen@meizu.com \
    --cc=broonie@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    /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).