Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp3478212pxp; Tue, 8 Mar 2022 15:29:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJzDIDh3lnN1bVaUPdLcQjUxhfQh3ndVAhTabORuHT9gvB7pyL5w741FDHXN6QXQPGfNDUsP X-Received: by 2002:a17:903:192:b0:151:8df9:6cdb with SMTP id z18-20020a170903019200b001518df96cdbmr20203668plg.20.1646782179724; Tue, 08 Mar 2022 15:29:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646782179; cv=none; d=google.com; s=arc-20160816; b=rgGnzgBpE3MfM0k78RXw2/IZJQ3uQytbbH7fnJmYFPHFo03YAt7dIQFDzj4p2BIJYT V2ylVNvpgNmvoP+3lSmISssTc8D6PX0YpEkAHkQ6GdF5N7FBclqcmvZxl95hR4agTQoz ocIU3buJr8qTyvu/lXVzbYcQb3T05GPONLQLC/xqBQDdenXSk1Lf3MX7XdUcyc3qP5fm l+8KQaR939m9lcwONY1x3lAVRvM0+HYQE4ygy5uuPOMlilrXPuN0c9zxunkK0NIx53K2 An+8FYR3VFejE4j29rbTtwGjItxDeNun0DOtuiL5phAAYP7VFF/xuj63pk9RL5ghEV1X A+XA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from :dkim-signature; bh=I8K/GbKHIgRGVF6Y27S47TZkoaxOyZifE0LQwcfM2Kc=; b=vhINa9H8uaD9IJR2FNVUAX6wAPhebJ+2I34ZpGb9dl1wmNsQRD2lZPDPm3pmJye5Vc wRcg5Md/GmVL7BDUz2mkhZvRExKQAKuRO6EiPsOKDX3SpJZycXpRX7WHPx6krcdMbiYA QXkBG+q1AdzbVlkY7HQF8+ImkTZm4D9lB5TZameuCO+WjXNUJQWy/1QLOThaBnIjBx6c WAzIbSzzn+egEPVurZOAfgUj44GanPDbQA7cRiYNXVtUYfhkRVQfC8a8iTrxceWUG82P sux4L7uPPA2ky3hgCfQe0TjA7yWwwmy+EXzwWEnSnUF2TzPwv9qiUAeMhh4432poGGRm SCNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=MGRjbZe5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id s193-20020a6277ca000000b004bcdf41d07asi199860pfc.93.2022.03.08.15.29.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Mar 2022 15:29:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=MGRjbZe5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 53CCA9D4CD; Tue, 8 Mar 2022 15:18:51 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239149AbiCHPVu (ORCPT + 99 others); Tue, 8 Mar 2022 10:21:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51624 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230263AbiCHPVt (ORCPT ); Tue, 8 Mar 2022 10:21:49 -0500 Received: from alexa-out-sd-02.qualcomm.com (alexa-out-sd-02.qualcomm.com [199.106.114.39]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6B024DF4E; Tue, 8 Mar 2022 07:20:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1646752852; x=1678288852; h=from:to:cc:subject:date:message-id:mime-version; bh=I8K/GbKHIgRGVF6Y27S47TZkoaxOyZifE0LQwcfM2Kc=; b=MGRjbZe5efZ37TIYTVdZ+qGWqTT27eEvaf3UK47lP2GitOEZbFRGghud TsCYues9+ml3Hiq2m7WAr0mn5c0BsZquWtrdbFq50kltF+78A/pZg4fhG KRWBMID8ays5r/uKz5QgjABGLwzhL/ljjUEJAssciOjr6WIjKa1ypXiig k=; Received: from unknown (HELO ironmsg05-sd.qualcomm.com) ([10.53.140.145]) by alexa-out-sd-02.qualcomm.com with ESMTP; 08 Mar 2022 07:20:52 -0800 X-QCInternal: smtphost Received: from nasanex01c.na.qualcomm.com ([10.47.97.222]) by ironmsg05-sd.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Mar 2022 07:20:52 -0800 Received: from nalasex01b.na.qualcomm.com (10.47.209.197) by nasanex01c.na.qualcomm.com (10.47.97.222) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.15; Tue, 8 Mar 2022 07:20:51 -0800 Received: from codeaurora.org (10.80.80.8) by nalasex01b.na.qualcomm.com (10.47.209.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.15; Tue, 8 Mar 2022 07:20:49 -0800 From: Manaf Meethalavalappu Pallikunhi To: "Rafael J . Wysocki" , Daniel Lezcano , Amit Kucheria , Zhang Rui CC: , , "Manaf Meethalavalappu Pallikunhi" Subject: [PATCH] drivers/thermal/thermal_of: Add change_mode ops support for thermal_of sensor Date: Tue, 8 Mar 2022 20:50:34 +0530 Message-ID: <1646752834-25043-1-git-send-email-quic_manafm@quicinc.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01b.na.qualcomm.com (10.47.209.197) X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The sensor driver which register through thermal_of interface doesn't have an option to get thermal zone mode change notification from thermal core. Add support for change_mode ops in thermal_of interface so that sensor driver can use this ops for mode change notification. Signed-off-by: Manaf Meethalavalappu Pallikunhi --- drivers/thermal/thermal_of.c | 14 ++++++++++++++ include/linux/thermal.h | 3 +++ 2 files changed, 17 insertions(+) diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c index 9233f7e..a4e3820 100644 --- a/drivers/thermal/thermal_of.c +++ b/drivers/thermal/thermal_of.c @@ -203,6 +203,17 @@ static int of_thermal_get_trend(struct thermal_zone_device *tz, int trip, return data->ops->get_trend(data->sensor_data, trip, trend); } +static int of_thermal_change_mode(struct thermal_zone_device *tz, + enum thermal_device_mode mode) +{ + struct __thermal_zone *data = tz->devdata; + + if (!data->ops || !data->ops->change_mode) + return -EINVAL; + + return data->ops->change_mode(data->sensor_data, mode); +} + static int of_thermal_bind(struct thermal_zone_device *thermal, struct thermal_cooling_device *cdev) { @@ -408,6 +419,9 @@ thermal_zone_of_add_sensor(struct device_node *zone, if (ops->set_emul_temp) tzd->ops->set_emul_temp = of_thermal_set_emul_temp; + if (ops->change_mode) + tzd->ops->change_mode = of_thermal_change_mode; + mutex_unlock(&tzd->lock); return tzd; diff --git a/include/linux/thermal.h b/include/linux/thermal.h index c3148939..365733b 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h @@ -299,6 +299,8 @@ struct thermal_zone_params { * temperature. * @set_trip_temp: a pointer to a function that sets the trip temperature on * hardware. + * @change_mode: a pointer to a function that notifies the thermal zone + * mode change. */ struct thermal_zone_of_device_ops { int (*get_temp)(void *, int *); @@ -306,6 +308,7 @@ struct thermal_zone_of_device_ops { int (*set_trips)(void *, int, int); int (*set_emul_temp)(void *, int); int (*set_trip_temp)(void *, int, int); + int (*change_mode) (void *, enum thermal_device_mode); }; /* Function declarations */