Re: [PATCHv3 1/4] mfd: tps65912: Add new mfd device

From: Mark Brown
Date: Sun May 15 2011 - 13:05:47 EST


On Fri, May 13, 2011 at 04:30:22PM -0500, Margarita Olaya wrote:

> +#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
> +static int tps65912_i2c_read(struct tps65912 *tps65912, u8 reg,
> + int bytes, void *dest)
> +{

Putting both SPI and I2C drivers into the same file means that I2C is
forced to be built in if SPI is enabled (SPI can't be built as a
module). This isn't a big deal really but it's nice to avoid the
dependency.

> + dcdc_avs = (pmic_plat_data->is_dcdc1_avs << 0 |
> + pmic_plat_data->is_dcdc2_avs << 1 |
> + pmic_plat_data->is_dcdc3_avs << 2 |
> + pmic_plat_data->is_dcdc4_avs << 3);
> + if (dcdc_avs) {
> + tps65912->read(tps65912, TPS65912_I2C_SPI_CFG, 1, &value);
> + dcdc_avs |= value;
> + tps65912->write(tps65912, TPS65912_I2C_SPI_CFG, 1, &dcdc_avs);
> + }
> +
> + ret = mfd_add_devices(tps65912->dev, -1,
> + tps65912s, ARRAY_SIZE(tps65912s),
> + NULL, 0);
> + if (ret < 0)
> + goto err;

The platform data and MFD handling are common to both I2C and SPI - it'd
seem sensible to factor them out into a separate function called by the
I2C and SPI init paths to ensure they are kept in sync.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/