[Pdbg] [PATCH 2/2] i2c: Add FORCE option

Joel Stanley joel at jms.id.au
Wed Jun 13 16:40:54 AEST 2018


On P8 machines with OpenBMC, the i2c address is claimed by the OCC hwmon
driver. We can ignore it and talk to the device anyway by passing
I2C_SLAVE_FORCE instead of I2C_SLAVE to the open ioctl.

This might not be the best idea, but it works fine for eg. getscom.

Signed-off-by: Joel Stanley <joel at jms.id.au>
--
We could put this behind a --force option.

Also, when the user does not pass --force, we could advise them to
unbind the hwmon driver. I don't know what OpenBMC userspace does when
you unbind it - it may decide to shut down the machine.

Signed-off-by: Joel Stanley <joel at jms.id.au>
---
 libpdbg/i2c.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libpdbg/i2c.c b/libpdbg/i2c.c
index b1580e176023..aa0a73ef8c19 100644
--- a/libpdbg/i2c.c
+++ b/libpdbg/i2c.c
@@ -34,7 +34,7 @@ struct i2c_data {
 
 static int i2c_set_addr(int fd, int addr)
 {
-	if (ioctl(fd, I2C_SLAVE, addr) < 0) {
+	if (ioctl(fd, I2C_SLAVE_FORCE, addr) < 0) {
 		PR_ERROR("Unable to set i2c slave address\n");
 		return -1;
 	}
-- 
2.17.1



More information about the Pdbg mailing list