[2/2] i2c: core: remove #ifdef for CONFIG_X86
diff mbox series

Message ID 20190917114918.7157-2-ben.dooks@codethink.co.uk
State New
Headers show
Series
  • [1/2] i2c: core: use IS_ENABLED for CONFIG_I2C_COMPAT
Related show

Commit Message

Ben Dooks Sept. 17, 2019, 11:49 a.m. UTC
Remove the #ifdef CONFIG_X86 in i2c_default_probe() and move the test
logic out into i2c_try_x86_default_probe() helper function. This makes
less #ifdef usage and the code in i2c_default_probe() a bit cleaer.

Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
---
 drivers/i2c/i2c-core-base.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

Patch
diff mbox series

diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
index fb8fd32f2783..87ab906eb536 100644
--- a/drivers/i2c/i2c-core-base.c
+++ b/drivers/i2c/i2c-core-base.c
@@ -2116,6 +2116,14 @@  EXPORT_SYMBOL_GPL(i2c_get_device_id);
  * ----------------------------------------------------
  */
 
+static bool i2c_try_x86_default_probe(struct i2c_adapter *adap, unsigned short addr)
+{
+	if (!IS_ENABLED(CONFIG_X86))
+		return false;
+	return (addr == 0x73 && (adap->class & I2C_CLASS_HWMON)
+		&& i2c_check_functionality(adap, I2C_FUNC_SMBUS_READ_BYTE_DATA));
+}
+
 /*
  * Legacy default probe function, mostly relevant for SMBus. The default
  * probe method is a quick write, but it is known to corrupt the 24RF08
@@ -2133,14 +2141,10 @@  static int i2c_default_probe(struct i2c_adapter *adap, unsigned short addr)
 	int err;
 	union i2c_smbus_data dummy;
 
-#ifdef CONFIG_X86
-	if (addr == 0x73 && (adap->class & I2C_CLASS_HWMON)
-	 && i2c_check_functionality(adap, I2C_FUNC_SMBUS_READ_BYTE_DATA))
+	if (i2c_try_x86_default_probe(adap, addr))
 		err = i2c_smbus_xfer(adap, addr, 0, I2C_SMBUS_READ, 0,
 				     I2C_SMBUS_BYTE_DATA, &dummy);
-	else
-#endif
-	if (!((addr & ~0x07) == 0x30 || (addr & ~0x0f) == 0x50)
+	else if (!((addr & ~0x07) == 0x30 || (addr & ~0x0f) == 0x50)
 	 && i2c_check_functionality(adap, I2C_FUNC_SMBUS_QUICK))
 		err = i2c_smbus_xfer(adap, addr, 0, I2C_SMBUS_WRITE, 0,
 				     I2C_SMBUS_QUICK, NULL);