diff mbox series

[1/5] power: supply: bq27xxx: Switch to a simpler IDA interface

Message ID 20240123150914.308510-1-afd@ti.com
State Accepted
Commit 67d85ee4bc749ee94cdfe9638618a506638d1926
Headers show
Series [1/5] power: supply: bq27xxx: Switch to a simpler IDA interface | expand

Commit Message

Andrew Davis Jan. 23, 2024, 3:09 p.m. UTC
We don't need to specify any ranges when allocating IDs so we can switch
to ida_alloc() and ida_free() instead of the ida_simple_ counterparts.

Signed-off-by: Andrew Davis <afd@ti.com>
---
 drivers/power/supply/bq27xxx_battery_i2c.c | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)

Comments

Sebastian Reichel Jan. 27, 2024, 12:48 a.m. UTC | #1
On Tue, 23 Jan 2024 09:09:10 -0600, Andrew Davis wrote:
> We don't need to specify any ranges when allocating IDs so we can switch
> to ida_alloc() and ida_free() instead of the ida_simple_ counterparts.
> 
> 

Applied, thanks!

[5/5] power: supply: bq27xxx: Move one time design full read out of poll
      commit: b282c30dad3e10738a4f03043efaff93d9e8de02

Best regards,
Sebastian Reichel Jan. 27, 2024, 1:32 a.m. UTC | #2
Hi,

On Sat, Jan 27, 2024 at 01:48:07AM +0100, Sebastian Reichel wrote:
> On Tue, 23 Jan 2024 09:09:10 -0600, Andrew Davis wrote:
> > We don't need to specify any ranges when allocating IDs so we can switch
> > to ida_alloc() and ida_free() instead of the ida_simple_ counterparts.
> 
> Applied, thanks!
> 
> [5/5] power: supply: bq27xxx: Move one time design full read out of poll
>       commit: b282c30dad3e10738a4f03043efaff93d9e8de02

FWIW, I queued all 5 patches.

-- Sebastian
diff mbox series

Patch

diff --git a/drivers/power/supply/bq27xxx_battery_i2c.c b/drivers/power/supply/bq27xxx_battery_i2c.c
index 3a1798b0c1a79..86ce13a8ab9dd 100644
--- a/drivers/power/supply/bq27xxx_battery_i2c.c
+++ b/drivers/power/supply/bq27xxx_battery_i2c.c
@@ -13,8 +13,7 @@ 
 
 #include <linux/power/bq27xxx_battery.h>
 
-static DEFINE_IDR(battery_id);
-static DEFINE_MUTEX(battery_mutex);
+static DEFINE_IDA(battery_id);
 
 static irqreturn_t bq27xxx_battery_irq_handler_thread(int irq, void *data)
 {
@@ -145,9 +144,7 @@  static int bq27xxx_battery_i2c_probe(struct i2c_client *client)
 	int num;
 
 	/* Get new ID for the new battery device */
-	mutex_lock(&battery_mutex);
-	num = idr_alloc(&battery_id, client, 0, 0, GFP_KERNEL);
-	mutex_unlock(&battery_mutex);
+	num = ida_alloc(&battery_id, GFP_KERNEL);
 	if (num < 0)
 		return num;
 
@@ -198,9 +195,7 @@  static int bq27xxx_battery_i2c_probe(struct i2c_client *client)
 	ret = -ENOMEM;
 
 err_failed:
-	mutex_lock(&battery_mutex);
-	idr_remove(&battery_id, num);
-	mutex_unlock(&battery_mutex);
+	ida_free(&battery_id, num);
 
 	return ret;
 }
@@ -212,9 +207,7 @@  static void bq27xxx_battery_i2c_remove(struct i2c_client *client)
 	free_irq(client->irq, di);
 	bq27xxx_battery_teardown(di);
 
-	mutex_lock(&battery_mutex);
-	idr_remove(&battery_id, di->id);
-	mutex_unlock(&battery_mutex);
+	ida_free(&battery_id, di->id);
 }
 
 static const struct i2c_device_id bq27xxx_i2c_id_table[] = {