diff options
| author | Tzung-Bi Shih <tzungbi@kernel.org> | 2025-08-28 08:35:57 +0000 |
|---|---|---|
| committer | Tzung-Bi Shih <tzungbi@kernel.org> | 2025-09-14 11:34:41 +0800 |
| commit | 918856986014142271a70a334d300994b9c41720 (patch) | |
| tree | 9bd31c49c6fd2be28ed450b75ca7cbb45fb3b2f6 /drivers/platform/chrome/cros_ec.c | |
| parent | f7439a723e5aa5b35c76355e1b9b2cd1108f656e (diff) | |
platform/chrome: Centralize cros_ec_device allocation
Introduce a helper function, cros_ec_device_alloc(), to centralize the
allocation of the struct cros_ec_device. Convert all protocol device
drivers to use this new function.
This is a preparatory step for separating common initialization logic
out of device drivers' probe() and cros_ec_register().
Link: https://lore.kernel.org/r/20250828083601.856083-2-tzungbi@kernel.org
Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org>
Diffstat (limited to 'drivers/platform/chrome/cros_ec.c')
| -rw-r--r-- | drivers/platform/chrome/cros_ec.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/drivers/platform/chrome/cros_ec.c b/drivers/platform/chrome/cros_ec.c index b1730362e399..25283a148ab9 100644 --- a/drivers/platform/chrome/cros_ec.c +++ b/drivers/platform/chrome/cros_ec.c @@ -30,6 +30,18 @@ static struct cros_ec_platform pd_p = { .cmd_offset = EC_CMD_PASSTHRU_OFFSET(CROS_EC_DEV_PD_INDEX), }; +struct cros_ec_device *cros_ec_device_alloc(struct device *dev) +{ + struct cros_ec_device *ec_dev; + + ec_dev = devm_kzalloc(dev, sizeof(*ec_dev), GFP_KERNEL); + if (!ec_dev) + return NULL; + + return ec_dev; +} +EXPORT_SYMBOL(cros_ec_device_alloc); + /** * cros_ec_irq_handler() - top half part of the interrupt handler * @irq: IRQ id |