Skip to contentSkip to conversation

PM / Domains: Mark "name" const in genpd_dev_pm_attach_by_name()

PATCH In review Douglas Anderson 6 participants 12 messages Feb 14, 2019 – Feb 19, 2019

Subsystems (6)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 PM / Domains: Mark "name" const in genpd_dev_pm_attach_by_name()

The genpd_dev_pm_attach_by_name() simply takes the name and passes it to of_property_match_string() where the argument is "const char *". Adding a const here allows a later patch to add a const to dev_pm_domain_attach_by_name() which allows drivers to pass in a name that was declared "const" in a driver.

Fixes 5d6be70add65 ("PM / Domains: Introduce option to attach a device by name to genpd")

---

 drivers/base/power/domain.c | 2 +-
 include/linux/pm_domain.h   | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/base/power/domain.c +1 -1
index 45eafe8cf7dd..2c334c01fc43 100644
@@ -2483,7 +2483,7 @@ EXPORT_SYMBOL_GPL(genpd_dev_pm_attach_by_id);
  * power-domain-names DT property. For further description see
  * genpd_dev_pm_attach_by_id().
  */
-struct device *genpd_dev_pm_attach_by_name(struct device *dev, char *name)
+struct device *genpd_dev_pm_attach_by_name(struct device *dev, const char *name)
 {
 	int index;
 
include/linux/pm_domain.h +2 -2
index dd364abb649a..203be5082f33 100644
@@ -271,7 +271,7 @@ int genpd_dev_pm_attach(struct device *dev);
 struct device *genpd_dev_pm_attach_by_id(struct device *dev,
 					 unsigned int index);
 struct device *genpd_dev_pm_attach_by_name(struct device *dev,
-					   char *name);
+					   const char *name);
 #else /* !CONFIG_PM_GENERIC_DOMAINS_OF */
 static inline int of_genpd_add_provider_simple(struct device_node *np,
 					struct generic_pm_domain *genpd)
@@ -324,7 +324,7 @@ static inline struct device *genpd_dev_pm_attach_by_id(struct device *dev,
 }
 
 static inline struct device *genpd_dev_pm_attach_by_name(struct device *dev,
-							 char *name)
+							 const char *name)
 {
 	return NULL;
 }
Signature · 1 line
2.21.0.rc0.258.g878e2cd30e-goog
#1 lore raw

PATCH 2/2 PM / Domains: Mark "name" const in dev_pm_domain_attach_by_name()

As of the patch ("PM / Domains: Mark "name" const in genpd_dev_pm_attach_by_name()") it's clear that the name in dev_pm_domain_attach_by_name() can be const. Mark it as so. This allows drivers to pass in a name that was declared "const" in a driver.

Fixes 27dceb81f445 ("PM / Domains: Introduce dev_pm_domain_attach_by_name()")

---

 drivers/base/power/common.c | 2 +-
 include/linux/pm_domain.h   | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/base/power/common.c +1 -1
index b413951c6abc..22aedb28aad7 100644
@@ -160,7 +160,7 @@ EXPORT_SYMBOL_GPL(dev_pm_domain_attach_by_id);
  * For a detailed function description, see dev_pm_domain_attach_by_id().
  */
 struct device *dev_pm_domain_attach_by_name(struct device *dev,
-					    char *name)
+					    const char *name)
 {
 	if (dev->pm_domain)
 		return ERR_PTR(-EEXIST);
include/linux/pm_domain.h +2 -2
index 203be5082f33..1ed5874bcee0 100644
@@ -341,7 +341,7 @@ int dev_pm_domain_attach(struct device *dev, bool power_on);
 struct device *dev_pm_domain_attach_by_id(struct device *dev,
 					  unsigned int index);
 struct device *dev_pm_domain_attach_by_name(struct device *dev,
-					    char *name);
+					    const char *name);
 void dev_pm_domain_detach(struct device *dev, bool power_off);
 void dev_pm_domain_set(struct device *dev, struct dev_pm_domain *pd);
 #else
@@ -355,7 +355,7 @@ static inline struct device *dev_pm_domain_attach_by_id(struct device *dev,
 	return NULL;
 }
 static inline struct device *dev_pm_domain_attach_by_name(struct device *dev,
-							  char *name)
+							  const char *name)
 {
 	return NULL;
 }
