[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20181218160445.GA32237@e107155-lin>
Date: Tue, 18 Dec 2018 16:04:45 +0000
From: Sudeep Holla <sudeep.holla@....com>
To: Thierry Reding <thierry.reding@...il.com>
Cc: Jassi Brar <jassisinghbrar@...il.com>,
linux-kernel@...r.kernel.org, Andy Gospodarek <gospo@...adcom.com>,
Anup Patel <anup.patel@...adcom.com>,
Bjorn Andersson <bjorn.andersson@...aro.org>,
Caesar Wang <wxt@...k-chips.com>, CK Hu <ck.hu@...iatek.com>,
Dong Aisheng <aisheng.dong@....com>, Duc Dang <dhdang@....com>,
Eric Anholt <eric@...olt.net>,
Fabien Dessenne <fabien.dessenne@...com>,
Feng Kan <fkan@....com>,
Florian Fainelli <f.fainelli@...il.com>,
Georgi Djakov <georgi.djakov@...aro.org>,
Houlong Wei <houlong.wei@...iatek.com>,
HS Liao <hs.liao@...iatek.com>,
Jon Mason <jon.mason@...adcom.com>,
Kaihua Zhong <zhongkaihua@...wei.com>,
Kevin Wangtao <kevin.wangtao@...ilicon.com>,
Lee Jones <lee.jones@...aro.org>, Leo Yan <leo.yan@...aro.org>,
Ley Foon Tan <lftan@...era.com>,
Ludovic Barre <ludovic.barre@...com>,
Neil Armstrong <narmstrong@...libre.com>,
Nishanth Menon <nm@...com>,
Oleksij Rempel <o.rempel@...gutronix.de>,
Ray Jui <ray.jui@...adcom.com>,
Rob Rice <rob.rice@...adcom.com>,
Ruyi Wang <wangruyi@...wei.com>,
Scott Branden <scott.branden@...adcom.com>,
Sibi Sankar <sibis@...eaurora.org>,
Stefan Wahren <stefan.wahren@...e.com>,
Steve Lin <steven.lin1@...adcom.com>,
Suman Anna <s-anna@...com>, Tony Lindgren <tony@...mide.com>,
Vikram Prakash <vikram.prakash@...adcom.com>,
Vladimir Zapolskiy <vz@...ia.com>,
Sudeep Holla <sudeep.holla@....com>
Subject: Re: [PATCH v2 01/19] mailbox: Add device-managed registration
functions
On Mon, Dec 17, 2018 at 04:01:59PM +0100, Thierry Reding wrote:
> From: Thierry Reding <treding@...dia.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@...dia.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@....com>
--
Regards,
Sudeep
Powered by blists - more mailing lists