All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] thermal: show supported policies
@ 2014-09-16 10:57 Sanjay Singh Rawat
  2014-09-18  0:57 ` Zhang Rui
  0 siblings, 1 reply; 3+ messages in thread
From: Sanjay Singh Rawat @ 2014-09-16 10:57 UTC (permalink / raw)
  To: rui.zhang, edubezval
  Cc: linux-pm, linux-kernel, linaro-kernel, Sanjay Singh Rawat

With knowledge of supported thermal policies from this attribute, it helps in
setting the policy without failure from the available ones.

Signed-off-by: Sanjay Singh Rawat <sanjay.rawat@linaro.org>
---
 drivers/thermal/thermal_core.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index 71b0ec0..6caefcd 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -772,6 +772,25 @@ policy_show(struct device *dev, struct device_attribute *devattr, char *buf)
 	return sprintf(buf, "%s\n", tz->governor->name);
 }
 
+static ssize_t
+available_policy_show(struct device *dev, struct device_attribute *devattr,
+			char *buf)
+{
+	ssize_t i = 0;
+	struct thermal_governor *temp;
+	struct thermal_zone_device *tz = to_thermal_zone(dev);
+
+	mutex_lock(&tz->lock);
+
+	list_for_each_entry(temp, &thermal_governor_list, governor_list)
+		i += sprintf(&buf[i], "%s ", temp->name);
+
+	mutex_unlock(&tz->lock);
+	i += sprintf(&buf[i], "\n");
+
+	return i;
+}
+
 #ifdef CONFIG_THERMAL_EMULATION
 static ssize_t
 emul_temp_store(struct device *dev, struct device_attribute *attr,
@@ -805,6 +824,7 @@ static DEVICE_ATTR(temp, 0444, temp_show, NULL);
 static DEVICE_ATTR(mode, 0644, mode_show, mode_store);
 static DEVICE_ATTR(passive, S_IRUGO | S_IWUSR, passive_show, passive_store);
 static DEVICE_ATTR(policy, S_IRUGO | S_IWUSR, policy_show, policy_store);
+static DEVICE_ATTR(available_policy, S_IRUGO, available_policy_show, NULL);
 
 /* sys I/F for cooling device */
 #define to_cooling_device(_dev)	\
@@ -1538,6 +1558,10 @@ struct thermal_zone_device *thermal_zone_device_register(const char *type,
 	if (result)
 		goto unregister;
 
+	result = device_create_file(&tz->device, &dev_attr_available_policy);
+	if (result)
+		goto unregister;
+
 	/* Update 'this' zone's governor information */
 	mutex_lock(&thermal_governor_lock);
 
-- 
1.8.3.2


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

* Re: [PATCH] thermal: show supported policies
  2014-09-16 10:57 [PATCH] thermal: show supported policies Sanjay Singh Rawat
@ 2014-09-18  0:57 ` Zhang Rui
  2014-09-18 10:02   ` Sanjay Singh Rawat
  0 siblings, 1 reply; 3+ messages in thread
From: Zhang Rui @ 2014-09-18  0:57 UTC (permalink / raw)
  To: Sanjay Singh Rawat; +Cc: edubezval, linux-pm, linux-kernel, linaro-kernel

On Tue, 2014-09-16 at 16:27 +0530, Sanjay Singh Rawat wrote:
> With knowledge of supported thermal policies from this attribute, it helps in
> setting the policy without failure from the available ones.
> 
Hmmm, I think it's better to reuse the "policy" attribute.
Say,
#cat policy
user_space [step_wise] fair_share
I'm not sure if this will break any userspace as it's an ABI change, but
we can give it a try, right?

thanks,
-rui
> Signed-off-by: Sanjay Singh Rawat <sanjay.rawat@linaro.org>
> ---
>  drivers/thermal/thermal_core.c | 24 ++++++++++++++++++++++++
>  1 file changed, 24 insertions(+)
> 
> diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
> index 71b0ec0..6caefcd 100644
> --- a/drivers/thermal/thermal_core.c
> +++ b/drivers/thermal/thermal_core.c
> @@ -772,6 +772,25 @@ policy_show(struct device *dev, struct device_attribute *devattr, char *buf)
>  	return sprintf(buf, "%s\n", tz->governor->name);
>  }
>  
> +static ssize_t
> +available_policy_show(struct device *dev, struct device_attribute *devattr,
> +			char *buf)
> +{
> +	ssize_t i = 0;
> +	struct thermal_governor *temp;
> +	struct thermal_zone_device *tz = to_thermal_zone(dev);
> +
> +	mutex_lock(&tz->lock);
> +
> +	list_for_each_entry(temp, &thermal_governor_list, governor_list)
> +		i += sprintf(&buf[i], "%s ", temp->name);
> +
> +	mutex_unlock(&tz->lock);
> +	i += sprintf(&buf[i], "\n");
> +
> +	return i;
> +}
> +
>  #ifdef CONFIG_THERMAL_EMULATION
>  static ssize_t
>  emul_temp_store(struct device *dev, struct device_attribute *attr,
> @@ -805,6 +824,7 @@ static DEVICE_ATTR(temp, 0444, temp_show, NULL);
>  static DEVICE_ATTR(mode, 0644, mode_show, mode_store);
>  static DEVICE_ATTR(passive, S_IRUGO | S_IWUSR, passive_show, passive_store);
>  static DEVICE_ATTR(policy, S_IRUGO | S_IWUSR, policy_show, policy_store);
> +static DEVICE_ATTR(available_policy, S_IRUGO, available_policy_show, NULL);
>  
>  /* sys I/F for cooling device */
>  #define to_cooling_device(_dev)	\
> @@ -1538,6 +1558,10 @@ struct thermal_zone_device *thermal_zone_device_register(const char *type,
>  	if (result)
>  		goto unregister;
>  
> +	result = device_create_file(&tz->device, &dev_attr_available_policy);
> +	if (result)
> +		goto unregister;
> +
>  	/* Update 'this' zone's governor information */
>  	mutex_lock(&thermal_governor_lock);
>  



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

* Re: [PATCH] thermal: show supported policies
  2014-09-18  0:57 ` Zhang Rui
@ 2014-09-18 10:02   ` Sanjay Singh Rawat
  0 siblings, 0 replies; 3+ messages in thread
From: Sanjay Singh Rawat @ 2014-09-18 10:02 UTC (permalink / raw)
  To: Zhang Rui; +Cc: edubezval, linux-pm, linux-kernel, linaro-kernel

thanks for the review Rui

On Thursday 18 September 2014 06:27 AM, Zhang Rui wrote:
> On Tue, 2014-09-16 at 16:27 +0530, Sanjay Singh Rawat wrote:
>> With knowledge of supported thermal policies from this attribute, it helps in
>> setting the policy without failure from the available ones.
>>
> Hmmm, I think it's better to reuse the "policy" attribute.
> Say,
> #cat policy
> user_space [step_wise] fair_share
> I'm not sure if this will break any userspace as it's an ABI change, but
> we can give it a try, right?

Looks good, but might break. So thought of simplified way of doing.

>
> thanks,
> -rui
>> Signed-off-by: Sanjay Singh Rawat <sanjay.rawat@linaro.org>
>> ---
>>   drivers/thermal/thermal_core.c | 24 ++++++++++++++++++++++++
>>   1 file changed, 24 insertions(+)
>>
>> diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
>> index 71b0ec0..6caefcd 100644
>> --- a/drivers/thermal/thermal_core.c
>> +++ b/drivers/thermal/thermal_core.c
>> @@ -772,6 +772,25 @@ policy_show(struct device *dev, struct device_attribute *devattr, char *buf)
>>   	return sprintf(buf, "%s\n", tz->governor->name);
>>   }
>>   
>> +static ssize_t
>> +available_policy_show(struct device *dev, struct device_attribute *devattr,
>> +			char *buf)
>> +{
>> +	ssize_t i = 0;
>> +	struct thermal_governor *temp;
>> +	struct thermal_zone_device *tz = to_thermal_zone(dev);
>> +
>> +	mutex_lock(&tz->lock);
>> +
>> +	list_for_each_entry(temp, &thermal_governor_list, governor_list)
>> +		i += sprintf(&buf[i], "%s ", temp->name);
>> +
>> +	mutex_unlock(&tz->lock);
>> +	i += sprintf(&buf[i], "\n");
>> +
>> +	return i;
>> +}
>> +
>>   #ifdef CONFIG_THERMAL_EMULATION
>>   static ssize_t
>>   emul_temp_store(struct device *dev, struct device_attribute *attr,
>> @@ -805,6 +824,7 @@ static DEVICE_ATTR(temp, 0444, temp_show, NULL);
>>   static DEVICE_ATTR(mode, 0644, mode_show, mode_store);
>>   static DEVICE_ATTR(passive, S_IRUGO | S_IWUSR, passive_show, passive_store);
>>   static DEVICE_ATTR(policy, S_IRUGO | S_IWUSR, policy_show, policy_store);
>> +static DEVICE_ATTR(available_policy, S_IRUGO, available_policy_show, NULL);
>>   
>>   /* sys I/F for cooling device */
>>   #define to_cooling_device(_dev)	\
>> @@ -1538,6 +1558,10 @@ struct thermal_zone_device *thermal_zone_device_register(const char *type,
>>   	if (result)
>>   		goto unregister;
>>   
>> +	result = device_create_file(&tz->device, &dev_attr_available_policy);
>> +	if (result)
>> +		goto unregister;
>> +
>>   	/* Update 'this' zone's governor information */
>>   	mutex_lock(&thermal_governor_lock);
>>   
>

-- 
sanjay


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

end of thread, other threads:[~2014-09-18 10:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-16 10:57 [PATCH] thermal: show supported policies Sanjay Singh Rawat
2014-09-18  0:57 ` Zhang Rui
2014-09-18 10:02   ` Sanjay Singh Rawat

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.