linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/5] platform/chrome: cros_ec_lpc: Move mec_init/destroy to device probe/remove
@ 2022-10-28 21:14 Brian Norris
  2022-10-28 21:14 ` [PATCH 2/5] platform/chrome: cros_ec_lpc: Mark PROBE_PREFER_ASYNCHRONOUS Brian Norris
                   ` (6 more replies)
  0 siblings, 7 replies; 10+ messages in thread
From: Brian Norris @ 2022-10-28 21:14 UTC (permalink / raw)
  To: Benson Leung, Guenter Roeck; +Cc: chrome-platform, linux-kernel, Brian Norris

Disregarding the weird global state hiding in this cros_ec_lpc_mec_*()
stuff, it belongs in device probe/remove. We shouldn't assume we can
access hardware resources when the device isn't attached to the driver.

Signed-off-by: Brian Norris <briannorris@chromium.org>
---

 drivers/platform/chrome/cros_ec_lpc.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/platform/chrome/cros_ec_lpc.c b/drivers/platform/chrome/cros_ec_lpc.c
index 7677ab3c0ead..0b6c7c912ec7 100644
--- a/drivers/platform/chrome/cros_ec_lpc.c
+++ b/drivers/platform/chrome/cros_ec_lpc.c
@@ -354,6 +354,9 @@ static int cros_ec_lpc_probe(struct platform_device *pdev)
 		return -EBUSY;
 	}
 
+	cros_ec_lpc_mec_init(EC_HOST_CMD_REGION0,
+			     EC_LPC_ADDR_MEMMAP + EC_MEMMAP_SIZE);
+
 	/*
 	 * Read the mapped ID twice, the first one is assuming the
 	 * EC is a Microchip Embedded Controller (MEC) variant, if the
@@ -456,6 +459,8 @@ static int cros_ec_lpc_remove(struct platform_device *pdev)
 
 	cros_ec_unregister(ec_dev);
 
+	cros_ec_lpc_mec_destroy();
+
 	return 0;
 }
 
@@ -586,9 +591,6 @@ static int __init cros_ec_lpc_init(void)
 		return -ENODEV;
 	}
 
-	cros_ec_lpc_mec_init(EC_HOST_CMD_REGION0,
-			     EC_LPC_ADDR_MEMMAP + EC_MEMMAP_SIZE);
-
 	/* Register the driver */
 	ret = platform_driver_register(&cros_ec_lpc_driver);
 	if (ret) {
@@ -615,7 +617,6 @@ static void __exit cros_ec_lpc_exit(void)
 	if (!cros_ec_lpc_acpi_device_found)
 		platform_device_unregister(&cros_ec_lpc_device);
 	platform_driver_unregister(&cros_ec_lpc_driver);
-	cros_ec_lpc_mec_destroy();
 }
 
 module_init(cros_ec_lpc_init);
-- 
2.38.1.273.g43a17bfeac-goog


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2022-11-02 12:30 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-28 21:14 [PATCH 1/5] platform/chrome: cros_ec_lpc: Move mec_init/destroy to device probe/remove Brian Norris
2022-10-28 21:14 ` [PATCH 2/5] platform/chrome: cros_ec_lpc: Mark PROBE_PREFER_ASYNCHRONOUS Brian Norris
2022-10-28 21:14 ` [PATCH 3/5] platform/chrome: cros_ec_debugfs: Set PROBE_PREFER_ASYNCHRONOUS Brian Norris
2022-10-28 21:14 ` [PATCH 4/5] platform/chrome: cros_ec_lightbar: " Brian Norris
2022-10-28 21:14 ` [PATCH 5/5] platform/chrome: cros_ec_spi: " Brian Norris
2022-10-31  4:55 ` [PATCH 1/5] platform/chrome: cros_ec_lpc: Move mec_init/destroy to device probe/remove Tzung-Bi Shih
2022-10-31  5:14   ` Tzung-Bi Shih
2022-10-31 16:42   ` Brian Norris
2022-11-02  4:30 ` patchwork-bot+chrome-platform
2022-11-02 12:30 ` patchwork-bot+chrome-platform

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 NNTP newsgroup(s).