Received: by 2002:a19:771d:0:0:0:0:0 with SMTP id s29csp1277466lfc; Wed, 1 Jun 2022 13:58:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzEag2PwfSHXSxzdSakzvxiJWCGnp13xpfGchZ5lZUssVbH0pEWVsnW8nOBnGA9xY5uSrQy X-Received: by 2002:a17:90b:d98:b0:1e3:2a7f:4ce1 with SMTP id bg24-20020a17090b0d9800b001e32a7f4ce1mr13589616pjb.226.1654117117080; Wed, 01 Jun 2022 13:58:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654117117; cv=none; d=google.com; s=arc-20160816; b=yf0EbrhZncpSCFXAZPRWFM71SI22ZUO/7+OQUIM3C9+2MTiPh7rvDA65sZAvOG2g1S u+x5saOyIFBrBkYAaHPQ6k2TB4yHQCWbFCsWKIKBnYJ/cTScLNfpV/7ZgcBfvGvWOC8E 5CQg0KuyN4OH8+f72PUFawGwK6BOMqMhUgBB+jfCRLVnDMYZb7r+jJY1JSgQM3gsDHKg +HgOFmveW2DgnD5rqDWle2SIct0aVXtrKu7cn197vKZMgAZbO4fdBl/y6QrVj3YOdgfH 4+ooYpGYt9qSA48vArPHdcSoFx/QEJPBj0DNq9aIl5pSUZpBnADSxQo1UecY9ElZQTT9 Veww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=thV3dq7IP3pZFJ/eKrgaz8exm55qhJj7BG42P4ZLFS4=; b=frWbLyECC3JQl+dbWgfde3Q508zvqvSUWKYRssX6nIIrwSrZYu5u2VmWN+ic2nyUQK lVi7SRY+VYwPOz4ZSJn6BO5t+zf/bzv5oVspcCdBAS9kO1dHUw9Yv+MVfPeVrJVmDwaM pVN7fDbwc5z3WV/g0U/CFEfGGi+FjmxYpQ57i5CmYRcjVKu1B9WFuo4/a2Xv1UjqAAzy qCyVTh7E97xW+SyKAC2NER+jSpELUO4fhMBVHxsywUmg6QPxbHfIOpO4FOr5fDxBsYww zb13+6Z2r4E2+MolA5EsPC//mnPIyiUVpMxoNIR3DhTQWnIvsJPdm5NDQfUIxPrwmJ6+ 5rMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=g8vqqojO; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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. [23.128.96.19]) by mx.google.com with ESMTPS id b17-20020a63a111000000b003fc1bb74001si3731280pgf.54.2022.06.01.13.58.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jun 2022 13:58:37 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=g8vqqojO; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 57F641B6FFB; Wed, 1 Jun 2022 13:00:22 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353144AbiFANOe (ORCPT + 99 others); Wed, 1 Jun 2022 09:14:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33674 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351588AbiFANOb (ORCPT ); Wed, 1 Jun 2022 09:14:31 -0400 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 C3C923CA46; Wed, 1 Jun 2022 06:14:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1654089267; x=1685625267; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=thV3dq7IP3pZFJ/eKrgaz8exm55qhJj7BG42P4ZLFS4=; b=g8vqqojOIhfpgb6zTUBNH4QKI4yuyNwJ8Kh8qe2dab1QdXukEP1+ipPT 524lEDQsgfXPgLEsczpCCwtvvijBKQ7cdlwGoKZsVBnrtnen3MJV9bQis AQoviHkYFntPSGysOLdm6SNPPibOjvsSOaeDHi8mBxjViiR8fldZDP/RX I=; Received: from unknown (HELO ironmsg03-sd.qualcomm.com) ([10.53.140.143]) by alexa-out-sd-02.qualcomm.com with ESMTP; 01 Jun 2022 06:14:27 -0700 X-QCInternal: smtphost Received: from nasanex01c.na.qualcomm.com ([10.47.97.222]) by ironmsg03-sd.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2022 06:14:27 -0700 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.22; Wed, 1 Jun 2022 06:14:27 -0700 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.22; Wed, 1 Jun 2022 06:14:24 -0700 From: Manaf Meethalavalappu Pallikunhi To: "Rafael J . Wysocki" , Daniel Lezcano , Amit Kucheria , Zhang Rui CC: , , "Manaf Meethalavalappu Pallikunhi" Subject: [PATCH 1/1] drivers/thermal/thermal_of: Add critical/hot ops support for thermal_of sensor Date: Wed, 1 Jun 2022 18:44:00 +0530 Message-ID: <20220601131400.24627-2-quic_manafm@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220601131400.24627-1-quic_manafm@quicinc.com> References: <20220601131400.24627-1-quic_manafm@quicinc.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) 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 critical, hot trip violation notification from thermal core. Add support for these ops in thermal_of interface so that sensor driver can use these ops. Signed-off-by: Manaf Meethalavalappu Pallikunhi --- drivers/thermal/thermal_of.c | 21 +++++++++++++++++++++ include/linux/thermal.h | 6 ++++++ 2 files changed, 27 insertions(+) diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c index b65d435cb92f..65e1848cb1dd 100644 --- a/drivers/thermal/thermal_of.c +++ b/drivers/thermal/thermal_of.c @@ -211,6 +211,20 @@ static int of_thermal_change_mode(struct thermal_zone_device *tz, return data->ops->change_mode(data->sensor_data, mode); } +static void of_thermal_hot_notify(struct thermal_zone_device *tz) +{ + struct __thermal_zone *data = tz->devdata; + + data->ops->hot(data->sensor_data); +} + +static void of_thermal_critical_notify(struct thermal_zone_device *tz) +{ + struct __thermal_zone *data = tz->devdata; + + data->ops->critical(data->sensor_data); +} + static int of_thermal_bind(struct thermal_zone_device *thermal, struct thermal_cooling_device *cdev) { @@ -419,6 +433,11 @@ thermal_zone_of_add_sensor(struct device_node *zone, if (ops->change_mode) tzd->ops->change_mode = of_thermal_change_mode; + if (ops->hot) + tzd->ops->hot = of_thermal_hot_notify; + + if (ops->critical) + tzd->ops->critical = of_thermal_critical_notify; mutex_unlock(&tzd->lock); return tzd; @@ -581,6 +600,8 @@ void thermal_zone_of_sensor_unregister(struct device *dev, tzd->ops->get_trend = NULL; tzd->ops->set_emul_temp = NULL; tzd->ops->change_mode = NULL; + tzd->ops->hot = NULL; + tzd->ops->critical = NULL; tz->ops = NULL; tz->sensor_data = NULL; diff --git a/include/linux/thermal.h b/include/linux/thermal.h index 365733b428d8..920f7e5c80bb 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h @@ -301,6 +301,10 @@ struct thermal_zone_params { * hardware. * @change_mode: a pointer to a function that notifies the thermal zone * mode change. + * @hot: a pointer to a function that notifies the thermal zone + * hot trip violation. + * @critical: a pointer to a function that notifies the thermal zone + * critical trip violation. */ struct thermal_zone_of_device_ops { int (*get_temp)(void *, int *); @@ -309,6 +313,8 @@ struct thermal_zone_of_device_ops { int (*set_emul_temp)(void *, int); int (*set_trip_temp)(void *, int, int); int (*change_mode) (void *, enum thermal_device_mode); + void (*hot)(void *sensor_data); + void (*critical)(void *sensor_data); }; /* Function declarations */