Skip to content

Commit a5db159

Browse files
Yu JiaoliangJiri Kosina
authored andcommitted
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 <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent 0d6b550 commit a5db159

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

drivers/hid/hid-mcp2221.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <linux/i2c.h>
1919
#include <linux/gpio/driver.h>
2020
#include <linux/iio/iio.h>
21+
#include <linux/minmax.h>
2122
#include "hid-ids.h"
2223

2324
/* Commands codes in a raw output report */
@@ -262,10 +263,7 @@ static int mcp_i2c_write(struct mcp2221 *mcp,
262263

263264
idx = 0;
264265
sent = 0;
265-
if (msg->len < 60)
266-
len = msg->len;
267-
else
268-
len = 60;
266+
len = min(msg->len, 60);
269267

270268
do {
271269
mcp->txbuf[0] = type;
@@ -292,10 +290,7 @@ static int mcp_i2c_write(struct mcp2221 *mcp,
292290
break;
293291

294292
idx = idx + len;
295-
if ((msg->len - sent) < 60)
296-
len = msg->len - sent;
297-
else
298-
len = 60;
293+
len = min(msg->len - sent, 60);
299294

300295
/*
301296
* Testing shows delay is needed between successive writes

0 commit comments

Comments
 (0)