2023-09-27 08:24:40

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH 00/27] platform: Convert to platform remove callback returning void

Hello,

this series converts all platform drivers below drivers/platform to use
.remove_new(). The motivation is to get rid of an integer return code
that is (mostly) ignored by the platform driver core and error prone on
the driver side.

See commit 5c5a7680e67b ("platform: Provide a remove callback that
returns no value") for an extended explanation and the eventual goal.

As there is no single maintainer team for drivers/platform, I suggest
the individual maintainers to pick up "their" patches. The only
inter-dependency in this series is that the patches #24 - #27 depend on
#23. Otherwise there are no inter-dependencies, so that should work
fine. As there are still quite a few drivers to convert in other areas
than drivers/platform, I'm happy about every patch that makes it in and
there is no need for further coordination. So even if there is a merge
conflict with one patch until you apply or a subject prefix is
suboptimal, please don't let you stop by negative feedback for other
patches (unless it applies to "your" patches, too, of course).

Best regards and thanks for considering,
Uwe

Uwe Kleine-König (27):
platform/chrome: cros_ec_chardev: Convert to platform remove callback
returning void
platform/chrome: cros_ec_debugfs: Convert to platform remove callback
returning void
platform/chrome: cros_ec_lightbar: Convert to platform remove callback
returning void
platform/chrome: cros_ec_lpc: Convert to platform remove callback
returning void
platform/chrome: cros_ec_sysfs: Convert to platform remove callback
returning void
platform/chrome: cros_ec_vbc: Convert to platform remove callback
returning void
platform/chrome: cros_typec_switch: Convert to platform remove
callback returning void
platform/chrome: cros_usbpd_logger: Convert to platform remove
callback returning void
platform/chrome: cros_usbpd_notify: Convert to platform remove
callback returning void
platform/chrome/wilco_ec: core: Convert to platform remove callback
returning void
platform/chrome/wilco_ec: debugfs: Convert to platform remove callback
returning void
platform/chrome/wilco_ec: telemetry: Convert to platform remove
callback returning void
platform/goldfish: goldfish_pipe: Convert to platform remove callback
returning void
platform/mellanox: mlxbf-bootctl: Convert to platform remove callback
returning void
platform/mellanox: mlxbf-tmfifo: Convert to platform remove callback
returning void
platform/mellanox: mlxreg-hotplug: Convert to platform remove callback
returning void
platform/mellanox: mlxreg-io: Convert to platform remove callback
returning void
platform/mellanox: mlxreg-lc: Convert to platform remove callback
returning void
platform/mellanox: nvsw-sn2201: Convert to platform remove callback
returning void
platform/x86/intel: bytcrc_pwrsrc: Convert to platform remove callback
returning void
platform/x86: mlx-platform: Convert to platform remove callback
returning void
platform/x86: sel3350-platform: Convert to platform remove callback
returning void
platform/x86/siemens: simatic-ipc-batt: Simplify
simatic_ipc_batt_remove()
platform/x86/siemens: simatic-ipc-batt: Convert to platform remove
callback returning void
platform/x86/siemens: simatic-ipc-batt-apollolake: Convert to platform
remove callback returning void
platform/x86/siemens: simatic-ipc-batt-elkhartlake: Convert to
platform remove callback returning void
platform/x86/siemens: simatic-ipc-batt-f7188x: Convert to platform
remove callback returning void

drivers/platform/chrome/cros_ec_chardev.c | 6 ++----
drivers/platform/chrome/cros_ec_debugfs.c | 6 ++----
drivers/platform/chrome/cros_ec_lightbar.c | 6 ++----
drivers/platform/chrome/cros_ec_lpc.c | 6 ++----
drivers/platform/chrome/cros_ec_sysfs.c | 6 ++----
drivers/platform/chrome/cros_ec_vbc.c | 6 ++----
drivers/platform/chrome/cros_typec_switch.c | 5 ++---
drivers/platform/chrome/cros_usbpd_logger.c | 6 ++----
drivers/platform/chrome/cros_usbpd_notify.c | 12 ++++--------
drivers/platform/chrome/wilco_ec/core.c | 5 ++---
drivers/platform/chrome/wilco_ec/debugfs.c | 6 ++----
drivers/platform/chrome/wilco_ec/telemetry.c | 6 ++----
drivers/platform/goldfish/goldfish_pipe.c | 5 ++---
drivers/platform/mellanox/mlxbf-bootctl.c | 6 ++----
drivers/platform/mellanox/mlxbf-tmfifo.c | 6 ++----
drivers/platform/mellanox/mlxreg-hotplug.c | 6 ++----
drivers/platform/mellanox/mlxreg-io.c | 6 ++----
drivers/platform/mellanox/mlxreg-lc.c | 8 +++-----
drivers/platform/mellanox/nvsw-sn2201.c | 6 ++----
drivers/platform/x86/intel/bytcrc_pwrsrc.c | 5 ++---
drivers/platform/x86/mlx-platform.c | 5 ++---
drivers/platform/x86/sel3350-platform.c | 6 ++----
.../x86/siemens/simatic-ipc-batt-apollolake.c | 6 +++---
.../x86/siemens/simatic-ipc-batt-elkhartlake.c | 6 +++---
.../platform/x86/siemens/simatic-ipc-batt-f7188x.c | 6 +++---
drivers/platform/x86/siemens/simatic-ipc-batt.c | 9 ++++-----
drivers/platform/x86/siemens/simatic-ipc-batt.h | 4 ++--
27 files changed, 62 insertions(+), 104 deletions(-)

base-commit: 18030226a48de1fbfabf4ae16aaa2695a484254f
--
2.40.1


2023-09-27 08:25:06

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH 12/27] platform/chrome/wilco_ec: telemetry: Convert to platform remove callback returning void

The .remove() callback for a platform driver returns an int which makes
many driver authors wrongly assume it's possible to do error handling by
returning an error code. However the value returned is ignored (apart
from emitting a warning) and this typically results in resource leaks.

To improve here there is a quest to make the remove callback return
void. In the first step of this quest all drivers are converted to
.remove_new(), which already returns void. Eventually after all drivers
are converted, .remove_new() will be renamed to .remove().

Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.

Signed-off-by: Uwe Kleine-König <[email protected]>
---
drivers/platform/chrome/wilco_ec/telemetry.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/platform/chrome/wilco_ec/telemetry.c b/drivers/platform/chrome/wilco_ec/telemetry.c
index 54708aa6c700..253098bace63 100644
--- a/drivers/platform/chrome/wilco_ec/telemetry.c
+++ b/drivers/platform/chrome/wilco_ec/telemetry.c
@@ -400,20 +400,18 @@ static int telem_device_probe(struct platform_device *pdev)
return 0;
}

-static int telem_device_remove(struct platform_device *pdev)
+static void telem_device_remove(struct platform_device *pdev)
{
struct telem_device_data *dev_data = platform_get_drvdata(pdev);

cdev_device_del(&dev_data->cdev, &dev_data->dev);
ida_simple_remove(&telem_ida, MINOR(dev_data->dev.devt));
put_device(&dev_data->dev);
-
- return 0;
}

static struct platform_driver telem_driver = {
.probe = telem_device_probe,
- .remove = telem_device_remove,
+ .remove_new = telem_device_remove,
.driver = {
.name = DRV_NAME,
},
--
2.40.1

2023-09-27 08:25:18

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH 17/27] platform/mellanox: mlxreg-io: Convert to platform remove callback returning void

The .remove() callback for a platform driver returns an int which makes
many driver authors wrongly assume it's possible to do error handling by
returning an error code. However the value returned is ignored (apart
from emitting a warning) and this typically results in resource leaks.

To improve here there is a quest to make the remove callback return
void. In the first step of this quest all drivers are converted to
.remove_new(), which already returns void. Eventually after all drivers
are converted, .remove_new() will be renamed to .remove().

Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.

