From: Jonathan Cameron <jic23-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
To: Guenter Roeck <linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
Cc: linux-iio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org,
Naveen Krishna Chatradhi
<ch.naveen-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>,
Lars-Peter Clausen <lars-Qo5EllUWu/uELgA04lAiVw@public.gmane.org>,
Doug Anderson <dianders-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>,
Tomasz Figa <tomasz.figa-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
Grant Likely
<grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>,
Rob Herring <rob.herring-bsGFqQB8/DxBDgjK7y7TUQ@public.gmane.org>
Subject: Re: [RFC 09/11] iio: Simplify iio_map_array_unregister API
Date: Sat, 02 Feb 2013 10:16:55 +0000 [thread overview]
Message-ID: <510CE797.3040201@kernel.org> (raw)
In-Reply-To: <1359668588-13678-10-git-send-email-linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
On 01/31/2013 09:43 PM, Guenter Roeck wrote:
> Instead of requiring the map to unregister, simply unregister all map entries
> associated with the given iio device. This simplifies map removal and also works
> for maps generated through devicetree.
>
> Signed-off-by: Guenter Roeck <linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
Sensible change. No idea why this never occured to me at the time ;)
Applied to togreg branch of iio.git.
Thanks,
Jonathan
> ---
> drivers/iio/adc/lp8788_adc.c | 11 ++---------
> drivers/iio/adc/max1363.c | 4 ++--
> drivers/iio/inkern.c | 36 +++++++++++-------------------------
> include/linux/iio/driver.h | 9 +++------
> 4 files changed, 18 insertions(+), 42 deletions(-)
>
> diff --git a/drivers/iio/adc/lp8788_adc.c b/drivers/iio/adc/lp8788_adc.c
> index e5293d0..d6d509b 100644
> --- a/drivers/iio/adc/lp8788_adc.c
> +++ b/drivers/iio/adc/lp8788_adc.c
> @@ -187,12 +187,6 @@ static int lp8788_iio_map_register(struct iio_dev *indio_dev,
> return 0;
> }
>
> -static inline void lp8788_iio_map_unregister(struct iio_dev *indio_dev,
> - struct lp8788_adc *adc)
> -{
> - iio_map_array_unregister(indio_dev, adc->map);
> -}
> -
> static int lp8788_adc_probe(struct platform_device *pdev)
> {
> struct lp8788 *lp = dev_get_drvdata(pdev->dev.parent);
> @@ -231,7 +225,7 @@ static int lp8788_adc_probe(struct platform_device *pdev)
> return 0;
>
> err_iio_device:
> - lp8788_iio_map_unregister(indio_dev, adc);
> + iio_map_array_unregister(indio_dev);
> err_iio_map:
> iio_device_free(indio_dev);
> return ret;
> @@ -240,10 +234,9 @@ err_iio_map:
> static int lp8788_adc_remove(struct platform_device *pdev)
> {
> struct iio_dev *indio_dev = platform_get_drvdata(pdev);
> - struct lp8788_adc *adc = iio_priv(indio_dev);
>
> iio_device_unregister(indio_dev);
> - lp8788_iio_map_unregister(indio_dev, adc);
> + iio_map_array_unregister(indio_dev);
> iio_device_free(indio_dev);
>
> return 0;
> diff --git a/drivers/iio/adc/max1363.c b/drivers/iio/adc/max1363.c
> index fdc8be9..51165d6 100644
> --- a/drivers/iio/adc/max1363.c
> +++ b/drivers/iio/adc/max1363.c
> @@ -1618,7 +1618,7 @@ error_disable_reg:
> error_put_reg:
> regulator_put(st->reg);
> error_unregister_map:
> - iio_map_array_unregister(indio_dev, client->dev.platform_data);
> + iio_map_array_unregister(indio_dev);
> error_free_device:
> iio_device_free(indio_dev);
> error_out:
> @@ -1638,7 +1638,7 @@ static int max1363_remove(struct i2c_client *client)
> kfree(indio_dev->available_scan_masks);
> regulator_disable(st->reg);
> regulator_put(st->reg);
> - iio_map_array_unregister(indio_dev, client->dev.platform_data);
> + iio_map_array_unregister(indio_dev);
> iio_device_free(indio_dev);
>
> return 0;
> diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
> index 58d0ffe..c42aba6 100644
> --- a/drivers/iio/inkern.c
> +++ b/drivers/iio/inkern.c
> @@ -54,39 +54,25 @@ error_ret:
> EXPORT_SYMBOL_GPL(iio_map_array_register);
>
>
> -/* Assumes the exact same array (e.g. memory locations)
> - * used at unregistration as used at registration rather than
> - * more complex checking of contents.
> +/*
> + * Remove all map entries associated with the given iio device
> */
> -int iio_map_array_unregister(struct iio_dev *indio_dev,
> - struct iio_map *maps)
> +int iio_map_array_unregister(struct iio_dev *indio_dev)
> {
> - int i = 0, ret = 0;
> - bool found_it;
> + int ret = -ENODEV;
> struct iio_map_internal *mapi;
> -
> - if (maps == NULL)
> - return 0;
> + struct list_head *pos, *tmp;
>
> mutex_lock(&iio_map_list_lock);
> - while (maps[i].consumer_dev_name != NULL) {
> - found_it = false;
> - list_for_each_entry(mapi, &iio_map_list, l)
> - if (&maps[i] == mapi->map) {
> - list_del(&mapi->l);
> - kfree(mapi);
> - found_it = true;
> - break;
> - }
> - if (!found_it) {
> - ret = -ENODEV;
> - goto error_ret;
> + list_for_each_safe(pos, tmp, &iio_map_list) {
> + mapi = list_entry(pos, struct iio_map_internal, l);
> + if (indio_dev == mapi->indio_dev) {
> + list_del(&mapi->l);
> + kfree(mapi);
> + ret = 0;
> }
> - i++;
> }
> -error_ret:
> mutex_unlock(&iio_map_list_lock);
> -
> return ret;
> }
> EXPORT_SYMBOL_GPL(iio_map_array_unregister);
> diff --git a/include/linux/iio/driver.h b/include/linux/iio/driver.h
> index a4f8b2e..7dfb10e 100644
> --- a/include/linux/iio/driver.h
> +++ b/include/linux/iio/driver.h
> @@ -22,13 +22,10 @@ int iio_map_array_register(struct iio_dev *indio_dev,
> struct iio_map *map);
>
> /**
> - * iio_map_array_unregister() - tell the core to remove consumer mappings
> + * iio_map_array_unregister() - tell the core to remove consumer mappings for
> + * the given provider device
> * @indio_dev: provider device
> - * @map: array of mappings to remove. Note these must have same memory
> - * addresses as those originally added not just equal parameter
> - * values.
> */
> -int iio_map_array_unregister(struct iio_dev *indio_dev,
> - struct iio_map *map);
> +int iio_map_array_unregister(struct iio_dev *indio_dev);
>
> #endif
>
next prev parent reply other threads:[~2013-02-02 10:16 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-31 21:42 [RFC 00/11] staging/iio: Devicetree support Guenter Roeck
[not found] ` <1359668588-13678-1-git-send-email-linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
2013-01-31 21:42 ` [PATCH 01/11] staging/iio: (iio_hwmon) Use devm_kzalloc Guenter Roeck
[not found] ` <1359668588-13678-2-git-send-email-linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
2013-02-02 9:50 ` Jonathan Cameron
2013-01-31 21:42 ` [PATCH 02/11] staging/iio: (iio_hwmon) Add support for sysfs name attribute Guenter Roeck
[not found] ` <1359668588-13678-3-git-send-email-linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
2013-02-02 9:52 ` Jonathan Cameron
2013-01-31 21:43 ` [PATCH 03/11] staging/iio: (iio_hwmon) Basic devicetree support Guenter Roeck
[not found] ` <1359668588-13678-4-git-send-email-linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
2013-02-02 9:54 ` Jonathan Cameron
2013-01-31 21:43 ` [PATCH 04/11] iio/adc: (lp8788) Provide OF node information to iio device Guenter Roeck
[not found] ` <1359668588-13678-5-git-send-email-linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
2013-02-02 9:55 ` Jonathan Cameron
2013-01-31 21:43 ` [PATCH 05/11] iio/adc: (max1363) " Guenter Roeck
[not found] ` <1359668588-13678-6-git-send-email-linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
2013-02-02 10:06 ` Jonathan Cameron
2013-01-31 21:43 ` [PATCH 06/11] iio/adc: (max1363) Remove duplicate code Guenter Roeck
[not found] ` <1359668588-13678-7-git-send-email-linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
2013-02-02 10:07 ` Jonathan Cameron
2013-01-31 21:43 ` [PATCH 07/11] iio/adc: (max1363) Fix data conversion problems Guenter Roeck
[not found] ` <1359668588-13678-8-git-send-email-linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
2013-02-02 10:08 ` Jonathan Cameron
2013-01-31 21:43 ` [RFC 08/11] iio: Update iio_channel_get_all and iio_channel_get_all_cb API Guenter Roeck
[not found] ` <1359668588-13678-9-git-send-email-linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
2013-02-02 10:14 ` Jonathan Cameron
2013-01-31 21:43 ` [RFC 09/11] iio: Simplify iio_map_array_unregister API Guenter Roeck
[not found] ` <1359668588-13678-10-git-send-email-linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
2013-02-02 10:16 ` Jonathan Cameron [this message]
2013-01-31 21:43 ` [RFC 10/11] iio: Add OF support Guenter Roeck
[not found] ` <1359668588-13678-11-git-send-email-linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
2013-02-01 11:58 ` Lars-Peter Clausen
[not found] ` <510BADCA.1030407-Qo5EllUWu/uELgA04lAiVw@public.gmane.org>
2013-02-01 14:33 ` Guenter Roeck
[not found] ` <20130201143307.GB20767-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
2013-02-01 14:59 ` Lars-Peter Clausen
[not found] ` <510BD845.1010200-Qo5EllUWu/uELgA04lAiVw@public.gmane.org>
2013-02-01 19:42 ` Guenter Roeck
[not found] ` <20130201194213.GA17968-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
2013-02-02 14:37 ` Lars-Peter Clausen
[not found] ` <510D24BA.5000300-Qo5EllUWu/uELgA04lAiVw@public.gmane.org>
2013-02-02 16:14 ` Guenter Roeck
2013-02-02 10:29 ` Jonathan Cameron
[not found] ` <510CEA6E.9010708-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2013-02-02 16:10 ` Guenter Roeck
[not found] ` <20130202161054.GA10386-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
2013-02-03 11:39 ` Jonathan Cameron
[not found] ` <510E4C85.9060507-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2013-02-03 11:47 ` Lars-Peter Clausen
[not found] ` <510E4E36.8090409-Qo5EllUWu/uELgA04lAiVw@public.gmane.org>
2013-02-03 11:52 ` Lars-Peter Clausen
[not found] ` <510E4F76.1030702-Qo5EllUWu/uELgA04lAiVw@public.gmane.org>
2013-02-03 11:57 ` Jonathan Cameron
[not found] ` <510E50C1.2010909-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2013-02-03 16:28 ` Guenter Roeck
2013-01-31 21:43 ` [RFC 11/11] iio/adc: (max1363) Add basic OF bindings and external vref support Guenter Roeck
[not found] ` <1359668588-13678-12-git-send-email-linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
2013-02-02 10:33 ` Jonathan Cameron
[not found] ` <510CEB68.5000205-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2013-02-02 16:13 ` Guenter Roeck
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=510CE797.3040201@kernel.org \
--to=jic23-dgejt+ai2ygdnm+yrofe0a@public.gmane.org \
--cc=ch.naveen-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org \
--cc=devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org \
--cc=dianders-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org \
--cc=grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org \
--cc=lars-Qo5EllUWu/uELgA04lAiVw@public.gmane.org \
--cc=linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org \
--cc=linux-iio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=rob.herring-bsGFqQB8/DxBDgjK7y7TUQ@public.gmane.org \
--cc=tomasz.figa-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.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;
as well as URLs for NNTP newsgroup(s).