From patchwork Tue Mar 25 10:49:14 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Shi X-Patchwork-Id: 27022 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f200.google.com (mail-ob0-f200.google.com [209.85.214.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 81B0720539 for ; Tue, 25 Mar 2014 10:49:55 +0000 (UTC) Received: by mail-ob0-f200.google.com with SMTP id gq1sf1072858obb.7 for ; Tue, 25 Mar 2014 03:49:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=HD+rkGetOgSrwoH2gKvnLdevbhEq0ZXcGsaR8xmCBSI=; b=VVZAGKzKK8eU9krhLyMiZGhz6kR7bgNXhKxTIYP+SK8MRWXxttBkqYbow6tTKAupLD Ja1eVYBrZ14ve4i6DvvMPP8iP6Gm4H3J8JRnp81IC8IHb0vITzENz1GbHQzIO4doiK+0 Kx+S0y4ZPFs5ywH7BsS2zXPCqQq8z5MhlBSwn73GJXUhebAz+xcWRlS1i7PzP9wY+Mog Zadh12rnHRtt6FqJXIGgdu6PsgTA2j1f1TGE2/NW5IyfYDd9wN5b5oi/Js49dYxiDbNd mMyYvku7q5t88cjjzPE/dDj8JYwZwqXOkturT4fNF9Zrt/w62AijdlXcoaTqYMWXjkLw OxIw== X-Gm-Message-State: ALoCoQnQaJXrHVcPpQE9XokmpHQmdIvRlIRtf/rZeoHD8I7Q7YQz0AmQTOuaUrbw5BzoFq3GpJ0m X-Received: by 10.182.51.200 with SMTP id m8mr14832133obo.16.1395744595045; Tue, 25 Mar 2014 03:49:55 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.42.20 with SMTP id b20ls184622qga.5.gmail; Tue, 25 Mar 2014 03:49:54 -0700 (PDT) X-Received: by 10.58.152.142 with SMTP id uy14mr22540491veb.4.1395744594908; Tue, 25 Mar 2014 03:49:54 -0700 (PDT) Received: from mail-vc0-f179.google.com (mail-vc0-f179.google.com [209.85.220.179]) by mx.google.com with ESMTPS id p8si3645350vef.122.2014.03.25.03.49.54 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 25 Mar 2014 03:49:54 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.179 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.179; Received: by mail-vc0-f179.google.com with SMTP id ij19so313366vcb.10 for ; Tue, 25 Mar 2014 03:49:54 -0700 (PDT) X-Received: by 10.58.126.4 with SMTP id mu4mr23126169veb.0.1395744594811; Tue, 25 Mar 2014 03:49:54 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.78.9 with SMTP id i9csp293732vck; Tue, 25 Mar 2014 03:49:54 -0700 (PDT) X-Received: by 10.66.21.73 with SMTP id t9mr22123601pae.36.1395744593876; Tue, 25 Mar 2014 03:49:53 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id et3si11128910pbc.420.2014.03.25.03.49.53; Tue, 25 Mar 2014 03:49:53 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753002AbaCYKtv (ORCPT + 12 others); Tue, 25 Mar 2014 06:49:51 -0400 Received: from mail-pa0-f51.google.com ([209.85.220.51]:40144 "EHLO mail-pa0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751907AbaCYKtu (ORCPT ); Tue, 25 Mar 2014 06:49:50 -0400 Received: by mail-pa0-f51.google.com with SMTP id kq14so277491pab.10 for ; Tue, 25 Mar 2014 03:49:50 -0700 (PDT) X-Received: by 10.68.239.70 with SMTP id vq6mr9748696pbc.152.1395744590213; Tue, 25 Mar 2014 03:49:50 -0700 (PDT) Received: from localhost.localdomain ([162.243.130.63]) by mx.google.com with ESMTPSA id db3sm42987987pbb.10.2014.03.25.03.49.44 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 25 Mar 2014 03:49:49 -0700 (PDT) From: Alex Shi To: mark.hambleton@broadcom.com, mark.brown@linaro.org, eduardo.valentin@ti.com, mporter@linaro.org, lsk-interest@linaro.org, linaro-kernel@linaro.org Cc: Zhang Rui , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Alex Shi Subject: [PATCH 01/19] thermal: allow registering without .get_temp Date: Tue, 25 Mar 2014 18:49:14 +0800 Message-Id: <1395744572-20014-2-git-send-email-alex.shi@linaro.org> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1395744572-20014-1-git-send-email-alex.shi@linaro.org> References: <1395744572-20014-1-git-send-email-alex.shi@linaro.org> Sender: linux-pm-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: alex.shi@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.179 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Eduardo Valentin This patch changes the thermal core driver to allow registration of thermal zones without the .get_temp callback. The idea behind this change is to allow lazy registration of sensor callbacks. The thermal zone will be disabled whenever the ops does not contain a .get_temp callback. The sysfs interface will be returning -EINVAL on any temperature read operation. Cc: Zhang Rui Cc: linux-pm@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Eduardo Valentin (cherry picked from commit 81bd4e1cebed5efb85bd94a15342ee4d6965a416) Signed-off-by: Alex Shi --- drivers/thermal/thermal_core.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index d755440..818cd78 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -388,7 +388,7 @@ int thermal_zone_get_temp(struct thermal_zone_device *tz, unsigned long *temp) enum thermal_trip_type type; #endif - if (!tz || IS_ERR(tz)) + if (!tz || IS_ERR(tz) || !tz->ops->get_temp) goto exit; mutex_lock(&tz->lock); @@ -441,6 +441,9 @@ void thermal_zone_device_update(struct thermal_zone_device *tz) { int count; + if (!tz->ops->get_temp) + return; + update_temperature(tz); for (count = 0; count < tz->trips; count++) @@ -1621,7 +1624,7 @@ struct thermal_zone_device *thermal_zone_device_register(const char *type, if (trips > THERMAL_MAX_TRIPS || trips < 0 || mask >> trips) return ERR_PTR(-EINVAL); - if (!ops || !ops->get_temp) + if (!ops) return ERR_PTR(-EINVAL); if (trips > 0 && !ops->get_trip_type) @@ -1723,6 +1726,9 @@ struct thermal_zone_device *thermal_zone_device_register(const char *type, INIT_DELAYED_WORK(&(tz->poll_queue), thermal_zone_device_check); + if (!tz->ops->get_temp) + thermal_zone_device_set_polling(tz, 0); + thermal_zone_device_update(tz); if (!result)