Re: [PATCHv2 1/3] misc: clean up bmp085 driver

From: Arnd Bergmann
Date: Tue Mar 06 2012 - 16:20:49 EST


On Tuesday 06 March 2012, Eric Andersson wrote:
> This patch includes various cleaning of the bmp085 driver including:
> - Addition of platform_data and header file
> - Implement pm functions
> - Whitespaces and alignment fixes
> - Minor typos
> - Consistency fixes
>
> Reviewed-by: Stefan Nilsson <stefan.nilsson@xxxxxxxxxxxxx>
> Signed-off-by: Eric Andersson <eric.andersson@xxxxxxxxxxxxx>

Most of the cleanups look good, just a few things that stick out:

> static int __devinit bmp085_probe(struct i2c_client *client,
> - const struct i2c_device_id *id)
> + const struct i2c_device_id *id)
> {
> struct bmp085_data *data;
> + struct bmp085_platform_data *pdata = client->dev.platform_data;
> + u8 chip_id = (pdata && pdata->chip_id) ? pdata->chip_id :
> + BMP085_CHIP_ID;
> int err = 0;
>
> + if (pdata && pdata->init_hw) {
> + err = pdata->init_hw(&client->dev);
> + if (err) {
> + dev_err(&client->dev, "%s: init_hw failed!\n",
> + BMP085_NAME);
> + return err;
> + }
> + }
> +

The addition of platform_data does not look like a cleanup to me,
it's a significant change in the interface to the platform, so I
would put it into a separate patch.

> + if (i2c_smbus_read_byte_data(client, BMP085_CHIP_ID_REG) != chip_id) {
> + dev_err(&client->dev, "%s: chip_id failed!\n", BMP085_NAME);
> + err = -ENODEV;
> + goto exit_free;
> + }
> +

This part looks like it belongs into the second patch where you add support
for more than one chip id.

> diff --git a/include/linux/i2c/bmp085.h b/include/linux/i2c/bmp085.h
> new file mode 100644
> index 0000000..e6fc752
> --- /dev/null
> +++ b/include/linux/i2c/bmp085.h

Since this file only adds platform_data, I think it should go into
include/linux/platform_data/, not include/linux/i2c, and it should
be in the same patch as the change to use the platform data when you
split that out.

Also, which platforms are actually using this driver? I could
not find any platform that defines a bmp085 platform_device. If this
is for new ARM platforms, I would rather not add platform_data at
all because those platforms will have to use device tree properties
rather than platform_data to pass initialization data.

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