Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1324035
| From | Pali Rohár <pali.rohar@gmail.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH] power: bq27xxx_battery: Restore device name |
| Date | 2016-02-02 13:30 +0100 |
| Message-ID | <qXIfM-2Pu-17@gated-at.bofh.it> (permalink) |
| References | <qXI67-2I0-21@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
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
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH] power: bq27xxx_battery: Restore device name Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com> - 2016-02-02 13:20 +0100
Re: [PATCH] power: bq27xxx_battery: Restore device name Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com> - 2016-02-02 13:30 +0100
Re: [PATCH] power: bq27xxx_battery: Restore device name Pali Rohár <pali.rohar@gmail.com> - 2016-02-02 13:30 +0100
Re: [PATCH] power: bq27xxx_battery: Restore device name Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com> - 2016-02-02 13:40 +0100
Re: [PATCH v1] power: bq27xxx_battery: Restore device name Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com> - 2016-02-02 13:40 +0100
[PATCH v2] power: bq27xxx_battery: Restore device name Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com> - 2016-02-02 13:50 +0100
Re: [PATCH v2] power: bq27xxx_battery: Restore device name Pali Rohár <pali.rohar@gmail.com> - 2016-02-06 11:40 +0100
[PATCH v1] power: bq27xxx_battery: Restore device name Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com> - 2016-02-02 13:40 +0100
Re: [PATCH v1] power: bq27xxx_battery: Restore device name kbuild test robot <lkp@intel.com> - 2016-02-02 13:50 +0100
csiph-web