Commit 05e2cefa authored by Tejun Heo's avatar Tejun Heo Committed by Linus Torvalds

power: convert to idr_alloc()

Convert to the much saner new idr interface.
Signed-off-by: default avatarTejun Heo <tj@kernel.org>
Acked-by: default avatarAnton Vorontsov <cbou@mail.ru>
Cc: David Woodhouse <dwmw2@infradead.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 2fa532c5
...@@ -1515,16 +1515,11 @@ static int bq2415x_probe(struct i2c_client *client, ...@@ -1515,16 +1515,11 @@ static int bq2415x_probe(struct i2c_client *client,
} }
/* Get new ID for the new device */ /* 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); 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); mutex_unlock(&bq2415x_id_mutex);
if (num < 0)
if (ret < 0) return num;
return ret;
name = kasprintf(GFP_KERNEL, "%s-%d", id->name, num); name = kasprintf(GFP_KERNEL, "%s-%d", id->name, num);
if (!name) { if (!name) {
......
...@@ -791,14 +791,11 @@ static int bq27x00_battery_probe(struct i2c_client *client, ...@@ -791,14 +791,11 @@ static int bq27x00_battery_probe(struct i2c_client *client,
int retval = 0; int retval = 0;
/* Get new ID for the new battery device */ /* 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); 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); mutex_unlock(&battery_mutex);
if (retval < 0) if (num < 0)
return retval; return num;
name = kasprintf(GFP_KERNEL, "%s-%d", id->name, num); name = kasprintf(GFP_KERNEL, "%s-%d", id->name, num);
if (!name) { if (!name) {
......
...@@ -395,17 +395,12 @@ static int ds278x_battery_probe(struct i2c_client *client, ...@@ -395,17 +395,12 @@ static int ds278x_battery_probe(struct i2c_client *client,
} }
/* Get an ID for this battery */ /* 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); 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); mutex_unlock(&battery_lock);
if (ret < 0) if (ret < 0)
goto fail_id; goto fail_id;
num = ret;
info = kzalloc(sizeof(*info), GFP_KERNEL); info = kzalloc(sizeof(*info), GFP_KERNEL);
if (!info) { if (!info) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment