[PATCH 4/5] mfd: cros_ec: Add a helper to retrieve the EC device from the MFD parent
From: Thomas Weißschuh
Date: Sat Apr 04 2026 - 03:56:17 EST
The 'struct cros_ec_dev' needs to be retrieved from the MFD parent
device through a non-typesafe API. This logic is duplicated over all
CrOS EC drivers and it is not obvious what is going on.
Add a dedicated helper function which makes clear what is happening.
Signed-off-by: Thomas Weißschuh <linux@xxxxxxxxxxxxxx>
---
include/linux/mfd/cros_ec.h | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/include/linux/mfd/cros_ec.h b/include/linux/mfd/cros_ec.h
new file mode 100644
index 000000000000..ea5b007accfc
--- /dev/null
+++ b/include/linux/mfd/cros_ec.h
@@ -0,0 +1,16 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+
+#ifndef __LINUX_MFD_CROS_EC_H
+#define __LINUX_MFD_CROS_EC_H
+
+#include <linux/compiler_attributes.h>
+
+struct cros_ec_dev;
+struct platform_device;
+
+static __always_inline struct cros_ec_dev *cros_ec_mfd_get_ec_dev(struct platform_device *pdev)
+{
+ return dev_get_drvdata(pdev->dev.parent);
+}
+
+#endif /* __LINUX_MFD_CROS_EC_H */
--
2.53.0