linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sudeep Holla <sudeep.holla@arm.com>
To: Thierry Reding <thierry.reding@gmail.com>
Cc: Jassi Brar <jassisinghbrar@gmail.com>,
	linux-kernel@vger.kernel.org,
	Andy Gospodarek <gospo@broadcom.com>,
	Anup Patel <anup.patel@broadcom.com>,
	Bjorn Andersson <bjorn.andersson@linaro.org>,
	Caesar Wang <wxt@rock-chips.com>, CK Hu <ck.hu@mediatek.com>,
	Dong Aisheng <aisheng.dong@nxp.com>, Duc Dang <dhdang@apm.com>,
	Eric Anholt <eric@anholt.net>,
	Fabien Dessenne <fabien.dessenne@st.com>, Feng Kan <fkan@apm.com>,
	Florian Fainelli <f.fainelli@gmail.com>,
	Georgi Djakov <georgi.djakov@linaro.org>,
	Houlong Wei <houlong.wei@mediatek.com>,
	HS Liao <hs.liao@mediatek.com>,
	Jon Mason <jon.mason@broadcom.com>,
	Kaihua Zhong <zhongkaihua@huawei.com>,
	Kevin Wangtao <kevin.wangtao@hisilicon.com>,
	Lee Jones <lee.jones@linaro.org>, Leo Yan <leo.yan@linaro.org>,
	Ley Foon Tan <lftan@altera.com>,
	Ludovic Barre <ludovic.barre@st.com>,
	Neil Armstrong <narmstrong@baylibre.com>,
	Nishanth Menon <nm@ti.com>,
	Oleksij Rempel <o.rempel@pengutronix.de>,
	Ray Jui <ray.jui@broadcom.com>, Rob Rice <rob.rice@broadcom.com>,
	Ruyi Wang <wangruyi@huawei.com>,
	Scott Branden <scott.branden@broadcom.com>,
	Sibi Sankar <sibis@codeaurora.org>,
	Stefan Wahren <stefan.wahren@i2se.com>,
	Steve Lin <steven.lin1@broadcom.com>, Suman Anna <s-anna@ti.com>,
	Tony Lindgren <tony@atomide.com>,
	Vikram Prakash <vikram.prakash@broadcom.com>,
	Vladimir Zapolskiy <vz@mleia.com>,
	Sudeep Holla <sudeep.holla@arm.com>
Subject: Re: [PATCH v2 01/19] mailbox: Add device-managed registration functions
Date: Tue, 18 Dec 2018 16:04:45 +0000	[thread overview]
Message-ID: <20181218160445.GA32237@e107155-lin> (raw)
In-Reply-To: <20181217150217.32435-2-thierry.reding@gmail.com>

