[PATCH] mfd: kempld: Switch back to earlier ->init() behavior

Heijligen, Thomas posted 1 patch 2 months, 3 weeks ago
There is a newer version of this series
drivers/mfd/kempld-core.c | 25 +++++++++++--------------
1 file changed, 11 insertions(+), 14 deletions(-)
[PATCH] mfd: kempld: Switch back to earlier ->init() behavior
Posted by Heijligen, Thomas 2 months, 3 weeks ago
Commit 9e36775c22c7 ("mfd: kempld: Remove custom DMI matching code")
removes the ability to load the driver if no matching system DMI data
is found. Before this commit the driver could be loaded using
alternative methods such as ACPI or `force_device_id` in the absence
of a matching system DMI entry.

Restore this ability while keeping the refactored
`platform_device_info` table.

Signed-off-by: Thomas Heijligen <thomas.heijligen@secunet.com>
---
 drivers/mfd/kempld-core.c | 25 +++++++++++--------------
 1 file changed, 11 insertions(+), 14 deletions(-)

diff --git a/drivers/mfd/kempld-core.c b/drivers/mfd/kempld-core.c
index c5bfb6440a93..b0ddceae3864 100644
--- a/drivers/mfd/kempld-core.c
+++ b/drivers/mfd/kempld-core.c
@@ -779,22 +779,19 @@ MODULE_DEVICE_TABLE(dmi, kempld_dmi_table);
 static int __init kempld_init(void)
 {
 	const struct dmi_system_id *id;
-	int ret = -ENODEV;
 
-	for (id = dmi_first_match(kempld_dmi_table); id; id = dmi_first_match(id + 1)) {
-		/* Check, if user asked for the exact device ID match */
-		if (force_device_id[0] && !strstr(id->ident, force_device_id))
-			continue;
-
-		ret = kempld_create_platform_device(&kempld_platform_data_generic);
-		if (ret)
-			continue;
-
-		break;
+	if (force_device_id[0]) {
+		for (id = kempld_dmi_table; id->matches[0].slot != DMI_NONE; id++)
+			if (strstr(id->ident, force_device_id))
+				if (!kempld_create_platform_device(&kempld_platform_data_generic))
+					break;
+		if (id->matches[0].slot == DMI_NONE)
+			return -ENODEV;
+	} else {
+		for (id = dmi_first_match(kempld_dmi_table); id; id = dmi_first_match(id+1))
+			if (kempld_create_platform_device(&kempld_platform_data_generic))
+				break;
 	}
-	if (ret)
-		return ret;
-
 	return platform_driver_register(&kempld_driver);
 }
 
-- 
2.49.0

Re: [PATCH] mfd: kempld: Switch back to earlier ->init() behavior
Posted by Lee Jones 2 months, 2 weeks ago
> Commit 9e36775c22c7 ("mfd: kempld: Remove custom DMI matching code")
> removes the ability to load the driver if no matching system DMI data
> is found. Before this commit the driver could be loaded using
> alternative methods such as ACPI or `force_device_id` in the absence
> of a matching system DMI entry.

You need to Cc the author of this change to give them a say.

> Restore this ability while keeping the refactored
> `platform_device_info` table.
> 
> Signed-off-by: Thomas Heijligen <thomas.heijligen@secunet.com>
> ---
>  drivers/mfd/kempld-core.c | 25 +++++++++++--------------
>  1 file changed, 11 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/mfd/kempld-core.c b/drivers/mfd/kempld-core.c
> index c5bfb6440a93..b0ddceae3864 100644
> --- a/drivers/mfd/kempld-core.c
> +++ b/drivers/mfd/kempld-core.c
> @@ -779,22 +779,19 @@ MODULE_DEVICE_TABLE(dmi, kempld_dmi_table);
>  static int __init kempld_init(void)
>  {
>  	const struct dmi_system_id *id;
> -	int ret = -ENODEV;
>  
> -	for (id = dmi_first_match(kempld_dmi_table); id; id = dmi_first_match(id + 1)) {
> -		/* Check, if user asked for the exact device ID match */
> -		if (force_device_id[0] && !strstr(id->ident, force_device_id))
> -			continue;
> -
> -		ret = kempld_create_platform_device(&kempld_platform_data_generic);
> -		if (ret)
> -			continue;
> -
> -		break;
> +	if (force_device_id[0]) {
> +		for (id = kempld_dmi_table; id->matches[0].slot != DMI_NONE; id++)
> +			if (strstr(id->ident, force_device_id))
> +				if (!kempld_create_platform_device(&kempld_platform_data_generic))
> +					break;
> +		if (id->matches[0].slot == DMI_NONE)
> +			return -ENODEV;
> +	} else {
> +		for (id = dmi_first_match(kempld_dmi_table); id; id = dmi_first_match(id+1))
> +			if (kempld_create_platform_device(&kempld_platform_data_generic))
> +				break;
>  	}
> -	if (ret)
> -		return ret;
> -
>  	return platform_driver_register(&kempld_driver);
>  }
>  
> -- 
> 2.49.0
> 

-- 
Lee Jones [李琼斯]
Re: [PATCH] mfd: kempld: Switch back to earlier ->init() behavior
Posted by Andy Shevchenko 2 months, 2 weeks ago
On Wed, Jul 23, 2025 at 10:56:47AM +0100, Lee Jones wrote:
> 
> > Commit 9e36775c22c7 ("mfd: kempld: Remove custom DMI matching code")
> > removes the ability to load the driver if no matching system DMI data
> > is found. Before this commit the driver could be loaded using
> > alternative methods such as ACPI or `force_device_id` in the absence
> > of a matching system DMI entry.
> 
> You need to Cc the author of this change to give them a say.

Thanks for Cc'ing me.

> > Restore this ability while keeping the refactored
> > `platform_device_info` table.

So, the error will be returned when CONFIG_DMI=n, or there is no matching entry
in the table. And the table only is filled when present in the firmware and kernel
has CONFIG_DMI=y. That's why the original code was iterating via DMI strings in
a custom way. Besides that there is an ACPI enumeration available, which is not
visible directly from that piece and hence no error should be returned if no
matches found.

Now to prevent similar patches (as mine) appear in the future, can we also add
a comment on top of the for-loop to explain all this?

With a comment added, you may add my
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

-- 
With Best Regards,
Andy Shevchenko
Re: [PATCH] mfd: kempld: Switch back to earlier ->init() behavior
Posted by Heijligen, Thomas 2 months, 1 week ago
On Wed, 2025-07-23 at 18:04 +0300, Andy Shevchenko wrote:
> On Wed, Jul 23, 2025 at 10:56:47AM +0100, Lee Jones wrote:
> > 
> > > Commit 9e36775c22c7 ("mfd: kempld: Remove custom DMI matching code")
> > > removes the ability to load the driver if no matching system DMI data
> > > is found. Before this commit the driver could be loaded using
> > > alternative methods such as ACPI or `force_device_id` in the absence
> > > of a matching system DMI entry.
> > 
> > You need to Cc the author of this change to give them a say.
> 
> Thanks for Cc'ing me.
> 
> > > Restore this ability while keeping the refactored
> > > `platform_device_info` table.
> 
> So, the error will be returned when CONFIG_DMI=n, or there is no matching entry
> in the table. And the table only is filled when present in the firmware and kernel
> has CONFIG_DMI=y. That's why the original code was iterating via DMI strings in
> a custom way. Besides that there is an ACPI enumeration available, which is not
> visible directly from that piece and hence no error should be returned if no
> matches found.
Correct
> 
> Now to prevent similar patches (as mine) appear in the future, can we also add
> a comment on top of the for-loop to explain all this?
I do this and send a v2 patch
> 
> With a comment added, you may add my
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Thanks