From: Romain Perier <romain.perier@free-electrons.com>
To: PrasannaKumar Muralidharan <prasannatsmkumar@gmail.com>
Cc: dsaxena@plexity.net, mpm@selenic.com,
Herbert Xu <herbert@gondor.apana.org.au>,
Gregory Clement <gregory.clement@free-electrons.com>,
Thomas Petazzoni <thomas.petazzoni@free-electrons.com>,
Nadav Haklai <nadavh@marvell.com>, Omri Itach <omrii@marvell.com>,
Shadi Ammouri <shadi@marvell.com>,
Yahuda Yitschak <yehuday@marvell.com>,
Hanna Hawa <hannah@marvell.com>,
Neta Zur Hershkovits <neta@marvell.com>,
Igal Liberman <igall@marvell.com>,
Marcin Wojtas <mw@semihalf.com>,
linux-crypto@vger.kernel.org
Subject: Re: [PATCH 4/9] hwrng: omap - Use the managed device resource API for registration
Date: Wed, 7 Sep 2016 16:23:53 +0200 [thread overview]
Message-ID: <57D022F9.2020407@free-electrons.com> (raw)
In-Reply-To: <CANc+2y6LeOqSy37x=vXaLPkGM3C5Wh6Yq11ybO+-0DU19wLBUQ@mail.gmail.com>
Hello,
Le 06/09/2016 18:31, PrasannaKumar Muralidharan a écrit :
>> Use devm_hwrng_register instead of hwrng_register. It avoids the need
>> to handle unregistration explicitly from the remove function.
>>
>> Signed-off-by: Romain Perier <romain.perier@free-electrons.com>
>> ---
>> drivers/char/hw_random/omap-rng.c | 4 +---
>> 1 file changed, 1 insertion(+), 3 deletions(-)
>>
>> diff --git a/drivers/char/hw_random/omap-rng.c b/drivers/char/hw_random/omap-rng.c
>> index d47b24d..171c3e8 100644
>> --- a/drivers/char/hw_random/omap-rng.c
>> +++ b/drivers/char/hw_random/omap-rng.c
>> @@ -381,7 +381,7 @@ static int omap_rng_probe(struct platform_device *pdev)
>> if (ret)
>> goto err_ioremap;
>>
>> - ret = hwrng_register(&omap_rng_ops);
>> + ret = devm_hwrng_register(dev, &omap_rng_ops);
>> if (ret)
>> goto err_register;
>>
>> @@ -402,8 +402,6 @@ static int omap_rng_remove(struct platform_device *pdev)
>> {
>> struct omap_rng_dev *priv = platform_get_drvdata(pdev);
>>
>> - hwrng_unregister(&omap_rng_ops);
>> -
>> priv->pdata->cleanup(priv);
>>
>> pm_runtime_put_sync(&pdev->dev);
>> --
>
> If devm_hwrng_register is used hwrng_unregister will be called after
> pm_runtime_disable is called. If RNG device is in use calling
> omap_rng_remove may not work properly.
>
The case where the remove function is called is if you unbind the driver
by hand or you call rmmod while the RNG device is used.
I don't think that the kernel will call platform->remove is the device
is in use (so /dev/hwrng). I mean the argument that the unregister
function is called after pm_runtime_disable is correct, but I don't
think that the remove function might be called while the device is in
use. There is necessarily a mutual exclusive case between "use the
device" and "call the remove function of the device". However, I am open
to suggestions.
Regards,
--
Romain Perier, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
next prev parent reply other threads:[~2016-09-07 14:23 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-06 15:38 [PATCH 0/9] Add support for SafeXcel IP-76 to OMAP RNG Romain Perier
2016-09-06 15:38 ` [PATCH 1/9] dt-bindings: Add vendor prefix for INSIDE Secure Romain Perier
2016-09-06 15:38 ` [PATCH 2/9] dt-bindings: omap-rng: Document SafeXcel IP-76 device variant Romain Perier
2016-09-06 15:38 ` [PATCH 3/9] hwrng: omap - Switch to non-obsolete read API implementation Romain Perier
2016-09-06 15:38 ` [PATCH 4/9] hwrng: omap - Use the managed device resource API for registration Romain Perier
2016-09-06 16:31 ` PrasannaKumar Muralidharan
2016-09-07 14:23 ` Romain Perier [this message]
2016-09-07 14:45 ` PrasannaKumar Muralidharan
2016-09-07 15:38 ` Romain Perier
2016-09-08 15:47 ` Romain Perier
2016-09-08 17:02 ` Herbert Xu
2016-09-06 15:38 ` [PATCH 5/9] hwrng: omap - Remove global definition of hwrng Romain Perier
2016-09-06 15:38 ` [PATCH 6/9] hwrng: omap - Add support for 128-bit output of data Romain Perier
2016-09-06 15:38 ` [PATCH 7/9] hwrng: omap - Don't prefix the probe message with OMAP Romain Perier
2016-09-06 15:38 ` [PATCH 8/9] hwrng: omap - Add device variant for SafeXcel IP-76 found in Armada 8K Romain Perier
2016-09-06 15:38 ` [PATCH 9/9] arm64: dts: marvell: add TRNG description for Armada 8K CP Romain Perier
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=57D022F9.2020407@free-electrons.com \
--to=romain.perier@free-electrons.com \
--cc=dsaxena@plexity.net \
--cc=gregory.clement@free-electrons.com \
--cc=hannah@marvell.com \
--cc=herbert@gondor.apana.org.au \
--cc=igall@marvell.com \
--cc=linux-crypto@vger.kernel.org \
--cc=mpm@selenic.com \
--cc=mw@semihalf.com \
--cc=nadavh@marvell.com \
--cc=neta@marvell.com \
--cc=omrii@marvell.com \
--cc=prasannatsmkumar@gmail.com \
--cc=shadi@marvell.com \
--cc=thomas.petazzoni@free-electrons.com \
--cc=yehuday@marvell.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).