Signed-off-by: Uwe Kleine-König <[email protected]>
---
drivers/platform/mellanox/mlxreg-io.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/platform/mellanox/mlxreg-io.c b/drivers/platform/mellanox/mlxreg-io.c
index 83ba037408cd..ee7bd623ba44 100644
--- a/drivers/platform/mellanox/mlxreg-io.c
+++ b/drivers/platform/mellanox/mlxreg-io.c
@@ -263,13 +263,11 @@ static int mlxreg_io_probe(struct platform_device *pdev)
return 0;
}

-static int mlxreg_io_remove(struct platform_device *pdev)
+static void mlxreg_io_remove(struct platform_device *pdev)
{
struct mlxreg_io_priv_data *priv = dev_get_drvdata(&pdev->dev);

mutex_destroy(&priv->io_lock);
-
- return 0;
}

static struct platform_driver mlxreg_io_driver = {
@@ -277,7 +275,7 @@ static struct platform_driver mlxreg_io_driver = {
.name = "mlxreg-io",
},
.probe = mlxreg_io_probe,
- .remove = mlxreg_io_remove,
+ .remove_new = mlxreg_io_remove,
};

module_platform_driver(mlxreg_io_driver);
--
2.40.1

2023-09-27 08:25:20

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH 15/27] platform/mellanox: mlxbf-tmfifo: Convert to platform remove callback returning void

The .remove() callback for a platform driver returns an int which makes
many driver authors wrongly assume it's possible to do error handling by
returning an error code. However the value returned is ignored (apart
from emitting a warning) and this typically results in resource leaks.

To improve here there is a quest to make the remove callback return
void. In the first step of this quest all drivers are converted to
.remove_new(), which already returns void. Eventually after all drivers
are converted, .remove_new() will be renamed to .remove().

Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.

Signed-off-by: Uwe Kleine-König <[email protected]>
---
drivers/platform/mellanox/mlxbf-tmfifo.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/platform/mellanox/mlxbf-tmfifo.c b/drivers/platform/mellanox/mlxbf-tmfifo.c
index f3696a54a2bd..69729ba8f505 100644
--- a/drivers/platform/mellanox/mlxbf-tmfifo.c
+++ b/drivers/platform/mellanox/mlxbf-tmfifo.c
@@ -1361,13 +1361,11 @@ static int mlxbf_tmfifo_probe(struct platform_device *pdev)
}

/* Device remove function. */
-static int mlxbf_tmfifo_remove(struct platform_device *pdev)
+static void mlxbf_tmfifo_remove(struct platform_device *pdev)
{
struct mlxbf_tmfifo *fifo = platform_get_drvdata(pdev);

mlxbf_tmfifo_cleanup(fifo);
-
- return 0;
}

static const struct acpi_device_id mlxbf_tmfifo_acpi_match[] = {
@@ -1378,7 +1376,7 @@ MODULE_DEVICE_TABLE(acpi, mlxbf_tmfifo_acpi_match);

static struct platform_driver mlxbf_tmfifo_driver = {
.probe = mlxbf_tmfifo_probe,
- .remove = mlxbf_tmfifo_remove,
+ .remove_new = mlxbf_tmfifo_remove,
.driver = {
.name = "bf-tmfifo",
.acpi_match_table = mlxbf_tmfifo_acpi_match,
--
2.40.1

2023-09-27 08:26:07

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH 26/27] platform/x86/siemens: simatic-ipc-batt-elkhartlake: Convert to platform remove callback returning void

The .remove() callback for a platform driver returns an int which makes
many driver authors wrongly assume it's possible to do error handling by
returning an error code. However the value returned is ignored (apart
from emitting a warning) and this typically results in resource leaks.

To improve here there is a quest to make the remove callback return
void. In the first step of this quest all drivers are converted to
.remove_new(), which already returns void. Eventually after all drivers
are converted, .remove_new() will be renamed to .remove().

Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.

Signed-off-by: Uwe Kleine-König <[email protected]>
---
drivers/platform/x86/siemens/simatic-ipc-batt-elkhartlake.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/platform/x86/siemens/simatic-ipc-batt-elkhartlake.c b/drivers/platform/x86/siemens/simatic-ipc-batt-elkhartlake.c
index 9e08c659f27d..a7676f224075 100644
--- a/drivers/platform/x86/siemens/simatic-ipc-batt-elkhartlake.c
+++ b/drivers/platform/x86/siemens/simatic-ipc-batt-elkhartlake.c
@@ -25,11 +25,9 @@ static struct gpiod_lookup_table simatic_ipc_batt_gpio_table_bx_21a = {
},
};

-static int simatic_ipc_batt_elkhartlake_remove(struct platform_device *pdev)
+static void simatic_ipc_batt_elkhartlake_remove(struct platform_device *pdev)
{
simatic_ipc_batt_remove(pdev, &simatic_ipc_batt_gpio_table_bx_21a);
-
- return 0;
}

static int simatic_ipc_batt_elkhartlake_probe(struct platform_device *pdev)
@@ -39,7 +37,7 @@ static int simatic_ipc_batt_elkhartlake_probe(struct platform_device *pdev)

static struct platform_driver simatic_ipc_batt_driver = {
.probe = simatic_ipc_batt_elkhartlake_probe,
- .remove = simatic_ipc_batt_elkhartlake_remove,
+ .remove_new = simatic_ipc_batt_elkhartlake_remove,
.driver = {
.name = KBUILD_MODNAME,
},
--
2.40.1

2023-09-27 08:26:08

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH 13/27] platform/goldfish: goldfish_pipe: Convert to platform remove callback returning void

The .remove() callback for a platform driver returns an int which makes
many driver authors wrongly assume it's possible to do error handling by
returning an error code. However the value returned is ignored (apart
from emitting a warning) and this typically results in resource leaks.

To improve here there is a quest to make the remove callback return
void. In the first step of this quest all drivers are converted to
.remove_new(), which already returns void. Eventually after all drivers
are converted, .remove_new() will be renamed to .remove().

Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.

Signed-off-by: Uwe Kleine-König <[email protected]>
---
drivers/platform/goldfish/goldfish_pipe.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/platform/goldfish/goldfish_pipe.c b/drivers/platform/goldfish/goldfish_pipe.c
index 7737d56191d7..061aa9647c19 100644
--- a/drivers/platform/goldfish/goldfish_pipe.c
+++ b/drivers/platform/goldfish/goldfish_pipe.c
@@ -915,12 +915,11 @@ static int goldfish_pipe_probe(struct platform_device *pdev)
return goldfish_pipe_device_init(pdev, dev);
}

-static int goldfish_pipe_remove(struct platform_device *pdev)
+static void goldfish_pipe_remove(struct platform_device *pdev)
{
struct goldfish_pipe_dev *dev = platform_get_drvdata(pdev);

goldfish_pipe_device_deinit(pdev, dev);
- return 0;
}

