[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20110515170158.GA11579@opensource.wolfsonmicro.com>
Date: Sun, 15 May 2011 10:01:59 -0700
From: Mark Brown <broonie@...nsource.wolfsonmicro.com>
To: Margarita Olaya <magi@...mlogic.co.uk>
Cc: linux-kernel@...r.kernel.org, Liam Girdwood <lrg@...mlogic.co.uk>
Subject: Re: [PATCHv3 4/4] tps65912: add regulator driver
On Fri, May 13, 2011 at 04:30:49PM -0500, Margarita Olaya wrote:
> The tps65912 consiste of 4 DCDCs and 10 LDOs. The output voltages can be
> configured by the SPI or I2C interface, they are meant to supply power
> to the main processor and other components.
Looks pretty good
Acked-by: Mark Brown <broonie@...nsource.wolfsonmicro.com>
though a few things that you could fix incrementally:
> +static unsigned int tps65912_get_mode(struct regulator_dev *dev)
> +{
> + struct tps65912_reg *pmic = rdev_get_drvdata(dev);
> + struct tps65912 *mfd = pmic->mfd;
> + int pwm_mode, eco, mode = 0, id = rdev_get_id(dev);
> +
> + switch (id) {
> + case TPS65912_REG_DCDC1:
> + pwm_mode = tps65912_reg_read(mfd, TPS65912_DCDC1_CTRL);
> + eco = tps65912_reg_read(mfd, TPS65912_DCDC1_AVS);
> + break;
This switch statement for the lookup could be factored out into a
separate function for sharing with set.
> +static int tps65912_get_voltage_dcdc(struct regulator_dev *dev)
> +{
> + struct tps65912_reg *pmic = rdev_get_drvdata(dev);
> + struct tps65912 *mfd = pmic->mfd;
> + int id = rdev_get_id(dev), voltage = 0, range;
> + int opvsel = 0, avsel = 0, sr, vsel;
You'd save code in this function if you made it into a get_voltage_sel()
- a large chunk of it is a selector to voltage lookup.
> +static int tps65912_get_voltage_ldo(struct regulator_dev *dev)
> +{
> + struct tps65912_reg *pmic = rdev_get_drvdata(dev);
> + struct tps65912 *mfd = pmic->mfd;
> + int id = rdev_get_id(dev);
> + int vsel = 0;
> + u8 reg;
> +
> + reg = tps65912_get_ldo_sel_register(pmic, id);
> + vsel = tps65912_reg_read(mfd, reg);
> + vsel &= 0x3F;
> +
> + return tps65912_vsel_to_uv_ldo(vsel);
This is just an open coded get_voltage_sel().
--
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