devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mudit Sharma <muditsharma.info@gmail.com>
To: Javier Carrasco <javier.carrasco.cruz@gmail.com>,
	jic23@kernel.org, lars@metafoo.de, krzk+dt@kernel.org,
	conor+dt@kernel.org, robh@kernel.org
Cc: ivan.orlov0322@gmail.com, linux-kernel@vger.kernel.org,
	linux-iio@vger.kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v5 2/2] iio: light: ROHM BH1745 colour sensor
Date: Tue, 25 Jun 2024 20:25:00 +0100	[thread overview]
Message-ID: <7fde0674-c20a-4455-bb78-3a6521ae99ed@gmail.com> (raw)
In-Reply-To: <cf06ea77-c8b0-4476-94d1-32171c96f22f@gmail.com>

On 24/06/2024 23:27, Javier Carrasco wrote:
> 
>> +static int bh1745_set_trigger_state(struct iio_trigger *trig, bool state)
>> +{
>> +	int ret;
> 
> Why is value initialized here? If regmap returns an error, you will not
> use value anyway. I caught my eye because it is initialized here, and
> not in the other functions where you use the same pattern.

Hi Javier,

Thank you for the review on this.

'value' is initialized here for case when we un-set the trigger. In that 
case, 'state' will be false and 'value' of 0 (default value for 
BH1745_INTR register) will be written.

Best regards,
Mudit Sharma
> 
>> +	int value = 0;
>> +	struct iio_dev *indio_dev = iio_trigger_get_drvdata(trig);
>> +	struct bh1745_data *data = iio_priv(indio_dev);
>> +
>> +	guard(mutex)(&data->lock);
>> +	if (state) {
>> +		ret = regmap_read(data->regmap, BH1745_INTR, &value);
>> +		if (ret)
>> +			return ret;
>> +		// Latch is always set when enabling interrupt
>> +		value |= BH1745_INT_ENABLE |
>> +			FIELD_PREP(BH1745_INT_SIGNAL_LATCHED, 1) |
>> +			FIELD_PREP(BH1745_INT_SOURCE_MASK, data->int_src);
>> +		return regmap_write(data->regmap, BH1745_INTR, value);
>> +	}
>> +
>> +	return regmap_write(data->regmap, BH1745_INTR, value);
>> +}
> 
> 
> Best regards,
> Javier Carrasco
> 


  reply	other threads:[~2024-06-25 19:25 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-24 21:55 [PATCH v5 1/2] dt-bindings: iio: light: ROHM BH1745 Mudit Sharma
2024-06-24 21:55 ` [PATCH v5 2/2] iio: light: ROHM BH1745 colour sensor Mudit Sharma
2024-06-24 22:27   ` Javier Carrasco
2024-06-25 19:25     ` Mudit Sharma [this message]
2024-06-25 23:44       ` Javier Carrasco

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=7fde0674-c20a-4455-bb78-3a6521ae99ed@gmail.com \
    --to=muditsharma.info@gmail.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=ivan.orlov0322@gmail.com \
    --cc=javier.carrasco.cruz@gmail.com \
    --cc=jic23@kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robh@kernel.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).