static const struct acpi_device_id goldfish_pipe_acpi_match[] = {
@@ -937,7 +936,7 @@ MODULE_DEVICE_TABLE(of, goldfish_pipe_of_match);

static struct platform_driver goldfish_pipe_driver = {
.probe = goldfish_pipe_probe,
- .remove = goldfish_pipe_remove,
+ .remove_new = goldfish_pipe_remove,
.driver = {
.name = "goldfish_pipe",
.of_match_table = goldfish_pipe_of_match,
--
2.40.1

2023-09-27 08:26:16

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH 02/27] platform/chrome: cros_ec_debugfs: Convert to platform remove callback returning void

The .remove() callback for a platform driver returns an int which makes
many driver authors wrongly assume it's possible to do error handling by
returning an error code. However the value returned is ignored (apart
from emitting a warning) and this typically results in resource leaks.

To improve here there is a quest to make the remove callback return
void. In the first step of this quest all drivers are converted to
.remove_new(), which already returns void. Eventually after all drivers
are converted, .remove_new() will be renamed to .remove().

Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.

Signed-off-by: Uwe Kleine-König <[email protected]>
---
drivers/platform/chrome/cros_ec_debugfs.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/platform/chrome/cros_ec_debugfs.c b/drivers/platform/chrome/cros_ec_debugfs.c
index c876120e0ebc..091fdc154d79 100644
--- a/drivers/platform/chrome/cros_ec_debugfs.c
+++ b/drivers/platform/chrome/cros_ec_debugfs.c
@@ -533,14 +533,12 @@ static int cros_ec_debugfs_probe(struct platform_device *pd)
return ret;
}

-static int cros_ec_debugfs_remove(struct platform_device *pd)
+static void cros_ec_debugfs_remove(struct platform_device *pd)
{
struct cros_ec_dev *ec = dev_get_drvdata(pd->dev.parent);

debugfs_remove_recursive(ec->debug_info->dir);
cros_ec_cleanup_console_log(ec->debug_info);
-
- return 0;
}

static int __maybe_unused cros_ec_debugfs_suspend(struct device *dev)
@@ -573,7 +571,7 @@ static struct platform_driver cros_ec_debugfs_driver = {
.probe_type = PROBE_PREFER_ASYNCHRONOUS,
},
.probe = cros_ec_debugfs_probe,
- .remove = cros_ec_debugfs_remove,
+ .remove_new = cros_ec_debugfs_remove,
};

module_platform_driver(cros_ec_debugfs_driver);
--
2.40.1

2023-09-27 08:26:18

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH 09/27] platform/chrome: cros_usbpd_notify: Convert to platform remove callback returning void

The .remove() callback for a platform driver returns an int which makes
many driver authors wrongly assume it's possible to do error handling by
returning an error code. However the value returned is ignored (apart
from emitting a warning) and this typically results in resource leaks.

To improve here there is a quest to make the remove callback return
void. In the first step of this quest all drivers are converted to
.remove_new(), which already returns void. Eventually after all drivers
are converted, .remove_new() will be renamed to .remove().

Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.

Signed-off-by: Uwe Kleine-König <[email protected]>
---
drivers/platform/chrome/cros_usbpd_notify.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/platform/chrome/cros_usbpd_notify.c b/drivers/platform/chrome/cros_usbpd_notify.c
index 10670b6588e3..aacad022f21d 100644
--- a/drivers/platform/chrome/cros_usbpd_notify.c
+++ b/drivers/platform/chrome/cros_usbpd_notify.c
@@ -134,15 +134,13 @@ static int cros_usbpd_notify_probe_acpi(struct platform_device *pdev)
return 0;
}

-static int cros_usbpd_notify_remove_acpi(struct platform_device *pdev)
+static void cros_usbpd_notify_remove_acpi(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct acpi_device *adev = ACPI_COMPANION(dev);

acpi_remove_notify_handler(adev->handle, ACPI_ALL_NOTIFY,
cros_usbpd_notify_acpi);
-
- return 0;
}

static const struct acpi_device_id cros_usbpd_notify_acpi_device_ids[] = {
@@ -157,7 +155,7 @@ static struct platform_driver cros_usbpd_notify_acpi_driver = {
.acpi_match_table = cros_usbpd_notify_acpi_device_ids,
},
.probe = cros_usbpd_notify_probe_acpi,
- .remove = cros_usbpd_notify_remove_acpi,
+ .remove_new = cros_usbpd_notify_remove_acpi,
};

#endif /* CONFIG_ACPI */
@@ -209,7 +207,7 @@ static int cros_usbpd_notify_probe_plat(struct platform_device *pdev)
return 0;
}

-static int cros_usbpd_notify_remove_plat(struct platform_device *pdev)
+static void cros_usbpd_notify_remove_plat(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct cros_ec_dev *ecdev = dev_get_drvdata(dev->parent);
@@ -218,8 +216,6 @@ static int cros_usbpd_notify_remove_plat(struct platform_device *pdev)

blocking_notifier_chain_unregister(&ecdev->ec_dev->event_notifier,
&pdnotify->nb);
-
- return 0;
}

static struct platform_driver cros_usbpd_notify_plat_driver = {
@@ -227,7 +223,7 @@ static struct platform_driver cros_usbpd_notify_plat_driver = {
.name = DRV_NAME,
},
.probe = cros_usbpd_notify_probe_plat,
- .remove = cros_usbpd_notify_remove_plat,
+ .remove_new = cros_usbpd_notify_remove_plat,
};

static int __init cros_usbpd_notify_init(void)
--
2.40.1

2023-09-27 08:26:40

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH 22/27] platform/x86: sel3350-platform: Convert to platform remove callback returning void

The .remove() callback for a platform driver returns an int which makes
many driver authors wrongly assume it's possible to do error handling by
returning an error code. However the value returned is ignored (apart
from emitting a warning) and this typically results in resource leaks.

To improve here there is a quest to make the remove callback return
void. In the first step of this quest all drivers are converted to
.remove_new(), which already returns void. Eventually after all drivers
are converted, .remove_new() will be renamed to .remove().

Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.

Signed-off-by: Uwe Kleine-König <[email protected]>
---
drivers/platform/x86/sel3350-platform.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/platform/x86/sel3350-platform.c b/drivers/platform/x86/sel3350-platform.c
index fa267d0d3778..d09e976e7148 100644
--- a/drivers/platform/x86/sel3350-platform.c
+++ b/drivers/platform/x86/sel3350-platform.c
@@ -218,15 +218,13 @@ static int sel3350_probe(struct platform_device *pdev)
return rs;
}

-static int sel3350_remove(struct platform_device *pdev)
+static void sel3350_remove(struct platform_device *pdev)
{
struct sel3350_data *sel3350 = platform_get_drvdata(pdev);

platform_device_unregister(sel3350->leds_pdev);
gpiod_remove_lookup_table(&sel3350_gpios_table);
gpiod_remove_lookup_table(&sel3350_leds_table);
-
- return 0;
}

