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

Heijligen, Thomas posted 1 patch 2 months ago
drivers/mfd/kempld-core.c | 32 ++++++++++++++++++--------------
1 file changed, 18 insertions(+), 14 deletions(-)
[PATCH v2] mfd: kempld: Switch back to earlier ->init() behavior
Posted by Heijligen, Thomas 2 months 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>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/mfd/kempld-core.c | 32 ++++++++++++++++++--------------
 1 file changed, 18 insertions(+), 14 deletions(-)

diff --git a/drivers/mfd/kempld-core.c b/drivers/mfd/kempld-core.c
index c5bfb6440a93..77980c7fc31f 100644
--- a/drivers/mfd/kempld-core.c
+++ b/drivers/mfd/kempld-core.c
@@ -779,22 +779,26 @@ 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;
+	/*
+	 * This custom DMI iteration allows the driver to be initialized in three ways:
+	 * - When a forced_device_id string matches any ident in the kempld_dmi_table,
+	 *   regardless of whether the DMI device is present in the system dmi table.
+	 * - When a matching entry is present in the DMI system tabe.
+	 * - Through alternative mechanisms like ACPI.
+	 */
+	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.50.0

Re: (subset) [PATCH v2] mfd: kempld: Switch back to earlier ->init() behavior
Posted by Lee Jones 1 month, 2 weeks ago
On Thu, 31 Jul 2025 14:45:00 +0000, Heijligen, Thomas 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.
> 
> Restore this ability while keeping the refactored
> `platform_device_info` table.
> 
> [...]

Applied, thanks!

[1/1] mfd: kempld: Switch back to earlier ->init() behavior
      commit: 5256abb7faba92e3c49dbd6aabd42f17ddf218ea

--
Lee Jones [李琼斯]

Re: (subset) [PATCH v2] mfd: kempld: Switch back to earlier ->init() behavior
Posted by Lee Jones 1 month, 2 weeks ago
On Tue, 19 Aug 2025, Lee Jones wrote:

> On Thu, 31 Jul 2025 14:45:00 +0000, Heijligen, Thomas 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.
> > 
> > Restore this ability while keeping the refactored
> > `platform_device_info` table.
> > 
> > [...]
> 
> Applied, thanks!
> 
> [1/1] mfd: kempld: Switch back to earlier ->init() behavior
>       commit: 5256abb7faba92e3c49dbd6aabd42f17ddf218ea

Not sure how you managed it, but the author doesn't match the SoB.

Suggest that you may have too many Git variables set.

This makes scripts/checkpatch.pl unhappy.  Try it out.

-- 
Lee Jones [李琼斯]