Signature · 1 line
2.21.0.rc0.258.g878e2cd30e-goog
Reviewed-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] PM / Domains: Mark "name" const in dev_pm_domain_attach_by_name()

Quoting Douglas Anderson (2019-02-14 10:12:49)

Quoted 9 lines

As of the patch ("PM / Domains: Mark "name" const in genpd_dev_pm_attach_by_name()") it's clear that the name in dev_pm_domain_attach_by_name() can be const. Mark it as so. This allows drivers to pass in a name that was declared "const" in a driver.

Fixes 27dceb81f445 ("PM / Domains: Introduce dev_pm_domain_attach_by_name()")

---

Reviewed-by on v1 2/2
#3 lore raw

Re: [PATCH 2/2] PM / Domains: Mark "name" const in dev_pm_domain_attach_by_name()

In reply to Douglas Anderson
Quoted 9 lines · Douglas Anderson

As of the patch ("PM / Domains: Mark "name" const in genpd_dev_pm_attach_by_name()") it's clear that the name in dev_pm_domain_attach_by_name() can be const. Mark it as so. This allows drivers to pass in a name that was declared "const" in a driver.

Fixes 27dceb81f445 ("PM / Domains: Introduce dev_pm_domain_attach_by_name()")

Perhaps fold $subject patch into patch1, they seems highly related. Anyway, no strong opinion here.

Kind regards
Uffe

Quoted 44 lines

---

 drivers/base/power/common.c | 2 +-
 include/linux/pm_domain.h   | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/base/power/common.c +1 -1
index b413951c6abc..22aedb28aad7 100644
@@ -160,7 +160,7 @@ EXPORT_SYMBOL_GPL(dev_pm_domain_attach_by_id);
  * For a detailed function description, see dev_pm_domain_attach_by_id().
  */
 struct device *dev_pm_domain_attach_by_name(struct device *dev,
-                                           char *name)
+                                           const char *name)
 {
        if (dev->pm_domain)
                return ERR_PTR(-EEXIST);
include/linux/pm_domain.h +2 -3
index 203be5082f33..1ed5874bcee0 100644
@@ -341,7 +341,7 @@ int dev_pm_domain_attach(struct device *dev, bool power_on);
 struct device *dev_pm_domain_attach_by_id(struct device *dev,
                                          unsigned int index);
 struct device *dev_pm_domain_attach_by_name(struct device *dev,
-                                           char *name);
+                                           const char *name);
 void dev_pm_domain_detach(struct device *dev, bool power_off);
 void dev_pm_domain_set(struct device *dev, struct dev_pm_domain *pd);
 #else
@@ -355,7 +355,7 @@ static inline struct device *dev_pm_domain_attach_by_id(struct device *dev,
        return NULL;
 }
 static inline struct device *dev_pm_domain_attach_by_name(struct device *dev,
-                                                         char *name)
+                                                         const char *name)
 {
        return NULL;
 }
--

2.21.0.rc0.258.g878e2cd30e-goog

#4 lore raw

Re: [PATCH 2/2] PM / Domains: Mark "name" const in dev_pm_domain_attach_by_name()

Hi,

Quoted 9 lines · Ulf Hansson
Quoted 7 lines · Douglas Anderson

As of the patch ("PM / Domains: Mark "name" const in genpd_dev_pm_attach_by_name()") it's clear that the name in dev_pm_domain_attach_by_name() can be const. Mark it as so. This allows drivers to pass in a name that was declared "const" in a driver.

Quoted 7 lines
Quoted 2 lines
Fixes 27dceb81f445 ("PM / Domains: Introduce dev_pm_domain_attach_by_name()")

Perhaps fold $subject patch into patch1, they seems highly related. Anyway, no strong opinion here.

Sure, either way is fine with me so I'll wait until someone tells me for sure one way or the other. I'm also happy if they just get squashed together when applied if that's easier. I originally kept them separate since the two APIs were originally added in separate patches so it seemed consistent to do the bugfixes in separate patches. ;-)

-Doug

Reviewed-by on v1 1/2
#5 lore raw
In reply to Douglas Anderson

Quoting Douglas Anderson (2019-02-14 10:12:48)

Quoted 9 lines

The genpd_dev_pm_attach_by_name() simply takes the name and passes it to of_property_match_string() where the argument is "const char *". Adding a const here allows a later patch to add a const to dev_pm_domain_attach_by_name() which allows drivers to pass in a name that was declared "const" in a driver.

