lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:	Thu, 1 Apr 2010 19:35:11 +0100
From:	Mark Brown <broonie@...nsource.wolfsonmicro.com>
To:	Rodolfo Giometti <giometti@...ux.it>
Cc:	linux-kernel@...r.kernel.org, Liam Girdwood <lrg@...mlogic.co.uk>
Subject: Re: [PATCH 04/19] regulator: add support for Dallas DS1803 dual
	digital potentiometer

On Thu, Apr 01, 2010 at 01:23:32PM +0200, Rodolfo Giometti wrote:

This looks good, a few nitpicky things below.

> +config REGULATOR_DS1803
> +	tristate "Dallas Maxim DS1803 addressable dual digital potentiometer"
> +	depends on I2C
> +	help
> +	  Say Y here to support the dual digital potentiometer on
> +	  Dallas Maxim DS1803
> +

Oh, wow.  A pot as a voltage regulator...  :)

> +struct ds1803_data {
> +	struct i2c_client *client;
> +	struct regulator_dev *rdev;
> +
> +	unsigned int min_uV;	/* voltage for selector value 0 */
> +	unsigned int max_uV;	/* voltage for selector value 255 */
> +	unsigned int init_uV;	/* initial voltage */

Given that you don't support get_voltage() or otherwise reference
init_uV it seems as well to just drop that for now.

> +static u8 ds1803_write_pot_lut[] = { 0xa9, 0xaa, /* both not supported */ };

Both what?  Since you don't seem to reference this I guess it could just
be dropped...

> +static int ds1803_list_voltage(struct regulator_dev *rdev, unsigned index)
> +{
> +	struct ds1803_data *ds1803 = rdev_get_drvdata(rdev);
> +
> +	return (ds1803->max_uV - ds1803->min_uV) * index / 255
> +							+ ds1803->min_uV;
> +}

I think I'd like more brackets in this calculation for clarity that the
operator precedence is OK.

> +		/* Set chip's name according to user supplied type */
> +		ds1803_reg[i].name = ds1803_names[pdata->type];

Perhaps just let the user write in something they feel like, or use a
constant string for the chip?  The type doesn't seem to be used
otherwise so I can see the data ending up wrong and misleading folks.

> +enum ds1803_type {
> +	DS1803_100K,
> +	DS1803_50K,
> +	DS1803_10K,
> +};

If you are going to keep these assign a value to the first item so you
don't end up with 0 as a valid type, or make the 0 type be "unspecified"
or something.  That way platform data that's left initialised to zero
can be distinguished from something that someone deliberately set.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