From: Andrew Davis <afd@ti.com>
To: "Pali Rohár" <pali@kernel.org>, "Sebastian Reichel" <sre@kernel.org>
Cc: <linux-pm@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
Andrew Davis <afd@ti.com>
Subject: [PATCH 1/5] power: supply: bq27xxx: Switch to a simpler IDA interface
Date: Tue, 23 Jan 2024 09:09:10 -0600 [thread overview]
Message-ID: <20240123150914.308510-1-afd@ti.com> (raw)
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(-)
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[] = {
--
2.39.2
next reply other threads:[~2024-01-23 15:09 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-23 15:09 Andrew Davis [this message]
2024-01-23 15:09 ` [PATCH 2/5] power: supply: bq27xxx: Add devm action to free IDA Andrew Davis
2024-01-23 15:09 ` [PATCH 3/5] power: supply: bq27xxx: Use devm to free device mutex Andrew Davis
2024-01-23 15:09 ` [PATCH 4/5] power: supply: bq27xxx: Use devm_power_supply_register() helper Andrew Davis
2024-01-23 15:09 ` [PATCH 5/5] power: supply: bq27xxx: Move one time design full read out of poll Andrew Davis
2024-01-27 0:48 ` (subset) [PATCH 1/5] power: supply: bq27xxx: Switch to a simpler IDA interface Sebastian Reichel
2024-01-27 1:32 ` Sebastian Reichel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240123150914.308510-1-afd@ti.com \
--to=afd@ti.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=pali@kernel.org \
--cc=sre@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox