[PATCH 344/379][SRU][OEM-5.6] bus: mhi: core: Introduce APIs to allocate and free the MHI controller
You-Sheng Yang
vicamo.yang at canonical.com
Wed Dec 23 08:51:17 UTC 2020
From: Bhaumik Bhatt <bbhatt at codeaurora.org>
BugLink: https://bugs.launchpad.net/bugs/1879633
Client devices should use the APIs provided to allocate and free
the MHI controller structure. This will help ensure that the
structure is zero-initialized and there are no false positives
with respect to reading any values such as the serial number or
the OEM PK hash.
Suggested-by: Manivannan Sadhasivam <manivannan.sadhasivam at linaro.org>
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam at linaro.org>
Signed-off-by: Bhaumik Bhatt <bbhatt at codeaurora.org>
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam at linaro.org>
Link: https://lore.kernel.org/r/20200929175218.8178-11-manivannan.sadhasivam@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh at linuxfoundation.org>
(cherry picked from commit f42dfbe8f712127031e7b9bc938a1c33cec2ff57)
Signed-off-by: You-Sheng Yang <vicamo.yang at canonical.com>
---
drivers/bus/mhi/core/init.c | 16 ++++++++++++++++
include/linux/mhi.h | 12 ++++++++++++
2 files changed, 28 insertions(+)
diff --git a/drivers/bus/mhi/core/init.c b/drivers/bus/mhi/core/init.c
index e2011ec46b92..f69a2f3d039d 100644
--- a/drivers/bus/mhi/core/init.c
+++ b/drivers/bus/mhi/core/init.c
@@ -954,6 +954,22 @@ void mhi_unregister_controller(struct mhi_controller *mhi_cntrl)
}
EXPORT_SYMBOL_GPL(mhi_unregister_controller);
+struct mhi_controller *mhi_alloc_controller(void)
+{
+ struct mhi_controller *mhi_cntrl;
+
+ mhi_cntrl = kzalloc(sizeof(*mhi_cntrl), GFP_KERNEL);
+
+ return mhi_cntrl;
+}
+EXPORT_SYMBOL_GPL(mhi_alloc_controller);
+
+void mhi_free_controller(struct mhi_controller *mhi_cntrl)
+{
+ kfree(mhi_cntrl);
+}
+EXPORT_SYMBOL_GPL(mhi_free_controller);
+
int mhi_prepare_for_power_up(struct mhi_controller *mhi_cntrl)
{
struct device *dev = &mhi_cntrl->mhi_dev->dev;
diff --git a/include/linux/mhi.h b/include/linux/mhi.h
index b321d620e82f..92c3c1e441e9 100644
--- a/include/linux/mhi.h
+++ b/include/linux/mhi.h
@@ -525,6 +525,18 @@ struct mhi_driver {
#define to_mhi_driver(drv) container_of(drv, struct mhi_driver, driver)
#define to_mhi_device(dev) container_of(dev, struct mhi_device, dev)
+/**
+ * mhi_alloc_controller - Allocate the MHI Controller structure
+ * Allocate the mhi_controller structure using zero initialized memory
+ */
+struct mhi_controller *mhi_alloc_controller(void);
+
+/**
+ * mhi_free_controller - Free the MHI Controller structure
+ * Free the mhi_controller structure which was previously allocated
+ */
+void mhi_free_controller(struct mhi_controller *mhi_cntrl);
+
/**
* mhi_register_controller - Register MHI controller
* @mhi_cntrl: MHI controller to register
--
2.29.2
More information about the kernel-team
mailing list