static const struct acpi_device_id sel3350_device_ids[] = {
@@ -237,7 +235,7 @@ MODULE_DEVICE_TABLE(acpi, sel3350_device_ids);

static struct platform_driver sel3350_platform_driver = {
.probe = sel3350_probe,
- .remove = sel3350_remove,
+ .remove_new = sel3350_remove,
.driver = {
.name = "sel3350-platform",
.acpi_match_table = sel3350_device_ids,
--
2.40.1

2023-09-27 08:26:41

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH 23/27] platform/x86/siemens: simatic-ipc-batt: Simplify simatic_ipc_batt_remove()

Instead of unconditionally returning zero, let simatic_ipc_batt_remove()
return no value. This is a preparation to convert the drivers using this
function to struct platform_driver::remove_new().

Signed-off-by: Uwe Kleine-König <[email protected]>
---
drivers/platform/x86/siemens/simatic-ipc-batt-apollolake.c | 4 +++-
.../platform/x86/siemens/simatic-ipc-batt-elkhartlake.c | 4 +++-
drivers/platform/x86/siemens/simatic-ipc-batt-f7188x.c | 4 +++-
drivers/platform/x86/siemens/simatic-ipc-batt.c | 7 ++++---
drivers/platform/x86/siemens/simatic-ipc-batt.h | 4 ++--
5 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/drivers/platform/x86/siemens/simatic-ipc-batt-apollolake.c b/drivers/platform/x86/siemens/simatic-ipc-batt-apollolake.c
index 8a67979d8f96..3e22a6bc9118 100644
--- a/drivers/platform/x86/siemens/simatic-ipc-batt-apollolake.c
+++ b/drivers/platform/x86/siemens/simatic-ipc-batt-apollolake.c
@@ -27,7 +27,9 @@ static struct gpiod_lookup_table simatic_ipc_batt_gpio_table_127e = {

static int simatic_ipc_batt_apollolake_remove(struct platform_device *pdev)
{
- return simatic_ipc_batt_remove(pdev, &simatic_ipc_batt_gpio_table_127e);
+ simatic_ipc_batt_remove(pdev, &simatic_ipc_batt_gpio_table_127e);
+
+ return 0;
}

static int simatic_ipc_batt_apollolake_probe(struct platform_device *pdev)
diff --git a/drivers/platform/x86/siemens/simatic-ipc-batt-elkhartlake.c b/drivers/platform/x86/siemens/simatic-ipc-batt-elkhartlake.c
index 607d033911a2..9e08c659f27d 100644
--- a/drivers/platform/x86/siemens/simatic-ipc-batt-elkhartlake.c
+++ b/drivers/platform/x86/siemens/simatic-ipc-batt-elkhartlake.c
@@ -27,7 +27,9 @@ static struct gpiod_lookup_table simatic_ipc_batt_gpio_table_bx_21a = {

static int simatic_ipc_batt_elkhartlake_remove(struct platform_device *pdev)
{
- return simatic_ipc_batt_remove(pdev, &simatic_ipc_batt_gpio_table_bx_21a);
+ simatic_ipc_batt_remove(pdev, &simatic_ipc_batt_gpio_table_bx_21a);
+
+ return 0;
}

static int simatic_ipc_batt_elkhartlake_probe(struct platform_device *pdev)
diff --git a/drivers/platform/x86/siemens/simatic-ipc-batt-f7188x.c b/drivers/platform/x86/siemens/simatic-ipc-batt-f7188x.c
index a66107e0fe1e..19c302a68911 100644
--- a/drivers/platform/x86/siemens/simatic-ipc-batt-f7188x.c
+++ b/drivers/platform/x86/siemens/simatic-ipc-batt-f7188x.c
@@ -47,7 +47,9 @@ static struct gpiod_lookup_table simatic_ipc_batt_gpio_table_bx_59a = {

static int simatic_ipc_batt_f7188x_remove(struct platform_device *pdev)
{
- return simatic_ipc_batt_remove(pdev, batt_lookup_table);
+ simatic_ipc_batt_remove(pdev, batt_lookup_table);
+
+ return 0;
}

static int simatic_ipc_batt_f7188x_probe(struct platform_device *pdev)
diff --git a/drivers/platform/x86/siemens/simatic-ipc-batt.c b/drivers/platform/x86/siemens/simatic-ipc-batt.c
index ef28c806b383..07cd4944de32 100644
--- a/drivers/platform/x86/siemens/simatic-ipc-batt.c
+++ b/drivers/platform/x86/siemens/simatic-ipc-batt.c
@@ -146,10 +146,9 @@ static const struct hwmon_chip_info simatic_ipc_batt_chip_info = {
.info = simatic_ipc_batt_info,
};

-int simatic_ipc_batt_remove(struct platform_device *pdev, struct gpiod_lookup_table *table)
+void simatic_ipc_batt_remove(struct platform_device *pdev, struct gpiod_lookup_table *table)
{
gpiod_remove_lookup_table(table);
- return 0;
}
EXPORT_SYMBOL_GPL(simatic_ipc_batt_remove);

@@ -230,7 +229,9 @@ EXPORT_SYMBOL_GPL(simatic_ipc_batt_probe);

static int simatic_ipc_batt_io_remove(struct platform_device *pdev)
{
- return simatic_ipc_batt_remove(pdev, NULL);
+ simatic_ipc_batt_remove(pdev, NULL);
+
+ return 0;
}

static int simatic_ipc_batt_io_probe(struct platform_device *pdev)
diff --git a/drivers/platform/x86/siemens/simatic-ipc-batt.h b/drivers/platform/x86/siemens/simatic-ipc-batt.h
index 4545cd3e3026..89891db26a2c 100644
--- a/drivers/platform/x86/siemens/simatic-ipc-batt.h
+++ b/drivers/platform/x86/siemens/simatic-ipc-batt.h
@@ -14,7 +14,7 @@
int simatic_ipc_batt_probe(struct platform_device *pdev,
struct gpiod_lookup_table *table);

-int simatic_ipc_batt_remove(struct platform_device *pdev,
- struct gpiod_lookup_table *table);
+void simatic_ipc_batt_remove(struct platform_device *pdev,
+ struct gpiod_lookup_table *table);

#endif /* _SIMATIC_IPC_BATT_H */
--
2.40.1

2023-09-27 08:27:08

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH 18/27] platform/mellanox: mlxreg-lc: Convert to platform remove callback returning void

The .remove() callback for a platform driver returns an int which makes
many driver authors wrongly assume it's possible to do error handling by
returning an error code. However the value returned is ignored (apart
from emitting a warning) and this typically results in resource leaks.

To improve here there is a quest to make the remove callback return
void. In the first step of this quest all drivers are converted to
.remove_new(), which already returns void. Eventually after all drivers
are converted, .remove_new() will be renamed to .remove().

Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.

Signed-off-by: Uwe Kleine-König <[email protected]>
---
drivers/platform/mellanox/mlxreg-lc.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/platform/mellanox/mlxreg-lc.c b/drivers/platform/mellanox/mlxreg-lc.c
index 8d833836a6d3..43d119e3a473 100644
--- a/drivers/platform/mellanox/mlxreg-lc.c
+++ b/drivers/platform/mellanox/mlxreg-lc.c
@@ -907,7 +907,7 @@ static int mlxreg_lc_probe(struct platform_device *pdev)
return err;
}

-static int mlxreg_lc_remove(struct platform_device *pdev)
+static void mlxreg_lc_remove(struct platform_device *pdev)
{
struct mlxreg_core_data *data = dev_get_platdata(&pdev->dev);
struct mlxreg_lc *mlxreg_lc = platform_get_drvdata(pdev);
@@ -921,7 +921,7 @@ static int mlxreg_lc_remove(struct platform_device *pdev)
* is nothing to remove.
*/
if (!data->notifier || !data->notifier->handle)
- return 0;
+ return;

/* Clear event notification callback and handle. */
data->notifier->user_handler = NULL;
@@ -940,13 +940,11 @@ static int mlxreg_lc_remove(struct platform_device *pdev)
i2c_put_adapter(data->hpdev.adapter);
data->hpdev.adapter = NULL;
}
-
- return 0;
}

static struct platform_driver mlxreg_lc_driver = {
.probe = mlxreg_lc_probe,
- .remove = mlxreg_lc_remove,
+ .remove_new = mlxreg_lc_remove,
.driver = {
.name = "mlxreg-lc",
},
--
2.40.1

2023-09-27 08:27:09

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH 16/27] platform/mellanox: mlxreg-hotplug: Convert to platform remove callback returning void

The .remove() callback for a platform driver returns an int which makes
many driver authors wrongly assume it's possible to do error handling by
returning an error code. However the value returned is ignored (apart
from emitting a warning) and this typically results in resource leaks.

To improve here there is a quest to make the remove callback return
void. In the first step of this quest all drivers are converted to
.remove_new(), which already returns void. Eventually after all drivers
are converted, .remove_new() will be renamed to .remove().

Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.

Signed-off-by: Uwe Kleine-König <[email protected]>
---
drivers/platform/mellanox/mlxreg-hotplug.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/platform/mellanox/mlxreg-hotplug.c b/drivers/platform/mellanox/mlxreg-hotplug.c
index eb5ad35274dd..5c022b258f91 100644
--- a/drivers/platform/mellanox/mlxreg-hotplug.c
+++ b/drivers/platform/mellanox/mlxreg-hotplug.c
@@ -786,15 +786,13 @@ static int mlxreg_hotplug_probe(struct platform_device *pdev)
return 0;
}

-static int mlxreg_hotplug_remove(struct platform_device *pdev)
+static void mlxreg_hotplug_remove(struct platform_device *pdev)
{
struct mlxreg_hotplug_priv_data *priv = dev_get_drvdata(&pdev->dev);

/* Clean interrupts setup. */
mlxreg_hotplug_unset_irq(priv);
devm_free_irq(&pdev->dev, priv->irq, priv);
-
- return 0;
}

static struct platform_driver mlxreg_hotplug_driver = {
@@ -802,7 +800,7 @@ static struct platform_driver mlxreg_hotplug_driver = {
.name = "mlxreg-hotplug",
},
.probe = mlxreg_hotplug_probe,
- .remove = mlxreg_hotplug_remove,
+ .remove_new = mlxreg_hotplug_remove,
};

module_platform_driver(mlxreg_hotplug_driver);
--
2.40.1

2023-09-27 08:27:12

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH 03/27] platform/chrome: cros_ec_lightbar: Convert to platform remove callback returning void

