All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anton Vorontsov <cbouatmailru@gmail.com>
To: Rhyland Klein <rklein@nvidia.com>
Cc: Grant Likely <grant.likely@secretlab.ca>,
	linux-kernel@vger.kernel.org,
	devicetree-discuss@lists.ozlabs.org
Subject: Re: [PATCH 5/5] power: sbs-battery: Change power supply name
Date: Tue, 6 Dec 2011 05:33:06 +0400	[thread overview]
Message-ID: <20111206013305.GB3065@oksana.dev.rtsoft.ru> (raw)
In-Reply-To: <1323129487-24859-5-git-send-email-rklein@nvidia.com>

On Mon, Dec 05, 2011 at 03:58:07PM -0800, Rhyland Klein wrote:
>  static int sbs_read_word_data(struct i2c_client *client, u8 address)
> @@ -681,15 +682,25 @@ static int __devinit sbs_probe(struct i2c_client *client,
>  	struct sbs_platform_data *pdata = client->dev.platform_data;
>  	int rc;
>  	int irq;
> +	char *name;
>  
> -	chip = kzalloc(sizeof(struct sbs_info), GFP_KERNEL);
> -	if (!chip)
> +	name = kasprintf(GFP_KERNEL, "%s-%s", "sbs", dev_name(&client->dev));

Mm... why not just

kasprintf(GFP_KERNEL, "sbs-%s", dev_name(&client->dev)) ?

> +	if (!name) {
> +		dev_err(&client->dev, "Failed to allocate device name\n");
>  		return -ENOMEM;
> +	}
> +
> +	chip = kzalloc(sizeof(struct sbs_info), GFP_KERNEL);
> +	if (!chip) {
> +		rc = -ENOMEM;
> +		goto exit_free_name;
> +	}
>  
>  	chip->client = client;
>  	chip->enable_detection = false;
>  	chip->gpio_detect = false;
> -	chip->power_supply.name = "battery";
> +	chip->name = name;
> +	chip->power_supply.name = name;
>  	chip->power_supply.type = POWER_SUPPLY_TYPE_BATTERY;
>  	chip->power_supply.properties = sbs_properties;
>  	chip->power_supply.num_properties = ARRAY_SIZE(sbs_properties);
> @@ -774,6 +785,9 @@ exit_psupply:
>  
>  	kfree(chip);
>  
> +exit_free_name:
> +	kfree(name);
> +
>  	return rc;
>  }
>  
> @@ -790,6 +804,7 @@ static int __devexit sbs_remove(struct i2c_client *client)
>  
>  	cancel_delayed_work_sync(&chip->work);
>  
> +	kfree(chip->name);

I think you don't really need chip->name.

power_supply_unregister() won't touch power_supply.name, so
you can kfree(chip->power_supply.name);

Otherwise, the patch looks great.

Thanks!

-- 
Anton Vorontsov
Email: cbouatmailru@gmail.com

  reply	other threads:[~2011-12-06  1:33 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-05 23:58 [PATCH 1/5] drivers: power: Rename bq20z75 to sbs-battery Rhyland Klein
2011-12-05 23:58 ` Rhyland Klein
     [not found] ` <1323129487-24859-1-git-send-email-rklein-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2011-12-05 23:58   ` [PATCH 2/5] power: sbs-battery: rename internals to new name Rhyland Klein
2011-12-05 23:58     ` Rhyland Klein
2011-12-06  1:20     ` Anton Vorontsov
     [not found]       ` <20111206012012.GA3065-wnGakbxT3iijyJ0x5qLZdcN33GVbZNy3@public.gmane.org>
2011-12-06  1:20         ` Rhyland Klein
2011-12-06  1:20           ` Rhyland Klein
2011-12-05 23:58   ` [PATCH 3/5] Adding entry for Smart Battery Systems Rhyland Klein
2011-12-05 23:58     ` Rhyland Klein
2011-12-05 23:58   ` [PATCH 4/5] Rename propgated to dt binding documentation Rhyland Klein
2011-12-05 23:58     ` Rhyland Klein
2011-12-05 23:58 ` [PATCH 5/5] power: sbs-battery: Change power supply name Rhyland Klein
2011-12-06  1:33   ` Anton Vorontsov [this message]
2011-12-06 17:41 ` [PATCH 1/5] drivers: power: Rename bq20z75 to sbs-battery Matthew Garrett
     [not found]   ` <20111206174100.GA15449-1xO5oi07KQx4cg9Nei1l7Q@public.gmane.org>
2011-12-14 19:26     ` Rhyland Klein
2011-12-14 19:26       ` Rhyland Klein
2011-12-14 19:51       ` Matthew Garrett

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=20111206013305.GB3065@oksana.dev.rtsoft.ru \
    --to=cbouatmailru@gmail.com \
    --cc=devicetree-discuss@lists.ozlabs.org \
    --cc=grant.likely@secretlab.ca \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rklein@nvidia.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.