From patchwork Fri Jul 14 17:48:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Prakash, Prashanth" X-Patchwork-Id: 9841489 X-Patchwork-Delegate: rui.zhang@intel.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2A3B060381 for ; Fri, 14 Jul 2017 17:59:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 180432879D for ; Fri, 14 Jul 2017 17:59:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0BBFB2879C; Fri, 14 Jul 2017 17:59:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AF85A2879C for ; Fri, 14 Jul 2017 17:59:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751020AbdGNR7E (ORCPT ); Fri, 14 Jul 2017 13:59:04 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:38048 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750725AbdGNR7C (ORCPT ); Fri, 14 Jul 2017 13:59:02 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id C7B7261295; Fri, 14 Jul 2017 17:49:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1500054549; bh=E612pst1PGRs8RvqrBNUrLepqwbLd0nMXDmGS07BNe0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XZdydo6RvWOGW6WesHfDcxKnDcvqjTdnDTYkkttM3j237y8gEani7kZS8b21DtSTj Dt0t0THp2a4Q/9iMA2omAoGEZSlhMEOtuqxI9UndNCpOay9SGVqGRSmCX+x9j1yoXU 25h8EXrNiexMUhW9r8Ew3qygNOoKOVzU+7fI4YeU= Received: from pprakash-lnx.qualcomm.com (unknown [129.46.15.3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: pprakash@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id B91DE61256; Fri, 14 Jul 2017 17:49:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1500054549; bh=E612pst1PGRs8RvqrBNUrLepqwbLd0nMXDmGS07BNe0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XZdydo6RvWOGW6WesHfDcxKnDcvqjTdnDTYkkttM3j237y8gEani7kZS8b21DtSTj Dt0t0THp2a4Q/9iMA2omAoGEZSlhMEOtuqxI9UndNCpOay9SGVqGRSmCX+x9j1yoXU 25h8EXrNiexMUhW9r8Ew3qygNOoKOVzU+7fI4YeU= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org B91DE61256 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=pprakash@codeaurora.org From: Prashanth Prakash To: linux-pm@vger.kernel.org, linux-acpi@vger.kernel.org Cc: rui.zhang@intel.com, edubezval@gmail.com, Prashanth Prakash Subject: [PATCH 2/2] ACPI/thermal: support for thermal zone description Date: Fri, 14 Jul 2017 11:48:55 -0600 Message-Id: <1500054535-975-3-git-send-email-pprakash@codeaurora.org> X-Mailer: git-send-email 1.8.2.1 In-Reply-To: <1500054535-975-1-git-send-email-pprakash@codeaurora.org> References: <1500054535-975-1-git-send-email-pprakash@codeaurora.org> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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. Signed-off-by: Prashanth Prakash --- 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 #include #include +#include #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, "", 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; }