Re: [PATCH] iio: accel: Add driver for the mCube MC3230 3-axis accelerometer

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

On 12-09-16 07:32, Peter Meerwald-Stadler wrote:

+static const struct iio_chan_spec mc3230_channels[] = {
+	MC3230_CHANNEL(MC3230_REG_XOUT, X),
+	MC3230_CHANNEL(MC3230_REG_YOUT, Y),
+	MC3230_CHANNEL(MC3230_REG_ZOUT, Z),
+};
+
+struct mc3230_data {
+	struct i2c_client *client;
+};

probably don't need mc3230_data (or the client pointer within), not worth
changing as likely stuff will be added in the future

I was thinking the same, but since iio does not use
set / get private_data but instead allocs private data
as part of devm_iio_device_alloc, this seemed cleaner then doing:

devm_iio_device_alloc(&client->dev, sizeof(struct i2c_client *));

And then doing somewhat ugly casts to retrieve the client pointer again.

+static int mc3230_set_opcon(struct mc3230_data *data, int opcon)
+{
+	int ret;
+	struct i2c_client *client = data->client;
+

guess we want locking here

This register only gets touched by this function, and this
function only gets called:

-pre iio_device_register
-post iio_device_unregister
-on suspend/resume

So I do not see what it could race with.

I didn't check where set_opcon() is actually called, seems safe

I think there is a theoretic race in _remove() as _unregister() retval is
not checked, no need to change

OK, I'll do a v2 adding the missing static then.

Regards,

Hans
--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux