Linux Input/HID development
 help / color / mirror / Atom feed
From: Chen Changcheng <chenchangcheng@kylinos.cn>
To: bonbons@linux-vserver.org, jikos@kernel.org, bentiss@kernel.org,
	srinivas.pandruvada@linux.intel.com, even.xu@intel.com,
	xinpeng.sun@intel.com
Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
	ccc194101@163.com, Chen Changcheng <chenchangcheng@kylinos.cn>
Subject: [PATCH 1/4] HID: intel-quicki2c: Use min() macro to simplify code
Date: Tue, 28 Jul 2026 10:57:47 +0800	[thread overview]
Message-ID: <20260728025750.48249-2-chenchangcheng@kylinos.cn> (raw)
In-Reply-To: <20260728025750.48249-1-chenchangcheng@kylinos.cn>

Replace open-coded min() logic with the standard min() macro in
pci-quicki2c.c for setting i2c_max_frame_size and i2c_int_delay.
This improves code readability and is consistent with kernel coding
style.

Detected by Coccinelle:
./intel-thc-hid/intel-quicki2c/pci-quicki2c.c:213:22-24: WARNING opportunity for min()
./intel-thc-hid/intel-quicki2c/pci-quicki2c.c:218:22-24: WARNING opportunity for min()

Signed-off-by: Chen Changcheng <chenchangcheng@kylinos.cn>
---
 .../hid/intel-thc-hid/intel-quicki2c/pci-quicki2c.c   | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/drivers/hid/intel-thc-hid/intel-quicki2c/pci-quicki2c.c b/drivers/hid/intel-thc-hid/intel-quicki2c/pci-quicki2c.c
index 46d3e9a01999..bd099600bb9f 100644
--- a/drivers/hid/intel-thc-hid/intel-quicki2c/pci-quicki2c.c
+++ b/drivers/hid/intel-thc-hid/intel-quicki2c/pci-quicki2c.c
@@ -210,15 +210,8 @@ static int quicki2c_get_acpi_resources(struct quicki2c_device *qcdev)
 		qcdev->i2c_max_frame_size_enable = i2c_config.FSEN;
 		qcdev->i2c_int_delay_enable = i2c_config.INDE;
 
-		if (i2c_config.FSVL <= qcdev->ddata->max_detect_size)
-			qcdev->i2c_max_frame_size = i2c_config.FSVL;
-		else
-			qcdev->i2c_max_frame_size = qcdev->ddata->max_detect_size;
-
-		if (i2c_config.INDV <= qcdev->ddata->max_interrupt_delay)
-			qcdev->i2c_int_delay = i2c_config.INDV;
-		else
-			qcdev->i2c_int_delay = qcdev->ddata->max_interrupt_delay;
+		qcdev->i2c_max_frame_size = min(i2c_config.FSVL, qcdev->ddata->max_detect_size);
+		qcdev->i2c_int_delay = min(i2c_config.INDV, qcdev->ddata->max_interrupt_delay);
 	}
 
 	return 0;
-- 
2.25.1


  reply	other threads:[~2026-07-28  2:58 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-28  2:57 [PATCH 0/4] HID: Address Coccinelle warnings Chen Changcheng
2026-07-28  2:57 ` Chen Changcheng [this message]
2026-07-28  3:05   ` [PATCH 1/4] HID: intel-quicki2c: Use min() macro to simplify code sashiko-bot
2026-07-28  2:57 ` [PATCH 2/4] HID: sony: " Chen Changcheng
2026-07-28  2:57 ` [PATCH 3/4] HID: picolcd: " Chen Changcheng
2026-07-28  3:06   ` sashiko-bot
2026-07-28  2:57 ` [PATCH 4/4] HID: intel-ish-hid: Use secs_to_jiffies() instead of msecs_to_jiffies(sec * MSEC_PER_SEC) Chen Changcheng

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=20260728025750.48249-2-chenchangcheng@kylinos.cn \
    --to=chenchangcheng@kylinos.cn \
    --cc=bentiss@kernel.org \
    --cc=bonbons@linux-vserver.org \
    --cc=ccc194101@163.com \
    --cc=even.xu@intel.com \
    --cc=jikos@kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=srinivas.pandruvada@linux.intel.com \
    --cc=xinpeng.sun@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