The .remove() callback for a platform driver returns an int which makes
many driver authors wrongly assume it's possible to do error handling by
returning an error code. However the value returned is ignored (apart
from emitting a warning) and this typically results in resource leaks.

To improve here there is a quest to make the remove callback return
void. In the first step of this quest all drivers are converted to
.remove_new(), which already returns void. Eventually after all drivers
are converted, .remove_new() will be renamed to .remove().

Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.

Signed-off-by: Uwe Kleine-König <[email protected]>
---
drivers/platform/chrome/cros_ec_lightbar.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/platform/chrome/cros_ec_lightbar.c b/drivers/platform/chrome/cros_ec_lightbar.c
index 376425bbd8ff..6677cc6c4984 100644
--- a/drivers/platform/chrome/cros_ec_lightbar.c
+++ b/drivers/platform/chrome/cros_ec_lightbar.c
@@ -560,7 +560,7 @@ static int cros_ec_lightbar_probe(struct platform_device *pd)
return ret;
}

-static int cros_ec_lightbar_remove(struct platform_device *pd)
+static void cros_ec_lightbar_remove(struct platform_device *pd)
{
struct cros_ec_dev *ec_dev = dev_get_drvdata(pd->dev.parent);

@@ -569,8 +569,6 @@ static int cros_ec_lightbar_remove(struct platform_device *pd)

/* Let the EC take over the lightbar again. */
lb_manual_suspend_ctrl(ec_dev, 0);
-
- return 0;
}

static int __maybe_unused cros_ec_lightbar_resume(struct device *dev)
@@ -603,7 +601,7 @@ static struct platform_driver cros_ec_lightbar_driver = {
.probe_type = PROBE_PREFER_ASYNCHRONOUS,
},
.probe = cros_ec_lightbar_probe,
- .remove = cros_ec_lightbar_remove,
+ .remove_new = cros_ec_lightbar_remove,
};

module_platform_driver(cros_ec_lightbar_driver);
--
2.40.1

2023-09-27 08:27:15

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH 24/27] platform/x86/siemens: simatic-ipc-batt: Convert to platform remove callback returning void

The .remove() callback for a platform driver returns an int which makes
many driver authors wrongly assume it's possible to do error handling by
returning an error code. However the value returned is ignored (apart
from emitting a warning) and this typically results in resource leaks.

To improve here there is a quest to make the remove callback return
void. In the first step of this quest all drivers are converted to
.remove_new(), which already returns void. Eventually after all drivers
are converted, .remove_new() will be renamed to .remove().

Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.

Signed-off-by: Uwe Kleine-König <[email protected]>
---
drivers/platform/x86/siemens/simatic-ipc-batt.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/platform/x86/siemens/simatic-ipc-batt.c b/drivers/platform/x86/siemens/simatic-ipc-batt.c
index 07cd4944de32..c6dd263b4ee3 100644
--- a/drivers/platform/x86/siemens/simatic-ipc-batt.c
+++ b/drivers/platform/x86/siemens/simatic-ipc-batt.c
@@ -227,11 +227,9 @@ int simatic_ipc_batt_probe(struct platform_device *pdev, struct gpiod_lookup_tab
}
EXPORT_SYMBOL_GPL(simatic_ipc_batt_probe);

-static int simatic_ipc_batt_io_remove(struct platform_device *pdev)
+static void simatic_ipc_batt_io_remove(struct platform_device *pdev)
{
simatic_ipc_batt_remove(pdev, NULL);
-
- return 0;
}

static int simatic_ipc_batt_io_probe(struct platform_device *pdev)
@@ -241,7 +239,7 @@ static int simatic_ipc_batt_io_probe(struct platform_device *pdev)

static struct platform_driver simatic_ipc_batt_driver = {
.probe = simatic_ipc_batt_io_probe,
- .remove = simatic_ipc_batt_io_remove,
+ .remove_new = simatic_ipc_batt_io_remove,
.driver = {
.name = KBUILD_MODNAME,
},
--
2.40.1

2023-09-27 08:28:11

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH 25/27] platform/x86/siemens: simatic-ipc-batt-apollolake: Convert to platform remove callback returning void

The .remove() callback for a platform driver returns an int which makes
many driver authors wrongly assume it's possible to do error handling by
returning an error code. However the value returned is ignored (apart
from emitting a warning) and this typically results in resource leaks.

To improve here there is a quest to make the remove callback return
void. In the first step of this quest all drivers are converted to
.remove_new(), which already returns void. Eventually after all drivers
are converted, .remove_new() will be renamed to .remove().

Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.

Signed-off-by: Uwe Kleine-König <[email protected]>
---
drivers/platform/x86/siemens/simatic-ipc-batt-apollolake.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/platform/x86/siemens/simatic-ipc-batt-apollolake.c b/drivers/platform/x86/siemens/simatic-ipc-batt-apollolake.c
index 3e22a6bc9118..31a139d87d9a 100644
--- a/drivers/platform/x86/siemens/simatic-ipc-batt-apollolake.c
+++ b/drivers/platform/x86/siemens/simatic-ipc-batt-apollolake.c
@@ -25,11 +25,9 @@ static struct gpiod_lookup_table simatic_ipc_batt_gpio_table_127e = {
},
};

-static int simatic_ipc_batt_apollolake_remove(struct platform_device *pdev)
+static void simatic_ipc_batt_apollolake_remove(struct platform_device *pdev)
{
simatic_ipc_batt_remove(pdev, &simatic_ipc_batt_gpio_table_127e);
-
- return 0;
}

static int simatic_ipc_batt_apollolake_probe(struct platform_device *pdev)
@@ -39,7 +37,7 @@ static int simatic_ipc_batt_apollolake_probe(struct platform_device *pdev)

static struct platform_driver simatic_ipc_batt_driver = {
.probe = simatic_ipc_batt_apollolake_probe,
- .remove = simatic_ipc_batt_apollolake_remove,
+ .remove_new = simatic_ipc_batt_apollolake_remove,
.driver = {
.name = KBUILD_MODNAME,
},
--
2.40.1

2023-09-27 08:28:15

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH 19/27] platform/mellanox: nvsw-sn2201: Convert to platform remove callback returning void

The .remove() callback for a platform driver returns an int which makes
many driver authors wrongly assume it's possible to do error handling by
returning an error code. However the value returned is ignored (apart
from emitting a warning) and this typically results in resource leaks.

To improve here there is a quest to make the remove callback return
void. In the first step of this quest all drivers are converted to
.remove_new(), which already returns void. Eventually after all drivers
are converted, .remove_new() will be renamed to .remove().

Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.

Signed-off-by: Uwe Kleine-König <[email protected]>
---
drivers/platform/mellanox/nvsw-sn2201.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/platform/mellanox/nvsw-sn2201.c b/drivers/platform/mellanox/nvsw-sn2201.c
index 75b699676ca6..3ef655591424 100644
--- a/drivers/platform/mellanox/nvsw-sn2201.c
+++ b/drivers/platform/mellanox/nvsw-sn2201.c
@@ -1217,7 +1217,7 @@ static int nvsw_sn2201_probe(struct platform_device *pdev)
return nvsw_sn2201_config_pre_init(nvsw_sn2201);
}

