summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYu Jiaoliang <yujiaoliang@vivo.com>2025-06-19 10:47:41 +0800
committerJiri Kosina <jkosina@suse.com>2025-06-20 09:03:04 +0200
commita5db1591d0829bda219d6967e5860764c648edbd (patch)
tree38097f587ee701d913083d5021ae8cb6fa5af32e
parent0d6b550dce55f2bd47579a92ffc000cb0186e4c4 (diff)
HID: mcp-2221: Replace manual comparison with min() macro
This improves code readability by using the standard kernel macro for minimal value selection while maintaining identical functionality. Signed-off-by: Yu Jiaoliang <yujiaoliang@vivo.com> Signed-off-by: Jiri Kosina <jkosina@suse.com>
-rw-r--r--drivers/hid/hid-mcp2221.c11
1 files changed, 3 insertions, 8 deletions
diff --git a/drivers/hid/hid-mcp2221.c b/drivers/hid/hid-mcp2221.c
index 3bc5884e572e..fcfe9370a887 100644
--- a/drivers/hid/hid-mcp2221.c
+++ b/drivers/hid/hid-mcp2221.c
@@ -18,6 +18,7 @@
#include <linux/i2c.h>
#include <linux/gpio/driver.h>
#include <linux/iio/iio.h>
+#include <linux/minmax.h>
#include "hid-ids.h"
/* Commands codes in a raw output report */
@@ -262,10 +263,7 @@ static int mcp_i2c_write(struct mcp2221 *mcp,
idx = 0;
sent = 0;
- if (msg->len < 60)
- len = msg->len;
- else
- len = 60;
+ len = min(msg->len, 60);
do {
mcp->txbuf[0] = type;
@@ -292,10 +290,7 @@ static int mcp_i2c_write(struct mcp2221 *mcp,
break;
idx = idx + len;
- if ((msg->len - sent) < 60)
- len = msg->len - sent;
- else
- len = 60;
+ len = min(msg->len - sent, 60);
/*
* Testing shows delay is needed between successive writes