Re: [RESEND PATCH 1/2] iio:core: Introduce unlocked version of iio_map_array_unregister()
On Sat, 28 Nov 2020 15:22:16 +0100 Lino Sanfilippo wrote: > Hi Jonathan, > > On 28.11.20 at 14:54, Jonathan Cameron wrote: > > > 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. > > > > Thanks for these hints, I will keep it in mind for future patch submissions. Mailing list seems to have recovered so I can use b4 again :) Applied to the togreg branch of iio.git and pushed out as testing so the autobuilders can try to find anything we missed. Thanks, Jonathan > > Regards, > Lino >
[RESEND PATCH 1/2] iio:core: Introduce unlocked version of iio_map_array_unregister()
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 Reviewed-by: Andy Shevchenko --- 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, _map_list, l) { + if (indio_dev == mapi->indio_dev) { + list_del(>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(_map_list_lock); - list_for_each_entry_safe(mapi, next, _map_list, l) { - if (indio_dev == mapi->indio_dev) { - list_del(>l); - kfree(mapi); - ret = 0; - } - } + ret = iio_map_array_unregister_locked(indio_dev); mutex_unlock(_map_list_lock); + return ret; } EXPORT_SYMBOL_GPL(iio_map_array_unregister); -- 2.7.4
Re: [RESEND PATCH 1/2] iio:core: Introduce unlocked version of iio_map_array_unregister()
Hi Jonathan, On 28.11.20 at 14:54, Jonathan Cameron wrote: > 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. > Thanks for these hints, I will keep it in mind for future patch submissions. Regards, Lino
Re: [RESEND PATCH 1/2] iio:core: Introduce unlocked version of iio_map_array_unregister()
On Sat, 28 Nov 2020 14:44:18 +0100 Lino Sanfilippo 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 > Reviewed-by: Andy Shevchenko 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, _map_list, l) { > + if (indio_dev == mapi->indio_dev) { > + list_del(>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(_map_list_lock); > - list_for_each_entry_safe(mapi, next, _map_list, l) { > - if (indio_dev == mapi->indio_dev) { > - list_del(>l); > - kfree(mapi); > - ret = 0; > - } > - } > + ret = iio_map_array_unregister_locked(indio_dev); > mutex_unlock(_map_list_lock); > + > return ret; > } > EXPORT_SYMBOL_GPL(iio_map_array_unregister);
Re: [PATCH 1/2] iio:core: Introduce unlocked version of iio_map_array_unregister()
On Sun, Oct 18, 2020 at 4:13 AM Lino Sanfilippo 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 if Jonathan is okay with them. > Signed-off-by: Lino Sanfilippo > --- > 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, _map_list, l) { > + if (indio_dev == mapi->indio_dev) { > + list_del(>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(_map_list_lock); > - list_for_each_entry_safe(mapi, next, _map_list, l) { > - if (indio_dev == mapi->indio_dev) { > - list_del(>l); > - kfree(mapi); > - ret = 0; > - } > - } > + ret = iio_map_array_unregister_locked(indio_dev); > mutex_unlock(_map_list_lock); > + > return ret; > } > EXPORT_SYMBOL_GPL(iio_map_array_unregister); > -- > 2.7.4 > -- With Best Regards, Andy Shevchenko
[PATCH 1/2] iio:core: Introduce unlocked version of iio_map_array_unregister()
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 --- 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, _map_list, l) { + if (indio_dev == mapi->indio_dev) { + list_del(>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(_map_list_lock); - list_for_each_entry_safe(mapi, next, _map_list, l) { - if (indio_dev == mapi->indio_dev) { - list_del(>l); - kfree(mapi); - ret = 0; - } - } + ret = iio_map_array_unregister_locked(indio_dev); mutex_unlock(_map_list_lock); + return ret; } EXPORT_SYMBOL_GPL(iio_map_array_unregister); -- 2.7.4