From: Gyeyoung Baek <gye976@gmail.com>
To: "Jonathan Cameron" <jic23@kernel.org>,
"David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>
Cc: Gyeyoung Baek <gye976@gmail.com>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] iio: trigger: Remove redundant conditionals
Date: Sun, 4 May 2025 03:56:50 +0900 [thread overview]
Message-ID: <20250503185651.29445-1-gye976@gmail.com> (raw)
Checks for null initially and return early.
So there is no need to check for null later.
Signed-off-by: Gyeyoung Baek <gye976@gmail.com>
---
drivers/iio/industrialio-trigger.c | 20 ++++++++------------
1 file changed, 8 insertions(+), 12 deletions(-)
diff --git a/drivers/iio/industrialio-trigger.c b/drivers/iio/industrialio-trigger.c
index 54416a384232..6abf2a450202 100644
--- a/drivers/iio/industrialio-trigger.c
+++ b/drivers/iio/industrialio-trigger.c
@@ -453,36 +453,32 @@ static ssize_t current_trigger_store(struct device *dev,
}
trig = iio_trigger_acquire_by_name(buf);
- if (oldtrig == trig) {
+ if (!trig || trig == oldtrig) {
ret = len;
goto out_trigger_put;
}
-
- if (trig && indio_dev->info->validate_trigger) {
+ if (indio_dev->info->validate_trigger) {
ret = indio_dev->info->validate_trigger(indio_dev, trig);
if (ret)
goto out_trigger_put;
}
-
- if (trig && trig->ops && trig->ops->validate_device) {
+ if (trig->ops && trig->ops->validate_device) {
ret = trig->ops->validate_device(trig, indio_dev);
if (ret)
goto out_trigger_put;
}
- indio_dev->trig = trig;
-
if (oldtrig) {
if (indio_dev->modes & INDIO_EVENT_TRIGGERED)
iio_trigger_detach_poll_func(oldtrig,
indio_dev->pollfunc_event);
iio_trigger_put(oldtrig);
}
- if (indio_dev->trig) {
- if (indio_dev->modes & INDIO_EVENT_TRIGGERED)
- iio_trigger_attach_poll_func(indio_dev->trig,
- indio_dev->pollfunc_event);
- }
+ if (indio_dev->modes & INDIO_EVENT_TRIGGERED)
+ iio_trigger_attach_poll_func(trig,
+ indio_dev->pollfunc_event);
+
+ indio_dev->trig = trig;
return len;
--
2.43.0
next reply other threads:[~2025-05-03 18:56 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-03 18:56 Gyeyoung Baek [this message]
2025-05-04 14:30 ` [PATCH] iio: trigger: Remove redundant conditionals Jonathan Cameron
2025-05-05 8:29 ` Gyeyoung Baek
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=20250503185651.29445-1-gye976@gmail.com \
--to=gye976@gmail.com \
--cc=andy@kernel.org \
--cc=dlechner@baylibre.com \
--cc=jic23@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nuno.sa@analog.com \
/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