From 7398783b6e9e600417873becc37d71af2f9581ca Mon Sep 17 00:00:00 2001 From: Matthew Wilcox Date: Mon, 18 Feb 2019 16:16:25 -0500 Subject: [PATCH] power: Convert ds2782_battery to IDA Signed-off-by: Matthew Wilcox --- drivers/power/supply/ds2782_battery.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/drivers/power/supply/ds2782_battery.c b/drivers/power/supply/ds2782_battery.c index 9ae273fde7a2..a0769c5f27b5 100644 --- a/drivers/power/supply/ds2782_battery.c +++ b/drivers/power/supply/ds2782_battery.c @@ -63,8 +63,7 @@ struct ds278x_info { int status; /* State Of Charge */ }; -static DEFINE_IDR(battery_id); -static DEFINE_MUTEX(battery_lock); +static DEFINE_IDA(battery_ids); static inline int ds278x_read_reg(struct ds278x_info *info, int reg, u8 *val) { @@ -321,10 +320,7 @@ static int ds278x_battery_remove(struct i2c_client *client) cancel_delayed_work_sync(&info->bat_work); kfree(info->battery_desc.name); kfree(info); - - mutex_lock(&battery_lock); - idr_remove(&battery_id, id); - mutex_unlock(&battery_lock); + ida_free(&battery_ids, id); return 0; } @@ -389,9 +385,7 @@ static int ds278x_battery_probe(struct i2c_client *client, } /* Get an ID for this battery */ - mutex_lock(&battery_lock); - ret = idr_alloc(&battery_id, client, 0, 0, GFP_KERNEL); - mutex_unlock(&battery_lock); + ret = ida_alloc(&battery_ids, GFP_KERNEL); if (ret < 0) goto fail_id; num = ret; @@ -441,9 +435,7 @@ fail_register: fail_name: kfree(info); fail_info: - mutex_lock(&battery_lock); - idr_remove(&battery_id, num); - mutex_unlock(&battery_lock); + ida_free(&battery_ids, num); fail_id: return ret; } -- 2.50.1