Skip to content

Commit 80e56b8

Browse files
hkallweitwsakernel
authored andcommitted
i2c: i801: Simplify class-based client device instantiation
Now that the legacy eeprom driver was removed, the only remaining i2c client driver with class SPD autodetection is jc42, and this driver supports also class HWMON. Therefore we can remove class SPD from the supported classes of the i801 adapter driver. Legacy class-based instantiation shouldn't be used in new code, so I think we can remove also the generic logic that ensures that supported classes of parent and muxed adapters don't overlap. Note: i801 parent supports just class HWMON now, and muxed childs class SPD, so the supported classes don't overlap. Signed-off-by: Heiner Kallweit <[email protected]> Reviewed-by: Jean Delvare <[email protected]> Acked-by: Andi Shyti <[email protected]> Signed-off-by: Wolfram Sang <[email protected]>
1 parent 445094c commit 80e56b8

File tree

1 file changed

+7
-31
lines changed

1 file changed

+7
-31
lines changed

drivers/i2c/busses/i2c-i801.c

Lines changed: 7 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,6 @@ struct i801_priv {
287287
u8 *data;
288288

289289
#if IS_ENABLED(CONFIG_I2C_MUX_GPIO) && defined CONFIG_DMI
290-
const struct i801_mux_config *mux_drvdata;
291290
struct platform_device *mux_pdev;
292291
struct gpiod_lookup_table *lookup;
293292
#endif
@@ -1285,7 +1284,7 @@ static void i801_probe_optional_slaves(struct i801_priv *priv)
12851284

12861285
/* Instantiate SPD EEPROMs unless the SMBus is multiplexed */
12871286
#if IS_ENABLED(CONFIG_I2C_MUX_GPIO)
1288-
if (!priv->mux_drvdata)
1287+
if (!priv->mux_pdev)
12891288
#endif
12901289
i2c_register_spd(&priv->adapter);
12911290
}
@@ -1387,11 +1386,14 @@ static void i801_add_mux(struct i801_priv *priv)
13871386
const struct i801_mux_config *mux_config;
13881387
struct i2c_mux_gpio_platform_data gpio_data;
13891388
struct gpiod_lookup_table *lookup;
1389+
const struct dmi_system_id *id;
13901390
int i;
13911391

1392-
if (!priv->mux_drvdata)
1392+
id = dmi_first_match(mux_dmi_table);
1393+
if (!id)
13931394
return;
1394-
mux_config = priv->mux_drvdata;
1395+
1396+
mux_config = id->driver_data;
13951397

13961398
/* Prepare the platform data */
13971399
memset(&gpio_data, 0, sizeof(struct i2c_mux_gpio_platform_data));
@@ -1435,35 +1437,9 @@ static void i801_del_mux(struct i801_priv *priv)
14351437
platform_device_unregister(priv->mux_pdev);
14361438
gpiod_remove_lookup_table(priv->lookup);
14371439
}
1438-
1439-
static unsigned int i801_get_adapter_class(struct i801_priv *priv)
1440-
{
1441-
const struct dmi_system_id *id;
1442-
const struct i801_mux_config *mux_config;
1443-
unsigned int class = I2C_CLASS_HWMON | I2C_CLASS_SPD;
1444-
int i;
1445-
1446-
id = dmi_first_match(mux_dmi_table);
1447-
if (id) {
1448-
/* Remove branch classes from trunk */
1449-
mux_config = id->driver_data;
1450-
for (i = 0; i < mux_config->n_values; i++)
1451-
class &= ~mux_config->classes[i];
1452-
1453-
/* Remember for later */
1454-
priv->mux_drvdata = mux_config;
1455-
}
1456-
1457-
return class;
1458-
}
14591440
#else
14601441
static inline void i801_add_mux(struct i801_priv *priv) { }
14611442
static inline void i801_del_mux(struct i801_priv *priv) { }
1462-
1463-
static inline unsigned int i801_get_adapter_class(struct i801_priv *priv)
1464-
{
1465-
return I2C_CLASS_HWMON | I2C_CLASS_SPD;
1466-
}
14671443
#endif
14681444

14691445
static struct platform_device *
@@ -1644,7 +1620,7 @@ static int i801_probe(struct pci_dev *dev, const struct pci_device_id *id)
16441620

16451621
i2c_set_adapdata(&priv->adapter, priv);
16461622
priv->adapter.owner = THIS_MODULE;
1647-
priv->adapter.class = i801_get_adapter_class(priv);
1623+
priv->adapter.class = I2C_CLASS_HWMON;
16481624
priv->adapter.algo = &smbus_algorithm;
16491625
priv->adapter.dev.parent = &dev->dev;
16501626
ACPI_COMPANION_SET(&priv->adapter.dev, ACPI_COMPANION(&dev->dev));

0 commit comments

Comments
 (0)