diff mbox series

[3/6] platform/chrome: cros_ec_lpc: Pass driver_data in static variable

Message ID 20240515055631.5775-4-ben@jubnut.com (mailing list archive)
State Superseded
Headers show
Series Fix MEC concurrency problems for Framework Laptop | expand

Commit Message

Ben Walsh May 15, 2024, 5:56 a.m. UTC
The module init passed extra data to the driver via the driver_data of
a new platform device. But when an ACPI device already existed, no
platform device was created, so this extra data wasn't passed to the
driver.

Stop using the driver_data and use a static variable instead.

Signed-off-by: Ben Walsh <ben@jubnut.com>
---
 drivers/platform/chrome/cros_ec_lpc.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

Comments

Tzung-Bi Shih May 20, 2024, 9:46 a.m. UTC | #1
On Wed, May 15, 2024 at 06:56:28AM +0100, Ben Walsh wrote:
> The module init passed extra data to the driver via the driver_data of
> a new platform device. But when an ACPI device already existed, no
> platform device was created, so this extra data wasn't passed to the
> driver.
> 
> Stop using the driver_data and use a static variable instead.

Could it be possible to put the driver data in the acpi_device_id and
somewhere calls acpi_device_get_match_data()?
diff mbox series

Patch

diff --git a/drivers/platform/chrome/cros_ec_lpc.c b/drivers/platform/chrome/cros_ec_lpc.c
index e638c7d82e22..b27519fbdf58 100644
--- a/drivers/platform/chrome/cros_ec_lpc.c
+++ b/drivers/platform/chrome/cros_ec_lpc.c
@@ -76,6 +76,8 @@  struct lpc_driver_ops {
 
 static struct lpc_driver_ops cros_ec_lpc_ops = { };
 
+static const struct lpc_driver_data *cros_ec_lpc_driver_data;
+
 /*
  * A generic instance of the read function of struct lpc_driver_ops, used for
  * the LPC EC.
@@ -435,7 +437,6 @@  static int cros_ec_lpc_probe(struct platform_device *pdev)
 	acpi_status status;
 	struct cros_ec_device *ec_dev;
 	struct cros_ec_lpc *ec_lpc;
-	struct lpc_driver_data *driver_data;
 	u8 buf[2] = {};
 	int irq, ret;
 	u32 quirks;
@@ -446,15 +447,15 @@  static int cros_ec_lpc_probe(struct platform_device *pdev)
 
 	ec_lpc->mmio_memory_base = EC_LPC_ADDR_MEMMAP;
 
-	driver_data = platform_get_drvdata(pdev);
-	if (driver_data) {
-		quirks = driver_data->quirks;
+	if (cros_ec_lpc_driver_data) {
+		quirks = cros_ec_lpc_driver_data->quirks;
 
 		if (quirks)
 			dev_info(dev, "loaded with quirks %8.08x\n", quirks);
 
 		if (quirks & CROS_EC_LPC_QUIRK_REMAP_MEMORY)
-			ec_lpc->mmio_memory_base = driver_data->quirk_mmio_memory_base;
+			ec_lpc->mmio_memory_base
+				= cros_ec_lpc_driver_data->quirk_mmio_memory_base;
 	}
 
 	/*
@@ -735,7 +736,10 @@  static int __init cros_ec_lpc_init(void)
 
 	dmi_match = dmi_first_match(cros_ec_lpc_dmi_table);
 
-	if (!cros_ec_lpc_acpi_device_found && !dmi_match) {
+	if (dmi_match) {
+		/* Pass the DMI match's driver data down to the platform device */
+		cros_ec_lpc_driver_data = dmi_match->driver_data;
+	} else if (!cros_ec_lpc_acpi_device_found) {
 		pr_err(DRV_NAME ": unsupported system.\n");
 		return -ENODEV;
 	}
@@ -748,9 +752,6 @@  static int __init cros_ec_lpc_init(void)
 	}
 
 	if (!cros_ec_lpc_acpi_device_found) {
-		/* Pass the DMI match's driver data down to the platform device */
-		platform_set_drvdata(&cros_ec_lpc_device, dmi_match->driver_data);
-
 		/* Register the device, and it'll get hooked up automatically */
 		ret = platform_device_register(&cros_ec_lpc_device);
 		if (ret) {