[PATCH v10 3/8] platform/x86: int3472: tps68470: move Windows MFD setup below the device-type switch
From: Thierry Chatard
Date: Mon Aug 31 2026 - 14:25:04 EST
The Windows path looks up the board data, builds the tps68470-clk
platform data and registers the MFD cells; none of this is needed for the
ChromeOS path, which registers its own cells. Move that handling out of
the switch and let the ChromeOS case return directly, so the Windows-only
work is no longer done for ChromeOS and the function reads top to bottom.
While moving the code, use a local struct device *dev to shorten the many
&client->dev references, and return -ENODATA (rather than -ENODEV) when no
board data matches this machine, to distinguish it from a missing device.
No functional change for either path.
Assisted-by: Claude Code:claude-opus-4-8
Signed-off-by: Thierry Chatard <tchatard@xxxxxxxxx>
---
drivers/platform/x86/intel/int3472/tps68470.c | 99 ++++++++++---------
1 file changed, 51 insertions(+), 48 deletions(-)
diff --git a/drivers/platform/x86/intel/int3472/tps68470.c b/drivers/platform/x86/intel/int3472/tps68470.c
index 35909a683..35fa77eb3 100644
--- a/drivers/platform/x86/intel/int3472/tps68470.c
+++ b/drivers/platform/x86/intel/int3472/tps68470.c
@@ -142,85 +142,88 @@ skl_int3472_fill_clk_pdata(struct device *dev, struct tps68470_clk_platform_data
static int skl_int3472_tps68470_probe(struct i2c_client *client)
{
- struct acpi_device *adev = ACPI_COMPANION(&client->dev);
const struct int3472_tps68470_board_data *board_data;
struct tps68470_clk_platform_data *clk_pdata;
+ struct acpi_device *adev;
struct mfd_cell *cells;
struct regmap *regmap;
+ struct device *dev;
int n_consumers;
int device_type;
unsigned int i;
int ret;
+ dev = &client->dev;
+ adev = ACPI_COMPANION(dev);
if (!adev)
return -ENODEV;
- n_consumers = skl_int3472_fill_clk_pdata(&client->dev, &clk_pdata);
- if (n_consumers < 0)
- return n_consumers;
-
regmap = devm_regmap_init_i2c(client, &tps68470_regmap_config);
if (IS_ERR(regmap)) {
- dev_err(&client->dev, "Failed to create regmap: %ld\n", PTR_ERR(regmap));
+ dev_err(dev, "Failed to create regmap: %ld\n", PTR_ERR(regmap));
return PTR_ERR(regmap);
}
i2c_set_clientdata(client, regmap);
- ret = tps68470_chip_init(&client->dev, regmap);
+ ret = tps68470_chip_init(dev, regmap);
if (ret < 0) {
- dev_err(&client->dev, "TPS68470 init error %d\n", ret);
+ dev_err(dev, "TPS68470 init error %d\n", ret);
return ret;
}
device_type = skl_int3472_tps68470_calc_type(adev);
switch (device_type) {
case DESIGNED_FOR_WINDOWS:
- board_data = int3472_tps68470_get_board_data(dev_name(&client->dev));
- if (!board_data)
- return dev_err_probe(&client->dev, -ENODEV, "No board-data found for this model\n");
-
- cells = kzalloc_objs(*cells, TPS68470_WIN_MFD_CELL_COUNT);
- if (!cells)
- return -ENOMEM;
+ break;
+ case DESIGNED_FOR_CHROMEOS:
+ return devm_mfd_add_devices(dev, PLATFORM_DEVID_NONE,
+ tps68470_cros, ARRAY_SIZE(tps68470_cros),
+ NULL, 0, NULL);
+ default:
+ dev_err(dev, "Failed to add MFD devices\n");
+ return device_type;
+ }
- /*
- * The order of the cells matters here! The clk must be first
- * because the regulator depends on it. The gpios must be last,
- * acpi_gpiochip_add() calls acpi_dev_clear_dependencies() and
- * the clk + regulators must be ready when this happens.
- */
- cells[0].name = "tps68470-clk";
- cells[0].platform_data = clk_pdata;
- cells[0].pdata_size = struct_size(clk_pdata, consumers, n_consumers);
- cells[1].name = "tps68470-regulator";
- cells[1].platform_data = (void *)board_data->tps68470_regulator_pdata;
- cells[1].pdata_size = sizeof(struct tps68470_regulator_platform_data);
- cells[2].name = "tps68470-gpio";
- cells[2].swnode = board_data->tps68470_gpio_swnode;
+ board_data = int3472_tps68470_get_board_data(dev_name(dev));
+ if (!board_data)
+ return dev_err_probe(dev, -ENODATA,
+ "No board-data found for this model\n");
- for (i = 0; i < board_data->n_gpiod_lookups; i++)
- gpiod_add_lookup_table(board_data->tps68470_gpio_lookup_tables[i]);
+ n_consumers = skl_int3472_fill_clk_pdata(dev, &clk_pdata);
+ if (n_consumers < 0)
+ return n_consumers;
- ret = devm_mfd_add_devices(&client->dev, PLATFORM_DEVID_NONE,
- cells, TPS68470_WIN_MFD_CELL_COUNT,
- NULL, 0, NULL);
- kfree(cells);
+ cells = kzalloc_objs(*cells, TPS68470_WIN_MFD_CELL_COUNT);
+ if (!cells)
+ return -ENOMEM;
- if (ret) {
- for (i = 0; i < board_data->n_gpiod_lookups; i++)
- gpiod_remove_lookup_table(board_data->tps68470_gpio_lookup_tables[i]);
- }
+ /*
+ * The order of the cells matters here! The clk must be first
+ * because the regulator depends on it. The gpios must be last,
+ * acpi_gpiochip_add() calls acpi_dev_clear_dependencies() and
+ * the clk + regulators must be ready when this happens.
+ */
+ cells[0].name = "tps68470-clk";
+ cells[0].platform_data = clk_pdata;
+ cells[0].pdata_size = struct_size(clk_pdata, consumers, n_consumers);
+ cells[1].name = "tps68470-regulator";
+ cells[1].platform_data = (void *)board_data->tps68470_regulator_pdata;
+ cells[1].pdata_size = sizeof(struct tps68470_regulator_platform_data);
+ cells[2].name = "tps68470-gpio";
+ cells[2].swnode = board_data->tps68470_gpio_swnode;
+
+ for (i = 0; i < board_data->n_gpiod_lookups; i++)
+ gpiod_add_lookup_table(board_data->tps68470_gpio_lookup_tables[i]);
+
+ ret = devm_mfd_add_devices(dev, PLATFORM_DEVID_NONE,
+ cells, TPS68470_WIN_MFD_CELL_COUNT,
+ NULL, 0, NULL);
+ kfree(cells);
- break;
- case DESIGNED_FOR_CHROMEOS:
- ret = devm_mfd_add_devices(&client->dev, PLATFORM_DEVID_NONE,
- tps68470_cros, ARRAY_SIZE(tps68470_cros),
- NULL, 0, NULL);
- break;
- default:
- dev_err(&client->dev, "Failed to add MFD devices\n");
- return device_type;
+ if (ret) {
+ for (i = 0; i < board_data->n_gpiod_lookups; i++)
+ gpiod_remove_lookup_table(board_data->tps68470_gpio_lookup_tables[i]);
}
/*
--
2.53.0