-static int nvsw_sn2201_remove(struct platform_device *pdev)
+static void nvsw_sn2201_remove(struct platform_device *pdev)
{
struct nvsw_sn2201 *nvsw_sn2201 = platform_get_drvdata(pdev);

@@ -1239,8 +1239,6 @@ static int nvsw_sn2201_remove(struct platform_device *pdev)
/* Unregister I2C controller. */
if (nvsw_sn2201->pdev_i2c)
platform_device_unregister(nvsw_sn2201->pdev_i2c);
-
- return 0;
}

static const struct acpi_device_id nvsw_sn2201_acpi_ids[] = {
@@ -1252,7 +1250,7 @@ MODULE_DEVICE_TABLE(acpi, nvsw_sn2201_acpi_ids);

static struct platform_driver nvsw_sn2201_driver = {
.probe = nvsw_sn2201_probe,
- .remove = nvsw_sn2201_remove,
+ .remove_new = nvsw_sn2201_remove,
.driver = {
.name = "nvsw-sn2201",
.acpi_match_table = nvsw_sn2201_acpi_ids,
--
2.40.1

2023-09-27 08:28:25

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH 06/27] platform/chrome: cros_ec_vbc: Convert to platform remove callback returning void

The .remove() callback for a platform driver returns an int which makes
many driver authors wrongly assume it's possible to do error handling by
returning an error code. However the value returned is ignored (apart
from emitting a warning) and this typically results in resource leaks.

To improve here there is a quest to make the remove callback return
void. In the first step of this quest all drivers are converted to
.remove_new(), which already returns void. Eventually after all drivers
are converted, .remove_new() will be renamed to .remove().

Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.

Signed-off-by: Uwe Kleine-König <[email protected]>
---
drivers/platform/chrome/cros_ec_vbc.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/platform/chrome/cros_ec_vbc.c b/drivers/platform/chrome/cros_ec_vbc.c
index c859c862d7ac..2e4af10c7679 100644
--- a/drivers/platform/chrome/cros_ec_vbc.c
+++ b/drivers/platform/chrome/cros_ec_vbc.c
@@ -121,14 +121,12 @@ static int cros_ec_vbc_probe(struct platform_device *pd)
return ret;
}

-static int cros_ec_vbc_remove(struct platform_device *pd)
+static void cros_ec_vbc_remove(struct platform_device *pd)
{
struct cros_ec_dev *ec_dev = dev_get_drvdata(pd->dev.parent);

sysfs_remove_group(&ec_dev->class_dev.kobj,
&cros_ec_vbc_attr_group);
-
- return 0;
}

static struct platform_driver cros_ec_vbc_driver = {
@@ -136,7 +134,7 @@ static struct platform_driver cros_ec_vbc_driver = {
.name = DRV_NAME,
},
.probe = cros_ec_vbc_probe,
- .remove = cros_ec_vbc_remove,
+ .remove_new = cros_ec_vbc_remove,
};

module_platform_driver(cros_ec_vbc_driver);
--
2.40.1

2023-09-27 08:39:42

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH 27/27] platform/x86/siemens: simatic-ipc-batt-f7188x: Convert to platform remove callback returning void

The .remove() callback for a platform driver returns an int which makes
many driver authors wrongly assume it's possible to do error handling by
returning an error code. However the value returned is ignored (apart
from emitting a warning) and this typically results in resource leaks.

To improve here there is a quest to make the remove callback return
void. In the first step of this quest all drivers are converted to
.remove_new(), which already returns void. Eventually after all drivers
are converted, .remove_new() will be renamed to .remove().

Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.

Signed-off-by: Uwe Kleine-König <[email protected]>
---
drivers/platform/x86/siemens/simatic-ipc-batt-f7188x.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/platform/x86/siemens/simatic-ipc-batt-f7188x.c b/drivers/platform/x86/siemens/simatic-ipc-batt-f7188x.c
index 19c302a68911..5e77e05fdb5d 100644
--- a/drivers/platform/x86/siemens/simatic-ipc-batt-f7188x.c
+++ b/drivers/platform/x86/siemens/simatic-ipc-batt-f7188x.c
@@ -45,11 +45,9 @@ static struct gpiod_lookup_table simatic_ipc_batt_gpio_table_bx_59a = {
}
};

-static int simatic_ipc_batt_f7188x_remove(struct platform_device *pdev)
+static void simatic_ipc_batt_f7188x_remove(struct platform_device *pdev)
{
simatic_ipc_batt_remove(pdev, batt_lookup_table);
-
- return 0;
}

static int simatic_ipc_batt_f7188x_probe(struct platform_device *pdev)
@@ -75,7 +73,7 @@ static int simatic_ipc_batt_f7188x_probe(struct platform_device *pdev)

static struct platform_driver simatic_ipc_batt_driver = {
.probe = simatic_ipc_batt_f7188x_probe,
- .remove = simatic_ipc_batt_f7188x_remove,
+ .remove_new = simatic_ipc_batt_f7188x_remove,
.driver = {
.name = KBUILD_MODNAME,
},
--
2.40.1

2023-09-27 09:15:15

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH 07/27] platform/chrome: cros_typec_switch: Convert to platform remove callback returning void

The .remove() callback for a platform driver returns an int which makes
many driver authors wrongly assume it's possible to do error handling by
returning an error code. However the value returned is ignored (apart
from emitting a warning) and this typically results in resource leaks.

To improve here there is a quest to make the remove callback return
void. In the first step of this quest all drivers are converted to
.remove_new(), which already returns void. Eventually after all drivers
are converted, .remove_new() will be renamed to .remove().

Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.

Signed-off-by: Uwe Kleine-König <[email protected]>
---
drivers/platform/chrome/cros_typec_switch.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/platform/chrome/cros_typec_switch.c b/drivers/platform/chrome/cros_typec_switch.c
index 0eefdcf14d63..07a19386dc4e 100644
--- a/drivers/platform/chrome/cros_typec_switch.c
+++ b/drivers/platform/chrome/cros_typec_switch.c
@@ -297,12 +297,11 @@ static int cros_typec_switch_probe(struct platform_device *pdev)
return cros_typec_register_switches(sdata);
}

-static int cros_typec_switch_remove(struct platform_device *pdev)
+static void cros_typec_switch_remove(struct platform_device *pdev)
{
struct cros_typec_switch_data *sdata = platform_get_drvdata(pdev);

cros_typec_unregister_switches(sdata);
- return 0;
}

#ifdef CONFIG_ACPI
@@ -319,7 +318,7 @@ static struct platform_driver cros_typec_switch_driver = {
.acpi_match_table = ACPI_PTR(cros_typec_switch_acpi_id),
},
.probe = cros_typec_switch_probe,
- .remove = cros_typec_switch_remove,
+ .remove_new = cros_typec_switch_remove,
};

module_platform_driver(cros_typec_switch_driver);
--
2.40.1

2023-09-27 09:28:41

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH 21/27] platform/x86: mlx-platform: Convert to platform remove callback returning void

The .remove() callback for a platform driver returns an int which makes
many driver authors wrongly assume it's possible to do error handling by
returning an error code. However the value returned is ignored (apart
from emitting a warning) and this typically results in resource leaks.

To improve here there is a quest to make the remove callback return
void. In the first step of this quest all drivers are converted to
.remove_new(), which already returns void. Eventually after all drivers
are converted, .remove_new() will be renamed to .remove().

Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.

Signed-off-by: Uwe Kleine-König <[email protected]>
---
drivers/platform/x86/mlx-platform.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/platform/x86/mlx-platform.c b/drivers/platform/x86/mlx-platform.c
index 3d96dbf79a72..03ccadee35d0 100644
--- a/drivers/platform/x86/mlx-platform.c
+++ b/drivers/platform/x86/mlx-platform.c
@@ -6606,7 +6606,7 @@ static int mlxplat_probe(struct platform_device *pdev)
return err;
}

