All of lore.kernel.org
 help / color / mirror / Atom feed
From: Guenter Roeck <guenter.roeck@ericsson.com>
To: Jonathan Cameron <jic23@cam.ac.uk>
Cc: "randy.dunlap@oracle.com" <randy.dunlap@oracle.com>,
	"dri-devel@lists.freedesktop.org"
	<dri-devel@lists.freedesktop.org>,
	"johnpol@2ka.mipt.ru" <johnpol@2ka.mipt.ru>,
	"thellstrom@vmware.com" <thellstrom@vmware.com>,
	"linux-scsi@vger.kernel.org" <linux-scsi@vger.kernel.org>,
	"JBottomley@parallels.com" <JBottomley@parallels.com>,
	"lm-sensors@lm-sensors.org" <lm-sensors@lm-sensors.org>,
	"bharrosh@panasas.com" <bharrosh@panasas.com>,
	"airlied@redhat.com" <airlied@redhat.com>,
	"paulmck@linux.vnet.ibm.com" <paulmck@linux.vnet.ibm.com>,
	"naota@elisp.net" <naota@elisp.net>,
	"rtc-linux@googlegroups.com" <rtc-linux@googlegroups.com>,
	"namhyung@gmail.com" <namhyung@gmail.com>,
	"rusty@rustcorp.com.au" <rusty@rustcorp.com.au>,
	"khali@linux-fr.org" <khali@linux-fr.org>,
	"osd-dev@open-osd.org" <osd-dev@open-osd.org>,
	"akpm@linux-foundation.org" <akpm@linux-foundation.org>,
	a.zummo
Subject: Re: [PATCH 2/8] hwmon: convert idr to ida and use ida_simple interface.
Date: Thu, 28 Jul 2011 17:19:07 -0700	[thread overview]
Message-ID: <20110729001907.GA4496@ericsson.com> (raw)
In-Reply-To: <1311352886-4047-3-git-send-email-jic23@cam.ac.uk>

On Fri, Jul 22, 2011 at 12:41:11PM -0400, Jonathan Cameron wrote:
> hwmon was using an idr with a NULL pointer, so convert to an
> ida which then allows use of Rusty's ida_simple_get.
> 
> Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>

Looks ok to me.

Acked-by: Guenter Roeck <guenter.roeck@ericsson.com>