Fixes 5d6be70add65 ("PM / Domains: Introduce option to attach a device by name to genpd")

---

Acked-by on v1 1/2
#6 lore raw
In reply to Douglas Anderson
Quoted 7 lines · Douglas Anderson

The genpd_dev_pm_attach_by_name() simply takes the name and passes it to of_property_match_string() where the argument is "const char *". Adding a const here allows a later patch to add a const to dev_pm_domain_attach_by_name() which allows drivers to pass in a name that was declared "const" in a driver.

Fixes 5d6be70add65 ("PM / Domains: Introduce option to attach a device by name to genpd")

Not sure if this should be counted as a fix.

Quoted 6 lines

---

 drivers/base/power/domain.c | 2 +-
 include/linux/pm_domain.h   | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

For both the patches:

Signature · 1 line
viresh
#7 lore raw

Hi,

Quoted 11 lines · Viresh Kumar
Quoted 7 lines · Douglas Anderson

The genpd_dev_pm_attach_by_name() simply takes the name and passes it to of_property_match_string() where the argument is "const char *". Adding a const here allows a later patch to add a const to dev_pm_domain_attach_by_name() which allows drivers to pass in a name that was declared "const" in a driver.

Fixes 5d6be70add65 ("PM / Domains: Introduce option to attach a device by name to genpd")

Not sure if this should be counted as a fix.

I'm OK if the "Fixes" is stripped when applying or if someone tells me to re-post without the Fixes--just let me know. In general I do a lot of cherry-picks from upstream and I appreciate the Fixes tag helping to link patches together. In this case if I picked the original patch I'd definitely want this one too. Certainly, though, CCing stable would make no sense in this case. ;-)

-Doug

#8 lore raw
Quoted 12 lines · Doug Anderson

Hi,

Quoted 10 lines · Viresh Kumar
Quoted 7 lines · Douglas Anderson

The genpd_dev_pm_attach_by_name() simply takes the name and passes it to of_property_match_string() where the argument is "const char *". Adding a const here allows a later patch to add a const to dev_pm_domain_attach_by_name() which allows drivers to pass in a name that was declared "const" in a driver.

Fixes 5d6be70add65 ("PM / Domains: Introduce option to attach a device by name to genpd")
Quoted 8 lines
Quoted 1 line

Not sure if this should be counted as a fix.

I'm OK if the "Fixes" is stripped when applying or if someone tells me to re-post without the Fixes--just let me know. In general I do a lot of cherry-picks from upstream and I appreciate the Fixes tag helping to link patches together. In this case if I picked the original patch I'd definitely want this one too. Certainly, though, CCing stable would make no sense in this case. ;-)

I am not sure if this is being done right now or not, but I read/heard somewhere that stable has started picking "Fixes" patches directly as well even if they aren't cc'd to stable.

Signature · 1 line
viresh
#9 lore raw
Quoted 22 lines · Viresh Kumar
Quoted 12 lines · Doug Anderson

Hi,

Quoted 10 lines · Viresh Kumar
Quoted 7 lines · Douglas Anderson

The genpd_dev_pm_attach_by_name() simply takes the name and passes it to of_property_match_string() where the argument is "const char *". Adding a const here allows a later patch to add a const to dev_pm_domain_attach_by_name() which allows drivers to pass in a name that was declared "const" in a driver.

Fixes 5d6be70add65 ("PM / Domains: Introduce option to attach a device by name to genpd")
Quoted 8 lines
Quoted 1 line

Not sure if this should be counted as a fix.

I'm OK if the "Fixes" is stripped when applying or if someone tells me to re-post without the Fixes--just let me know. In general I do a lot of cherry-picks from upstream and I appreciate the Fixes tag helping to link patches together. In this case if I picked the original patch I'd definitely want this one too. Certainly, though, CCing stable would make no sense in this case. ;-)

Quoted 3 lines

I am not sure if this is being done right now or not, but I read/heard somewhere that stable has started picking "Fixes" patches directly as well even if they aren't cc'd to stable.

It's random, not always happening, and nothing you can rely on.

If you know this is a patch for older kernels, then always add the cc:
stable line, as the documentation says you have to do!

thanks,

greg k-h

Reviewed-by on v1 1/2
#10 lore raw
In reply to Douglas Anderson
Quoted 9 lines · Douglas Anderson

