From: Bartosz Golaszewski <brgl@bgdev.pl>
To: Drew Fustini <drew@pdp7.com>, Guo Ren <guoren@kernel.org>,
Fu Wei <wefu@redhat.com>, Bartosz Golaszewski <brgl@bgdev.pl>,
Ulf Hansson <ulf.hansson@linaro.org>,
Michal Wilczynski <m.wilczynski@samsung.com>
Cc: linux-riscv@lists.infradead.org, linux-pm@vger.kernel.org,
linux-kernel@vger.kernel.org,
Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Subject: [PATCH 3/5] pwrseq: add defines for return values of the match() callback
Date: Tue, 24 Jun 2025 16:32:20 +0200 [thread overview]
Message-ID: <20250624-pwrseq-match-defines-v1-3-a59d90a951f1@linaro.org> (raw)
In-Reply-To: <20250624-pwrseq-match-defines-v1-0-a59d90a951f1@linaro.org>
From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Instead of using 0 and 1 as magic numbers, let's add proper defines
whose names tell the reader what the meaning behind them is.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
drivers/power/sequencing/core.c | 6 +++---
include/linux/pwrseq/provider.h | 3 +++
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/drivers/power/sequencing/core.c b/drivers/power/sequencing/core.c
index 0ffc259c6bb6c8333ba1fc5e6ab43e42ba0d3524..190564e55988557940206b059fef52981bd49e5b 100644
--- a/drivers/power/sequencing/core.c
+++ b/drivers/power/sequencing/core.c
@@ -628,7 +628,7 @@ static int pwrseq_match_device(struct device *pwrseq_dev, void *data)
return 0;
ret = pwrseq->match(pwrseq, match_data->dev);
- if (ret <= 0)
+ if (ret == PWRSEQ_NO_MATCH || ret < 0)
return ret;
/* We got the matching device, let's find the right target. */
@@ -651,7 +651,7 @@ static int pwrseq_match_device(struct device *pwrseq_dev, void *data)
match_data->desc->pwrseq = pwrseq_device_get(pwrseq);
- return 1;
+ return PWRSEQ_MATCH_OK;
}
/**
@@ -684,7 +684,7 @@ struct pwrseq_desc *pwrseq_get(struct device *dev, const char *target)
pwrseq_match_device);
if (ret < 0)
return ERR_PTR(ret);
- if (ret == 0)
+ if (ret == PWRSEQ_NO_MATCH)
/* No device matched. */
return ERR_PTR(-EPROBE_DEFER);
diff --git a/include/linux/pwrseq/provider.h b/include/linux/pwrseq/provider.h
index cbc3607cbfcfeb5acbc94908a1eb4a861159dc41..33b3d2c2e39decafac6c6fca9254ad4329d90e94 100644
--- a/include/linux/pwrseq/provider.h
+++ b/include/linux/pwrseq/provider.h
@@ -13,6 +13,9 @@ struct pwrseq_device;
typedef int (*pwrseq_power_state_func)(struct pwrseq_device *);
typedef int (*pwrseq_match_func)(struct pwrseq_device *, struct device *);
+#define PWRSEQ_NO_MATCH 0
+#define PWRSEQ_MATCH_OK 1
+
/**
* struct pwrseq_unit_data - Configuration of a single power sequencing
* unit.
--
2.48.1
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
next prev parent reply other threads:[~2025-06-24 16:01 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-24 14:32 [PATCH 0/5] pwrseq: replace magic numbers with defines for match() return values Bartosz Golaszewski
2025-06-24 14:32 ` [PATCH 1/5] pwrseq: thead-gpu: add missing header Bartosz Golaszewski
2025-06-24 14:32 ` [PATCH 2/5] pwrseq: extend build coverage for pwrseq drivers with COMPILE_TEST=y Bartosz Golaszewski
2025-06-24 14:32 ` Bartosz Golaszewski [this message]
2025-06-24 14:32 ` [PATCH 4/5] pwrseq: qcom-wcn: use new defines for match() return values Bartosz Golaszewski
2025-06-24 14:32 ` [PATCH 5/5] pwrseq: thead-gpu: " Bartosz Golaszewski
2025-06-25 10:03 ` [PATCH 0/5] pwrseq: replace magic numbers with " Ulf Hansson
2025-06-30 7:11 ` Bartosz Golaszewski
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=20250624-pwrseq-match-defines-v1-3-a59d90a951f1@linaro.org \
--to=brgl@bgdev.pl \
--cc=bartosz.golaszewski@linaro.org \
--cc=drew@pdp7.com \
--cc=guoren@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=m.wilczynski@samsung.com \
--cc=ulf.hansson@linaro.org \
--cc=wefu@redhat.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;
as well as URLs for NNTP newsgroup(s).