Re: [PATCH] hwmon: (asus-ec-sensors) autoload module via DMI data

From: Guenter Roeck
Date: Fri Sep 09 2022 - 10:43:34 EST


On Fri, Sep 09, 2022 at 01:38:20PM +0200, Eugene Shalygin wrote:
> Replace autoloading data based on the ACPI EC device with the DMI
> records for motherboards models. The ACPI method created a bug that when
> this driver returns error from the probe function because of the
> unsupported motherboard model, the ACPI subsystem concludes
> that the EC device does not work properly.
>
> Fixes: 5cd29012028d
> Bug: https://bugzilla.kernel.org/show_bug.cgi?id=216412
> Bug: https://bugzilla.redhat.com/show_bug.cgi?id=2121844
> Signed-off-by: Eugene Shalygin <eugene.shalygin@xxxxxxxxx>
> ---
> drivers/hwmon/asus-ec-sensors.c | 413 ++++++++++++++++++--------------
> 1 file changed, 227 insertions(+), 186 deletions(-)
>
> diff --git a/drivers/hwmon/asus-ec-sensors.c b/drivers/hwmon/asus-ec-sensors.c
> index 61a4684fc020..206265ea8122 100644
> --- a/drivers/hwmon/asus-ec-sensors.c
> +++ b/drivers/hwmon/asus-ec-sensors.c

[ ... ]

> +
> +static void cleanup_device(void)
> +{
> + platform_device_unregister(asus_ec_sensors_platform_device);
> + platform_driver_unregister(&asus_ec_sensors_platform_driver);
> +}
> +
> +static int __init asus_ec_init(void)
> +{
> + asus_ec_sensors_platform_device =
> + platform_create_bundle(&asus_ec_sensors_platform_driver,
> + asus_ec_probe, NULL, 0, NULL, 0);
> +
> + if (IS_ERR(asus_ec_sensors_platform_device))
> + return PTR_ERR(asus_ec_sensors_platform_device);
> +
> + return 0;
> +}
> +
> +static void __exit asus_ec_exit(void)
> +{
> + cleanup_device();

I don't see the point of that extra function. Please drop and call
platform_device_unregister() as well as platform_driver_unregister()
directly.

> +}
> +
> +module_init(asus_ec_init);
> +module_exit(asus_ec_exit);
>
> module_param_named(mutex_path, mutex_path_override, charp, 0);
> MODULE_PARM_DESC(mutex_path,
> --
> 2.37.3
>