The genpd_dev_pm_attach_by_name() simply takes the name and passes it to of_property_match_string() where the argument is "const char *". Adding a const here allows a later patch to add a const to dev_pm_domain_attach_by_name() which allows drivers to pass in a name that was declared "const" in a driver.

Fixes 5d6be70add65 ("PM / Domains: Introduce option to attach a device by name to genpd")

Kind regards
Uffe

Quoted 44 lines

---

 drivers/base/power/domain.c | 2 +-
 include/linux/pm_domain.h   | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/base/power/domain.c +1 -1
index 45eafe8cf7dd..2c334c01fc43 100644
@@ -2483,7 +2483,7 @@ EXPORT_SYMBOL_GPL(genpd_dev_pm_attach_by_id);
  * power-domain-names DT property. For further description see
  * genpd_dev_pm_attach_by_id().
  */
-struct device *genpd_dev_pm_attach_by_name(struct device *dev, char *name)
+struct device *genpd_dev_pm_attach_by_name(struct device *dev, const char *name)
 {
        int index;
 
include/linux/pm_domain.h +2 -3
index dd364abb649a..203be5082f33 100644
@@ -271,7 +271,7 @@ int genpd_dev_pm_attach(struct device *dev);
 struct device *genpd_dev_pm_attach_by_id(struct device *dev,
                                         unsigned int index);
 struct device *genpd_dev_pm_attach_by_name(struct device *dev,
-                                          char *name);
+                                          const char *name);
 #else /* !CONFIG_PM_GENERIC_DOMAINS_OF */
 static inline int of_genpd_add_provider_simple(struct device_node *np,
                                        struct generic_pm_domain *genpd)
@@ -324,7 +324,7 @@ static inline struct device *genpd_dev_pm_attach_by_id(struct device *dev,
 }
 
 static inline struct device *genpd_dev_pm_attach_by_name(struct device *dev,
-                                                        char *name)
+                                                        const char *name)
 {
        return NULL;
 }
--

2.21.0.rc0.258.g878e2cd30e-goog

#11 lore raw
In reply to Douglas Anderson
Quoted 42 lines · CET Douglas Anderson

The genpd_dev_pm_attach_by_name() simply takes the name and passes it to of_property_match_string() where the argument is "const char *". Adding a const here allows a later patch to add a const to dev_pm_domain_attach_by_name() which allows drivers to pass in a name that was declared "const" in a driver.

Fixes 5d6be70add65 ("PM / Domains: Introduce option to attach a device by name to genpd")

---

 drivers/base/power/domain.c | 2 +-
 include/linux/pm_domain.h   | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/base/power/domain.c +1 -1
index 45eafe8cf7dd..2c334c01fc43 100644
@@ -2483,7 +2483,7 @@ EXPORT_SYMBOL_GPL(genpd_dev_pm_attach_by_id);
  * power-domain-names DT property. For further description see
  * genpd_dev_pm_attach_by_id().
  */
-struct device *genpd_dev_pm_attach_by_name(struct device *dev, char *name)
+struct device *genpd_dev_pm_attach_by_name(struct device *dev, const char *name)
 {
 	int index;
 
include/linux/pm_domain.h +1 -1
index dd364abb649a..203be5082f33 100644
@@ -271,7 +271,7 @@ int genpd_dev_pm_attach(struct device *dev);
 struct device *genpd_dev_pm_attach_by_id(struct device *dev,
 					 unsigned int index);
 struct device *genpd_dev_pm_attach_by_name(struct device *dev,
-					   char *name);
+					   const char *name);
 #else /* !CONFIG_PM_GENERIC_DOMAINS_OF */
 static inline int of_genpd_add_provider_simple(struct device_node *np,
 					struct generic_pm_domain *genpd)

include/linux/pm_domain.h static inline struct device *genpd_dev_pm_attach_by_id(struct device *dev, · line 330

Quoted 8 lines
include/linux/pm_domain.h +1 -1
@@ -324,7 +324,7 @@ static inline struct device *genpd_dev_pm_attach_by_id(struct device *dev,
 }
 
 static inline struct device *genpd_dev_pm_attach_by_name(struct device *dev,
-							 char *name)
+							 const char *name)
 {
 	return NULL;
 }

Both this and the [2/2] applied, thanks!