-static int mlxplat_remove(struct platform_device *pdev)
+static void mlxplat_remove(struct platform_device *pdev)
{
struct mlxplat_priv *priv = platform_get_drvdata(mlxplat_dev);

@@ -6617,7 +6617,6 @@ static int mlxplat_remove(struct platform_device *pdev)
mlxplat_pre_exit(priv);
mlxplat_i2c_main_exit(priv);
mlxplat_post_exit();
- return 0;
}

static const struct acpi_device_id mlxplat_acpi_table[] = {
@@ -6633,7 +6632,7 @@ static struct platform_driver mlxplat_driver = {
.probe_type = PROBE_FORCE_SYNCHRONOUS,
},
.probe = mlxplat_probe,
- .remove = mlxplat_remove,
+ .remove_new = mlxplat_remove,
};

static int __init mlxplat_init(void)
--
2.40.1

2023-09-27 09:30:47

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH 08/27] platform/chrome: cros_usbpd_logger: Convert to platform remove callback returning void

The .remove() callback for a platform driver returns an int which makes
many driver authors wrongly assume it's possible to do error handling by
returning an error code. However the value returned is ignored (apart
from emitting a warning) and this typically results in resource leaks.

To improve here there is a quest to make the remove callback return
void. In the first step of this quest all drivers are converted to
.remove_new(), which already returns void. Eventually after all drivers
are converted, .remove_new() will be renamed to .remove().

Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.

Signed-off-by: Uwe Kleine-König <[email protected]>
---
drivers/platform/chrome/cros_usbpd_logger.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/platform/chrome/cros_usbpd_logger.c b/drivers/platform/chrome/cros_usbpd_logger.c
index d16931203d82..f618757f8b32 100644
--- a/drivers/platform/chrome/cros_usbpd_logger.c
+++ b/drivers/platform/chrome/cros_usbpd_logger.c
@@ -219,14 +219,12 @@ static int cros_usbpd_logger_probe(struct platform_device *pd)
return 0;
}

-static int cros_usbpd_logger_remove(struct platform_device *pd)
+static void cros_usbpd_logger_remove(struct platform_device *pd)
{
struct logger_data *logger = platform_get_drvdata(pd);

cancel_delayed_work_sync(&logger->log_work);
destroy_workqueue(logger->log_workqueue);
-
- return 0;
}

static int __maybe_unused cros_usbpd_logger_resume(struct device *dev)
@@ -257,7 +255,7 @@ static struct platform_driver cros_usbpd_logger_driver = {
.pm = &cros_usbpd_logger_pm_ops,
},
.probe = cros_usbpd_logger_probe,
- .remove = cros_usbpd_logger_remove,
+ .remove_new = cros_usbpd_logger_remove,
};

module_platform_driver(cros_usbpd_logger_driver);
--
2.40.1

2023-09-27 09:40:30

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH 14/27] platform/mellanox: mlxbf-bootctl: Convert to platform remove callback returning void

The .remove() callback for a platform driver returns an int which makes
many driver authors wrongly assume it's possible to do error handling by
returning an error code. However the value returned is ignored (apart
from emitting a warning) and this typically results in resource leaks.

To improve here there is a quest to make the remove callback return
void. In the first step of this quest all drivers are converted to
.remove_new(), which already returns void. Eventually after all drivers
are converted, .remove_new() will be renamed to .remove().

Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.

Signed-off-by: Uwe Kleine-König <[email protected]>
---
drivers/platform/mellanox/mlxbf-bootctl.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/platform/mellanox/mlxbf-bootctl.c b/drivers/platform/mellanox/mlxbf-bootctl.c
index 4ee7bb431b7c..1ac7dab22c63 100644
--- a/drivers/platform/mellanox/mlxbf-bootctl.c
+++ b/drivers/platform/mellanox/mlxbf-bootctl.c
@@ -1028,17 +1028,15 @@ static int mlxbf_bootctl_probe(struct platform_device *pdev)
return ret;
}

-static int mlxbf_bootctl_remove(struct platform_device *pdev)
+static void mlxbf_bootctl_remove(struct platform_device *pdev)
{
sysfs_remove_bin_file(&pdev->dev.kobj,
&mlxbf_bootctl_bootfifo_sysfs_attr);
-
- return 0;
}

