linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mark Brown <broonie-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
To: Cyril Chemparathy <cyril-l0cyMroinI0@public.gmane.org>
Cc: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org,
	davinci-linux-open-source-VycZQUHpC/PFrsHnngEfi1aTQe2KTcn/@public.gmane.org,
	dbrownell-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org,
	lrg-kDsPt+C1G03kYMGBc/C6ZA@public.gmane.org
Subject: Re: [PATCH 06/12] regulator: add driver for tps6524x regulator
Date: Thu, 14 Oct 2010 22:03:24 +0100	[thread overview]
Message-ID: <20101014210323.GB14479@opensource.wolfsonmicro.com> (raw)
In-Reply-To: <1287081535-2864-7-git-send-email-cyril-l0cyMroinI0@public.gmane.org>

On Thu, Oct 14, 2010 at 02:38:49PM -0400, Cyril Chemparathy wrote:
> TPS6524X provides three step-down converters and two general-purpose LDO
> voltage regulators.  This device is interfaced using SPI.
> 
> Signed-off-by: Cyril Chemparathy <cyril-l0cyMroinI0@public.gmane.org>

This looks mostly good but...

> +static int read(struct tps6524x *hw, int reg)
> +{

I suspect you may run into a namespace issue with this in the future.

> +static const int dcdc1_voltages[] = {
> +	 800000,  825000,  850000,  875000,
> +	 900000,  925000,  950000,  975000,
> +	1000000, 1025000, 1050000, 1075000,
> +	1100000, 1125000, 1150000, 1175000,
> +	1200000, 1225000, 1250000, 1275000,
> +	1300000, 1325000, 1350000, 1375000,
> +	1400000, 1425000, 1450000, 1475000,
> +	1500000, 1525000, 1550000, 1575000,

Looks like you could just do the maths for most of these tables, might
be a bit clearer/simpler?  Not a major issue either way, though.

> +static int list_voltage(struct regulator_dev *rdev, unsigned selector)
> +{
> +	const struct supply_info *info;
> +	struct tps6524x *hw;
> +
> +	hw	= rdev_get_drvdata(rdev);
> +	info	= &supply_info[rdev_get_id(rdev)];
> +
> +	if (info->flags & FIXED_VOLTAGE)
> +		return selector ? -EINVAL : info->fixed_voltage;
> +	else
> +		return (selector < 0 || selector >= info->n_voltages) ?
> +			-EINVAL : info->voltages[selector];

I'm not sure the ternery operator is helping legibility here - if
statements might be more legible.

> +	ret = read_field(hw, &info->voltage);
> +	if (ret < 0)
> +		return ret;
> +	if (ret >= info->n_voltages)
> +		return -EINVAL;

Shouldn't this be warning somehow - if we can't understand the register
setting that'd be a driver bug, -EINVAL makes it sound like an invalid
parameter was supplied.  Similarly for the current limit.

> +static ssize_t show_reg(struct device *dev, struct device_attribute *attr,
> +			char *buf);
> +static ssize_t store_reg(struct device *dev, struct device_attribute *attr,
> +			 const char *buf, size_t size);
> +
> +static DEVICE_ATTR(ldo_set,	0664, show_reg, store_reg);
> +static DEVICE_ATTR(block_en,	0664, show_reg, store_reg);
> +static DEVICE_ATTR(dcdc_set,	0664, show_reg, store_reg);
> +static DEVICE_ATTR(dcdc_en,	0664, show_reg, store_reg);
> +static DEVICE_ATTR(usb,		0664, show_reg, store_reg);
> +static DEVICE_ATTR(alarm,	0664, show_reg, store_reg);
> +static DEVICE_ATTR(int_enable,	0664, show_reg, store_reg);
> +static DEVICE_ATTR(int_status,	0664, show_reg, store_reg);
> +static DEVICE_ATTR(rev_id,	0664, show_reg, store_reg);
> +static DEVICE_ATTR(write_enable,   0664, show_reg, store_reg);
> +static DEVICE_ATTR(software_reset, 0664, show_reg, store_reg);

Large chunks of this looks like it's exporting functionality which is
part of the regulator API to userspace, replicating functionality which
the API provides.  Please either remove or replace with standard
functionality.

The USB setting should be integrated with the USB subsystem, assuming
it's changing a USB current limit.

> +	init_data = dev->platform_data;
> +	if (!init_data) {
> +		dev_err(dev, "could not find regulator platform data\n");
> +		return -EIO;
> +	}

EIO doesn't look right here...

  parent reply	other threads:[~2010-10-14 21:03 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-14 18:38 [PATCH 00/12] tnetv107x ssp driver stack Cyril Chemparathy
     [not found] ` <1287081535-2864-1-git-send-email-cyril-l0cyMroinI0@public.gmane.org>
2010-10-14 18:38   ` [PATCH 01/12] misc: add driver for sequencer serial port Cyril Chemparathy
     [not found]     ` <1287081535-2864-2-git-send-email-cyril-l0cyMroinI0@public.gmane.org>
2010-10-16  5:00       ` Grant Likely
     [not found]         ` <20101016050055.GH21170-MrY2KI0G/OVr83L8+7iqerDks+cytr/Z@public.gmane.org>
2010-10-18 13:56           ` Cyril Chemparathy
     [not found]             ` <4CBC520B.9070502-l0cyMroinI0@public.gmane.org>
2010-10-18 14:59               ` Grant Likely
2010-10-14 18:38   ` [PATCH 02/12] davinci: add tnetv107x ssp platform device Cyril Chemparathy
2010-10-14 18:38   ` [PATCH 03/12] davinci: add ssp config for tnetv107x evm board Cyril Chemparathy
2010-10-14 18:38   ` [PATCH 04/12] spi: add ti-ssp spi master driver Cyril Chemparathy
     [not found]     ` <1287081535-2864-5-git-send-email-cyril-l0cyMroinI0@public.gmane.org>
2010-10-16  5:05       ` Grant Likely
2010-10-14 18:38   ` [PATCH 05/12] davinci: add spi devices on tnetv107x evm Cyril Chemparathy
2010-10-14 18:38   ` [PATCH 06/12] regulator: add driver for tps6524x regulator Cyril Chemparathy
     [not found]     ` <1287081535-2864-7-git-send-email-cyril-l0cyMroinI0@public.gmane.org>
2010-10-14 21:03       ` Mark Brown [this message]
     [not found]         ` <20101014210323.GB14479-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
2010-10-18 12:50           ` Cyril Chemparathy
2010-10-16 10:00       ` Mark Brown
2010-10-14 18:38   ` [PATCH 07/12] davinci: add tnetv107x evm regulators Cyril Chemparathy
     [not found]     ` <1287081535-2864-8-git-send-email-cyril-l0cyMroinI0@public.gmane.org>
2010-10-14 21:05       ` Mark Brown
2010-10-14 18:38   ` [PATCH 08/12] gpio: add ti-ssp virtual gpio driver Cyril Chemparathy
2010-10-14 18:38   ` [PATCH 09/12] davinci: add tnetv107x evm ti-ssp gpio device Cyril Chemparathy
2010-10-14 18:38   ` [PATCH 10/12] backlight: add support for tps6116x controller Cyril Chemparathy
2010-10-14 18:38   ` [PATCH 11/12] davinci: add tnetv107x evm backlight device Cyril Chemparathy
2010-10-14 18:38   ` [PATCH 12/12] davinci: add tnetv107x evm i2c eeprom device Cyril Chemparathy

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=20101014210323.GB14479@opensource.wolfsonmicro.com \
    --to=broonie-yzvpicuk2aatku/dhu1wvuem+bqzidxxqq4iyu8u01e@public.gmane.org \
    --cc=cyril-l0cyMroinI0@public.gmane.org \
    --cc=davinci-linux-open-source-VycZQUHpC/PFrsHnngEfi1aTQe2KTcn/@public.gmane.org \
    --cc=dbrownell-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
    --cc=lrg-kDsPt+C1G03kYMGBc/C6ZA@public.gmane.org \
    --cc=spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
    /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).