2024-02-08 20:28:47

by Krzysztof Kozlowski

[permalink] [raw]
Subject: [PATCH 1/2] pmdomain: constify of_phandle_args in xlate

The xlate callbacks are supposed to translate of_phandle_args to proper
provider without modifying the of_phandle_args. Make the argument
pointer to const for code safety and readability.

Signed-off-by: Krzysztof Kozlowski <[email protected]>
---
drivers/pmdomain/core.c | 4 ++--
drivers/pmdomain/imx/scu-pd.c | 2 +-
drivers/pmdomain/tegra/powergate-bpmp.c | 2 +-
drivers/pmdomain/ti/ti_sci_pm_domains.c | 2 +-
drivers/pmdomain/xilinx/zynqmp-pm-domains.c | 2 +-
include/linux/pm_domain.h | 2 +-
6 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/pmdomain/core.c b/drivers/pmdomain/core.c
index 46331e71108a..ea4b29475206 100644
--- a/drivers/pmdomain/core.c
+++ b/drivers/pmdomain/core.c
@@ -2266,7 +2266,7 @@ static DEFINE_MUTEX(of_genpd_mutex);
* to be a valid pointer to struct generic_pm_domain.
*/
static struct generic_pm_domain *genpd_xlate_simple(
- struct of_phandle_args *genpdspec,
+ const struct of_phandle_args *genpdspec,
void *data)
{
return data;
@@ -2283,7 +2283,7 @@ static struct generic_pm_domain *genpd_xlate_simple(
* the genpd_onecell_data struct when registering the provider.
*/
static struct generic_pm_domain *genpd_xlate_onecell(
- struct of_phandle_args *genpdspec,
+ const struct of_phandle_args *genpdspec,
void *data)
{
struct genpd_onecell_data *genpd_data = data;
diff --git a/drivers/pmdomain/imx/scu-pd.c b/drivers/pmdomain/imx/scu-pd.c
index 891c1d925a9d..05841b0bf7f3 100644
--- a/drivers/pmdomain/imx/scu-pd.c
+++ b/drivers/pmdomain/imx/scu-pd.c
@@ -393,7 +393,7 @@ static int imx_sc_pd_power_off(struct generic_pm_domain *domain)
return imx_sc_pd_power(domain, false);
}

-static struct generic_pm_domain *imx_scu_pd_xlate(struct of_phandle_args *spec,
+static struct generic_pm_domain *imx_scu_pd_xlate(const struct of_phandle_args *spec,
void *data)
{
struct generic_pm_domain *domain = ERR_PTR(-ENOENT);
diff --git a/drivers/pmdomain/tegra/powergate-bpmp.c b/drivers/pmdomain/tegra/powergate-bpmp.c
index 179ed895c279..b0138ca9f851 100644
--- a/drivers/pmdomain/tegra/powergate-bpmp.c
+++ b/drivers/pmdomain/tegra/powergate-bpmp.c
@@ -305,7 +305,7 @@ static void tegra_bpmp_remove_powergates(struct tegra_bpmp *bpmp)
}

static struct generic_pm_domain *
-tegra_powergate_xlate(struct of_phandle_args *spec, void *data)
+tegra_powergate_xlate(const struct of_phandle_args *spec, void *data)
{
struct generic_pm_domain *domain = ERR_PTR(-ENOENT);
struct genpd_onecell_data *genpd = data;
diff --git a/drivers/pmdomain/ti/ti_sci_pm_domains.c b/drivers/pmdomain/ti/ti_sci_pm_domains.c
index c091d569ecd5..9dddf227a3a6 100644
--- a/drivers/pmdomain/ti/ti_sci_pm_domains.c
+++ b/drivers/pmdomain/ti/ti_sci_pm_domains.c
@@ -85,7 +85,7 @@ static int ti_sci_pd_power_on(struct generic_pm_domain *domain)
* @data: genpd core data for all the powerdomains on the device
*/
static struct generic_pm_domain *ti_sci_pd_xlate(
- struct of_phandle_args *genpdspec,
+ const struct of_phandle_args *genpdspec,
void *data)
{
struct genpd_onecell_data *genpd_data = data;
diff --git a/drivers/pmdomain/xilinx/zynqmp-pm-domains.c b/drivers/pmdomain/xilinx/zynqmp-pm-domains.c
index 6fd514286d82..0b5831e5ba1b 100644
--- a/drivers/pmdomain/xilinx/zynqmp-pm-domains.c
+++ b/drivers/pmdomain/xilinx/zynqmp-pm-domains.c
@@ -210,7 +210,7 @@ static void zynqmp_gpd_detach_dev(struct generic_pm_domain *domain,
}

static struct generic_pm_domain *zynqmp_gpd_xlate
- (struct of_phandle_args *genpdspec, void *data)
+ (const struct of_phandle_args *genpdspec, void *data)
{
struct genpd_onecell_data *genpd_data = data;
unsigned int i, idx = genpdspec->args[0];
diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
index fb91770ba4ba..1a391ef1b6f8 100644
--- a/include/linux/pm_domain.h
+++ b/include/linux/pm_domain.h
@@ -349,7 +349,7 @@ static inline void dev_pm_genpd_resume(struct device *dev) {}
/* OF PM domain providers */
struct of_device_id;

-typedef struct generic_pm_domain *(*genpd_xlate_t)(struct of_phandle_args *args,
+typedef struct generic_pm_domain *(*genpd_xlate_t)(const struct of_phandle_args *args,
void *data);

struct genpd_onecell_data {
--
2.34.1



2024-02-08 20:30:48

by Krzysztof Kozlowski

[permalink] [raw]
Subject: [PATCH 2/2] pmdomain: constify of_phandle_args in add device and subdomain

Pointer to of_phandle_args is not modified by of_genpd_add_device() and
of_genpd_add_subdomain(), so it can be made pointer to const for code
safety and readability.

Signed-off-by: Krzysztof Kozlowski <[email protected]>
---
drivers/pmdomain/core.c | 12 ++++++------
include/linux/pm_domain.h | 20 ++++++++++----------
2 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/drivers/pmdomain/core.c b/drivers/pmdomain/core.c
index ea4b29475206..4215ffd9b11c 100644
--- a/drivers/pmdomain/core.c
+++ b/drivers/pmdomain/core.c
@@ -2526,7 +2526,7 @@ EXPORT_SYMBOL_GPL(of_genpd_del_provider);
* on failure.
*/
static struct generic_pm_domain *genpd_get_from_provider(
- struct of_phandle_args *genpdspec)
+ const struct of_phandle_args *genpdspec)
{
struct generic_pm_domain *genpd = ERR_PTR(-ENOENT);
struct of_genpd_provider *provider;
@@ -2557,7 +2557,7 @@ static struct generic_pm_domain *genpd_get_from_provider(
* Looks-up an I/O PM domain based upon phandle args provided and adds
* the device to the PM domain. Returns a negative error code on failure.
*/
-int of_genpd_add_device(struct of_phandle_args *genpdspec, struct device *dev)
+int of_genpd_add_device(const struct of_phandle_args *genpdspec, struct device *dev)
{
struct generic_pm_domain *genpd;
int ret;
@@ -2591,8 +2591,8 @@ EXPORT_SYMBOL_GPL(of_genpd_add_device);
* provided and adds the subdomain to the parent PM domain. Returns a
* negative error code on failure.
*/
-int of_genpd_add_subdomain(struct of_phandle_args *parent_spec,
- struct of_phandle_args *subdomain_spec)
+int of_genpd_add_subdomain(const struct of_phandle_args *parent_spec,
+ const struct of_phandle_args *subdomain_spec)
{
struct generic_pm_domain *parent, *subdomain;
int ret;
@@ -2629,8 +2629,8 @@ EXPORT_SYMBOL_GPL(of_genpd_add_subdomain);
* provided and removes the subdomain from the parent PM domain. Returns a
* negative error code on failure.
*/
-int of_genpd_remove_subdomain(struct of_phandle_args *parent_spec,
- struct of_phandle_args *subdomain_spec)
+int of_genpd_remove_subdomain(const struct of_phandle_args *parent_spec,
+ const struct of_phandle_args *subdomain_spec)
{
struct generic_pm_domain *parent, *subdomain;
int ret;
diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
index 1a391ef1b6f8..772d3280d35f 100644
--- a/include/linux/pm_domain.h
+++ b/include/linux/pm_domain.h
@@ -364,11 +364,11 @@ int of_genpd_add_provider_simple(struct device_node *np,
int of_genpd_add_provider_onecell(struct device_node *np,
struct genpd_onecell_data *data);
void of_genpd_del_provider(struct device_node *np);
-int of_genpd_add_device(struct of_phandle_args *args, struct device *dev);
-int of_genpd_add_subdomain(struct of_phandle_args *parent_spec,
- struct of_phandle_args *subdomain_spec);
-int of_genpd_remove_subdomain(struct of_phandle_args *parent_spec,
- struct of_phandle_args *subdomain_spec);
+int of_genpd_add_device(const struct of_phandle_args *args, struct device *dev);
+int of_genpd_add_subdomain(const struct of_phandle_args *parent_spec,
+ const struct of_phandle_args *subdomain_spec);
+int of_genpd_remove_subdomain(const struct of_phandle_args *parent_spec,
+ const struct of_phandle_args *subdomain_spec);
struct generic_pm_domain *of_genpd_remove_last(struct device_node *np);
int of_genpd_parse_idle_states(struct device_node *dn,
struct genpd_power_state **states, int *n);
@@ -393,20 +393,20 @@ static inline int of_genpd_add_provider_onecell(struct device_node *np,

static inline void of_genpd_del_provider(struct device_node *np) {}

-static inline int of_genpd_add_device(struct of_phandle_args *args,
+static inline int of_genpd_add_device(const struct of_phandle_args *args,
struct device *dev)
{
return -ENODEV;
}

-static inline int of_genpd_add_subdomain(struct of_phandle_args *parent_spec,
- struct of_phandle_args *subdomain_spec)
+static inline int of_genpd_add_subdomain(const struct of_phandle_args *parent_spec,
+ const struct of_phandle_args *subdomain_spec)
{
return -ENODEV;
}

-static inline int of_genpd_remove_subdomain(struct of_phandle_args *parent_spec,
- struct of_phandle_args *subdomain_spec)
+static inline int of_genpd_remove_subdomain(const struct of_phandle_args *parent_spec,
+ const struct of_phandle_args *subdomain_spec)
{
return -ENODEV;
}
--
2.34.1


2024-02-13 12:34:30

by Ulf Hansson

[permalink] [raw]
Subject: Re: [PATCH 1/2] pmdomain: constify of_phandle_args in xlate

On Thu, 8 Feb 2024 at 21:28, Krzysztof Kozlowski
<[email protected]> wrote:
>
> The xlate callbacks are supposed to translate of_phandle_args to proper
> provider without modifying the of_phandle_args. Make the argument
> pointer to const for code safety and readability.
>
> Signed-off-by: Krzysztof Kozlowski <[email protected]>

Applied for next, thanks!

Kind regards
Uffe


> ---
> drivers/pmdomain/core.c | 4 ++--
> drivers/pmdomain/imx/scu-pd.c | 2 +-
> drivers/pmdomain/tegra/powergate-bpmp.c | 2 +-
> drivers/pmdomain/ti/ti_sci_pm_domains.c | 2 +-
> drivers/pmdomain/xilinx/zynqmp-pm-domains.c | 2 +-
> include/linux/pm_domain.h | 2 +-
> 6 files changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/pmdomain/core.c b/drivers/pmdomain/core.c
> index 46331e71108a..ea4b29475206 100644
> --- a/drivers/pmdomain/core.c
> +++ b/drivers/pmdomain/core.c
> @@ -2266,7 +2266,7 @@ static DEFINE_MUTEX(of_genpd_mutex);
> * to be a valid pointer to struct generic_pm_domain.
> */
> static struct generic_pm_domain *genpd_xlate_simple(
> - struct of_phandle_args *genpdspec,
> + const struct of_phandle_args *genpdspec,
> void *data)
> {
> return data;
> @@ -2283,7 +2283,7 @@ static struct generic_pm_domain *genpd_xlate_simple(
> * the genpd_onecell_data struct when registering the provider.
> */
> static struct generic_pm_domain *genpd_xlate_onecell(
> - struct of_phandle_args *genpdspec,
> + const struct of_phandle_args *genpdspec,
> void *data)
> {
> struct genpd_onecell_data *genpd_data = data;
> diff --git a/drivers/pmdomain/imx/scu-pd.c b/drivers/pmdomain/imx/scu-pd.c
> index 891c1d925a9d..05841b0bf7f3 100644
> --- a/drivers/pmdomain/imx/scu-pd.c
> +++ b/drivers/pmdomain/imx/scu-pd.c
> @@ -393,7 +393,7 @@ static int imx_sc_pd_power_off(struct generic_pm_domain *domain)
> return imx_sc_pd_power(domain, false);
> }
>
> -static struct generic_pm_domain *imx_scu_pd_xlate(struct of_phandle_args *spec,
> +static struct generic_pm_domain *imx_scu_pd_xlate(const struct of_phandle_args *spec,
> void *data)
> {
> struct generic_pm_domain *domain = ERR_PTR(-ENOENT);
> diff --git a/drivers/pmdomain/tegra/powergate-bpmp.c b/drivers/pmdomain/tegra/powergate-bpmp.c
> index 179ed895c279..b0138ca9f851 100644
> --- a/drivers/pmdomain/tegra/powergate-bpmp.c
> +++ b/drivers/pmdomain/tegra/powergate-bpmp.c
> @@ -305,7 +305,7 @@ static void tegra_bpmp_remove_powergates(struct tegra_bpmp *bpmp)
> }
>
> static struct generic_pm_domain *
> -tegra_powergate_xlate(struct of_phandle_args *spec, void *data)
> +tegra_powergate_xlate(const struct of_phandle_args *spec, void *data)
> {
> struct generic_pm_domain *domain = ERR_PTR(-ENOENT);
> struct genpd_onecell_data *genpd = data;
> diff --git a/drivers/pmdomain/ti/ti_sci_pm_domains.c b/drivers/pmdomain/ti/ti_sci_pm_domains.c
> index c091d569ecd5..9dddf227a3a6 100644
> --- a/drivers/pmdomain/ti/ti_sci_pm_domains.c
> +++ b/drivers/pmdomain/ti/ti_sci_pm_domains.c
> @@ -85,7 +85,7 @@ static int ti_sci_pd_power_on(struct generic_pm_domain *domain)
> * @data: genpd core data for all the powerdomains on the device
> */
> static struct generic_pm_domain *ti_sci_pd_xlate(
> - struct of_phandle_args *genpdspec,
> + const struct of_phandle_args *genpdspec,
> void *data)
> {
> struct genpd_onecell_data *genpd_data = data;
> diff --git a/drivers/pmdomain/xilinx/zynqmp-pm-domains.c b/drivers/pmdomain/xilinx/zynqmp-pm-domains.c
> index 6fd514286d82..0b5831e5ba1b 100644
> --- a/drivers/pmdomain/xilinx/zynqmp-pm-domains.c
> +++ b/drivers/pmdomain/xilinx/zynqmp-pm-domains.c
> @@ -210,7 +210,7 @@ static void zynqmp_gpd_detach_dev(struct generic_pm_domain *domain,
> }
>
> static struct generic_pm_domain *zynqmp_gpd_xlate
> - (struct of_phandle_args *genpdspec, void *data)
> + (const struct of_phandle_args *genpdspec, void *data)
> {
> struct genpd_onecell_data *genpd_data = data;
> unsigned int i, idx = genpdspec->args[0];
> diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
> index fb91770ba4ba..1a391ef1b6f8 100644
> --- a/include/linux/pm_domain.h
> +++ b/include/linux/pm_domain.h
> @@ -349,7 +349,7 @@ static inline void dev_pm_genpd_resume(struct device *dev) {}
> /* OF PM domain providers */
> struct of_device_id;
>
> -typedef struct generic_pm_domain *(*genpd_xlate_t)(struct of_phandle_args *args,
> +typedef struct generic_pm_domain *(*genpd_xlate_t)(const struct of_phandle_args *args,
> void *data);
>
> struct genpd_onecell_data {
> --
> 2.34.1
>

2024-02-13 12:38:02

by Ulf Hansson

[permalink] [raw]
Subject: Re: [PATCH 2/2] pmdomain: constify of_phandle_args in add device and subdomain

On Thu, 8 Feb 2024 at 21:28, Krzysztof Kozlowski
<[email protected]> wrote:
>
> Pointer to of_phandle_args is not modified by of_genpd_add_device() and
> of_genpd_add_subdomain(), so it can be made pointer to const for code
> safety and readability.
>
> Signed-off-by: Krzysztof Kozlowski <[email protected]>

Applied for next, thanks!

Kind regards
Uffe


> ---
> drivers/pmdomain/core.c | 12 ++++++------
> include/linux/pm_domain.h | 20 ++++++++++----------
> 2 files changed, 16 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/pmdomain/core.c b/drivers/pmdomain/core.c
> index ea4b29475206..4215ffd9b11c 100644
> --- a/drivers/pmdomain/core.c
> +++ b/drivers/pmdomain/core.c
> @@ -2526,7 +2526,7 @@ EXPORT_SYMBOL_GPL(of_genpd_del_provider);
> * on failure.
> */
> static struct generic_pm_domain *genpd_get_from_provider(
> - struct of_phandle_args *genpdspec)
> + const struct of_phandle_args *genpdspec)
> {
> struct generic_pm_domain *genpd = ERR_PTR(-ENOENT);
> struct of_genpd_provider *provider;
> @@ -2557,7 +2557,7 @@ static struct generic_pm_domain *genpd_get_from_provider(
> * Looks-up an I/O PM domain based upon phandle args provided and adds
> * the device to the PM domain. Returns a negative error code on failure.
> */
> -int of_genpd_add_device(struct of_phandle_args *genpdspec, struct device *dev)
> +int of_genpd_add_device(const struct of_phandle_args *genpdspec, struct device *dev)
> {
> struct generic_pm_domain *genpd;
> int ret;
> @@ -2591,8 +2591,8 @@ EXPORT_SYMBOL_GPL(of_genpd_add_device);
> * provided and adds the subdomain to the parent PM domain. Returns a
> * negative error code on failure.
> */
> -int of_genpd_add_subdomain(struct of_phandle_args *parent_spec,
> - struct of_phandle_args *subdomain_spec)
> +int of_genpd_add_subdomain(const struct of_phandle_args *parent_spec,
> + const struct of_phandle_args *subdomain_spec)
> {
> struct generic_pm_domain *parent, *subdomain;
> int ret;
> @@ -2629,8 +2629,8 @@ EXPORT_SYMBOL_GPL(of_genpd_add_subdomain);
> * provided and removes the subdomain from the parent PM domain. Returns a
> * negative error code on failure.
> */
> -int of_genpd_remove_subdomain(struct of_phandle_args *parent_spec,
> - struct of_phandle_args *subdomain_spec)
> +int of_genpd_remove_subdomain(const struct of_phandle_args *parent_spec,
> + const struct of_phandle_args *subdomain_spec)
> {
> struct generic_pm_domain *parent, *subdomain;
> int ret;
> diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
> index 1a391ef1b6f8..772d3280d35f 100644
> --- a/include/linux/pm_domain.h
> +++ b/include/linux/pm_domain.h
> @@ -364,11 +364,11 @@ int of_genpd_add_provider_simple(struct device_node *np,
> int of_genpd_add_provider_onecell(struct device_node *np,
> struct genpd_onecell_data *data);
> void of_genpd_del_provider(struct device_node *np);
> -int of_genpd_add_device(struct of_phandle_args *args, struct device *dev);
> -int of_genpd_add_subdomain(struct of_phandle_args *parent_spec,
> - struct of_phandle_args *subdomain_spec);
> -int of_genpd_remove_subdomain(struct of_phandle_args *parent_spec,
> - struct of_phandle_args *subdomain_spec);
> +int of_genpd_add_device(const struct of_phandle_args *args, struct device *dev);
> +int of_genpd_add_subdomain(const struct of_phandle_args *parent_spec,
> + const struct of_phandle_args *subdomain_spec);
> +int of_genpd_remove_subdomain(const struct of_phandle_args *parent_spec,
> + const struct of_phandle_args *subdomain_spec);
> struct generic_pm_domain *of_genpd_remove_last(struct device_node *np);
> int of_genpd_parse_idle_states(struct device_node *dn,
> struct genpd_power_state **states, int *n);
> @@ -393,20 +393,20 @@ static inline int of_genpd_add_provider_onecell(struct device_node *np,
>
> static inline void of_genpd_del_provider(struct device_node *np) {}
>
> -static inline int of_genpd_add_device(struct of_phandle_args *args,
> +static inline int of_genpd_add_device(const struct of_phandle_args *args,
> struct device *dev)
> {
> return -ENODEV;
> }
>
> -static inline int of_genpd_add_subdomain(struct of_phandle_args *parent_spec,
> - struct of_phandle_args *subdomain_spec)
> +static inline int of_genpd_add_subdomain(const struct of_phandle_args *parent_spec,
> + const struct of_phandle_args *subdomain_spec)
> {
> return -ENODEV;
> }
>
> -static inline int of_genpd_remove_subdomain(struct of_phandle_args *parent_spec,
> - struct of_phandle_args *subdomain_spec)
> +static inline int of_genpd_remove_subdomain(const struct of_phandle_args *parent_spec,
> + const struct of_phandle_args *subdomain_spec)
> {
> return -ENODEV;
> }
> --
> 2.34.1
>