From: Andy Shevchenko <andy.shevchenko@gmail.com>
To: Lino Sanfilippo <LinoSanfilippo@gmx.de>
Cc: Jonathan Cameron <jic23@kernel.org>,
Hartmut Knaack <knaack.h@gmx.de>,
Lars-Peter Clausen <lars@metafoo.de>,
Peter Meerwald <pmeerw@pmeerw.net>,
linux-iio <linux-iio@vger.kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/2] iio:core: Introduce unlocked version of iio_map_array_unregister()
Date: Sun, 18 Oct 2020 21:21:56 +0300 [thread overview]
Message-ID: <CAHp75VcJGMNnU4j8S=J5wk1yTMgDLJcg-SD9Nh415L_TJju9zA@mail.gmail.com> (raw)
In-Reply-To: <1602983516-22913-2-git-send-email-LinoSanfilippo@gmx.de>
On Sun, Oct 18, 2020 at 4:13 AM 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.
Both looks good to me, FWIW,
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
if Jonathan is okay with them.
> Signed-off-by: Lino Sanfilippo <LinoSanfilippo@gmx.de>
> ---
> 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);
> --
> 2.7.4
>
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2020-10-18 18:22 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-11 12:41 [PATCH] iio:core: In map_array_register() cleanup in case of error Lino Sanfilippo
2020-10-11 15:07 ` Jonathan Cameron
2020-10-11 18:05 ` Lino Sanfilippo
2020-10-11 18:22 ` [PATCH v2] " Lino Sanfilippo
2020-10-16 15:09 ` Andy Shevchenko
2020-10-18 1:11 ` Lino Sanfilippo
2020-10-18 1:11 ` [PATCH 1/2] iio:core: Introduce unlocked version of iio_map_array_unregister() Lino Sanfilippo
2020-10-18 18:21 ` Andy Shevchenko [this message]
2020-10-18 1:11 ` [PATCH 2/2] iio:core: In iio_map_array_register() cleanup in case of error Lino Sanfilippo
2020-10-18 9:56 ` [PATCH v2] iio:core: In map_array_register() " 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='CAHp75VcJGMNnU4j8S=J5wk1yTMgDLJcg-SD9Nh415L_TJju9zA@mail.gmail.com' \
--to=andy.shevchenko@gmail.com \
--cc=LinoSanfilippo@gmx.de \
--cc=jic23@kernel.org \
--cc=knaack.h@gmx.de \
--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).