From patchwork Tue Nov 18 10:16:30 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Majewski X-Patchwork-Id: 5326991 X-Patchwork-Delegate: eduardo.valentin@ti.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.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 689629F1E1 for ; Tue, 18 Nov 2014 10:16:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 923DC20179 for ; Tue, 18 Nov 2014 10:16:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3F778200EC for ; Tue, 18 Nov 2014 10:16:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752933AbaKRKQ4 (ORCPT ); Tue, 18 Nov 2014 05:16:56 -0500 Received: from mailout4.samsung.com ([203.254.224.34]:51820 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751699AbaKRKQz (ORCPT ); Tue, 18 Nov 2014 05:16:55 -0500 Received: from epcpsbgm1.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout4.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NF800L4ICK4ZU40@mailout4.samsung.com>; Tue, 18 Nov 2014 19:16:53 +0900 (KST) X-AuditID: cbfee61a-f79c06d000004e71-87-546b1c94a336 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id E0.4E.20081.49C1B645; Tue, 18 Nov 2014 19:16:52 +0900 (KST) Received: from mcdsrvbld02.digital.local ([106.116.37.23]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0NF800EYJCJMEE50@mmp1.samsung.com>; Tue, 18 Nov 2014 19:16:52 +0900 (KST) From: Lukasz Majewski To: Eduardo Valentin , Zhang Rui Cc: Ezequiel Garcia , Kuninori Morimoto , Linux PM list , Vincenzo Frascino , Bartlomiej Zolnierkiewicz , Lukasz Majewski , Nobuhiro Iwamatsu , Mikko Perttunen , Stephen Warren , Thierry Reding , Alexandre Courbot , linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org, Lukasz Majewski Subject: [PATCH v2] thermal:core:fix: Check return code of the ->get_max_state() callback Date: Tue, 18 Nov 2014 11:16:30 +0100 Message-id: <1416305790-27746-1-git-send-email-l.majewski@samsung.com> X-Mailer: git-send-email 1.7.10.4 In-reply-to: <1415898165-27406-1-git-send-email-l.majewski@samsung.com> References: <1415898165-27406-1-git-send-email-l.majewski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrLLMWRmVeSWpSXmKPExsVy+t9jAd0pMtkhBk1nZSw2zljPajH/yjVW i9OnFrBanHv1iMXibXOxxavDuxgt3jzitnjzcDOjxeVdc9gsPvceYbTo/DKLzeLB1WlsFk8e 9rFZvDrYxmLxc9c8FotjJ2awOgh4PNl0kdFj56y77B6L97xk8lg37S2zx4HJ51g9epvfsXl8 OzORxaNvyypGj6c/9jJ7fN4k57FxbmgAdxSXTUpqTmZZapG+XQJXxsY1e1gKJvJWtG+6ztrA +Iiri5GTQ0LAROL71I+sELaYxIV769m6GLk4hAQWMUr8bN/HCOF0MUncOP+aBaSKTUBP4vPd p0wgtoiAt8TrfdPBipgFXrNIHPrRwA6SEBaIlvjf8ZkRxGYRUJW4OOsAWAOvgJvE7klrGSHW KUp0P5vABmJzCrhLHD3xCaxXCKjm+PuV7BMYeRcwMqxiFE0tSC4oTkrPNdQrTswtLs1L10vO z93ECA70Z1I7GFc2WBxiFOBgVOLhTZiaFSLEmlhWXJl7iFGCg1lJhPdcN1CINyWxsiq1KD++ qDQntfgQozQHi5I474FW60AhgfTEktTs1NSC1CKYLBMHp1QD43GLXdKvNCwS976O/lRQUqH/ jOvbh7lHFvnNv2h6+6PIM9sk3ee396QIevM99tXYuSNXrvL87sismzHM9qp3blhn/H5p/6or UaJXL0o33OLzoV/1S/PNz7Lzac1s2O316Oes5jOlX+7EM7N9tGaxrtNiF7wcFrgnd+G+Wfax xbclzkQd2X9fR4mlOCPRUIu5qDgRAMgg+jZwAgAA 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 The return code from ->get_max_state() callback was not checked during binding cooling device to thermal zone device. Signed-off-by: Lukasz Majewski Reviewed-by: Lukasz Majewski --- Changes for v2: - It turned out that patches from 1 to 6 from v1 are not needed, since they either already solve the problem (like imx_thermal.c) or not use cpufreq as a thermal cooling device. - The patch 7 from v1 is also not needed since this patch on error exits this function without using max_state variable. - In thermal driver probe the cpufreq_cooling_register() method presence is crucial to evaluate if the thermal driver needs any actions with -EPROBE_DEFER. --- drivers/thermal/thermal_core.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index 43b9070..8567929 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -928,7 +928,7 @@ int thermal_zone_bind_cooling_device(struct thermal_zone_device *tz, struct thermal_zone_device *pos1; struct thermal_cooling_device *pos2; unsigned long max_state; - int result; + int result, ret; if (trip >= tz->trips || (trip < 0 && trip != THERMAL_TRIPS_NONE)) return -EINVAL; @@ -945,7 +945,9 @@ int thermal_zone_bind_cooling_device(struct thermal_zone_device *tz, if (tz != pos1 || cdev != pos2) return -EINVAL; - cdev->ops->get_max_state(cdev, &max_state); + ret = cdev->ops->get_max_state(cdev, &max_state); + if (ret) + return ret; /* lower default 0, upper default max_state */ lower = lower == THERMAL_NO_LIMIT ? 0 : lower;