Re: [PATCHv3] iio: adc: add driver for MCP3204/08 12-bit ADC

From: Lars-Peter Clausen
Date: Fri May 03 2013 - 05:35:54 EST


On 05/03/2013 10:55 AM, Oskar Andero wrote:
[...]
> +
> +struct mcp320x {
> + struct spi_device *spi;
> + struct spi_message msg;
> + struct spi_transfer transfer[2];
> +
> + u8 tx_buf;
> + u8 rx_buf[2];
> +
> + struct regulator *reg;
> + unsigned int ref_mv;

ref_mv looks unused.

> +
> + struct mutex lock;
> +};
> +
[..]
> +static int mcp320x_probe(struct spi_device *spi)
> +{
[...]
> +
> + ret = regulator_enable(adc->reg);
> + if (ret < 0)
> + goto reg_free;

You shouldn't disable the regulator if enabling it failed.

> +
> + mutex_init(&adc->lock);
> +
> + ret = iio_device_register(indio_dev);
> + if (ret < 0)
> + goto reg_free;
> +
> + return 0;
> +
> +reg_free:
> + regulator_disable(adc->reg);
> + regulator_put(adc->reg);
> +iio_free:
> + iio_device_free(indio_dev);
> +
> + return ret;
> +}
[...]

--
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/