summaryrefslogtreecommitdiff
path: root/drivers/platform/chrome/cros_ec.c
diff options
context:
space:
mode:
authorTzung-Bi Shih <tzungbi@kernel.org>2025-08-28 08:35:58 +0000
committerTzung-Bi Shih <tzungbi@kernel.org>2025-09-14 11:34:41 +0800
commite19ceeb1c0f63e3e15b197c5f34797134b51ba0e (patch)
tree3737c3fd556834d10f91e43f5fb38623884984d3 /drivers/platform/chrome/cros_ec.c
parent918856986014142271a70a334d300994b9c41720 (diff)
platform/chrome: Centralize common cros_ec_device initialization
Move the common initialization from protocol device drivers into central cros_ec_device_alloc(). This removes duplicated code from each driver's probe function. The buffer sizes are now calculated once, using the maximum possible overhead required by any of the transport protocols, ensuring the allocated buffers are sufficient for all cases. Link: https://lore.kernel.org/r/20250828083601.856083-3-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.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/drivers/platform/chrome/cros_ec.c b/drivers/platform/chrome/cros_ec.c
index 25283a148ab9..da049068b6e9 100644
--- a/drivers/platform/chrome/cros_ec.c
+++ b/drivers/platform/chrome/cros_ec.c
@@ -38,6 +38,15 @@ struct cros_ec_device *cros_ec_device_alloc(struct device *dev)
if (!ec_dev)
return NULL;
+ ec_dev->din_size = sizeof(struct ec_host_response) +
+ sizeof(struct ec_response_get_protocol_info) +
+ EC_MAX_RESPONSE_OVERHEAD;
+ ec_dev->dout_size = sizeof(struct ec_host_request) +
+ sizeof(struct ec_params_rwsig_action) +
+ EC_MAX_REQUEST_OVERHEAD;
+
+ ec_dev->dev = dev;
+
return ec_dev;
}
EXPORT_SYMBOL(cros_ec_device_alloc);