public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	linux-kernel@vger.kernel.org
Cc: Lee Jones <lee@kernel.org>
Subject: [PATCH v1 1/6] mfd: kempld: Replace ACPI code with agnostic one
Date: Fri, 23 Feb 2024 21:49:50 +0200	[thread overview]
Message-ID: <20240223195113.880121-2-andriy.shevchenko@linux.intel.com> (raw)
In-Reply-To: <20240223195113.880121-1-andriy.shevchenko@linux.intel.com>

There is no need to include and use entire ACPI stack in the driver.
Replace respective pieces by agnostic code. No functional change
indented.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/mfd/kempld-core.c | 38 +++++++++++---------------------------
 1 file changed, 11 insertions(+), 27 deletions(-)

diff --git a/drivers/mfd/kempld-core.c b/drivers/mfd/kempld-core.c
index 5557f023a173..99c8656e723c 100644
--- a/drivers/mfd/kempld-core.c
+++ b/drivers/mfd/kempld-core.c
@@ -9,11 +9,12 @@
 #include <linux/platform_device.h>
 #include <linux/mfd/core.h>
 #include <linux/mfd/kempld.h>
+#include <linux/mod_devicetable.h>
 #include <linux/module.h>
+#include <linux/property.h>
 #include <linux/dmi.h>
 #include <linux/io.h>
 #include <linux/delay.h>
-#include <linux/acpi.h>
 
 #define MAX_ID_LEN 4
 static char force_device_id[MAX_ID_LEN + 1] = "";
@@ -425,26 +426,6 @@ static int kempld_detect_device(struct kempld_device_data *pld)
 	return ret;
 }
 
-#ifdef CONFIG_ACPI
-static int kempld_get_acpi_data(struct platform_device *pdev)
-{
-	struct device *dev = &pdev->dev;
-	const struct kempld_platform_data *pdata;
-	int ret;
-
-	pdata = acpi_device_get_match_data(dev);
-	ret = platform_device_add_data(pdev, pdata,
-				       sizeof(struct kempld_platform_data));
-
-	return ret;
-}
-#else
-static int kempld_get_acpi_data(struct platform_device *pdev)
-{
-	return -ENODEV;
-}
-#endif /* CONFIG_ACPI */
-
 static int kempld_probe(struct platform_device *pdev)
 {
 	const struct kempld_platform_data *pdata;
@@ -458,10 +439,16 @@ static int kempld_probe(struct platform_device *pdev)
 		 * No kempld_pdev device has been registered in kempld_init,
 		 * so we seem to be probing an ACPI platform device.
 		 */
-		ret = kempld_get_acpi_data(pdev);
+		pdata = device_get_match_data(dev);
+		if (!pdata)
+			return -ENODEV;
+
+		ret = platform_device_add_data(pdev, pdata, sizeof(*pdata));
 		if (ret)
 			return ret;
-	} else if (kempld_pdev != pdev) {
+	} else if (kempld_pdev == pdev) {
+		pdata = dev_get_platdata(dev);
+	} else {
 		/*
 		 * The platform device we are probing is not the one we
 		 * registered in kempld_init using the DMI table, so this one
@@ -472,7 +459,6 @@ static int kempld_probe(struct platform_device *pdev)
 		dev_notice(dev, "platform device exists - not using ACPI\n");
 		return -ENODEV;
 	}
-	pdata = dev_get_platdata(dev);
 
 	pld = devm_kzalloc(dev, sizeof(*pld), GFP_KERNEL);
 	if (!pld)
@@ -509,19 +495,17 @@ static void kempld_remove(struct platform_device *pdev)
 	pdata->release_hardware_mutex(pld);
 }
 
-#ifdef CONFIG_ACPI
 static const struct acpi_device_id kempld_acpi_table[] = {
 	{ "KEM0000", (kernel_ulong_t)&kempld_platform_data_generic },
 	{ "KEM0001", (kernel_ulong_t)&kempld_platform_data_generic },
 	{}
 };
 MODULE_DEVICE_TABLE(acpi, kempld_acpi_table);
-#endif
 
 static struct platform_driver kempld_driver = {
 	.driver		= {
 		.name	= "kempld",
-		.acpi_match_table = ACPI_PTR(kempld_acpi_table),
+		.acpi_match_table = kempld_acpi_table,
 	},
 	.probe		= kempld_probe,
 	.remove_new	= kempld_remove,
-- 
2.43.0.rc1.1.gbec44491f096


  reply	other threads:[~2024-02-23 19:51 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-23 19:49 [PATCH v1 0/6] mfd: kempld: A few cleanups Andy Shevchenko
2024-02-23 19:49 ` Andy Shevchenko [this message]
2024-02-23 19:49 ` [PATCH v1 2/6] mfd: kempld: Use device core to create driver-specific device attributes Andy Shevchenko
2024-02-23 19:49 ` [PATCH v1 3/6] mfd: kempld: Simplify device registration Andy Shevchenko
2024-02-23 19:49 ` [PATCH v1 4/6] mfd: kempld: Use PLATFORM_DEVID_NONE instead of -1 Andy Shevchenko
2024-02-23 19:49 ` [PATCH v1 5/6] mfd: kempld: Drop duplicate NULL check in ->exit() Andy Shevchenko
2024-02-23 19:49 ` [PATCH v1 6/6] mfd: kempld: Remove dead code Andy Shevchenko
2024-04-02 15:31 ` [PATCH v1 0/6] mfd: kempld: A few cleanups Andy Shevchenko
2024-04-11  9:29   ` Lee Jones
2024-04-11 10:20     ` Andy Shevchenko
2024-04-11 10:56       ` Lee Jones
2024-04-11 12:12         ` Andy Shevchenko
2024-04-11 10:10 ` Lee Jones

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240223195113.880121-2-andriy.shevchenko@linux.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=lee@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox