Re: [PATCH v4 3/3] iio: light: vcnl4000: Add interrupt support for vcnl4040

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

 




On 1/17/23 16:59, Andy Shevchenko wrote:
On Tue, Jan 17, 2023 at 05:58:54PM +0200, Andy Shevchenko wrote:
On Tue, Jan 17, 2023 at 04:24:35PM +0100, Mårten Lindahl wrote:
...

+	val = ret;
+
+	if (dir == IIO_EV_DIR_RISING)
+		val = state ? (val | VCNL4040_PS_IF_AWAY) :
+		    (val & ~VCNL4040_PS_IF_AWAY);
+	else
+		val = state ? (val | VCNL4040_PS_IF_CLOSE) :
+		    (val & ~VCNL4040_PS_IF_CLOSE);

Wouldn't be better

	uXX val, mask;


	if (dir == IIO_EV_DIR_RISING)
		mask = VCNL4040_PS_IF_AWAY;
	else
		mask = VCNL4040_PS_IF_CLOSE;

	val = state ? (val | mask) : (val & ~mask);
Of course I meant

	val = state ? (ret | mask) : (ret & ~mask);

?

Sure. There are several ways to do this, but your suggestion may be more clear. I'll fix it. Thanks!

Kind regards

Mårten




[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