linux-kernel-mentees.lists.linuxfoundation.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Anshul Dalal <anshulusr@gmail.com>
Cc: linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org,
	devicetree@vger.kernel.org, Conor Dooley <conor+dt@kernel.org>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Rob Herring <robh+dt@kernel.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
	linux-kernel-mentees@lists.linuxfoundation.org,
	Shuah Khan <skhan@linuxfoundation.org>
Subject: Re: [PATCH v2 2/2] iio: light: driver for Lite-On ltr390
Date: Mon, 4 Dec 2023 10:05:17 +0000	[thread overview]
Message-ID: <20231204100517.30df720e@jic23-huawei> (raw)
In-Reply-To: <f6ced6e9-65d2-4bbc-9792-473465bad547@gmail.com>


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


  reply	other threads:[~2023-12-04 10:05 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-17  7:45 [PATCH v2 1/2] dt-bindings: iio: light: add ltr390 Anshul Dalal
2023-11-17  7:45 ` [PATCH v2 2/2] iio: light: driver for Lite-On ltr390 Anshul Dalal
2023-11-17 14:23   ` kernel test robot
2023-11-17 18:13   ` kernel test robot
2023-11-25 14:06   ` Jonathan Cameron
2023-11-27 15:47     ` Anshul Dalal
2023-12-04 10:05       ` Jonathan Cameron [this message]
2023-11-17 11:09 ` [PATCH v2 1/2] dt-bindings: iio: light: add ltr390 Krzysztof Kozlowski
2023-11-25 13:50 ` Jonathan Cameron

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231204100517.30df720e@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=anshulusr@gmail.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel-mentees@lists.linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robh+dt@kernel.org \
    --cc=skhan@linuxfoundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).