Re: [PATCH 4/4]-V2 Add MFD driver for TPS6507x family ofmulti-function chips and move TPS6507x regulator driver from beingstand-alone to using the MFD driver.

From: Mark Brown
Date: Mon Apr 05 2010 - 09:57:11 EST


On Fri, Apr 02, 2010 at 03:37:33PM -0600, Todd Fischer wrote:
> Add MFD driver for TPS6507x family of multi-function chips. Move TPS6507x
> regulator driver from being stand-alone driver to using the MFD TPS6507x driver.
>
> Signed-off-by: Todd Fischer <todd.fischer@xxxxxxxxxxxx>

One issue...

> +static int tps6507x_i2c_read_device(struct tps6507x_dev *tps6507x, char reg,
> + int bytes, void *dest)
> +{
> + struct i2c_client *i2c = tps6507x->i2c_client;
> + int ret;
> +
> + ret = i2c_master_send(i2c, &reg, 1);
> + if (ret < 0)
> + return ret;
> +
> + ret = i2c_master_recv(i2c, dest, bytes);
> + if (ret < 0)
> + return ret;
> + if (ret != bytes)
> + return -EIO;
> + return 0;
> +}

Your register I/O functions don't have anything protecting them against
concurrent access. This isn't really an issue for the writes by
themselves since they do a single transaction on the I2C bus so the I2C
layer concurrency protection ought to be enough but for reads you need
to send the register address first then read back the data, opening up
an issue. A simple mutex in the read and write functions ought to cover
this.
--
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/