Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

power: convert to idr_alloc()

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>

authored by

Tejun Heo and committed by
Linus Torvalds
05e2cefa 2fa532c5

+8 -21
+3 -8
drivers/power/bq2415x_charger.c
··· 1515 1515 } 1516 1516 1517 1517 /* Get new ID for the new device */ 1518 - ret = idr_pre_get(&bq2415x_id, GFP_KERNEL); 1519 - if (ret == 0) 1520 - return -ENOMEM; 1521 - 1522 1518 mutex_lock(&bq2415x_id_mutex); 1523 - ret = idr_get_new(&bq2415x_id, client, &num); 1519 + num = idr_alloc(&bq2415x_id, client, 0, 0, GFP_KERNEL); 1524 1520 mutex_unlock(&bq2415x_id_mutex); 1525 - 1526 - if (ret < 0) 1527 - return ret; 1521 + if (num < 0) 1522 + return num; 1528 1523 1529 1524 name = kasprintf(GFP_KERNEL, "%s-%d", id->name, num); 1530 1525 if (!name) {
+3 -6
drivers/power/bq27x00_battery.c
··· 791 791 int retval = 0; 792 792 793 793 /* Get new ID for the new battery device */ 794 - retval = idr_pre_get(&battery_id, GFP_KERNEL); 795 - if (retval == 0) 796 - return -ENOMEM; 797 794 mutex_lock(&battery_mutex); 798 - retval = idr_get_new(&battery_id, client, &num); 795 + num = idr_alloc(&battery_id, client, 0, 0, GFP_KERNEL); 799 796 mutex_unlock(&battery_mutex); 800 - if (retval < 0) 801 - return retval; 797 + if (num < 0) 798 + return num; 802 799 803 800 name = kasprintf(GFP_KERNEL, "%s-%d", id->name, num); 804 801 if (!name) {
+2 -7
drivers/power/ds2782_battery.c
··· 395 395 } 396 396 397 397 /* Get an ID for this battery */ 398 - ret = idr_pre_get(&battery_id, GFP_KERNEL); 399 - if (ret == 0) { 400 - ret = -ENOMEM; 401 - goto fail_id; 402 - } 403 - 404 398 mutex_lock(&battery_lock); 405 - ret = idr_get_new(&battery_id, client, &num); 399 + ret = idr_alloc(&battery_id, client, 0, 0, GFP_KERNEL); 406 400 mutex_unlock(&battery_lock); 407 401 if (ret < 0) 408 402 goto fail_id; 403 + num = ret; 409 404 410 405 info = kzalloc(sizeof(*info), GFP_KERNEL); 411 406 if (!info) {