From patchwork Thu Jan 29 13:04:52 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Rui X-Patchwork-Id: 5742071 X-Patchwork-Delegate: rui.zhang@intel.com Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 463799F399 for ; Thu, 29 Jan 2015 13:05:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 69B972024D for ; Thu, 29 Jan 2015 13:05:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 51D9D2022D for ; Thu, 29 Jan 2015 13:05:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755719AbbA2NFI (ORCPT ); Thu, 29 Jan 2015 08:05:08 -0500 Received: from mga09.intel.com ([134.134.136.24]:48305 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755582AbbA2NFH (ORCPT ); Thu, 29 Jan 2015 08:05:07 -0500 Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga102.jf.intel.com with ESMTP; 29 Jan 2015 05:01:47 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.97,862,1389772800"; d="scan'208";a="446988904" Received: from unknown (HELO rzhang1-toshiba.ccr.corp.intel.com) ([10.255.21.92]) by FMSMGA003.fm.intel.com with ESMTP; 29 Jan 2015 04:51:13 -0800 From: Zhang Rui To: linux-pm@vger.kernel.org Cc: srinivas.pandruvada@linux.intel.com, rui.zhang@intel.com Subject: [PATCH 2/2] Thermal/int3400 thermal: support _ART/_TRT change event Date: Thu, 29 Jan 2015 21:04:52 +0800 Message-Id: <1422536692-18632-1-git-send-email-rui.zhang@intel.com> X-Mailer: git-send-email 1.9.1 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In some cases, the _ART/_TRT data may be changed at runtime, and ACPI notification 0x83/0x84 will be delivered to INT3400 ACPI device object when this happens. Add this support in int3400_thermal driver. Signed-off-by: Zhang Rui --- drivers/thermal/int340x_thermal/int3400_thermal.c | 54 ++++++++++++++++++++++- 1 file changed, 52 insertions(+), 2 deletions(-) diff --git a/drivers/thermal/int340x_thermal/int3400_thermal.c b/drivers/thermal/int340x_thermal/int3400_thermal.c index 25d244c..3780b39 100644 --- a/drivers/thermal/int340x_thermal/int3400_thermal.c +++ b/drivers/thermal/int340x_thermal/int3400_thermal.c @@ -16,6 +16,9 @@ #include #include "acpi_thermal_rel.h" +#define INT3400_THERMAL_ART_CHANGED 0x83 +#define INT3400_THERMAL_TRT_CHANGED 0x84 + enum int3400_thermal_uuid { INT3400_THERMAL_PASSIVE_1, INT3400_THERMAL_ACTIVE, @@ -240,6 +243,42 @@ static struct thermal_zone_params int3400_thermal_params = { .no_hwmon = true, }; +static void int3400_notify(acpi_handle handle, u32 event, void *data) +{ + struct platform_device *pdev = data; + struct int3400_thermal_priv *priv = platform_get_drvdata(pdev); + int count; + struct art *arts; + struct trt *trts; + int result; + + if (!priv) + return; + + switch (event) { + case INT3400_THERMAL_ART_CHANGED: + result = acpi_parse_art(priv->adev->handle, &count, + &arts, false); + if (result) + return; + priv->art_count = count; + priv->arts = arts; + kobject_uevent(&pdev->dev.kobj, KOBJ_CHANGE); + return; + case INT3400_THERMAL_TRT_CHANGED: + result = acpi_parse_trt(priv->adev->handle, &count, + &trts, false); + if (result) + return; + priv->trt_count = count; + priv->trts = trts; + kobject_uevent(&pdev->dev.kobj, KOBJ_CHANGE); + return; + default: + return; + } +} + static int int3400_thermal_probe(struct platform_device *pdev) { struct acpi_device *adev = ACPI_COMPANION(&pdev->dev); @@ -287,13 +326,22 @@ static int int3400_thermal_probe(struct platform_device *pdev) priv->rel_misc_dev_res = acpi_thermal_rel_misc_device_add( priv->adev->handle); + result = acpi_install_notify_handler(priv->adev->handle, + ACPI_DEVICE_NOTIFY, int3400_notify, (void *)pdev); + if (result) + goto free_misc; + result = sysfs_create_group(&pdev->dev.kobj, &uuid_attribute_group); if (result) - goto free_zone; + goto free_notify; return 0; -free_zone: +free_notify: + acpi_remove_notify_handler(priv->adev->handle, ACPI_DEVICE_NOTIFY, + int3400_notify); +free_misc: + acpi_thermal_rel_misc_device_remove(priv->adev->handle); thermal_zone_device_unregister(priv->thermal); free_trt: kfree(priv->trts); @@ -311,6 +359,8 @@ static int int3400_thermal_remove(struct platform_device *pdev) if (!priv->rel_misc_dev_res) acpi_thermal_rel_misc_device_remove(priv->adev->handle); + acpi_remove_notify_handler(priv->adev->handle, ACPI_DEVICE_NOTIFY, + int3400_notify); sysfs_remove_group(&pdev->dev.kobj, &uuid_attribute_group); thermal_zone_device_unregister(priv->thermal); kfree(priv->trts);