chrome-platform.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Ben Walsh <ben@jubnut.com>
To: "Benson Leung" <bleung@chromium.org>,
	"Tzung-Bi Shih" <tzungbi@kernel.org>,
	"Guenter Roeck" <groeck@chromium.org>,
	"Dustin L. Howett" <dustin@howett.net>,
	"Kieran Levin" <ktl@frame.work>,
	"Thomas Weißschuh" <linux@weissschuh.net>,
	"Mario Limonciello" <mario.limonciello@amd.com>,
	chrome-platform@lists.linux.dev, linux-kernel@vger.kernel.org
Cc: Ben Walsh <ben@jubnut.com>
Subject: [PATCH 3/6] platform/chrome: cros_ec_lpc: Pass driver_data in static variable
Date: Wed, 15 May 2024 06:56:28 +0100	[thread overview]
Message-ID: <20240515055631.5775-4-ben@jubnut.com> (raw)
In-Reply-To: <20240515055631.5775-1-ben@jubnut.com>

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(-)

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) {
-- 
2.45.0


  parent reply	other threads:[~2024-05-15  5:56 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-15  5:56 [PATCH 0/6] Fix MEC concurrency problems for Framework Laptop Ben Walsh
2024-05-15  5:56 ` [PATCH 1/6] platform/chrome: cros_ec_lpc: MEC access can return error code Ben Walsh
2024-05-20  9:45   ` Tzung-Bi Shih
2024-05-15  5:56 ` [PATCH 2/6] platform/chrome: cros_ec_lpc: MEC access can use an AML mutex Ben Walsh
2024-05-20  9:46   ` Tzung-Bi Shih
2024-05-15  5:56 ` Ben Walsh [this message]
2024-05-20  9:46   ` [PATCH 3/6] platform/chrome: cros_ec_lpc: Pass driver_data in static variable Tzung-Bi Shih
2024-05-15  5:56 ` [PATCH 4/6] platform/chrome: cros_ec_lpc: Add a new quirk for AML mutex Ben Walsh
2024-05-15  5:56 ` [PATCH 5/6] platform/chrome: cros_ec_lpc: Correct ACPI name for Framework Laptop Ben Walsh
2024-05-20  9:47   ` Tzung-Bi Shih
2024-05-23 18:42     ` Ben Walsh
2024-05-24  2:26       ` Tzung-Bi Shih
2024-05-24 18:35         ` Ben Walsh
2024-05-24 18:39           ` Dustin Howett
2024-05-24 18:45             ` Ben Walsh
2024-05-26  1:26           ` Tzung-Bi Shih
2024-05-27 18:06             ` Ben Walsh
2024-05-28  3:08               ` Tzung-Bi Shih
2024-05-15  5:56 ` [PATCH 6/6] platform/chrome: cros_ec_lpc: Add AML mutex " Ben Walsh

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=20240515055631.5775-4-ben@jubnut.com \
    --to=ben@jubnut.com \
    --cc=bleung@chromium.org \
    --cc=chrome-platform@lists.linux.dev \
    --cc=dustin@howett.net \
    --cc=groeck@chromium.org \
    --cc=ktl@frame.work \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@weissschuh.net \
    --cc=mario.limonciello@amd.com \
    --cc=tzungbi@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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).