From: Jonathan Cameron <jic23@kernel.org>
To: Julia Lawall <julia.lawall@lip6.fr>
Cc: Himangi Saraogi <himangi774@gmail.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-iio@vger.kernel.org, devel@driverdev.osuosl.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] staging: iio: ad9832: Use devm_iio_device_register
Date: Sun, 03 Aug 2014 14:22:45 +0100 [thread overview]
Message-ID: <c6110228-a107-4a63-9e09-620b688d7fc1@email.android.com> (raw)
In-Reply-To: <alpine.DEB.2.02.1408031243500.2000@localhost6.localdomain6>
On August 3, 2014 11:45:00 AM GMT+01:00, Julia Lawall <julia.lawall@lip6.fr> wrote:
>
>
>On Sun, 3 Aug 2014, Jonathan Cameron wrote:
>
>>
>>
>> On August 3, 2014 10:56:58 AM GMT+01:00, Himangi Saraogi
><himangi774@gmail.com> wrote:
>> >This patch introduces the use of devm_iio_device_register and does
>away
>> >with the unregister in the remove function.
>> >
>> And changes the resulting ordering so the regulator disable occurs
>before the user
>> space interface has been removed by the unregister.
>>
>> Please be very wary of using devm_iio_register. It is only correct if
>the remove function does nothing else.
>
>I wonder if there could be a way to document these constraints?
Perhaps though the simple rule of not doing anything that results in the remove sequence
not being the mirror image of the probe covers most cases. Whilst there are safe
ways to break this rule they make the code less obviously correct and so arguably
should not be used anyway.
>
>julia
>
>> Jonathan
>> >Signed-off-by: Himangi Saraogi <himangi774@gmail.com>
>> >Acked-by: Julia Lawall <julia.lawall@lip6.fr>
>> >---
>> > drivers/staging/iio/frequency/ad9832.c | 3 +--
>> > 1 file changed, 1 insertion(+), 2 deletions(-)
>> >
>> >diff --git a/drivers/staging/iio/frequency/ad9832.c
>> >b/drivers/staging/iio/frequency/ad9832.c
>> >index cf68159..8a72c78 100644
>> >--- a/drivers/staging/iio/frequency/ad9832.c
>> >+++ b/drivers/staging/iio/frequency/ad9832.c
>> >@@ -304,7 +304,7 @@ static int ad9832_probe(struct spi_device *spi)
>> > if (ret)
>> > goto error_disable_reg;
>> >
>> >- ret = iio_device_register(indio_dev);
>> >+ ret = devm_iio_device_register(&spi->dev, indio_dev);
>> > if (ret)
>> > goto error_disable_reg;
>> >
>> >@@ -322,7 +322,6 @@ static int ad9832_remove(struct spi_device *spi)
>> > struct iio_dev *indio_dev = spi_get_drvdata(spi);
>> > struct ad9832_state *st = iio_priv(indio_dev);
>> >
>> >- iio_device_unregister(indio_dev);
>> > if (!IS_ERR(st->reg))
>> > regulator_disable(st->reg);
>> >
>>
>> --
>> Sent from my Android phone with K-9 Mail. Please excuse my brevity.
>>
--
Sent from my Android phone with K-9 Mail. Please excuse my brevity.
prev parent reply other threads:[~2014-08-03 13:22 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-03 9:56 Himangi Saraogi
2014-08-03 10:22 ` Jonathan Cameron
2014-08-03 10:45 ` Julia Lawall
2014-08-03 13:22 ` Jonathan Cameron [this message]
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=c6110228-a107-4a63-9e09-620b688d7fc1@email.android.com \
--to=jic23@kernel.org \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=himangi774@gmail.com \
--cc=julia.lawall@lip6.fr \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®