Re: [PATCH v2 2/2] iio: light: driver for Lite-On ltr390

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

 



> >> +struct ltr390_data {
> >> +	struct regmap *regmap;
> >> +	struct i2c_client *client;
> >> +	struct mutex lock;  
> > 
> > All locks need a comment explaining the scope of data they protect.
> > Note that regmap and the i2c bus will have their own locks by default
> > so I'm not sure you need one here at all as I'm not seeing read modify write
> > cycles or anything like that (I might be missing one though!)  
> 
> My goal with the mutex was to protect the sysfs though that might be
> unnecessary.

Ok.  So, there is nothing stopping multiple parallel sysfs accesses, but
what you'll actually be protecting is either device or driver state, not
sysfs as such.

> 
> >> +};
> >> +
> >> +static const struct regmap_config ltr390_regmap_config = {
> >> +	.name = LTR390_DEVICE_NAME,
> >> +	.reg_bits = 8,
> >> +	.reg_stride = 1,
> >> +	.val_bits = 8,
> >> +};
> >> +


> >> +static int ltr390_probe(struct i2c_client *client)
> >> +{
> >> +	struct ltr390_data *data;
> >> +	struct iio_dev *indio_dev;
> >> +	int ret, part_number;
> >> +
> >> +	indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data));
> >> +	if (!indio_dev)
> >> +		return -ENOMEM;
> >> +
> >> +	data = iio_priv(indio_dev);
> >> +
> >> +	data->regmap = devm_regmap_init_i2c(client, &ltr390_regmap_config);
> >> +	if (IS_ERR(data->regmap))
> >> +		return dev_err_probe(&client->dev, PTR_ERR(data->regmap),  
> > There are quite a few &client->dev in here. I'd introduce
> > struct device *dev = &client->dev;
> > as a local variable then use that to shorten all those lines a little.
> >   
> >> +				     "regmap initialization failed\n");
> >> +
> >> +	data->client = client;
> >> +	i2c_set_clientdata(client, indio_dev);  
> > 
> > Why set this? I don' think you are using it.
> >   
> 
> It seems to be necessary for regmap to work properly, I tested without
> it and I get an EREMOTEIO(121) when reading the part id.

That's weird given regmap will have no understanding of an iio_dev.

If you can do some more debugging on where that error is coming from
in regmap that would be great.

I suspect it's coming from down in the bus master which should not
be touching this at all.  What is the i2c master in this case?

Jonathan


> 
> >> [..]  
> 
> Thanks for the review,
> Best regards,
> Anshul





[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux