diff options
-rw-r--r-- | drivers/power/bq2415x_charger.c | 11 | ||||
-rw-r--r-- | drivers/power/bq27x00_battery.c | 9 | ||||
-rw-r--r-- | drivers/power/ds2782_battery.c | 9 |
3 files changed, 8 insertions, 21 deletions
diff --git a/drivers/power/bq2415x_charger.c b/drivers/power/bq2415x_charger.c index ca91396fc48e..0727f9256138 100644 --- a/drivers/power/bq2415x_charger.c +++ b/drivers/power/bq2415x_charger.c | |||
@@ -1515,16 +1515,11 @@ static int bq2415x_probe(struct i2c_client *client, | |||
1515 | } | 1515 | } |
1516 | 1516 | ||
1517 | /* Get new ID for the new device */ | 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 | mutex_lock(&bq2415x_id_mutex); | 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 | mutex_unlock(&bq2415x_id_mutex); | 1520 | mutex_unlock(&bq2415x_id_mutex); |
1525 | 1521 | if (num < 0) | |
1526 | if (ret < 0) | 1522 | return num; |
1527 | return ret; | ||
1528 | 1523 | ||
1529 | name = kasprintf(GFP_KERNEL, "%s-%d", id->name, num); | 1524 | name = kasprintf(GFP_KERNEL, "%s-%d", id->name, num); |
1530 | if (!name) { | 1525 | if (!name) { |
diff --git a/drivers/power/bq27x00_battery.c b/drivers/power/bq27x00_battery.c index 8ccf5d7d0add..26037ca7efb4 100644 --- a/drivers/power/bq27x00_battery.c +++ b/drivers/power/bq27x00_battery.c | |||
@@ -791,14 +791,11 @@ static int bq27x00_battery_probe(struct i2c_client *client, | |||
791 | int retval = 0; | 791 | int retval = 0; |
792 | 792 | ||
793 | /* Get new ID for the new battery device */ | 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 | mutex_lock(&battery_mutex); | 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 | mutex_unlock(&battery_mutex); | 796 | mutex_unlock(&battery_mutex); |
800 | if (retval < 0) | 797 | if (num < 0) |
801 | return retval; | 798 | return num; |
802 | 799 | ||
803 | name = kasprintf(GFP_KERNEL, "%s-%d", id->name, num); | 800 | name = kasprintf(GFP_KERNEL, "%s-%d", id->name, num); |
804 | if (!name) { | 801 | if (!name) { |
diff --git a/drivers/power/ds2782_battery.c b/drivers/power/ds2782_battery.c index e7301b3ed623..c09e7726c96c 100644 --- a/drivers/power/ds2782_battery.c +++ b/drivers/power/ds2782_battery.c | |||
@@ -395,17 +395,12 @@ static int ds278x_battery_probe(struct i2c_client *client, | |||
395 | } | 395 | } |
396 | 396 | ||
397 | /* Get an ID for this battery */ | 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 | mutex_lock(&battery_lock); | 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 | mutex_unlock(&battery_lock); | 400 | mutex_unlock(&battery_lock); |
407 | if (ret < 0) | 401 | if (ret < 0) |
408 | goto fail_id; | 402 | goto fail_id; |
403 | num = ret; | ||
409 | 404 | ||
410 | info = kzalloc(sizeof(*info), GFP_KERNEL); | 405 | info = kzalloc(sizeof(*info), GFP_KERNEL); |
411 | if (!info) { | 406 | if (!info) { |