static struct platform_driver mlxbf_bootctl_driver = {
.probe = mlxbf_bootctl_probe,
- .remove = mlxbf_bootctl_remove,
+ .remove_new = mlxbf_bootctl_remove,
.driver = {
.name = "mlxbf-bootctl",
.dev_groups = mlxbf_bootctl_groups,
--
2.40.1

Subject: Re: [PATCH 00/27] platform: Convert to platform remove callback returning void

Hello:

This series was applied to chrome-platform/linux.git (for-kernelci)
by Tzung-Bi Shih <[email protected]>:

On Wed, 27 Sep 2023 10:10:13 +0200 you wrote:
> Hello,
>
> this series converts all platform drivers below drivers/platform to use
> .remove_new(). The motivation is to get rid of an integer return code
> that is (mostly) ignored by the platform driver core and error prone on
> the driver side.
>
> [...]

Here is the summary with links:
- [01/27] platform/chrome: cros_ec_chardev: Convert to platform remove callback returning void
https://git.kernel.org/chrome-platform/c/f04410e7be65
- [02/27] platform/chrome: cros_ec_debugfs: Convert to platform remove callback returning void
https://git.kernel.org/chrome-platform/c/f366fa0064ef
- [03/27] platform/chrome: cros_ec_lightbar: Convert to platform remove callback returning void
https://git.kernel.org/chrome-platform/c/fa45583c3133
- [04/27] platform/chrome: cros_ec_lpc: Convert to platform remove callback returning void
https://git.kernel.org/chrome-platform/c/e02944e85169
- [05/27] platform/chrome: cros_ec_sysfs: Convert to platform remove callback returning void
https://git.kernel.org/chrome-platform/c/6478e302409a
- [06/27] platform/chrome: cros_ec_vbc: Convert to platform remove callback returning void
https://git.kernel.org/chrome-platform/c/58b15196b0ef
- [07/27] platform/chrome: cros_typec_switch: Convert to platform remove callback returning void
https://git.kernel.org/chrome-platform/c/ea4bad2badb7
- [08/27] platform/chrome: cros_usbpd_logger: Convert to platform remove callback returning void
https://git.kernel.org/chrome-platform/c/b6c1fea83550
- [09/27] platform/chrome: cros_usbpd_notify: Convert to platform remove callback returning void
https://git.kernel.org/chrome-platform/c/b98362be7c92
- [10/27] platform/chrome/wilco_ec: core: Convert to platform remove callback returning void
https://git.kernel.org/chrome-platform/c/48648504e488
- [11/27] platform/chrome/wilco_ec: debugfs: Convert to platform remove callback returning void
https://git.kernel.org/chrome-platform/c/1fca58f347d8
- [12/27] platform/chrome/wilco_ec: telemetry: Convert to platform remove callback returning void
https://git.kernel.org/chrome-platform/c/7396a5b980fd

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html


2023-09-28 17:17:17

by Prashant Malani

[permalink] [raw]
Subject: Re: [PATCH 07/27] platform/chrome: cros_typec_switch: Convert to platform remove callback returning void

Hi Uwe,

On Wed, Sep 27, 2023 at 1:10 AM Uwe Kleine-König
<[email protected]> wrote:
>
> The .remove() callback for a platform driver returns an int which makes
> many driver authors wrongly assume it's possible to do error handling by
> returning an error code. However the value returned is ignored (apart
> from emitting a warning) and this typically results in resource leaks.
>
> To improve here there is a quest to make the remove callback return
> void. In the first step of this quest all drivers are converted to
> .remove_new(), which already returns void. Eventually after all drivers
> are converted, .remove_new() will be renamed to .remove().
>
> Trivially convert this driver from always returning zero in the remove
> callback to the void returning variant.
>
> Signed-off-by: Uwe Kleine-König <[email protected]>
Acked-by: Prashant Malani <[email protected]>


BR,

-Prashant

2023-09-28 17:46:54

by Ilpo Järvinen

[permalink] [raw]
Subject: Re: [PATCH 00/27] platform: Convert to platform remove callback returning void

On Wed, 27 Sep 2023, Uwe Kleine-König wrote:

> Hello,
>
> this series converts all platform drivers below drivers/platform to use
> .remove_new(). The motivation is to get rid of an integer return code
> that is (mostly) ignored by the platform driver core and error prone on
> the driver side.
>
> See commit 5c5a7680e67b ("platform: Provide a remove callback that
> returns no value") for an extended explanation and the eventual goal.
>
> As there is no single maintainer team for drivers/platform, I suggest
> the individual maintainers to pick up "their" patches. The only
> inter-dependency in this series is that the patches #24 - #27 depend on
> #23. Otherwise there are no inter-dependencies, so that should work
> fine. As there are still quite a few drivers to convert in other areas
> than drivers/platform, I'm happy about every patch that makes it in and
> there is no need for further coordination. So even if there is a merge
> conflict with one patch until you apply or a subject prefix is
> suboptimal, please don't let you stop by negative feedback for other
> patches (unless it applies to "your" patches, too, of course).
>
> Best regards and thanks for considering,
> Uwe
>
> Uwe Kleine-König (27):
> platform/chrome: cros_ec_chardev: Convert to platform remove callback
> returning void
> platform/chrome: cros_ec_debugfs: Convert to platform remove callback
> returning void
> platform/chrome: cros_ec_lightbar: Convert to platform remove callback
> returning void
> platform/chrome: cros_ec_lpc: Convert to platform remove callback
> returning void
> platform/chrome: cros_ec_sysfs: Convert to platform remove callback
> returning void
> platform/chrome: cros_ec_vbc: Convert to platform remove callback
> returning void
> platform/chrome: cros_typec_switch: Convert to platform remove
> callback returning void
> platform/chrome: cros_usbpd_logger: Convert to platform remove
> callback returning void
> platform/chrome: cros_usbpd_notify: Convert to platform remove
> callback returning void
> platform/chrome/wilco_ec: core: Convert to platform remove callback
> returning void
> platform/chrome/wilco_ec: debugfs: Convert to platform remove callback
> returning void
> platform/chrome/wilco_ec: telemetry: Convert to platform remove
> callback returning void
> platform/goldfish: goldfish_pipe: Convert to platform remove callback
> returning void
> platform/mellanox: mlxbf-bootctl: Convert to platform remove callback
> returning void
> platform/mellanox: mlxbf-tmfifo: Convert to platform remove callback
> returning void
> platform/mellanox: mlxreg-hotplug: Convert to platform remove callback
> returning void
> platform/mellanox: mlxreg-io: Convert to platform remove callback
> returning void
> platform/mellanox: mlxreg-lc: Convert to platform remove callback
> returning void
> platform/mellanox: nvsw-sn2201: Convert to platform remove callback
> returning void
> platform/x86/intel: bytcrc_pwrsrc: Convert to platform remove callback
> returning void
> platform/x86: mlx-platform: Convert to platform remove callback
> returning void
> platform/x86: sel3350-platform: Convert to platform remove callback
> returning void
> platform/x86/siemens: simatic-ipc-batt: Simplify
> simatic_ipc_batt_remove()
> platform/x86/siemens: simatic-ipc-batt: Convert to platform remove
> callback returning void
> platform/x86/siemens: simatic-ipc-batt-apollolake: Convert to platform
> remove callback returning void
> platform/x86/siemens: simatic-ipc-batt-elkhartlake: Convert to
> platform remove callback returning void
> platform/x86/siemens: simatic-ipc-batt-f7188x: Convert to platform
> remove callback returning void

Thanks for the patches.

I don't know if you got the auto generated thank you email as it seemed to
hit a character encoding problem while sending the email out.

But in any case, I've applied patches 14-27 to my local review-ilpo branch
(they will eventually appear on the public repo too and propagate to
for-next).


--
i.

2023-09-28 21:58:09

by Prashant Malani

[permalink] [raw]
Subject: Re: [PATCH 09/27] platform/chrome: cros_usbpd_notify: Convert to platform remove callback returning void

Hi Uwe,

On Wed, Sep 27, 2023 at 1:10 AM Uwe Kleine-König
<[email protected]> wrote:
>
> The .remove() callback for a platform driver returns an int which makes
> many driver authors wrongly assume it's possible to do error handling by
> returning an error code. However the value returned is ignored (apart
> from emitting a warning) and this typically results in resource leaks.
>
> To improve here there is a quest to make the remove callback return
> void. In the first step of this quest all drivers are converted to
> .remove_new(), which already returns void. Eventually after all drivers
> are converted, .remove_new() will be renamed to .remove().
>
> Trivially convert this driver from always returning zero in the remove
> callback to the void returning variant.
>
> Signed-off-by: Uwe Kleine-König <[email protected]>
Acked-by: Prashant Malani <[email protected]>

BR,

-Prashant

Subject: Re: [PATCH 00/27] platform: Convert to platform remove callback returning void

Hello:

This series was applied to chrome-platform/linux.git (for-next)
by Tzung-Bi Shih <[email protected]>:

On Wed, 27 Sep 2023 10:10:13 +0200 you wrote:
> Hello,
>
> this series converts all platform drivers below drivers/platform to use
> .remove_new(). The motivation is to get rid of an integer return code
> that is (mostly) ignored by the platform driver core and error prone on
> the driver side.
>
> [...]

Here is the summary with links:
- [01/27] platform/chrome: cros_ec_chardev: Convert to platform remove callback returning void
https://git.kernel.org/chrome-platform/c/f04410e7be65
- [02/27] platform/chrome: cros_ec_debugfs: Convert to platform remove callback returning void
https://git.kernel.org/chrome-platform/c/f366fa0064ef
- [03/27] platform/chrome: cros_ec_lightbar: Convert to platform remove callback returning void
https://git.kernel.org/chrome-platform/c/fa45583c3133
- [04/27] platform/chrome: cros_ec_lpc: Convert to platform remove callback returning void
https://git.kernel.org/chrome-platform/c/e02944e85169
- [05/27] platform/chrome: cros_ec_sysfs: Convert to platform remove callback returning void
https://git.kernel.org/chrome-platform/c/6478e302409a
- [06/27] platform/chrome: cros_ec_vbc: Convert to platform remove callback returning void
https://git.kernel.org/chrome-platform/c/58b15196b0ef
- [07/27] platform/chrome: cros_typec_switch: Convert to platform remove callback returning void
https://git.kernel.org/chrome-platform/c/ea4bad2badb7
- [08/27] platform/chrome: cros_usbpd_logger: Convert to platform remove callback returning void
https://git.kernel.org/chrome-platform/c/b6c1fea83550
- [09/27] platform/chrome: cros_usbpd_notify: Convert to platform remove callback returning void
https://git.kernel.org/chrome-platform/c/b98362be7c92
- [10/27] platform/chrome/wilco_ec: core: Convert to platform remove callback returning void
https://git.kernel.org/chrome-platform/c/48648504e488
- [11/27] platform/chrome/wilco_ec: debugfs: Convert to platform remove callback returning void
https://git.kernel.org/chrome-platform/c/1fca58f347d8
- [12/27] platform/chrome/wilco_ec: telemetry: Convert to platform remove callback returning void
https://git.kernel.org/chrome-platform/c/7396a5b980fd

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html