* [PATCH 0/5] pwrseq: replace magic numbers with defines for match() return values
@ 2025-06-24 14:32 Bartosz Golaszewski
2025-06-24 14:32 ` [PATCH 1/5] pwrseq: thead-gpu: add missing header Bartosz Golaszewski
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: Bartosz Golaszewski @ 2025-06-24 14:32 UTC (permalink / raw)
To: Drew Fustini, Guo Ren, Fu Wei, Bartosz Golaszewski, Ulf Hansson,
Michal Wilczynski
Cc: linux-riscv, linux-pm, linux-kernel, Bartosz Golaszewski
We currently use 0 or 1 as magic numbers returned from the match()
callback. It's more readable to replace them with proper defines whose
names indicate the meaning. While at it: fix a build issue with the
thead-gpu driver I noticed and extend build coverage for the drivers.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
Bartosz Golaszewski (5):
pwrseq: thead-gpu: add missing header
pwrseq: extend build coverage for pwrseq drivers with COMPILE_TEST=y
pwrseq: add defines for return values of the match() callback
pwrseq: qcom-wcn: use new defines for match() return values
pwrseq: thead-gpu: use new defines for match() return values
drivers/power/sequencing/Kconfig | 4 ++--
drivers/power/sequencing/core.c | 6 +++---
drivers/power/sequencing/pwrseq-qcom-wcn.c | 8 ++++----
drivers/power/sequencing/pwrseq-thead-gpu.c | 12 +++++++-----
include/linux/pwrseq/provider.h | 3 +++
5 files changed, 19 insertions(+), 14 deletions(-)
---
base-commit: d4c2d9b5b7ceed14a3a835fd969bb0699b9608d3
change-id: 20250624-pwrseq-match-defines-aec46817e69e
Best regards,
--
Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 1/5] pwrseq: thead-gpu: add missing header
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 ` Bartosz Golaszewski
2025-06-24 14:32 ` [PATCH 2/5] pwrseq: extend build coverage for pwrseq drivers with COMPILE_TEST=y Bartosz Golaszewski
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Bartosz Golaszewski @ 2025-06-24 14:32 UTC (permalink / raw)
To: Drew Fustini, Guo Ren, Fu Wei, Bartosz Golaszewski, Ulf Hansson,
Michal Wilczynski
Cc: linux-riscv, linux-pm, linux-kernel, Bartosz Golaszewski
From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
When using kcalloc(), kfree() etc., we need to include linux/slab.h.
While on some architectures it may work fine because the header is
pulled in implicitly, on others it triggers the following errors:
drivers/power/sequencing/pwrseq-thead-gpu.c: In function ‘pwrseq_thead_gpu_match’:
drivers/power/sequencing/pwrseq-thead-gpu.c:147:21: error: implicit declaration of function ‘kcalloc’ [-Wimplicit-function-declaration]
147 | ctx->clks = kcalloc(ctx->num_clks, sizeof(*ctx->clks), GFP_KERNEL);
Fixes: d4c2d9b5b7ce ("power: sequencing: Add T-HEAD TH1520 GPU power sequencer driver")
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
drivers/power/sequencing/pwrseq-thead-gpu.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/power/sequencing/pwrseq-thead-gpu.c b/drivers/power/sequencing/pwrseq-thead-gpu.c
index 3dd27c32020a6d3b551eeaff2859456fed679814..855c6cc4f3b5bd1aa6e93305af0417d5791b092d 100644
--- a/drivers/power/sequencing/pwrseq-thead-gpu.c
+++ b/drivers/power/sequencing/pwrseq-thead-gpu.c
@@ -21,6 +21,7 @@
#include <linux/of.h>
#include <linux/pwrseq/provider.h>
#include <linux/reset.h>
+#include <linux/slab.h>
#include <dt-bindings/power/thead,th1520-power.h>
--
2.48.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/5] pwrseq: extend build coverage for pwrseq drivers with COMPILE_TEST=y
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 ` Bartosz Golaszewski
2025-06-24 14:32 ` [PATCH 3/5] pwrseq: add defines for return values of the match() callback Bartosz Golaszewski
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Bartosz Golaszewski @ 2025-06-24 14:32 UTC (permalink / raw)
To: Drew Fustini, Guo Ren, Fu Wei, Bartosz Golaszewski, Ulf Hansson,
Michal Wilczynski
Cc: linux-riscv, linux-pm, linux-kernel, Bartosz Golaszewski
From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Enable building the pwrseq drivers with COMPILE_TEST enabled. This makes
it easier to build-test them.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
drivers/power/sequencing/Kconfig | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/power/sequencing/Kconfig b/drivers/power/sequencing/Kconfig
index 0f118d57c1ceddc03954c006f99b5990acf546d4..280f92beb5d0ed524e67a28d1c5dd264bbd6c87e 100644
--- a/drivers/power/sequencing/Kconfig
+++ b/drivers/power/sequencing/Kconfig
@@ -16,7 +16,7 @@ if POWER_SEQUENCING
config POWER_SEQUENCING_QCOM_WCN
tristate "Qualcomm WCN family PMU driver"
default m if ARCH_QCOM
- depends on OF
+ depends on OF || COMPILE_TEST
help
Say Y here to enable the power sequencing driver for Qualcomm
WCN Bluetooth/WLAN chipsets.
@@ -29,7 +29,7 @@ config POWER_SEQUENCING_QCOM_WCN
config POWER_SEQUENCING_TH1520_GPU
tristate "T-HEAD TH1520 GPU power sequencing driver"
- depends on ARCH_THEAD && AUXILIARY_BUS
+ depends on (ARCH_THEAD && AUXILIARY_BUS) || COMPILE_TEST
help
Say Y here to enable the power sequencing driver for the TH1520 SoC
GPU. This driver handles the complex clock and reset sequence
--
2.48.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 3/5] pwrseq: add defines for return values of the match() callback
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
2025-06-24 14:32 ` [PATCH 4/5] pwrseq: qcom-wcn: use new defines for match() return values Bartosz Golaszewski
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Bartosz Golaszewski @ 2025-06-24 14:32 UTC (permalink / raw)
To: Drew Fustini, Guo Ren, Fu Wei, Bartosz Golaszewski, Ulf Hansson,
Michal Wilczynski
Cc: linux-riscv, linux-pm, linux-kernel, Bartosz Golaszewski
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
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 4/5] pwrseq: qcom-wcn: use new defines for match() return values
2025-06-24 14:32 [PATCH 0/5] pwrseq: replace magic numbers with defines for match() return values Bartosz Golaszewski
` (2 preceding siblings ...)
2025-06-24 14:32 ` [PATCH 3/5] pwrseq: add defines for return values of the match() callback Bartosz Golaszewski
@ 2025-06-24 14:32 ` Bartosz Golaszewski
2025-06-24 14:32 ` [PATCH 5/5] pwrseq: thead-gpu: " Bartosz Golaszewski
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Bartosz Golaszewski @ 2025-06-24 14:32 UTC (permalink / raw)
To: Drew Fustini, Guo Ren, Fu Wei, Bartosz Golaszewski, Ulf Hansson,
Michal Wilczynski
Cc: linux-riscv, linux-pm, linux-kernel, Bartosz Golaszewski
From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Replace the magic numbers with proper defines we now have in the header.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
drivers/power/sequencing/pwrseq-qcom-wcn.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/power/sequencing/pwrseq-qcom-wcn.c b/drivers/power/sequencing/pwrseq-qcom-wcn.c
index e8f5030f2639a69254ad5efe0a313d2f3d10fa1d..f14801b4c28e53c5905fd2345b773c2aa96af44c 100644
--- a/drivers/power/sequencing/pwrseq-qcom-wcn.c
+++ b/drivers/power/sequencing/pwrseq-qcom-wcn.c
@@ -341,12 +341,12 @@ static int pwrseq_qcom_wcn_match(struct pwrseq_device *pwrseq,
* device.
*/
if (!of_property_present(dev_node, "vddaon-supply"))
- return 0;
+ return PWRSEQ_NO_MATCH;
struct device_node *reg_node __free(device_node) =
of_parse_phandle(dev_node, "vddaon-supply", 0);
if (!reg_node)
- return 0;
+ return PWRSEQ_NO_MATCH;
/*
* `reg_node` is the PMU AON regulator, its parent is the `regulators`
@@ -355,9 +355,9 @@ static int pwrseq_qcom_wcn_match(struct pwrseq_device *pwrseq,
*/
if (!reg_node->parent || !reg_node->parent->parent ||
reg_node->parent->parent != ctx->of_node)
- return 0;
+ return PWRSEQ_NO_MATCH;
- return 1;
+ return PWRSEQ_MATCH_OK;
}
static int pwrseq_qcom_wcn_probe(struct platform_device *pdev)
--
2.48.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 5/5] pwrseq: thead-gpu: use new defines for match() return values
2025-06-24 14:32 [PATCH 0/5] pwrseq: replace magic numbers with defines for match() return values Bartosz Golaszewski
` (3 preceding siblings ...)
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 ` Bartosz Golaszewski
2025-06-25 10:03 ` [PATCH 0/5] pwrseq: replace magic numbers with " Ulf Hansson
2025-06-30 7:11 ` Bartosz Golaszewski
6 siblings, 0 replies; 8+ messages in thread
From: Bartosz Golaszewski @ 2025-06-24 14:32 UTC (permalink / raw)
To: Drew Fustini, Guo Ren, Fu Wei, Bartosz Golaszewski, Ulf Hansson,
Michal Wilczynski
Cc: linux-riscv, linux-pm, linux-kernel, Bartosz Golaszewski
From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Replace the magic numbers with proper defines we now have in the header.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
drivers/power/sequencing/pwrseq-thead-gpu.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/drivers/power/sequencing/pwrseq-thead-gpu.c b/drivers/power/sequencing/pwrseq-thead-gpu.c
index 855c6cc4f3b5bd1aa6e93305af0417d5791b092d..7c82a10ca9f6917e673711c55dd5e58e58dc8f5c 100644
--- a/drivers/power/sequencing/pwrseq-thead-gpu.c
+++ b/drivers/power/sequencing/pwrseq-thead-gpu.c
@@ -124,24 +124,25 @@ static int pwrseq_thead_gpu_match(struct pwrseq_device *pwrseq,
/* We only match the specific T-HEAD TH1520 GPU compatible */
if (!of_device_is_compatible(dev->of_node, "thead,th1520-gpu"))
- return 0;
+ return PWRSEQ_NO_MATCH;
ret = of_parse_phandle_with_args(dev->of_node, "power-domains",
"#power-domain-cells", 0, &pwr_spec);
if (ret)
- return 0;
+ return PWRSEQ_NO_MATCH;
/* Additionally verify consumer device has AON as power-domain */
if (pwr_spec.np != ctx->aon_node || pwr_spec.args[0] != TH1520_GPU_PD) {
of_node_put(pwr_spec.np);
- return 0;
+ return PWRSEQ_NO_MATCH;
}
of_node_put(pwr_spec.np);
/* If a consumer is already bound, only allow a re-match from it */
if (ctx->consumer_node)
- return ctx->consumer_node == dev->of_node ? 1 : 0;
+ return ctx->consumer_node == dev->of_node ?
+ PWRSEQ_MATCH_OK : PWRSEQ_NO_MATCH;
ctx->num_clks = ARRAY_SIZE(clk_names);
ctx->clks = kcalloc(ctx->num_clks, sizeof(*ctx->clks), GFP_KERNEL);
@@ -163,7 +164,7 @@ static int pwrseq_thead_gpu_match(struct pwrseq_device *pwrseq,
ctx->consumer_node = of_node_get(dev->of_node);
- return 1;
+ return PWRSEQ_MATCH_OK;
err_put_clks:
clk_bulk_put(ctx->num_clks, ctx->clks);
--
2.48.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 0/5] pwrseq: replace magic numbers with defines for match() return values
2025-06-24 14:32 [PATCH 0/5] pwrseq: replace magic numbers with defines for match() return values Bartosz Golaszewski
` (4 preceding siblings ...)
2025-06-24 14:32 ` [PATCH 5/5] pwrseq: thead-gpu: " Bartosz Golaszewski
@ 2025-06-25 10:03 ` Ulf Hansson
2025-06-30 7:11 ` Bartosz Golaszewski
6 siblings, 0 replies; 8+ messages in thread
From: Ulf Hansson @ 2025-06-25 10:03 UTC (permalink / raw)
To: Bartosz Golaszewski
Cc: Drew Fustini, Guo Ren, Fu Wei, Michal Wilczynski, linux-riscv,
linux-pm, linux-kernel, Bartosz Golaszewski
On Tue, 24 Jun 2025 at 16:32, Bartosz Golaszewski <brgl@bgdev.pl> wrote:
>
> We currently use 0 or 1 as magic numbers returned from the match()
> callback. It's more readable to replace them with proper defines whose
> names indicate the meaning. While at it: fix a build issue with the
> thead-gpu driver I noticed and extend build coverage for the drivers.
>
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> ---
> Bartosz Golaszewski (5):
> pwrseq: thead-gpu: add missing header
> pwrseq: extend build coverage for pwrseq drivers with COMPILE_TEST=y
> pwrseq: add defines for return values of the match() callback
> pwrseq: qcom-wcn: use new defines for match() return values
> pwrseq: thead-gpu: use new defines for match() return values
>
> drivers/power/sequencing/Kconfig | 4 ++--
> drivers/power/sequencing/core.c | 6 +++---
> drivers/power/sequencing/pwrseq-qcom-wcn.c | 8 ++++----
> drivers/power/sequencing/pwrseq-thead-gpu.c | 12 +++++++-----
> include/linux/pwrseq/provider.h | 3 +++
> 5 files changed, 19 insertions(+), 14 deletions(-)
> ---
> base-commit: d4c2d9b5b7ceed14a3a835fd969bb0699b9608d3
> change-id: 20250624-pwrseq-match-defines-aec46817e69e
>
> Best regards,
> --
> Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
>
For the series, feel free to add:
Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
Kind regards
Uffe
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 0/5] pwrseq: replace magic numbers with defines for match() return values
2025-06-24 14:32 [PATCH 0/5] pwrseq: replace magic numbers with defines for match() return values Bartosz Golaszewski
` (5 preceding siblings ...)
2025-06-25 10:03 ` [PATCH 0/5] pwrseq: replace magic numbers with " Ulf Hansson
@ 2025-06-30 7:11 ` Bartosz Golaszewski
6 siblings, 0 replies; 8+ messages in thread
From: Bartosz Golaszewski @ 2025-06-30 7:11 UTC (permalink / raw)
To: Drew Fustini, Guo Ren, Fu Wei, Ulf Hansson, Michal Wilczynski,
Bartosz Golaszewski
Cc: Bartosz Golaszewski, linux-riscv, linux-pm, linux-kernel
From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
On Tue, 24 Jun 2025 16:32:17 +0200, Bartosz Golaszewski wrote:
> We currently use 0 or 1 as magic numbers returned from the match()
> callback. It's more readable to replace them with proper defines whose
> names indicate the meaning. While at it: fix a build issue with the
> thead-gpu driver I noticed and extend build coverage for the drivers.
>
>
Applied with commit subjects tweaked to say "power: sequencing: ...", thanks!
[1/5] pwrseq: thead-gpu: add missing header
https://git.kernel.org/brgl/linux/c/5bcfc4ef40dabcd16a0b736fea7f0d00a9efdbfb
[2/5] pwrseq: extend build coverage for pwrseq drivers with COMPILE_TEST=y
https://git.kernel.org/brgl/linux/c/1a7312b93ab023f68b48a1550049a4f850c2c808
[3/5] pwrseq: add defines for return values of the match() callback
https://git.kernel.org/brgl/linux/c/62b5848f73dd4f8ae17304dae54562d0c9ecdd3d
[4/5] pwrseq: qcom-wcn: use new defines for match() return values
https://git.kernel.org/brgl/linux/c/f698155029efc708349126c8944fa8c95b28098c
[5/5] pwrseq: thead-gpu: use new defines for match() return values
https://git.kernel.org/brgl/linux/c/385b735c90ae44dbde65fab76e356a96ff8f67be
Best regards,
--
Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2025-06-30 7:11 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [PATCH 3/5] pwrseq: add defines for return values of the match() callback Bartosz Golaszewski
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
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).