From: "Pali Rohár" <pali.rohar@gmail.com>
To: Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com>
Cc: sre@kernel.org, dbaryshkov@gmail.com, dwmw2@infradead.org,
linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] power: bq27xxx_battery: Restore device name
Date: Tue, 2 Feb 2016 13:27:56 +0100 [thread overview]
Message-ID: <20160202122756.GI4389@pali> (raw)
In-Reply-To: <1454415319-31380-1-git-send-email-ivo.g.dimitrov.75@gmail.com>
On Tuesday 02 February 2016 14:15:19 Ivaylo Dimitrov wrote:
> Patch <703df6c097956d17a818e63961c82e8e9eef9fef> ("power: bq27xxx_battery:
> Reorganize I2C into a module") has removed the device name numbering from
> bq27xxx_battery_i2c_probe. Fix that by restoring the code.
>
> Signed-off-by: Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com>
> ---
> drivers/power/bq27xxx_battery_i2c.c | 32 +++++++++++++++++++++++++++++---
> 1 file changed, 29 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/power/bq27xxx_battery_i2c.c b/drivers/power/bq27xxx_battery_i2c.c
> index b810e08..d98cdc5 100644
> --- a/drivers/power/bq27xxx_battery_i2c.c
> +++ b/drivers/power/bq27xxx_battery_i2c.c
> @@ -21,6 +21,9 @@
>
> #include <linux/power/bq27xxx_battery.h>
>
> +static DEFINE_IDR(battery_id);
> +static DEFINE_MUTEX(battery_mutex);
> +
> static irqreturn_t bq27xxx_battery_irq_handler_thread(int irq, void *data)
> {
> struct bq27xxx_device_info *di = data;
> @@ -70,19 +73,32 @@ static int bq27xxx_battery_i2c_probe(struct i2c_client *client,
> {
> struct bq27xxx_device_info *di;
> int ret;
> + char *name;
> + 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);
> + if (num < 0)
> + return num;
> +
> + name = devm_kasprintf(&client->dev, GFP_KERNEL, "%s-%d", id->name, num);
> + if (!name)
> + goto err_mem;
>
> di = devm_kzalloc(&client->dev, sizeof(*di), GFP_KERNEL);
> if (!di)
> - return -ENOMEM;
> + goto err_mem;
>
> di->dev = &client->dev;
> di->chip = id->driver_data;
> - di->name = id->name;
> + di->name = name;
> di->bus.read = bq27xxx_battery_i2c_read;
>
> ret = bq27xxx_battery_setup(di);
> if (ret)
> - return ret;
> + goto err_failed;
>
> /* Schedule a polling after about 1 min */
> schedule_delayed_work(&di->work, 60 * HZ);
> @@ -103,6 +119,16 @@ static int bq27xxx_battery_i2c_probe(struct i2c_client *client,
> }
>
> return 0;
> +
> +err_mem:
> + ret = -ENOMEM;
> +
> +err_failed:
> + mutex_lock(&battery_mutex);
> + idr_remove(&battery_id, num);
> + mutex_unlock(&battery_mutex);
> +
> + return ret;
> }
>
> static int bq27xxx_battery_i2c_remove(struct i2c_client *client)
Hi! Should not we call idr_remove() also in bq27xxx_battery_i2c_remove()?
--
Pali Rohár
pali.rohar@gmail.com
next prev parent reply other threads:[~2016-02-02 12:27 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-02 12:15 [PATCH] power: bq27xxx_battery: Restore device name Ivaylo Dimitrov
2016-02-02 12:27 ` Pali Rohár [this message]
2016-02-02 12:32 ` Ivaylo Dimitrov
2016-02-02 12:34 ` [PATCH v1] " Ivaylo Dimitrov
2016-02-02 12:37 ` Ivaylo Dimitrov
2016-02-02 12:47 ` [PATCH v2] " Ivaylo Dimitrov
2016-02-06 10:35 ` Pali Rohár
2016-02-21 11:34 ` Pali Rohár
2016-02-23 9:32 ` Pali Rohár
2016-02-02 12:47 ` [PATCH v1] " kbuild test robot
2016-02-02 12:27 ` [PATCH] " Ivaylo Dimitrov
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=20160202122756.GI4389@pali \
--to=pali.rohar@gmail.com \
--cc=dbaryshkov@gmail.com \
--cc=dwmw2@infradead.org \
--cc=ivo.g.dimitrov.75@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.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;
as well as URLs for NNTP newsgroup(s).