dm thin: support a non power of 2 discard_granularity
[cascardo/linux.git] / drivers / power / bq27x00_battery.c
index 8ccf5d7..26037ca 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) {