* Re: [PATCH v6 01/10] mhi: Add mhi_controller_initialize helper
[not found] ` <1609231431-10048-2-git-send-email-loic.poulain@linaro.org>
@ 2020-12-31 6:48 ` Manivannan Sadhasivam
0 siblings, 0 replies; only message in thread
From: Manivannan Sadhasivam @ 2020-12-31 6:48 UTC (permalink / raw)
To: Loic Poulain; +Cc: linux-arm-msm, ath11k, bbhatt, kvalo, hemantk
Hi Loic,
+ath11k, kalle
On Tue, Dec 29, 2020 at 09:43:42AM +0100, Loic Poulain wrote:
> This function allows to initialize a mhi_controller structure.
> Today, it only zeroing the structure.
>
> Use this function from mhi_alloc_controller so that any further
> initialization can be factorized in initalize function.
>
I know that this has been discussed in earlier revisions but I'm still not
convinced to have 2 APIs doing a similar job. Since we don't have any usecase
currently to initialize extra fields other than the struct, we should be using
the alloc_controller API.
If you want to have a devres managed allocation, then the API should be extended
as below:
struct mhi_controller *mhi_alloc_controller(struct device *dev)
{
struct mhi_controller *mhi_cntrl;
if (!dev)
mhi_cntrl = kzalloc(sizeof(*mhi_cntrl), GFP_KERNEL);
else
mhi_cntrl = devm_kzalloc(dev, sizeof(*mhi_cntrl), GFP_KERNEL);
return mhi_cntrl;
}
In this case, the ath11k MHI controller also need to be adjusted but we can use
the same immutable branch way.
Thanks,
Mani
> Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
> ---
> drivers/bus/mhi/core/init.c | 6 ++++++
> include/linux/mhi.h | 6 ++++++
> 2 files changed, 12 insertions(+)
>
> diff --git a/drivers/bus/mhi/core/init.c b/drivers/bus/mhi/core/init.c
> index 96cde9c..a75ab8c 100644
> --- a/drivers/bus/mhi/core/init.c
> +++ b/drivers/bus/mhi/core/init.c
> @@ -1021,6 +1021,12 @@ void mhi_unregister_controller(struct mhi_controller *mhi_cntrl)
> }
> EXPORT_SYMBOL_GPL(mhi_unregister_controller);
>
> +void mhi_initialize_controller(struct mhi_controller *mhi_cntrl)
> +{
> + memset(mhi_cntrl, 0, sizeof(*mhi_cntrl));
> +}
> +EXPORT_SYMBOL_GPL(mhi_initialize_controller);
> +
> struct mhi_controller *mhi_alloc_controller(void)
> {
> struct mhi_controller *mhi_cntrl;
> diff --git a/include/linux/mhi.h b/include/linux/mhi.h
> index 04cf7f3..2754742 100644
> --- a/include/linux/mhi.h
> +++ b/include/linux/mhi.h
> @@ -537,6 +537,12 @@ struct mhi_driver {
> #define to_mhi_device(dev) container_of(dev, struct mhi_device, dev)
>
> /**
> + * mhi_initialize_controller - Initialize MHI Controller structure
> + * @mhi_cntrl: MHI controller structure to initialize
> + */
> +void mhi_initialize_controller(struct mhi_controller *mhi_cntrl);
> +
> +/**
> * mhi_alloc_controller - Allocate the MHI Controller structure
> * Allocate the mhi_controller structure using zero initialized memory
> */
> --
> 2.7.4
>
--
ath11k mailing list
ath11k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath11k
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-12-31 6:48 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <1609231431-10048-1-git-send-email-loic.poulain@linaro.org>
[not found] ` <1609231431-10048-2-git-send-email-loic.poulain@linaro.org>
2020-12-31 6:48 ` [PATCH v6 01/10] mhi: Add mhi_controller_initialize helper Manivannan Sadhasivam
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).