linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lee Jones <lee.jones@linaro.org>
To: Stefan Agner <stefan@agner.ch>
Cc: swarren@wwwdotorg.org, thierry.reding@gmail.com,
	sameo@linux.intel.com, dev@lynxeye.de, mark.rutland@arm.com,
	linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH 1/3] mfd: tps6586x: add version detection
Date: Wed, 27 Nov 2013 13:09:54 +0000	[thread overview]
Message-ID: <20131127130954.GF3296@lee--X1> (raw)
In-Reply-To: <ef881d39f78b75b4badeebb5be0264edc3906d86.1385508112.git.stefan@agner.ch>

<snip>

>  static int __remove_subdev(struct device *dev, void *unused)
>  {
>  	platform_device_unregister(to_platform_device(dev));
> @@ -477,6 +486,7 @@ static int tps6586x_i2c_probe(struct i2c_client *client,
>  {
>  	struct tps6586x_platform_data *pdata = dev_get_platdata(&client->dev);
>  	struct tps6586x *tps6586x;
> +	const char *name = "";

How much memory space does this guarantee?

>  	int ret;
>  
>  	if (!pdata && client->dev.of_node)
> @@ -487,20 +497,39 @@ static int tps6586x_i2c_probe(struct i2c_client *client,
>  		return -ENOTSUPP;
>  	}
>  
> +	tps6586x = devm_kzalloc(&client->dev, sizeof(*tps6586x), GFP_KERNEL);
> +	if (tps6586x == NULL) {

Can you take this oppotunity to change to:
  if (!tps6586x)

> +		dev_err(&client->dev, "memory for tps6586x alloc failed\n");

I'm not keen on -ENOMEM prints, just return -ENOMEM and be done with it.

> +		return -ENOMEM;
> +	}
> +
>  	ret = i2c_smbus_read_byte_data(client, TPS6586X_VERSIONCRC);

If you're going to do this, please change 'ret' to 'version'.

>  	if (ret < 0) {
>  		dev_err(&client->dev, "Chip ID read failed: %d\n", ret);
>  		return -EIO;

Why are you returning an error here when you have a valid enum of:
  TPS6586X_ANY	= -1,

>  	}
>  
> -	dev_info(&client->dev, "VERSIONCRC is %02x\n", ret);
> -
> -	tps6586x = devm_kzalloc(&client->dev, sizeof(*tps6586x), GFP_KERNEL);
> -	if (tps6586x == NULL) {
> -		dev_err(&client->dev, "memory for tps6586x alloc failed\n");
> -		return -ENOMEM;
> +	tps6586x->version = (enum tps6586x_version)ret;
> +	switch (ret) {
> +	case TPS658621A:
> +		name = "TPS658621A";
> +		break;
> +	case TPS658621CD:
> +		name = "TPS658621C/D";
> +		break;
> +	case TPS658623:
> +		name = "TPS658623";
> +		break;
> +	case TPS658643:
> +		name = "TPS658643";
> +		break;
> +	default:
> +		name = "TPS6586X";
> +		break;
>  	}
>  
> +	dev_info(&client->dev, "Found %s, VERSIONCRC is %02x\n", name, ret);
> +

I'd suggest pulling this out of probe() and into a separate subroutine.

<snip>

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

  reply	other threads:[~2013-11-27 13:10 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-26 23:45 [PATCH 0/3] regulator: tps6586x: add version detection and voltage tables Stefan Agner
2013-11-26 23:45 ` [PATCH 1/3] mfd: tps6586x: add version detection Stefan Agner
2013-11-27 13:09   ` Lee Jones [this message]
2013-11-27 13:11     ` Lee Jones
2013-11-27 13:49     ` Stefan Agner
2013-11-27 13:55       ` Lee Jones
     [not found]         ` <cfb203a896eda67c106794d89e668d56@agner.ch>
     [not found]           ` <20131127143429.GN3296@lee--X1>
2013-11-27 14:36             ` Lee Jones
2013-11-27 15:26               ` Stefan Agner
2013-11-27 15:30                 ` Lee Jones
2013-11-27 15:52                   ` Stefan Agner
2013-11-27 16:14                     ` Lee Jones
2013-11-27 16:58   ` Stephen Warren
2013-11-27 21:44     ` Stefan Agner
2013-11-26 23:45 ` [PATCH 2/3] regulator: tps6586x: add voltage table for tps658643 Stefan Agner
2013-11-27 17:09   ` Stephen Warren
2013-11-27 21:56     ` Stefan Agner
2013-11-28  8:30       ` Thierry Reding
2013-11-26 23:45 ` [PATCH 3/3] ARM: tegra: set SM2 voltage correct Stefan Agner
2013-11-27  9:59   ` Lucas Stach
2013-11-27 11:05     ` Stefan Agner
2013-11-27 11:06       ` Lucas Stach
2013-11-27 17:13   ` Stephen Warren
2013-11-27 22:03     ` Stefan Agner
2013-11-28  9:49     ` Lucas Stach
2013-11-30 16:24       ` Stefan Agner
2013-11-28  8:13 ` [PATCH 0/3] regulator: tps6586x: add version detection and voltage tables Thierry Reding
2013-11-29  8:20   ` Kai Poggensee

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=20131127130954.GF3296@lee--X1 \
    --to=lee.jones@linaro.org \
    --cc=dev@lynxeye.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=sameo@linux.intel.com \
    --cc=stefan@agner.ch \
    --cc=swarren@wwwdotorg.org \
    --cc=thierry.reding@gmail.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 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).