On Mon, Dec 17, 2018 at 04:01:59PM +0100, Thierry Reding wrote:
> From: Thierry Reding <treding@nvidia.com>
> 
> Add device-managed equivalents of the mbox_controller_register() and
> mbox_controller_unregister() functions that can be used to have the
> devres infrastructure automatically unregister mailbox controllers on
> driver probe failure or driver removal. This can help remove a lot of
> boiler plate code from drivers.
> 
> Signed-off-by: Thierry Reding <treding@nvidia.com>
> ---
>  drivers/mailbox/mailbox.c          | 70 ++++++++++++++++++++++++++++++
>  include/linux/mailbox_controller.h |  5 +++
>  2 files changed, 75 insertions(+)
> 
> diff --git a/drivers/mailbox/mailbox.c b/drivers/mailbox/mailbox.c
> index 674b35f402f5..eb781e2b19cb 100644
> --- a/drivers/mailbox/mailbox.c
> +++ b/drivers/mailbox/mailbox.c
> @@ -515,3 +515,73 @@ void mbox_controller_unregister(struct mbox_controller *mbox)
>  	mutex_unlock(&con_mutex);
>  }
>  EXPORT_SYMBOL_GPL(mbox_controller_unregister);
> +
> +static void __devm_mbox_controller_unregister(struct device *dev, void *res)
> +{
> +	struct mbox_controller *mbox = res;
> +
> +	mbox_controller_unregister(mbox);

This looks wrong to me. See below for details.

[...]

> +int devm_mbox_controller_register(struct device *dev,
> +				  struct mbox_controller *mbox)
> +{
> +	struct mbox_controller **ptr;
> +	int err;
> +
> +	ptr = devres_alloc(__devm_mbox_controller_unregister, sizeof(*ptr),
> +			   GFP_KERNEL);

devres_alloc returns devres->data as ptr above

> +	if (!ptr)
> +		return -ENOMEM;
> +
> +	err = mbox_controller_register(mbox);
> +	if (err < 0) {
> +		devres_free(ptr);
> +		return err;
> +	}
> +
> +	devres_add(dev, ptr);
> +	*ptr = mbox;

And ...release is called with devres->data so we need *ptr
in devm_mbox_controller_unregister and not ptr itself something like:

	struct mbox_controller **mbox = res;
	mbox_controller_unregister(*mbox);

With above fixed:

Reviewed-by: Sudeep Holla <sudeep.holla@arm.com>

--
Regards,
Sudeep


  parent reply	other threads:[~2018-12-18 16:05 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-17 15:01 [PATCH v2 00/19] mailbox: Device-managed registration Thierry Reding
2018-12-17 15:01 ` [PATCH v2 01/19] mailbox: Add device-managed registration functions Thierry Reding
2018-12-17 18:15   ` Bjorn Andersson
2018-12-18 16:04   ` Sudeep Holla [this message]
2018-12-17 15:02 ` [PATCH v2 02/19] mailbox: arm-mhu: Use device-managed registration API Thierry Reding
2018-12-18 16:07   ` Sudeep Holla
2018-12-17 15:02 ` [PATCH v2 03/19] mailbox: bcm2835: " Thierry Reding
2018-12-18 19:24   ` Eric Anholt
2018-12-17 15:02 ` [PATCH v2 04/19] mailbox: bcm-flexrm: " Thierry Reding
2018-12-17 15:02 ` [PATCH v2 05/19] mailbox: bcm-pdc: " Thierry Reding
2018-12-17 15:02 ` [PATCH v2 06/19] mailbox: hi3660: " Thierry Reding
2018-12-18  9:16   ` leo.yan
2018-12-17 15:02 ` [PATCH v2 07/19] mailbox: hi6220: " Thierry Reding
2018-12-18  9:17   ` leo.yan
2018-12-17 15:02 ` [PATCH v2 08/19] mailbox: imx: " Thierry Reding
2018-12-17 15:31   ` Oleksij Rempel
2018-12-17 15:02 ` [PATCH v2 09/19] mailbox: altera: " Thierry Reding
2018-12-17 15:02 ` [PATCH v2 10/19] mailbox: sti: " Thierry Reding
2018-12-18  8:27   ` Lee Jones
2018-12-17 15:02 ` [PATCH v2 11/19] mailbox: xgene-slimpro: " Thierry Reding
2018-12-17 15:02 ` [PATCH v2 12/19] mailbox: mtk-cmdq: " Thierry Reding
2018-12-17 15:02 ` [PATCH v2 13/19] mailbox: mtk-cmdq: Remove needless devm_kfree() calls Thierry Reding
2018-12-17 15:02 ` [PATCH v2 14/19] mailbox: omap: Use device-managed registration API Thierry Reding
2018-12-18  0:10   ` kbuild test robot
2018-12-17 15:02 ` [PATCH v2 15/19] mailbox: platform-mhu: " Thierry Reding
2018-12-17 15:04   ` Neil Armstrong
2018-12-17 15:02 ` [PATCH v2 16/19] mailbox: qcom-apcs: " Thierry Reding
2018-12-17 18:16   ` Bjorn Andersson
2018-12-17 15:02 ` [PATCH v2 17/19] mailbox: rockchip: " Thierry Reding
2018-12-18  0:36   ` Caesar Wang
2018-12-17 15:02 ` [PATCH v2 18/19] mailbox: stm32-ipcc: " Thierry Reding
2018-12-18  8:26   ` Ludovic BARRE
2018-12-17 15:02 ` [PATCH v2 19/19] mailbox: ti-msgmgr: " Thierry Reding

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=20181218160445.GA32237@e107155-lin \
    --to=sudeep.holla@arm.com \
    --cc=aisheng.dong@nxp.com \
    --cc=anup.patel@broadcom.com \
    --cc=bjorn.andersson@linaro.org \
    --cc=ck.hu@mediatek.com \
    --cc=dhdang@apm.com \
    --cc=eric@anholt.net \
    --cc=f.fainelli@gmail.com \
    --cc=fabien.dessenne@st.com \
    --cc=fkan@apm.com \
    --cc=georgi.djakov@linaro.org \
    --cc=gospo@broadcom.com \
    --cc=houlong.wei@mediatek.com \
    --cc=hs.liao@mediatek.com \
    --cc=jassisinghbrar@gmail.com \
    --cc=jon.mason@broadcom.com \
    --cc=kevin.wangtao@hisilicon.com \
    --cc=lee.jones@linaro.org \
    --cc=leo.yan@linaro.org \
    --cc=lftan@altera.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ludovic.barre@st.com \
    --cc=narmstrong@baylibre.com \
    --cc=nm@ti.com \
    --cc=o.rempel@pengutronix.de \
    --cc=ray.jui@broadcom.com \
    --cc=rob.rice@broadcom.com \
    --cc=s-anna@ti.com \
    --cc=scott.branden@broadcom.com \
    --cc=sibis@codeaurora.org \
    --cc=stefan.wahren@i2se.com \
    --cc=steven.lin1@broadcom.com \
    --cc=thierry.reding@gmail.com \
    --cc=tony@atomide.com \
    --cc=vikram.prakash@broadcom.com \
    --cc=vz@mleia.com \
    --cc=wangruyi@huawei.com \
    --cc=wxt@rock-chips.com \
    --cc=zhongkaihua@huawei.com \
    /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 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).