[PATCH 2/2] i2c: core: remove #ifdef for CONFIG_X86

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxx>
---
 drivers/i2c/i2c-core-base.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

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);
-- 
2.23.0




[Index of Archives]     [Linux GPIO]     [Linux SPI]     [Linux Hardward Monitoring]     [LM Sensors]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux