Re: [PATCHv3 12/15] Thermal: Register a governor for user space

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 六, 2012-09-01 at 17:21 +0530, Durgadoss R wrote:
> This patch registers a governor which will let the
> user land manage the platform thermals. Whenever a
> trip happens, this governor just notifies the user
> space using kobj_uevent().
> 
Hmm, we can make this governor configurable, not the step_wise (which is
used as the default governor), right?

thanks,
rui

> Signed-off-by: Durgadoss R <durgadoss.r@xxxxxxxxx>
> ---
>  drivers/thermal/thermal_sys.c |   18 ++++++++++++++++++
>  include/linux/thermal.h       |    2 ++
>  2 files changed, 20 insertions(+)
> 
> diff --git a/drivers/thermal/thermal_sys.c b/drivers/thermal/thermal_sys.c
> index 936b025..93672aa 100644
> --- a/drivers/thermal/thermal_sys.c
> +++ b/drivers/thermal/thermal_sys.c
> @@ -130,6 +130,15 @@ exit:
>  }
>  EXPORT_SYMBOL_GPL(thermal_unregister_governor);
>  
> +static int notify_user_space(struct thermal_zone_device *tz, int trip)
> +{
> +	mutex_lock(&tz->lock);
> +	kobject_uevent(&tz->device.kobj, KOBJ_CHANGE);
> +	mutex_unlock(&tz->lock);
> +
> +	return 0;
> +}
> +
>  static int get_idr(struct idr *idr, struct mutex *lock, int *id)
>  {
>  	int err;
> @@ -1860,6 +1869,12 @@ static inline int genetlink_init(void) { return 0; }
>  static inline void genetlink_exit(void) {}
>  #endif /* !CONFIG_NET */
>  
> +struct thermal_governor thermal_gov_user_space = {
> +	.name		= USER_SPACE_THERMAL_GOVERNOR,
> +	.throttle	= notify_user_space,
> +	.owner		= THIS_MODULE,
> +};
> +
>  static int __init thermal_init(void)
>  {
>  	int result = 0;
> @@ -1871,6 +1886,8 @@ static int __init thermal_init(void)
>  		mutex_destroy(&thermal_idr_lock);
>  		mutex_destroy(&thermal_list_lock);
>  	}
> +	/* Register a governor to notify user space */
> +	thermal_register_governor(&thermal_gov_user_space);
>  	result = genetlink_init();
>  	return result;
>  }
> @@ -1882,6 +1899,7 @@ static void __exit thermal_exit(void)
>  	idr_destroy(&thermal_cdev_idr);
>  	mutex_destroy(&thermal_idr_lock);
>  	mutex_destroy(&thermal_list_lock);
> +	thermal_unregister_governor(&thermal_gov_user_space);
>  	genetlink_exit();
>  }
>  
> diff --git a/include/linux/thermal.h b/include/linux/thermal.h
> index 2bd9158..aa903dd 100644
> --- a/include/linux/thermal.h
> +++ b/include/linux/thermal.h
> @@ -48,6 +48,8 @@
>  
>  /* Default Thermal Governor: Does Linear Throttling */
>  #define DEFAULT_THERMAL_GOVERNOR	"step_wise"
> +/* User space Thermal governor */
> +#define USER_SPACE_THERMAL_GOVERNOR	"user_space"
>  
>  struct thermal_zone_device;
>  struct thermal_cooling_device;


--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux IBM ACPI]     [Linux Power Management]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux