hc
2024-05-16 8d2a02b24d66aa359e83eebc1ed3c0f85367a1cb
kernel/drivers/i2c/algos/i2c-algo-bit.c
....@@ -1,21 +1,12 @@
1
-/* -------------------------------------------------------------------------
2
- * i2c-algo-bit.c i2c driver algorithms for bit-shift adapters
3
- * -------------------------------------------------------------------------
1
+// SPDX-License-Identifier: GPL-2.0+
2
+/*
3
+ * i2c-algo-bit.c: i2c driver algorithms for bit-shift adapters
4
+ *
45 * Copyright (C) 1995-2000 Simon G. Vogl
5
-
6
- This program is free software; you can redistribute it and/or modify
7
- it under the terms of the GNU General Public License as published by
8
- the Free Software Foundation; either version 2 of the License, or
9
- (at your option) any later version.
10
-
11
- This program is distributed in the hope that it will be useful,
12
- but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- GNU General Public License for more details.
15
- * ------------------------------------------------------------------------- */
16
-
17
-/* With some changes from Frodo Looijaard <frodol@dds.nl>, Kyösti Mälkki
18
- <kmalkki@cc.hut.fi> and Jean Delvare <jdelvare@suse.de> */
6
+ *
7
+ * With some changes from Frodo Looijaard <frodol@dds.nl>, Kyösti Mälkki
8
+ * <kmalkki@cc.hut.fi> and Jean Delvare <jdelvare@suse.de>
9
+ */
1910
2011 #include <linux/kernel.h>
2112 #include <linux/module.h>
....@@ -612,6 +603,23 @@
612603 return ret;
613604 }
614605
606
+/*
607
+ * We print a warning when we are not flagged to support atomic transfers but
608
+ * will try anyhow. That's what the I2C core would do as well. Sadly, we can't
609
+ * modify the algorithm struct at probe time because this struct is exported
610
+ * 'const'.
611
+ */
612
+static int bit_xfer_atomic(struct i2c_adapter *i2c_adap, struct i2c_msg msgs[],
613
+ int num)
614
+{
615
+ struct i2c_algo_bit_data *adap = i2c_adap->algo_data;
616
+
617
+ if (!adap->can_do_atomic)
618
+ dev_warn(&i2c_adap->dev, "not flagged for atomic transfers\n");
619
+
620
+ return bit_xfer(i2c_adap, msgs, num);
621
+}
622
+
615623 static u32 bit_func(struct i2c_adapter *adap)
616624 {
617625 return I2C_FUNC_I2C | I2C_FUNC_NOSTART | I2C_FUNC_SMBUS_EMUL |
....@@ -624,8 +632,9 @@
624632 /* -----exported algorithm data: ------------------------------------- */
625633
626634 const struct i2c_algorithm i2c_bit_algo = {
627
- .master_xfer = bit_xfer,
628
- .functionality = bit_func,
635
+ .master_xfer = bit_xfer,
636
+ .master_xfer_atomic = bit_xfer_atomic,
637
+ .functionality = bit_func,
629638 };
630639 EXPORT_SYMBOL(i2c_bit_algo);
631640