hc
2024-10-12 a5969cabbb4660eab42b6ef0412cbbd1200cf14d
kernel/drivers/i2c/busses/i2c-diolan-u2c.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Driver for the Diolan u2c-12 USB-I2C adapter
34 *
....@@ -6,10 +7,6 @@
67 * Derived from:
78 * i2c-tiny-usb.c
89 * Copyright (C) 2006-2007 Till Harbaum (Till@Harbaum.org)
9
- *
10
- * This program is free software; you can redistribute it and/or
11
- * modify it under the terms of the GNU General Public License as
12
- * published by the Free Software Foundation, version 2.
1310 */
1411
1512 #include <linux/kernel.h>
....@@ -67,8 +64,6 @@
6764 #define U2C_I2C_SPEED_2KHZ 242 /* 2 kHz, minimum speed */
6865 #define U2C_I2C_SPEED(f) ((DIV_ROUND_UP(1000000, (f)) - 10) / 2 + 1)
6966
70
-#define U2C_I2C_FREQ_FAST 400000
71
-#define U2C_I2C_FREQ_STD 100000
7267 #define U2C_I2C_FREQ(s) (1000000 / (2 * (s - 1) + 10))
7368
7469 #define DIOLAN_USB_TIMEOUT 100 /* in ms */
....@@ -90,7 +85,7 @@
9085 int ocount; /* Number of enqueued messages */
9186 };
9287
93
-static uint frequency = U2C_I2C_FREQ_STD; /* I2C clock frequency in Hz */
88
+static uint frequency = I2C_MAX_STANDARD_MODE_FREQ; /* I2C clock frequency in Hz */
9489
9590 module_param(frequency, uint, S_IRUGO | S_IWUSR);
9691 MODULE_PARM_DESC(frequency, "I2C clock frequency in hertz");
....@@ -302,12 +297,12 @@
302297 {
303298 int speed, ret;
304299
305
- if (frequency >= 200000) {
300
+ if (frequency >= 2 * I2C_MAX_STANDARD_MODE_FREQ) {
306301 speed = U2C_I2C_SPEED_FAST;
307
- frequency = U2C_I2C_FREQ_FAST;
308
- } else if (frequency >= 100000 || frequency == 0) {
302
+ frequency = I2C_MAX_FAST_MODE_FREQ;
303
+ } else if (frequency >= I2C_MAX_STANDARD_MODE_FREQ || frequency == 0) {
309304 speed = U2C_I2C_SPEED_STD;
310
- frequency = U2C_I2C_FREQ_STD;
305
+ frequency = I2C_MAX_STANDARD_MODE_FREQ;
311306 } else {
312307 speed = U2C_I2C_SPEED(frequency);
313308 if (speed > U2C_I2C_SPEED_2KHZ)