> ---
>  drivers/hwmon/hwmon.c |   32 ++++++++------------------------
>  1 files changed, 8 insertions(+), 24 deletions(-)
> 
> diff --git a/drivers/hwmon/hwmon.c b/drivers/hwmon/hwmon.c
> index a61e781..6460487 100644
> --- a/drivers/hwmon/hwmon.c
> +++ b/drivers/hwmon/hwmon.c
> @@ -27,8 +27,7 @@
>  
>  static struct class *hwmon_class;
>  
> -static DEFINE_IDR(hwmon_idr);
> -static DEFINE_SPINLOCK(idr_lock);
> +static DEFINE_IDA(hwmon_ida);
>  
>  /**
>   * hwmon_device_register - register w/ hwmon
> @@ -42,30 +41,17 @@ static DEFINE_SPINLOCK(idr_lock);
>  struct device *hwmon_device_register(struct device *dev)
>  {
>  	struct device *hwdev;
> -	int id, err;
> -
> -again:
> -	if (unlikely(idr_pre_get(&hwmon_idr, GFP_KERNEL) == 0))
> -		return ERR_PTR(-ENOMEM);
> -
> -	spin_lock(&idr_lock);
> -	err = idr_get_new(&hwmon_idr, NULL, &id);
> -	spin_unlock(&idr_lock);
> +	int id;
>  
> -	if (unlikely(err == -EAGAIN))
> -		goto again;
> -	else if (unlikely(err))
> -		return ERR_PTR(err);
> +	id = ida_simple_get(&hwmon_ida, 0, 0, GFP_KERNEL);
> +	if (id < 0)
> +		return ERR_PTR(id);
>  
> -	id = id & MAX_ID_MASK;
>  	hwdev = device_create(hwmon_class, dev, MKDEV(0, 0), NULL,
>  			      HWMON_ID_FORMAT, id);
>  
> -	if (IS_ERR(hwdev)) {
> -		spin_lock(&idr_lock);
> -		idr_remove(&hwmon_idr, id);
> -		spin_unlock(&idr_lock);
> -	}
> +	if (IS_ERR(hwdev))
> +		ida_simple_remove(&hwmon_ida, id);
>  
>  	return hwdev;
>  }
> @@ -81,9 +67,7 @@ void hwmon_device_unregister(struct device *dev)
>  
>  	if (likely(sscanf(dev_name(dev), HWMON_ID_FORMAT, &id) == 1)) {
>  		device_unregister(dev);
> -		spin_lock(&idr_lock);
> -		idr_remove(&hwmon_idr, id);
> -		spin_unlock(&idr_lock);
> +		ida_simple_remove(&hwmon_ida, id);
>  	} else
>  		dev_dbg(dev->parent,
>  			"hwmon_device_unregister() failed: bad class ID!\n");
> -- 
> 1.7.3.4
> 

WARNING: multiple messages have this Message-ID (diff)
From: Guenter Roeck <guenter.roeck@ericsson.com>
To: Jonathan Cameron <jic23@cam.ac.uk>
Cc: "randy.dunlap@oracle.com" <randy.dunlap@oracle.com>,
	"dri-devel@lists.freedesktop.org"
	<dri-devel@lists.freedesktop.org>,
	"johnpol@2ka.mipt.ru" <johnpol@2ka.mipt.ru>,
	"thellstrom@vmware.com" <thellstrom@vmware.com>,
	"linux-scsi@vger.kernel.org" <linux-scsi@vger.kernel.org>,
	"JBottomley@parallels.com" <JBottomley@parallels.com>,
	"lm-sensors@lm-sensors.org" <lm-sensors@lm-sensors.org>,
	"bharrosh@panasas.com" <bharrosh@panasas.com>,
	"airlied@redhat.com" <airlied@redhat.com>,
	"paulmck@linux.vnet.ibm.com" <paulmck@linux.vnet.ibm.com>,
	"naota@elisp.net" <naota@elisp.net>,
	"rtc-linux@googlegroups.com" <rtc-linux@googlegroups.com>,
	"namhyung@gmail.com" <namhyung@gmail.com>,
	"rusty@rustcorp.com.au" <rusty@rustcorp.com.au>,
	"khali@linux-fr.org" <khali@linux-fr.org>,
	"osd-dev@open-osd.org" <osd-dev@open-osd.org>,
	"akpm@linux-foundation.org" <akpm@linux-foundation.org>,
	a.zummo
Subject: Re: [lm-sensors] [PATCH 2/8] hwmon: convert idr to ida and use
Date: Fri, 29 Jul 2011 00:19:07 +0000	[thread overview]
Message-ID: <20110729001907.GA4496@ericsson.com> (raw)
In-Reply-To: <1311352886-4047-3-git-send-email-jic23@cam.ac.uk>

On Fri, Jul 22, 2011 at 12:41:11PM -0400, Jonathan Cameron wrote:
> hwmon was using an idr with a NULL pointer, so convert to an
> ida which then allows use of Rusty's ida_simple_get.
> 
> Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>

Looks ok to me.

Acked-by: Guenter Roeck <guenter.roeck@ericsson.com>

> ---
>  drivers/hwmon/hwmon.c |   32 ++++++++------------------------
>  1 files changed, 8 insertions(+), 24 deletions(-)
> 
> diff --git a/drivers/hwmon/hwmon.c b/drivers/hwmon/hwmon.c
> index a61e781..6460487 100644
> --- a/drivers/hwmon/hwmon.c
> +++ b/drivers/hwmon/hwmon.c
> @@ -27,8 +27,7 @@
>  
>  static struct class *hwmon_class;
>  
> -static DEFINE_IDR(hwmon_idr);
> -static DEFINE_SPINLOCK(idr_lock);
> +static DEFINE_IDA(hwmon_ida);
>  
>  /**
>   * hwmon_device_register - register w/ hwmon
> @@ -42,30 +41,17 @@ static DEFINE_SPINLOCK(idr_lock);
>  struct device *hwmon_device_register(struct device *dev)
>  {
>  	struct device *hwdev;
> -	int id, err;
> -
> -again:
> -	if (unlikely(idr_pre_get(&hwmon_idr, GFP_KERNEL) = 0))
> -		return ERR_PTR(-ENOMEM);
> -
> -	spin_lock(&idr_lock);
> -	err = idr_get_new(&hwmon_idr, NULL, &id);
> -	spin_unlock(&idr_lock);
> +	int id;
>  
> -	if (unlikely(err = -EAGAIN))
> -		goto again;
> -	else if (unlikely(err))
> -		return ERR_PTR(err);
> +	id = ida_simple_get(&hwmon_ida, 0, 0, GFP_KERNEL);
> +	if (id < 0)
> +		return ERR_PTR(id);
>  
> -	id = id & MAX_ID_MASK;
>  	hwdev = device_create(hwmon_class, dev, MKDEV(0, 0), NULL,
>  			      HWMON_ID_FORMAT, id);
>  
> -	if (IS_ERR(hwdev)) {
> -		spin_lock(&idr_lock);
> -		idr_remove(&hwmon_idr, id);
> -		spin_unlock(&idr_lock);
> -	}
> +	if (IS_ERR(hwdev))
> +		ida_simple_remove(&hwmon_ida, id);
>  
>  	return hwdev;
>  }
> @@ -81,9 +67,7 @@ void hwmon_device_unregister(struct device *dev)
>  
>  	if (likely(sscanf(dev_name(dev), HWMON_ID_FORMAT, &id) = 1)) {
>  		device_unregister(dev);
> -		spin_lock(&idr_lock);
> -		idr_remove(&hwmon_idr, id);
> -		spin_unlock(&idr_lock);
> +		ida_simple_remove(&hwmon_ida, id);
>  	} else
>  		dev_dbg(dev->parent,
>  			"hwmon_device_unregister() failed: bad class ID!\n");
> -- 
> 1.7.3.4
> 

_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

  reply	other threads:[~2011-07-29  0:19 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-22 16:41 [PATCH 0/8] RFC: Introduce ida_simple interfaces and use them Jonathan Cameron
2011-07-22 16:41 ` [lm-sensors] [PATCH 0/8] RFC: Introduce ida_simple interfaces and Jonathan Cameron
2011-07-22 16:41 ` [PATCH 1/8] ida: Simplified functions for id allocation Jonathan Cameron
2011-07-22 16:41   ` [lm-sensors] [PATCH 1/8] ida: Simplified functions for id Jonathan Cameron
2011-07-22 16:41 ` [PATCH 2/8] hwmon: convert idr to ida and use ida_simple interface Jonathan Cameron
2011-07-29  0:19   ` Guenter Roeck [this message]
2011-07-29  0:19     ` [lm-sensors] [PATCH 2/8] hwmon: convert idr to ida and use Guenter Roeck
2011-07-22 16:41 ` [PATCH 3/8] hwmon: ibmaem: convert idr to ida and use ida_simple_get Jonathan Cameron
2011-07-26 18:04   ` Darrick J. Wong
2011-07-26 18:04     ` [lm-sensors] [PATCH 3/8] hwmon: ibmaem: convert idr to ida and Darrick J. Wong
2011-07-22 16:41 ` [PATCH 4/8] [SCSI] use ida_simple_get and ida_simple remove in place of boilerplate code Jonathan Cameron
2011-07-22 16:41   ` [lm-sensors] [PATCH 4/8] [SCSI] use ida_simple_get and ida_simple Jonathan Cameron
2011-07-22 16:41 ` [PATCH 5/8] drm/vmwgfx: use ida_simple_get for id allocation Jonathan Cameron
2011-07-22 16:41   ` [lm-sensors] [PATCH 5/8] drm/vmwgfx: use ida_simple_get for id Jonathan Cameron
2011-07-22 16:41 ` [PATCH 6/8] [SCSI] osduld: use ida_simple_get to handle id Jonathan Cameron
2011-07-22 21:47   ` [osd-dev] " Boaz Harrosh
2011-07-22 21:47     ` Boaz Harrosh
2011-07-22 21:47     ` [lm-sensors] [osd-dev] [PATCH 6/8] [SCSI] osduld: use Boaz Harrosh
2011-07-25 11:06     ` [osd-dev] [PATCH 6/8] [SCSI] osduld: use ida_simple_get to handle id Jonathan Cameron
2011-07-25 11:06       ` [lm-sensors] [osd-dev] [PATCH 6/8] [SCSI] osduld: use Jonathan Cameron
2011-07-22 16:41 ` [PATCH 7/8] w1: ds2760 and ds2780, use ida for id and ida_simple_get to get it Jonathan Cameron
2011-07-22 16:41 ` [PATCH 8/8] rtc: class idr converted to ida and ida_simple_get used Jonathan Cameron
2011-07-23 10:17   ` Tejun Heo
2011-07-23 10:17     ` [lm-sensors] [PATCH 8/8] rtc: class idr converted to ida and Tejun Heo
2011-07-22 16:41 ` [PATCH 0/8] RFC: Introduce ida_simple interfaces and use them Jonathan Cameron
2011-07-22 16:41   ` [lm-sensors] [PATCH 0/8] RFC: Introduce ida_simple interfaces and Jonathan Cameron
2011-07-22 16:41 ` [PATCH 1/8] ida: Simplified functions for id allocation Jonathan Cameron
2011-07-23 10:04   ` Tejun Heo
2011-07-23 10:04     ` [lm-sensors] [PATCH 1/8] ida: Simplified functions for id Tejun Heo
2011-07-22 16:41 ` [PATCH 2/8] hwmon: convert idr to ida and use ida_simple interface Jonathan Cameron
2011-07-22 16:41   ` [lm-sensors] [PATCH 2/8] hwmon: convert idr to ida and use Jonathan Cameron
2011-07-22 16:41 ` [PATCH 3/8] hwmon: ibmaem: convert idr to ida and use ida_simple_get Jonathan Cameron
2011-07-22 16:41   ` [lm-sensors] [PATCH 3/8] hwmon: ibmaem: convert idr to ida and use Jonathan Cameron
2011-07-22 16:41 ` [PATCH 4/8] [SCSI] use ida_simple_get and ida_simple remove in place of boilerplate code Jonathan Cameron
2011-07-22 16:41 ` [PATCH 5/8] drm/vmwgfx: use ida_simple_get for id allocation Jonathan Cameron
2011-07-22 16:41   ` [lm-sensors] [PATCH 5/8] drm/vmwgfx: use ida_simple_get for id Jonathan Cameron
2011-07-22 16:41 ` [PATCH 6/8] [SCSI] osduld: use ida_simple_get to handle id Jonathan Cameron
2011-07-22 16:41   ` [lm-sensors] [PATCH 6/8] [SCSI] osduld: use ida_simple_get to Jonathan Cameron
2011-07-22 16:41 ` [PATCH 7/8] w1: ds2760 and ds2780, use ida for id and ida_simple_get to get it Jonathan Cameron
2011-07-22 16:41   ` [lm-sensors] [PATCH 7/8] w1: ds2760 and ds2780, Jonathan Cameron
2011-08-24 17:22   ` [PATCH 7/8] w1: ds2760 and ds2780, use ida for id and ida_simple_get to get it Barnes, Clifton A.
2011-08-24 17:22     ` [lm-sensors] [PATCH 7/8] w1: ds2760 and ds2780, Barnes, Clifton A.
2011-07-22 16:41 ` [PATCH 8/8] rtc: class idr converted to ida and ida_simple_get used Jonathan Cameron
2011-07-22 16:41   ` [lm-sensors] [PATCH 8/8] rtc: class idr converted to ida and Jonathan Cameron
2011-07-22 16:48 ` [PATCH 0/8] RFC: Introduce ida_simple interfaces and use them Jonathan Cameron
2011-07-22 16:48   ` Jonathan Cameron
2011-07-22 16:48   ` [lm-sensors] [PATCH 0/8] RFC: Introduce ida_simple interfaces 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=20110729001907.GA4496@ericsson.com \
    --to=guenter.roeck@ericsson.com \
    --cc=JBottomley@parallels.com \
    --cc=airlied@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=bharrosh@panasas.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jic23@cam.ac.uk \
    --cc=johnpol@2ka.mipt.ru \
    --cc=khali@linux-fr.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=lm-sensors@lm-sensors.org \
    --cc=namhyung@gmail.com \
    --cc=naota@elisp.net \
    --cc=osd-dev@open-osd.org \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=randy.dunlap@oracle.com \
    --cc=rtc-linux@googlegroups.com \
    --cc=rusty@rustcorp.com.au \
    --cc=thellstrom@vmware.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.