All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] power: supply: core: move psy_has_property()
@ 2021-09-28 14:40 trix
  2021-09-29 16:04 ` Matthias Kaehlcke
  0 siblings, 1 reply; 2+ messages in thread
From: trix @ 2021-09-28 14:40 UTC (permalink / raw)
  To: sre, mka; +Cc: linux-pm, linux-kernel, Tom Rix

From: Tom Rix <trix@redhat.com>

A ranconfig produces this error
power_supply_core.c:1137:6: error: implicit declaration
  of function 'psy_has_property'
 1137 |  if (psy_has_property(desc, POWER_SUPPLY_PROP_USB_TYPE) &&

psy_has_property() compiling is conditional on THERMAL.  It is used
in __power_supply_register() to check a non thermal property.
So move psy_has_property() out of the THERMAL conditional.

Fixes: 9ba533eb99bb ("power: supply: core: Add psy_has_property()")
Signed-off-by: Tom Rix <trix@redhat.com>
---
 drivers/power/supply/power_supply_core.c | 32 ++++++++++++------------
 1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/drivers/power/supply/power_supply_core.c b/drivers/power/supply/power_supply_core.c
index 75575ea45f21dd..fc12a4f407f431 100644
--- a/drivers/power/supply/power_supply_core.c
+++ b/drivers/power/supply/power_supply_core.c
@@ -951,6 +951,22 @@ void power_supply_unreg_notifier(struct notifier_block *nb)
 }
 EXPORT_SYMBOL_GPL(power_supply_unreg_notifier);
 
+static bool psy_has_property(const struct power_supply_desc *psy_desc,
+			     enum power_supply_property psp)
+{
+	bool found = false;
+	int i;
+
+	for (i = 0; i < psy_desc->num_properties; i++) {
+		if (psy_desc->properties[i] == psp) {
+			found = true;
+			break;
+		}
+	}
+
+	return found;
+}
+
 #ifdef CONFIG_THERMAL
 static int power_supply_read_temp(struct thermal_zone_device *tzd,
 		int *temp)
@@ -975,22 +991,6 @@ static struct thermal_zone_device_ops psy_tzd_ops = {
 	.get_temp = power_supply_read_temp,
 };
 
-static bool psy_has_property(const struct power_supply_desc *psy_desc,
-			     enum power_supply_property psp)
-{
-	bool found = false;
-	int i;
-
-	for (i = 0; i < psy_desc->num_properties; i++) {
-		if (psy_desc->properties[i] == psp) {
-			found = true;
-			break;
-		}
-	}
-
-	return found;
-}
-
 static int psy_register_thermal(struct power_supply *psy)
 {
 	int ret;
-- 
2.26.3


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] power: supply: core: move psy_has_property()
  2021-09-28 14:40 [PATCH] power: supply: core: move psy_has_property() trix
@ 2021-09-29 16:04 ` Matthias Kaehlcke
  0 siblings, 0 replies; 2+ messages in thread
From: Matthias Kaehlcke @ 2021-09-29 16:04 UTC (permalink / raw)
  To: trix; +Cc: sre, linux-pm, linux-kernel

Hi Tom,

thanks for the fix!

Geert sent a similar patch earlier:

https://patchwork.kernel.org/project/linux-pm/patch/7b35a74f2c2ad19c8dc1ca60c59e48a14288677f.1632830348.git.geert+renesas@glider.be/

On Tue, Sep 28, 2021 at 07:40:46AM -0700, trix@redhat.com wrote:
> From: Tom Rix <trix@redhat.com>
> 
> A ranconfig produces this error
> power_supply_core.c:1137:6: error: implicit declaration
>   of function 'psy_has_property'
>  1137 |  if (psy_has_property(desc, POWER_SUPPLY_PROP_USB_TYPE) &&
> 
> psy_has_property() compiling is conditional on THERMAL.  It is used
> in __power_supply_register() to check a non thermal property.
> So move psy_has_property() out of the THERMAL conditional.
> 
> Fixes: 9ba533eb99bb ("power: supply: core: Add psy_has_property()")
> Signed-off-by: Tom Rix <trix@redhat.com>
> ---
>  drivers/power/supply/power_supply_core.c | 32 ++++++++++++------------
>  1 file changed, 16 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/power/supply/power_supply_core.c b/drivers/power/supply/power_supply_core.c
> index 75575ea45f21dd..fc12a4f407f431 100644
> --- a/drivers/power/supply/power_supply_core.c
> +++ b/drivers/power/supply/power_supply_core.c
> @@ -951,6 +951,22 @@ void power_supply_unreg_notifier(struct notifier_block *nb)
>  }
>  EXPORT_SYMBOL_GPL(power_supply_unreg_notifier);
>  
> +static bool psy_has_property(const struct power_supply_desc *psy_desc,
> +			     enum power_supply_property psp)
> +{
> +	bool found = false;
> +	int i;
> +
> +	for (i = 0; i < psy_desc->num_properties; i++) {
> +		if (psy_desc->properties[i] == psp) {
> +			found = true;
> +			break;
> +		}
> +	}
> +
> +	return found;
> +}
> +
>  #ifdef CONFIG_THERMAL
>  static int power_supply_read_temp(struct thermal_zone_device *tzd,
>  		int *temp)
> @@ -975,22 +991,6 @@ static struct thermal_zone_device_ops psy_tzd_ops = {
>  	.get_temp = power_supply_read_temp,
>  };
>  
> -static bool psy_has_property(const struct power_supply_desc *psy_desc,
> -			     enum power_supply_property psp)
> -{
> -	bool found = false;
> -	int i;
> -
> -	for (i = 0; i < psy_desc->num_properties; i++) {
> -		if (psy_desc->properties[i] == psp) {
> -			found = true;
> -			break;
> -		}
> -	}
> -
> -	return found;
> -}
> -
>  static int psy_register_thermal(struct power_supply *psy)
>  {
>  	int ret;
> -- 
> 2.26.3
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-09-29 16:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-28 14:40 [PATCH] power: supply: core: move psy_has_property() trix
2021-09-29 16:04 ` Matthias Kaehlcke

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.