linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Tallys Martins <tallysmartins@gmail.com>
Cc: Lars-Peter Clausen <lars@metafoo.de>,
	Michael Hennerich <Michael.Hennerich@analog.com>,
	Stefan Popa <stefan.popa@analog.com>,
	Hartmut Knaack <knaack.h@gmx.de>,
	Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-iio@vger.kernel.org, devel@driverdev.osuosl.org,
	linux-kernel@vger.kernel.or, kernel-usp@googlegroups.com,
	Souza Guilherme <gdsdsilva@inf.ufpel.edu.br>
Subject: Re: [PATCH 1/2] staging: iio: ad2s1210: Destroy mutex at remove
Date: Sun, 19 May 2019 12:12:09 +0100	[thread overview]
Message-ID: <20190519121209.71524d18@archlinux> (raw)
In-Reply-To: <20190518221558.21799-1-tallysmartins@gmail.com>

On Sat, 18 May 2019 19:15:57 -0300
Tallys Martins <tallysmartins@gmail.com> wrote:

> Ensure the mutex will be destroyed on drive removal.
> Also adds mutex comment description.
> 
> Signed-off-by: Tallys Martins <tallysmartins@gmail.com>
> Signed-off-by: Souza Guilherme <gdsdsilva@inf.ufpel.edu.br>
> Co-developed-by: Souza Guilherme <gdsdsilva@inf.ufpel.edu.br>
Hi.

This particular 'issue' is never a simple one.

The destroy_mutex call is intended for lock debugging only,
which is why there is devm_init_mutex or similar to allow for
automatic unwinding. 

It simple cleanup paths like this, it provides very little value
and leads to a more complex unwind.

It is for this reason that the vast majority of drivers simply
don't bother.

Hence, unless there is a good reason I'm missing I won't be
introducing more of them.

Thanks,

Jonathan

> ---
>  drivers/staging/iio/resolver/ad2s1210.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/iio/resolver/ad2s1210.c b/drivers/staging/iio/resolver/ad2s1210.c
> index b6be0bc202f5..b91cf57c5e57 100644
> --- a/drivers/staging/iio/resolver/ad2s1210.c
> +++ b/drivers/staging/iio/resolver/ad2s1210.c
> @@ -86,7 +86,7 @@ static const struct ad2s1210_gpio gpios[] = {
>  static const unsigned int ad2s1210_resolution_value[] = { 10, 12, 14, 16 };
>  
>  struct ad2s1210_state {
> -	struct mutex lock;
> +	struct mutex lock; /* lock to protect the state on r/w operations */
>  	struct spi_device *sdev;
>  	struct gpio_desc *gpios[5];
>  	unsigned int fclkin;
> @@ -689,8 +689,10 @@ static int ad2s1210_probe(struct spi_device *spi)
>  static int ad2s1210_remove(struct spi_device *spi)
>  {
>  	struct iio_dev *indio_dev = spi_get_drvdata(spi);
> +	struct ad2s1210_state *ad2s1210_ad = iio_priv(indio_dev);
>  
>  	iio_device_unregister(indio_dev);
> +	mutex_destroy(&ad2s1210_ad->lock);
>  
>  	return 0;
>  }


      parent reply	other threads:[~2019-05-19 17:47 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-18 22:15 [PATCH 1/2] staging: iio: ad2s1210: Destroy mutex at remove Tallys Martins
2019-05-18 22:15 ` [PATCH 2/2] staging: iio: ad2s1210: Add devicetree yaml doc Tallys Martins
2019-05-19 11:17   ` Jonathan Cameron
2019-05-20 10:17     ` Alexandru Ardelean
2019-05-19 11:12 ` 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=20190519121209.71524d18@archlinux \
    --to=jic23@kernel.org \
    --cc=Michael.Hennerich@analog.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gdsdsilva@inf.ufpel.edu.br \
    --cc=gregkh@linuxfoundation.org \
    --cc=kernel-usp@googlegroups.com \
    --cc=knaack.h@gmx.de \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.or \
    --cc=pmeerw@pmeerw.net \
    --cc=stefan.popa@analog.com \
    --cc=tallysmartins@gmail.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).