From: Jonathan Cameron <jic23@kernel.org>
To: Lino Sanfilippo <LinoSanfilippo@gmx.de>
Cc: andy.shevchenko@gmail.com, lars@metafoo.de, pmeerw@pmeerw.net,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [RESEND PATCH 1/2] iio:core: Introduce unlocked version of iio_map_array_unregister()
Date: Sat, 28 Nov 2020 13:54:35 +0000 [thread overview]
Message-ID: <20201128135435.33e9f6ee@archlinux> (raw)
In-Reply-To: <1606571059-13974-1-git-send-email-LinoSanfilippo@gmx.de>
On Sat, 28 Nov 2020 14:44:18 +0100
Lino Sanfilippo <LinoSanfilippo@gmx.de> wrote:
> Introduce an unlocked version of iio_map_array_unregister(). This function
> can help to unwind in case of error while the iio_map_list_lock mutex is
> held.
>
> Signed-off-by: Lino Sanfilippo <LinoSanfilippo@gmx.de>
> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Hi.
The mailing list is having issues today and as I use b4 to pull patches
from lore.kernel.org I can't easily pick this up.
I had as you've probably guessed forgotten about this one.
A few notes to make it harder for people to do that in future.
1. Don't send patch series (or new versions of older patches) in reply
to an existing thread. They get lost and difficult to pull out.
b4 can't automatically figure out which patches to pull from that
original thread for example.
2. Always version number whole series with same number, even if some patches
are new. So this should be v3.
Anyhow, I'll pick up this resend once the mailing list recovers or I get
annoyed enough to do it the old fashioned manual way.
Thanks,
Jonathan
> ---
> drivers/iio/inkern.c | 27 ++++++++++++++++++---------
> 1 file changed, 18 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
> index ede99e0..39c1d63 100644
> --- a/drivers/iio/inkern.c
> +++ b/drivers/iio/inkern.c
> @@ -24,6 +24,21 @@ struct iio_map_internal {
> static LIST_HEAD(iio_map_list);
> static DEFINE_MUTEX(iio_map_list_lock);
>
> +static int iio_map_array_unregister_locked(struct iio_dev *indio_dev)
> +{
> + int ret = -ENODEV;
> + struct iio_map_internal *mapi, *next;
> +
> + list_for_each_entry_safe(mapi, next, &iio_map_list, l) {
> + if (indio_dev == mapi->indio_dev) {
> + list_del(&mapi->l);
> + kfree(mapi);
> + ret = 0;
> + }
> + }
> + return ret;
> +}
> +
> int iio_map_array_register(struct iio_dev *indio_dev, struct iio_map *maps)
> {
> int i = 0, ret = 0;
> @@ -57,18 +72,12 @@ EXPORT_SYMBOL_GPL(iio_map_array_register);
> */
> int iio_map_array_unregister(struct iio_dev *indio_dev)
> {
> - int ret = -ENODEV;
> - struct iio_map_internal *mapi, *next;
> + int ret;
>
> mutex_lock(&iio_map_list_lock);
> - list_for_each_entry_safe(mapi, next, &iio_map_list, l) {
> - if (indio_dev == mapi->indio_dev) {
> - list_del(&mapi->l);
> - kfree(mapi);
> - ret = 0;
> - }
> - }
> + ret = iio_map_array_unregister_locked(indio_dev);
> mutex_unlock(&iio_map_list_lock);
> +
> return ret;
> }
> EXPORT_SYMBOL_GPL(iio_map_array_unregister);
next prev parent reply other threads:[~2020-11-28 22:22 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-28 13:44 [RESEND PATCH 1/2] iio:core: Introduce unlocked version of iio_map_array_unregister() Lino Sanfilippo
2020-11-28 13:44 ` [RESEND PATCH 2/2] io:core: In iio_map_array_register() cleanup in case of error Lino Sanfilippo
2020-11-28 13:54 ` Jonathan Cameron [this message]
2020-11-28 14:22 ` [RESEND PATCH 1/2] iio:core: Introduce unlocked version of iio_map_array_unregister() Lino Sanfilippo
2020-11-29 13:08 ` Jonathan Cameron
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=20201128135435.33e9f6ee@archlinux \
--to=jic23@kernel.org \
--cc=LinoSanfilippo@gmx.de \
--cc=andy.shevchenko@gmail.com \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pmeerw@pmeerw.net \
/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).