]> git.proxmox.com Git - mirror_ubuntu-disco-kernel.git/commitdiff
power: convert to idr_alloc()
authorTejun Heo <tj@kernel.org>
Thu, 28 Feb 2013 01:04:37 +0000 (17:04 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 28 Feb 2013 03:10:18 +0000 (19:10 -0800)
Convert to the much saner new idr interface.

Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: Anton Vorontsov <cbou@mail.ru>
Cc: David Woodhouse <dwmw2@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
drivers/power/bq2415x_charger.c
drivers/power/bq27x00_battery.c
drivers/power/ds2782_battery.c

index ca91396fc48eef616f812bf97e12696a038c61a2..0727f9256138589cf0184756b46adc5f216df4bd 100644 (file)
@@ -1515,16 +1515,11 @@ static int bq2415x_probe(struct i2c_client *client,
        }
 
        /* Get new ID for the new device */
-       ret = idr_pre_get(&bq2415x_id, GFP_KERNEL);
-       if (ret == 0)
-               return -ENOMEM;
-
        mutex_lock(&bq2415x_id_mutex);
-       ret = idr_get_new(&bq2415x_id, client, &num);
+       num = idr_alloc(&bq2415x_id, client, 0, 0, GFP_KERNEL);
        mutex_unlock(&bq2415x_id_mutex);
-
-       if (ret < 0)
-               return ret;
+       if (num < 0)
+               return num;
 
        name = kasprintf(GFP_KERNEL, "%s-%d", id->name, num);
        if (!name) {
index 8ccf5d7d0add29c12c7830036b1881977ec3f188..26037ca7efb49cf78c8ed41d097f6bad6f5ffc5b 100644 (file)
@@ -791,14 +791,11 @@ static int bq27x00_battery_probe(struct i2c_client *client,
        int retval = 0;
 
        /* Get new ID for the new battery device */
-       retval = idr_pre_get(&battery_id, GFP_KERNEL);
-       if (retval == 0)
-               return -ENOMEM;
        mutex_lock(&battery_mutex);
-       retval = idr_get_new(&battery_id, client, &num);
+       num = idr_alloc(&battery_id, client, 0, 0, GFP_KERNEL);
        mutex_unlock(&battery_mutex);
-       if (retval < 0)
-               return retval;
+       if (num < 0)
+               return num;
 
        name = kasprintf(GFP_KERNEL, "%s-%d", id->name, num);
        if (!name) {
index e7301b3ed6237566de0325b53645dd15c4b6a769..c09e7726c96cc25c6b890872db9b64f4f7903b52 100644 (file)
@@ -395,17 +395,12 @@ static int ds278x_battery_probe(struct i2c_client *client,
        }
 
        /* Get an ID for this battery */
-       ret = idr_pre_get(&battery_id, GFP_KERNEL);
-       if (ret == 0) {
-               ret = -ENOMEM;
-               goto fail_id;
-       }
-
        mutex_lock(&battery_lock);
-       ret = idr_get_new(&battery_id, client, &num);
+       ret = idr_alloc(&battery_id, client, 0, 0, GFP_KERNEL);
        mutex_unlock(&battery_lock);
        if (ret < 0)
                goto fail_id;
+       num = ret;
 
        info = kzalloc(sizeof(*info), GFP_KERNEL);
        if (!info) {