All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bhaumik Bhatt <bbhatt@codeaurora.org>
To: manivannan.sadhasivam@linaro.org
Cc: linux-arm-msm@vger.kernel.org, hemantk@codeaurora.org,
	jhugo@codeaurora.org, linux-kernel@vger.kernel.org,
	Bhaumik Bhatt <bbhatt@codeaurora.org>
Subject: [PATCH v7 10/11] bus: mhi: core: Introduce APIs to allocate and free the MHI controller
Date: Mon, 10 Aug 2020 15:01:04 -0700	[thread overview]
Message-ID: <1597096865-19636-11-git-send-email-bbhatt@codeaurora.org> (raw)
In-Reply-To: <1597096865-19636-1-git-send-email-bbhatt@codeaurora.org>

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.

Signed-off-by: Bhaumik Bhatt <bbhatt@codeaurora.org>
Suggested-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
---
 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 d2c0f6e..972dbf0 100644
--- a/drivers/bus/mhi/core/init.c
+++ b/drivers/bus/mhi/core/init.c
@@ -959,6 +959,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 4065762..4955634 100644
--- a/include/linux/mhi.h
+++ b/include/linux/mhi.h
@@ -530,6 +530,18 @@ struct mhi_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
  * @config: Configuration to use for the controller
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project


  parent reply	other threads:[~2020-08-10 22:02 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-10 22:00 [PATCH v7 00/11] Introduce features and debugfs/sysfs entries for MHI Bhaumik Bhatt
2020-08-10 22:00 ` [PATCH v7 01/11] bus: mhi: core: Remove double occurrence for mhi_ctrl_ev_task() declaration Bhaumik Bhatt
2020-08-10 22:00 ` [PATCH v7 02/11] bus: mhi: core: Abort suspends due to outgoing pending packets Bhaumik Bhatt
2020-08-10 22:00 ` [PATCH v7 03/11] bus: mhi: core: Use helper API to trigger a non-blocking host resume Bhaumik Bhatt
2020-08-10 22:00 ` [PATCH v7 04/11] bus: mhi: core: Trigger host resume if suspended during mhi_device_get() Bhaumik Bhatt
2020-08-10 22:00 ` [PATCH v7 05/11] bus: mhi: core: Use generic name field for an MHI device Bhaumik Bhatt
2020-08-10 22:01 ` [PATCH v7 06/11] bus: mhi: core: Introduce helper function to check device state Bhaumik Bhatt
2020-08-10 22:01 ` [PATCH v7 07/11] bus: mhi: core: Introduce counters to track MHI device state transitions Bhaumik Bhatt
2020-08-10 22:01 ` [PATCH v7 08/11] bus: mhi: core: Introduce debugfs entries for MHI Bhaumik Bhatt
2020-08-11  0:30   ` kernel test robot
2020-08-11  0:30     ` kernel test robot
2020-08-11  6:24   ` Manivannan Sadhasivam
2020-08-10 22:01 ` [PATCH v7 09/11] bus: mhi: core: Read and save device hardware information from BHI Bhaumik Bhatt
2020-08-10 22:01 ` Bhaumik Bhatt [this message]
2020-08-10 22:01 ` [PATCH v7 11/11] bus: mhi: core: Introduce sysfs entries for MHI Bhaumik Bhatt
2020-08-11  6:18   ` Manivannan Sadhasivam
2020-08-11  6:26 ` [PATCH v7 00/11] Introduce features and debugfs/sysfs " Manivannan Sadhasivam
2020-08-11 17:53   ` bbhatt
2020-08-18  9:52   ` Manivannan Sadhasivam

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1597096865-19636-11-git-send-email-bbhatt@codeaurora.org \
    --to=bbhatt@codeaurora.org \
    --cc=hemantk@codeaurora.org \
    --cc=jhugo@codeaurora.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=manivannan.sadhasivam@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.