* [PATCH v1 0/1] iio: Remove assignment to pf->timestamp by using elvis
@ 2024-09-22 16:03 Vasileios Amoiridis
2024-09-22 16:03 ` [PATCH v1 1/1] iio: acpi-als: Use elvis operator to simplify if statement Vasileios Amoiridis
0 siblings, 1 reply; 3+ messages in thread
From: Vasileios Amoiridis @ 2024-09-22 16:03 UTC (permalink / raw)
To: jic23, lars; +Cc: linux-iio, linux-kernel, Vasileios Amoiridis
Instead of checking the value of the pf->timestamp and determining to assign
to it a new one or not, use the elvis operator to save some lines and
to simplify it.
Vasileios Amoiridis (1):
iio: acpi-als: Use elvis operator to simplify if statement
drivers/iio/light/acpi-als.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
base-commit: 8bea3878a1511bceadc2fbf284b00bcc5a2ef28d
--
2.25.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v1 1/1] iio: acpi-als: Use elvis operator to simplify if statement
2024-09-22 16:03 [PATCH v1 0/1] iio: Remove assignment to pf->timestamp by using elvis Vasileios Amoiridis
@ 2024-09-22 16:03 ` Vasileios Amoiridis
2024-09-28 14:58 ` Jonathan Cameron
0 siblings, 1 reply; 3+ messages in thread
From: Vasileios Amoiridis @ 2024-09-22 16:03 UTC (permalink / raw)
To: jic23, lars; +Cc: linux-iio, linux-kernel, Vasileios Amoiridis
By using the elvis operator here, we can get rid of the if statement
and simplify the code.
Signed-off-by: Vasileios Amoiridis <vassilisamir@gmail.com>
---
drivers/iio/light/acpi-als.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/iio/light/acpi-als.c b/drivers/iio/light/acpi-als.c
index 2d91caf24dd0..cea3499c3af3 100644
--- a/drivers/iio/light/acpi-als.c
+++ b/drivers/iio/light/acpi-als.c
@@ -171,10 +171,8 @@ static irqreturn_t acpi_als_trigger_handler(int irq, void *p)
*
* If the timestamp was actually 0, the timestamp is set one more time.
*/
- if (!pf->timestamp)
- pf->timestamp = iio_get_time_ns(indio_dev);
-
- iio_push_to_buffers_with_timestamp(indio_dev, buffer, pf->timestamp);
+ iio_push_to_buffers_with_timestamp(indio_dev, buffer,
+ pf->timestamp ?: iio_get_time_ns(indio_dev));
out:
mutex_unlock(&als->lock);
iio_trigger_notify_done(indio_dev->trig);
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v1 1/1] iio: acpi-als: Use elvis operator to simplify if statement
2024-09-22 16:03 ` [PATCH v1 1/1] iio: acpi-als: Use elvis operator to simplify if statement Vasileios Amoiridis
@ 2024-09-28 14:58 ` Jonathan Cameron
0 siblings, 0 replies; 3+ messages in thread
From: Jonathan Cameron @ 2024-09-28 14:58 UTC (permalink / raw)
To: Vasileios Amoiridis; +Cc: lars, linux-iio, linux-kernel
On Sun, 22 Sep 2024 18:03:04 +0200
Vasileios Amoiridis <vassilisamir@gmail.com> wrote:
> By using the elvis operator here, we can get rid of the if statement
> and simplify the code.
>
> Signed-off-by: Vasileios Amoiridis <vassilisamir@gmail.com>
> ---
> drivers/iio/light/acpi-als.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/iio/light/acpi-als.c b/drivers/iio/light/acpi-als.c
> index 2d91caf24dd0..cea3499c3af3 100644
> --- a/drivers/iio/light/acpi-als.c
> +++ b/drivers/iio/light/acpi-als.c
> @@ -171,10 +171,8 @@ static irqreturn_t acpi_als_trigger_handler(int irq, void *p)
> *
> * If the timestamp was actually 0, the timestamp is set one more time.
> */
> - if (!pf->timestamp)
> - pf->timestamp = iio_get_time_ns(indio_dev);
> -
> - iio_push_to_buffers_with_timestamp(indio_dev, buffer, pf->timestamp);
> + iio_push_to_buffers_with_timestamp(indio_dev, buffer,
> + pf->timestamp ?: iio_get_time_ns(indio_dev));
Hi Vasileios,
If the original code had looked like this I wouldn't mind, but
I actually prefer the original from a readability point of view, particularly
as it keeps the comment and code more closely coupled than after the patch.
So to my eyes this isn't an improvement.
Thanks
Jonathan
> out:
> mutex_unlock(&als->lock);
> iio_trigger_notify_done(indio_dev->trig);
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-09-28 14:58 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-22 16:03 [PATCH v1 0/1] iio: Remove assignment to pf->timestamp by using elvis Vasileios Amoiridis
2024-09-22 16:03 ` [PATCH v1 1/1] iio: acpi-als: Use elvis operator to simplify if statement Vasileios Amoiridis
2024-09-28 14:58 ` Jonathan Cameron
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox