Re: [PATCH 2/2] Give ACPI hwmon thermal devices a name if BIOS provides one

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

 



On Mon, 2008-08-25 at 06:11 +0800, Thomas Renninger wrote:
> On a HP tx2500z laptop one thermal device provides this function:
>             Name (REGN, "Processor Thermal Zone")
> 
> Evaluate it and pass it as a name to hwmon.
> 
> Signed-off-by: Thomas Renninger <trenn@xxxxxxx>
> ---
>  drivers/acpi/thermal.c        |   15 ++++++++++++++-
>  drivers/thermal/thermal_sys.c |   11 +++++++++--
>  2 files changed, 23 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
> index 9127036..8095e9e 100644
> --- a/drivers/acpi/thermal.c
> +++ b/drivers/acpi/thermal.c
> @@ -1600,11 +1600,24 @@ static void acpi_thermal_notify(acpi_handle
> handle, u32 event, void *data)
>  static int acpi_thermal_get_info(struct acpi_thermal *tz)
>  {
>         int result = 0;
> -
> +       char *name = NULL;
> +       acpi_status status;
> 
>         if (!tz)
>                 return -EINVAL;
> 
> +       /* Get optional name of the thermal zone */
> +       status = acpi_evaluate_string(tz->device->handle, "REGN",
> NULL,
> +                                     &name);

As this is not defined in the ACPI spec, I don't know if it's
appropriate to implement this in the generic code.

> +       if (ACPI_SUCCESS(status)){
> +               ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Thermal zone %s has
> name: "
> +                                 "%s\n", acpi_device_bid(tz->device),
> name));
> +               /* This is hard coded limited to 16, why? */
> +               strncpy(tz->thermal_zone->temp_input.name, name, 16);
> +               kfree(name);
> +               tz->thermal_zone->temp_input.name[15] = '\n';
> +       }
> +
>         /* Get temperature [_TMP] (required) */
>         result = acpi_thermal_get_temperature(tz);
>         if (result)
> diff --git a/drivers/thermal/thermal_sys.c
> b/drivers/thermal/thermal_sys.c
> index fe07462..51a7077 100644
> --- a/drivers/thermal/thermal_sys.c
> +++ b/drivers/thermal/thermal_sys.c
> @@ -371,8 +371,15 @@ thermal_add_hwmon_sysfs(struct
> thermal_zone_device *tz)
>         tz->hwmon = hwmon;
>         hwmon->count++;
> 
> -       snprintf(tz->temp_input.name, THERMAL_NAME_LENGTH,
> -                "temp%d_input", hwmon->count);
> +       /*
> +        * What happens if we get duplicate zone names from the BIOS?
> +        * Is that allowed? If not, should we still just add the
> +        * hwmon count at the end?
> +        * tz->temp_input.name is char[16], this is ugly to do...
> +        */
> +       if (!tz->temp_input.name)
> +               snprintf(tz->temp_input.name, THERMAL_NAME_LENGTH,
> +                        "temp%d_input", hwmon->count);
we should create a new attribute here rather than replacing the old one.
the new hwmon sysfs I/F should be like:
temp1_input:	current temperature
temp1_crit:	critical threshold
temp1_label:	string like "Processor Thermal Zone"

thanks,
rui
>         tz->temp_input.attr.attr.name = tz->temp_input.name;
>         tz->temp_input.attr.attr.mode = 0444;
>         tz->temp_input.attr.show = temp_input_show;
> --
> 1.5.4.5
> 
> 
> 

--
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