Received: by 10.213.65.68 with SMTP id h4csp3854477imn; Tue, 10 Apr 2018 05:49:29 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+FWm5CR4Et34OnZl5mrvRnDHBIhqoDg69ug7KmOj2ZSknMD0Tr+OzcJxXpcYeCArXxryU+ X-Received: by 10.98.163.74 with SMTP id s71mr266263pfe.72.1523364569329; Tue, 10 Apr 2018 05:49:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523364569; cv=none; d=google.com; s=arc-20160816; b=kY18y/m+u8tabrd+q9UfYP6LgF4qQgpY6EFMYqxlFRZ1KO4nVDlVTMSFLFNYPcVnlI hZxOumAbMi7CiJtY+IoY4U2YcgyLGQdHvX7uA9NQS8CdetrNs0q+bMVK6CT6Y+fkRc/5 zKar82VMp68E6JBPxZvj5chrbnR/RyiZ+X3A/RDxfQSWcPoXKkAZJDBmsTXy5/2YtH/6 7VIhRMlAmZuM3kVhbesJ0p/8zQksQyvwcjRhYnT0YllhuBOT3hB5Zxi1G6lR0SOZB6AM lYRX7koesggJ4fW3IEXgdVDfUsmJhuWwB5rrHFs519lGRgXVbhpD/dkns99/FvnEQE6j f3lg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:cms-type:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature:dkim-filter :arc-authentication-results; bh=oZwHiV4CVBsAUw9DkGe0xxC+KcGfp0wWDFcBCM+JZtk=; b=d+4RAGQBazc2VA7MZCLGPUFEksceRs37PSYltbMiS+PNOjvbhtqpmWiS59Ou0QE3/Z e5FRBhZrJZBHnrdGrCVtJj7fHHpwy1rwx20PL8HJ55JUAxyNL1l/FRmultGi29yW3Y2N HUeSsvxX7xjCCTgJWD1IoaE4RLyzdc3UdyVTdOVikMQPuSSjgsI+bx+oIt8baRUYgDmV zfZHPVFoljfD8L4PZ9+3lBiNj69+DCmU24PlB6F9M63dKQvHgHyB3Tx4uTxJwjsy4e9Z sTzfp/ymLiZhKtO2q+0aXPuNLxiCJarbC466FBUGW2h64bCTHvBYLRT1N/CvfXWnbeP+ Eb+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=pVT8/E18; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x32-v6si2625673pld.591.2018.04.10.05.48.52; Tue, 10 Apr 2018 05:49:29 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=pVT8/E18; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752978AbeDJMmz (ORCPT + 99 others); Tue, 10 Apr 2018 08:42:55 -0400 Received: from mailout1.samsung.com ([203.254.224.24]:32552 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752932AbeDJMmv (ORCPT ); Tue, 10 Apr 2018 08:42:51 -0400 Received: from epcas1p2.samsung.com (unknown [182.195.41.46]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20180410124249epoutp01132be7dac7a6204caa09cb3cd35ed13c~kE6QlzQU52465424654epoutp01y; Tue, 10 Apr 2018 12:42:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20180410124249epoutp01132be7dac7a6204caa09cb3cd35ed13c~kE6QlzQU52465424654epoutp01y DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1523364169; bh=oZwHiV4CVBsAUw9DkGe0xxC+KcGfp0wWDFcBCM+JZtk=; h=From:To:Cc:Subject:Date:In-reply-to:References:From; b=pVT8/E18GrHTwl85UQRrZvL0Qu42gfo5AOdEn/oO2qTyQZGV+Go0pMXECqPrnRmBt 63TowJC+xsY0WOcyZ7Jka9Z01AlYFtmKS93EMHimPSQPN2FlobqFVa5rjBOsM2q6X3 ba5nZRVLK2HvGLF30dZ2lMoqntICDyjju7B7MA7E= Received: from epsmges1p5.samsung.com (unknown [182.195.42.57]) by epcas1p3.samsung.com (KnoxPortal) with ESMTP id 20180410124248epcas1p30e4438867f93db921031cf2dd0ae34ff~kE6PhSbXf0327603276epcas1p3k; Tue, 10 Apr 2018 12:42:48 +0000 (GMT) Received: from epcas1p1.samsung.com ( [182.195.41.45]) by epsmges1p5.samsung.com (Symantec Messaging Gateway) with SMTP id C6.5F.04084.841BCCA5; Tue, 10 Apr 2018 21:42:48 +0900 (KST) Received: from epsmgms2p1new.samsung.com (unknown [182.195.42.142]) by epcas1p4.samsung.com (KnoxPortal) with ESMTP id 20180410124248epcas1p453f74df4e183f9d68de255847c093d4e~kE6PP7Cx51368613686epcas1p4k; Tue, 10 Apr 2018 12:42:48 +0000 (GMT) X-AuditID: b6c32a39-591ff70000000ff4-6d-5accb1482a89 Received: from epmmp1.local.host ( [203.254.227.16]) by epsmgms2p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 5B.21.03849.741BCCA5; Tue, 10 Apr 2018 21:42:48 +0900 (KST) Received: from AMDC3058.DIGITAL.local ([106.120.53.102]) by mmp1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0P6Y00EUVZATQUB0@mmp1.samsung.com>; Tue, 10 Apr 2018 21:42:47 +0900 (KST) From: Bartlomiej Zolnierkiewicz To: Zhang Rui , Eduardo Valentin Cc: Eric Anholt , Stefan Wahren , Markus Mayer , bcm-kernel-feedback-list@broadcom.com, Heiko Stuebner , Thierry Reding , Jonathan Hunter , Keerthy , Masahiro Yamada , Jun Nie , Baoyou Xie , Shawn Guo , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, b.zolnierkie@samsung.com Subject: [PATCH 01/17] thermal: add thermal_zone_device_toggle() helper Date: Tue, 10 Apr 2018 14:41:55 +0200 Message-id: <1523364131-31059-2-git-send-email-b.zolnierkie@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1523364131-31059-1-git-send-email-b.zolnierkie@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAAzWSa0iTYRTHe/Ze9m41eZu3RyWDYWCK1iLpKUsthF7RovrmPlRD39xw6tp0 ZBB5ibygZiWmQ9TUD7ka4tKcOkvntWZGGWKleb/HjDStTK05/fY/z/93nv85cChMmEW4U/L4 RFYVL1WISD7+ov2gnx9T2ys5PLXshmqLagg0vdQNkD63E0dlHwcI1JraD9Dm+AKB3jSkcdAd bQWOqibHuKi/qYRES7kdAJVYv3DR5FgeiWbrXJHhySCJfjeV4qjl6xII2cukLXaRjHbkLck0 aoe5TP3nAKbSNMdhDLoskhkaMJFMbrqVZPLqdIBpGCjFmJ5HqzjTPdjAYZYMnhcEEv7JaFYh 17CqQ0FX+bK15XxMuRBww2LIAynA6pcNeBSkj8LmMj2RDfiUkDYCaK1aIO3FKoA95gpyhxox LnLtRjOAGZmfuDZDSP8B0NgXYdMkfQLez9CBbEBRTnQ4rHtG2XiMLsbh96FOzMY40mdh00QO ZmNw+gCsKdtnexbQDFyf/saxZ3nC110PCZvm0WFwrWVxazpI3+PCVytt2wOFwtam1O0GRzjf Xce1/QlpD/ih85SdTwdwxWjC7Ew+gKYaoV0Hwvbu91sBGO0ArT9zCHuvAGbe3UYYWDXftR11 GlqHjBz7uiUA1s945wP3crBLB1xYpTouhlWLlQH+ammcOik+xj8qIc4Atg7E57gRdPVFmAFN AdEeQX6bRS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 4UxSne6WiORDMzuWVOQxm+7bqGggKu99sfkclxJLcUaioRZzUXEiAOTgZ951AgAA X-CMS-MailID: 20180410124248epcas1p453f74df4e183f9d68de255847c093d4e X-Msg-Generator: CA CMS-TYPE: 101P X-CMS-RootMailID: 20180410124248epcas1p453f74df4e183f9d68de255847c093d4e X-RootMTR: 20180410124248epcas1p453f74df4e183f9d68de255847c093d4e References: <1523364131-31059-1-git-send-email-b.zolnierkie@samsung.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add thermal_zone_device_toggle() helper. Then update core code and drivers to use it. Signed-off-by: Bartlomiej Zolnierkiewicz --- drivers/thermal/hisi_thermal.c | 14 ++------------ drivers/thermal/of-thermal.c | 2 +- drivers/thermal/rockchip_thermal.c | 22 +++++----------------- drivers/thermal/thermal_helpers.c | 15 +++++++++++++++ drivers/thermal/thermal_sysfs.c | 8 +++++--- include/linux/thermal.h | 1 + 6 files changed, 29 insertions(+), 33 deletions(-) diff --git a/drivers/thermal/hisi_thermal.c b/drivers/thermal/hisi_thermal.c index 761d055..9428499 100644 --- a/drivers/thermal/hisi_thermal.c +++ b/drivers/thermal/hisi_thermal.c @@ -515,15 +515,6 @@ static int hisi_thermal_register_sensor(struct platform_device *pdev, }; MODULE_DEVICE_TABLE(of, of_hisi_thermal_match); -static void hisi_thermal_toggle_sensor(struct hisi_thermal_sensor *sensor, - bool on) -{ - struct thermal_zone_device *tzd = sensor->tzd; - - tzd->ops->set_mode(tzd, - on ? THERMAL_DEVICE_ENABLED : THERMAL_DEVICE_DISABLED); -} - static int hisi_thermal_probe(struct platform_device *pdev) { struct hisi_thermal_data *data; @@ -571,7 +562,7 @@ static int hisi_thermal_probe(struct platform_device *pdev) } } - hisi_thermal_toggle_sensor(&data->sensor, true); + thermal_zone_device_toggle((&data->sensor)->tzd, true); return 0; } @@ -579,9 +570,8 @@ static int hisi_thermal_probe(struct platform_device *pdev) static int hisi_thermal_remove(struct platform_device *pdev) { struct hisi_thermal_data *data = platform_get_drvdata(pdev); - struct hisi_thermal_sensor *sensor = &data->sensor; - hisi_thermal_toggle_sensor(sensor, false); + thermal_zone_device_toggle((&data->sensor)->tzd, false); data->disable_sensor(data); diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c index e09f035..f138b78 100644 --- a/drivers/thermal/of-thermal.c +++ b/drivers/thermal/of-thermal.c @@ -510,7 +510,7 @@ struct thermal_zone_device * tzd = thermal_zone_of_add_sensor(child, sensor_np, data, ops); if (!IS_ERR(tzd)) - tzd->ops->set_mode(tzd, THERMAL_DEVICE_ENABLED); + thermal_zone_device_toggle(tzd, true); of_node_put(sensor_specs.np); of_node_put(child); diff --git a/drivers/thermal/rockchip_thermal.c b/drivers/thermal/rockchip_thermal.c index f36375d..c191e41 100644 --- a/drivers/thermal/rockchip_thermal.c +++ b/drivers/thermal/rockchip_thermal.c @@ -1022,15 +1022,6 @@ static void rk_tsadcv2_tshut_mode(int chn, void __iomem *regs, }; MODULE_DEVICE_TABLE(of, of_rockchip_thermal_match); -static void -rockchip_thermal_toggle_sensor(struct rockchip_thermal_sensor *sensor, bool on) -{ - struct thermal_zone_device *tzd = sensor->tzd; - - tzd->ops->set_mode(tzd, - on ? THERMAL_DEVICE_ENABLED : THERMAL_DEVICE_DISABLED); -} - static irqreturn_t rockchip_thermal_alarm_irq_thread(int irq, void *dev) { struct rockchip_thermal_data *thermal = dev; @@ -1292,7 +1283,7 @@ static int rockchip_thermal_probe(struct platform_device *pdev) thermal->chip->control(thermal->regs, true); for (i = 0; i < thermal->chip->chn_num; i++) - rockchip_thermal_toggle_sensor(&thermal->sensors[i], true); + thermal_zone_device_toggle((&thermal->sensors[i])->tzd, true); platform_set_drvdata(pdev, thermal); @@ -1311,11 +1302,8 @@ static int rockchip_thermal_remove(struct platform_device *pdev) struct rockchip_thermal_data *thermal = platform_get_drvdata(pdev); int i; - for (i = 0; i < thermal->chip->chn_num; i++) { - struct rockchip_thermal_sensor *sensor = &thermal->sensors[i]; - - rockchip_thermal_toggle_sensor(sensor, false); - } + for (i = 0; i < thermal->chip->chn_num; i++) + thermal_zone_device_toggle((&thermal->sensors[i])->tzd, false); thermal->chip->control(thermal->regs, false); @@ -1332,7 +1320,7 @@ static int __maybe_unused rockchip_thermal_suspend(struct device *dev) int i; for (i = 0; i < thermal->chip->chn_num; i++) - rockchip_thermal_toggle_sensor(&thermal->sensors[i], false); + thermal_zone_device_toggle((&thermal->sensors[i])->tzd, false); thermal->chip->control(thermal->regs, false); @@ -1383,7 +1371,7 @@ static int __maybe_unused rockchip_thermal_resume(struct device *dev) thermal->chip->control(thermal->regs, true); for (i = 0; i < thermal->chip->chn_num; i++) - rockchip_thermal_toggle_sensor(&thermal->sensors[i], true); + thermal_zone_device_toggle((&thermal->sensors[i])->tzd, true); pinctrl_pm_select_default_state(dev); diff --git a/drivers/thermal/thermal_helpers.c b/drivers/thermal/thermal_helpers.c index eb03d7e..d5db101 100644 --- a/drivers/thermal/thermal_helpers.c +++ b/drivers/thermal/thermal_helpers.c @@ -227,3 +227,18 @@ int thermal_zone_get_offset(struct thermal_zone_device *tz) return 0; } EXPORT_SYMBOL_GPL(thermal_zone_get_offset); + +/** + * thermal_zone_device_toggle() - enables/disables thermal zone device + * @tz: a valid pointer to a struct thermal_zone_device + * + * Enables/Disables thermal zone device. + * + * Return: On success returns 0, an error code otherwise. + */ +int thermal_zone_device_toggle(struct thermal_zone_device *tz, bool on) +{ + return tz->ops->set_mode(tz, + on ? THERMAL_DEVICE_ENABLED : THERMAL_DEVICE_DISABLED); +} +EXPORT_SYMBOL_GPL(thermal_zone_device_toggle); diff --git a/drivers/thermal/thermal_sysfs.c b/drivers/thermal/thermal_sysfs.c index 23b5e0a..343f52b 100644 --- a/drivers/thermal/thermal_sysfs.c +++ b/drivers/thermal/thermal_sysfs.c @@ -72,17 +72,19 @@ { struct thermal_zone_device *tz = to_thermal_zone(dev); int result; + bool on; if (!tz->ops->set_mode) return -EPERM; if (!strncmp(buf, "enabled", sizeof("enabled") - 1)) - result = tz->ops->set_mode(tz, THERMAL_DEVICE_ENABLED); + on = true; else if (!strncmp(buf, "disabled", sizeof("disabled") - 1)) - result = tz->ops->set_mode(tz, THERMAL_DEVICE_DISABLED); + on = false; else - result = -EINVAL; + return -EINVAL; + result = thermal_zone_device_toggle(tz, on); if (result) return result; diff --git a/include/linux/thermal.h b/include/linux/thermal.h index 7834be6..4fbbabe 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h @@ -467,6 +467,7 @@ struct thermal_cooling_device * int thermal_zone_get_temp(struct thermal_zone_device *tz, int *temp); int thermal_zone_get_slope(struct thermal_zone_device *tz); int thermal_zone_get_offset(struct thermal_zone_device *tz); +int thermal_zone_device_toggle(struct thermal_zone_device *tz, bool on); int get_tz_trend(struct thermal_zone_device *, int); struct thermal_instance *get_thermal_instance(struct thermal_zone_device *, -- 1.9.1