linux-acpi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Zhang Rui <rui.zhang@intel.com>
To: Prashanth Prakash <pprakash@codeaurora.org>,
	linux-pm@vger.kernel.org, linux-acpi@vger.kernel.org,
	"Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
Cc: edubezval@gmail.com
Subject: Re: [PATCH 2/2] ACPI/thermal: support for thermal zone description
Date: Tue, 08 Aug 2017 16:23:23 +0800	[thread overview]
Message-ID: <1502180603.4296.15.camel@intel.com> (raw)
In-Reply-To: <1500054535-975-3-git-send-email-pprakash@codeaurora.org>

On Fri, 2017-07-14 at 11:48 -0600, Prashanth Prakash wrote:
> Per ACPI 6.2 spec, platforms can optionally add a string(_STR)
> object within each thermal zone package which provides a user
> friendly name/description.
> 
> Add support to parse the string object, which will be exposed
> to userspace by thermal framework.
> 

is there any real request for this?

_STR is a generic control method for all the ACPI devices.
Thus I'm wondering, if really needed, should we expose this in acpi bus
instead?

thanks,
rui

> Signed-off-by: Prashanth Prakash <pprakash@codeaurora.org>
> ---
>  drivers/acpi/thermal.c | 38 ++++++++++++++++++++++++++++++++++++++
>  1 file changed, 38 insertions(+)
> 
> diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
> index 1d0417b..6ab6480 100644
> --- a/drivers/acpi/thermal.c
> +++ b/drivers/acpi/thermal.c
> @@ -41,6 +41,7 @@
>  #include <linux/acpi.h>
>  #include <linux/workqueue.h>
>  #include <linux/uaccess.h>
> +#include <linux/nls.h>
>  
>  #define PREFIX "ACPI: "
>  
> @@ -188,6 +189,7 @@ struct acpi_thermal {
>  	int tz_enabled;
>  	int kelvin_offset;
>  	struct work_struct thermal_check_work;
> +	char desc[THERMAL_MAX_DESC_STR_LEN];
>  };
>  
>  /* ---------------------------------------------------------------
> -----------
> @@ -543,6 +545,15 @@ static int thermal_get_temp(struct
> thermal_zone_device *thermal, int *temp)
>  	return 0;
>  }
>  
> +static int thermal_get_desc(struct thermal_zone_device *thermal,
> char *desc,
> +			int size)
> +{
> +	struct acpi_thermal *tz = thermal->devdata;
> +
> +	strlcpy(desc, tz->desc, size);
> +	return 0;
> +}
> +
>  static int thermal_get_mode(struct thermal_zone_device *thermal,
>  				enum thermal_device_mode *mode)
>  {
> @@ -880,6 +891,7 @@ static int acpi_thermal_cooling_device_cb(struct
> thermal_zone_device *thermal,
>  	.get_crit_temp = thermal_get_crit_temp,
>  	.get_trend = thermal_get_trend,
>  	.notify = thermal_notify,
> +	.get_desc = thermal_get_desc,
>  };
>  
>  static int acpi_thermal_register_thermal_zone(struct acpi_thermal
> *tz)
> @@ -1014,6 +1026,29 @@ static void
> acpi_thermal_aml_dependency_fix(struct acpi_thermal *tz)
>  	acpi_evaluate_integer(handle, "_TMP", NULL, &value);
>  }
>  
> +static void acpi_thermal_get_desc(struct acpi_thermal *tz)
> +{
> +	acpi_handle handle = tz->device->handle;
> +	acpi_status status;
> +	struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL};
> +
> +	status = acpi_evaluate_object(handle, "_STR", NULL,
> &buffer);
> +
> +	if (ACPI_FAILURE(status))
> +		strlcpy(tz->desc, "<not supported>",
> THERMAL_MAX_DESC_STR_LEN);
> +	else {
> +		union acpi_object *str;
> +		int result;
> +
> +		str = buffer.pointer;
> +		result = utf16s_to_utf8s((wchar_t *)str-
> >string.pointer,
> +					str->string.length,
> UTF16_LITTLE_ENDIAN,
> +					tz->desc,
> THERMAL_MAX_DESC_STR_LEN-1);
> +		tz->desc[result] = 0;
> +		kfree(buffer.pointer);
> +	}
> +}
> +
>  static int acpi_thermal_get_info(struct acpi_thermal *tz)
>  {
>  	int result = 0;
> @@ -1045,6 +1080,9 @@ static int acpi_thermal_get_info(struct
> acpi_thermal *tz)
>  	else
>  		acpi_thermal_get_polling_frequency(tz);
>  
> +	/* Get thermal zone description [_STR] (optional) */
> +	acpi_thermal_get_desc(tz);
> +
>  	return 0;
>  }
>  

  reply	other threads:[~2017-08-08  8:23 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-14 17:48 [PATCH 0/2] User-friendly description for thermal zones Prashanth Prakash
2017-07-14 17:48 ` [PATCH 1/2] thermal: add a sysfs entry for thermal zone description Prashanth Prakash
2017-07-14 17:48 ` [PATCH 2/2] ACPI/thermal: support " Prashanth Prakash
2017-08-08  8:23   ` Zhang Rui [this message]
2017-08-08 16:01     ` Prakash, Prashanth
2017-08-09 14:27       ` Zhang Rui
2017-08-18  0:09         ` Rafael J. Wysocki
2017-08-18  2:14           ` Zhang Rui
2017-08-18 12:34             ` Rafael J. Wysocki
2017-08-21 14:28               ` Zhang Rui
2017-08-21 21:53                 ` Rafael J. Wysocki
2017-08-18 22:31             ` Prakash, Prashanth
2017-08-21 14:37               ` Zhang Rui
2017-08-21 21:21                 ` Prakash, Prashanth

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1502180603.4296.15.camel@intel.com \
    --to=rui.zhang@intel.com \
    --cc=edubezval@gmail.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=pprakash@codeaurora.org \
    --cc=rafael.j.wysocki@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).