Skip to content

Commit b0209b3

Browse files
committed
i2c: export bit-banging algo functions
i915 has a hw i2c controller (gmbus) but for a bunch of stupid reasons we need to be able to fall back to the bit-banging algo on gpio pins. The current code sets up a 2nd i2c controller for the same i2c bus using the bit-banging algo. This has a bunch of issues, the major one being that userspace can directly access this fallback i2c adaptor behind the drivers back. But we need to frob a few registers before and after using fallback gpio bit-banging, so this horribly fails. The new plan is to only set up one i2c adaptor and transparently fall back to bit-banging by directly calling the xfer function of the bit- banging algo in the i2c core. To make that possible, export the 2 i2c algo functions. v2: As suggested by Jean Delvare, simply export the i2c_bit_algo vtable instead of the individual functions. Acked-by: Jean Delvare <khali@linux-fr.org> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
1 parent 1298330 commit b0209b3

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

‎drivers/i2c/algos/i2c-algo-bit.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,10 +610,11 @@ static u32 bit_func(struct i2c_adapter *adap)
610610

611611
/* -----exported algorithm data: ------------------------------------- */
612612

613-
static const struct i2c_algorithm i2c_bit_algo = {
613+
const struct i2c_algorithm i2c_bit_algo = {
614614
.master_xfer = bit_xfer,
615615
.functionality = bit_func,
616616
};
617+
EXPORT_SYMBOL(i2c_bit_algo);
617618

618619
/*
619620
* registering functions to load algorithms at runtime

‎include/linux/i2c-algo-bit.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,6 @@ struct i2c_algo_bit_data {
4949

5050
int i2c_bit_add_bus(struct i2c_adapter *);
5151
int i2c_bit_add_numbered_bus(struct i2c_adapter *);
52+
extern const struct i2c_algorithm i2c_bit_algo;
5253

5354
#endif /* _LINUX_I2C_ALGO_BIT_H */

0 commit comments

Comments
 (0)