mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mark Brown <broonie@kernel.org>
To: James Ban <james.ban.opensource@diasemi.com>
Cc: Liam Girdwood <lgirdwood@gmail.com>,
	Support Opensource <support.opensource@diasemi.com>,
	LKML <linux-kernel@vger.kernel.org>,
	David Dajun Chen <david.chen@diasemi.com>
Subject: Re: [PATCH V1] regulator: DA9211 : support DA9213
Date: Thu, 7 Aug 2014 11:04:50 +0100	[thread overview]
Message-ID: <20140807100450.GE17528@sirena.org.uk> (raw)
In-Reply-To: <201408050102.s7512cAr016807@krsrvapps-01.diasemi.com>

[-- Attachment #1: Type: text/plain, Size: 1226 bytes --]

On Tue, Aug 05, 2014 at 09:56:45AM +0900, James Ban wrote:

This is mostly good, just one fairly small thing:

> +static const int da9211_current_limits[2][16] = {
> +	/* DA9211 current limits */
> +	{2000000, 2200000, 2400000, 2600000, 2800000, 3000000, 3200000, 3400000,
> +	3600000, 3800000, 4000000, 4200000, 4400000, 4600000, 4800000, 5000000},
> +	/* DA9213 current limits */
> +	{3000000, 3200000, 3400000, 3600000, 3800000, 4000000, 4200000, 4400000,
> +	4600000, 4800000, 5000000, 5200000, 5400000, 5600000, 5800000, 6000000},
>  };

It's going to be more robust to have two arrays here, C doesn't deal
with multiply nested arrays well and indexing by arbatrary number is
generally fragile.

> +	if (chip->chip_id == DA9213)
> +		row = 1;

switch statement, what happens when there's another derivative?

> +	if (!(chip->chip_id == DA9211 && data == DA9211_DEVICE_ID)
> +		&& !(chip->chip_id == DA9213 && data == DA9213_DEVICE_ID)) {
> +		dev_err(chip->dev, "Chip ID and configuration is mismatched\n");
> +		ret = -ENODEV;
> +		return ret;
> +	}

You could convert this to a switch statement and then set driver data
pointing to the right tables and so on so you don't have conditional
code elsewhere in the driver.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

      reply	other threads:[~2014-08-07 10:04 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-05  0:56 James Ban
2014-08-07 10:04 ` Mark Brown [this message]

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=20140807100450.GE17528@sirena.org.uk \
    --to=broonie@kernel.org \
    --cc=david.chen@diasemi.com \
    --cc=james.ban.opensource@diasemi.com \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=support.opensource@diasemi.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

all inboxes | Powered by JetHome®