Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp171910rwb; Mon, 26 Sep 2022 16:45:16 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5Pi9Uz98s1GKIsTci/IERzt6axOdiGdooxoFw3ms1UIxIuFD9CrK426bTYrPYrQI2zNgKC X-Received: by 2002:a17:906:7f03:b0:781:6462:4214 with SMTP id d3-20020a1709067f0300b0078164624214mr21406069ejr.274.1664235916432; Mon, 26 Sep 2022 16:45:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664235916; cv=none; d=google.com; s=arc-20160816; b=lAe9qEq49Y2R4KIsHs+50gKGq39Z8NDF7ED/nf/DF76Fh4Ecqt0iFK40OgExJYWvnJ SAovTBGsWJptgn19jw1QrBG6QWYUi/8/j+xsXXCxzKbAwQv57HruHHyJID+Pc/y1G7Le FnEuDoNUgeh31P4vbACD5jGbaT8/TcTQK3ddfXnpGvFPRLinGJ7eeobco/cUxBPGlPAU 7BPv8LQMfwjrrMxcTZGe+yW2GLEqlOlqHfJw7+01dbIzRmdnvpfmCUiOf9YOn4edqXsX rTUVw/c4z6iQVTkr9h/5RadhtZ+bAXVal6WyVgody7q0YW4d4QNGzKYPu2or5LXDujK0 pYlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=OVsxSLNmaJcqcwbpm1oGmfhwAHf39kZvm2oJ0u13iLM=; b=PMVij2ZewG676WTl5zq4d9EzPpF1pYFKLZ/m0u7Wzp77yTFA2k3AxP3vUcihHj11Qu BadJu3Q6gE3Pfv84Qsx3CUQ9uh8Ch07n4KhmeADwaIuQwnaN9Lzi8/BI6sSDTsqOngz6 nPWkwSiIxoPMHI0kFuAn9JGuu3dG7+69FJqQloXx9MyEDlzzBOw5xqEgxzd7ZfMCjTOf WzZqm6CnEAMBtFXHLhfNnPfIcC+/QDBAVWhalCrme/ZtFN3TTtbVzvfs/m0GM8BD9Ypj 8NkmXWNAnMyjcx0W5TS/AaLwHr57TsT1iWmMH8G/+xYXkP9tAgUCFg0Ga+IgegTmhCNX lXvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="efvWO/lJ"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w5-20020a05640234c500b0044f231c89edsi148859edc.20.2022.09.26.16.44.50; Mon, 26 Sep 2022 16:45:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="efvWO/lJ"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231533AbiIZWOV (ORCPT + 99 others); Mon, 26 Sep 2022 18:14:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231526AbiIZWN7 (ORCPT ); Mon, 26 Sep 2022 18:13:59 -0400 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED2FE95ACE for ; Mon, 26 Sep 2022 15:11:52 -0700 (PDT) Received: by mail-wr1-x430.google.com with SMTP id t14so12259031wrx.8 for ; Mon, 26 Sep 2022 15:11:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date; bh=OVsxSLNmaJcqcwbpm1oGmfhwAHf39kZvm2oJ0u13iLM=; b=efvWO/lJ34nWle9/vF5eb4/g3qsGvhPS032pxcYwnDOz9CLcOVhDT7REyGD+cqJPQ0 50brlHV192H1I+fTNnW02YbS9+KgUb7/MS93EHBlIreKFVkveJmaKueHFgD77auWSs6e Rx7Jj3IjWKKC8r3pwZWp13+rtJV7sD61Or4YUdHijutx2R5QkgmDYHcDgyYC3YNGhpJd 5m7bQ2Ujh/14bv6wVbbGq4l8znxyuwPLosTedPVhxnttEARTHRA6vIh4GiVQ3eJehtV7 zxQkyGj4aBE/FDeOCudie6nY53bFHubRm7FOOB0SfKF2d6Ja9Gy8SJr8vrOY3nAQyyEF MFZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date; bh=OVsxSLNmaJcqcwbpm1oGmfhwAHf39kZvm2oJ0u13iLM=; b=7d3hTtA734+TwVW0CQUQIzI4r+IBywOuuHppUXsi/5WHBvlnPivoqVNtSl6H2gswXY AUBkjLA11G2iheZSXGX/R23BclPGF9s+UB2l5qSRjtubB9UQ8Op0IeHzTBJlb0nZjysJ O5EXJs7f1aU4KSyz/Fc5+xybbwmQdf29mYm+p7Tqky/DlnQYfR4o/s+mUupEg1aLSfKj B7bptM9+KHtDkYLR6BCgpuyoEIqyfPG29YYkjEeLaa1LuUSVlXK7DPSgrV0JZBcpaaAc wbfUnufRZNiH8EsaEzYwxd+gpQbjVjPIqnjdN6oOZ9rlZ42bpdfD2/rHbTXrO45VQHGH m4+Q== X-Gm-Message-State: ACrzQf0GBpmkh67WUa55KSCAz/7Zk+fxSl9A/i2CmtDe4yTSuR24hBAa Tmojycw3Zxw3+r7LXOr+SkROAg== X-Received: by 2002:adf:fb0a:0:b0:225:265d:493 with SMTP id c10-20020adffb0a000000b00225265d0493mr14790401wrr.394.1664230311378; Mon, 26 Sep 2022 15:11:51 -0700 (PDT) Received: from [192.168.10.46] (146725694.box.freepro.com. [130.180.211.218]) by smtp.googlemail.com with ESMTPSA id v8-20020adfa1c8000000b0022865038308sm15730369wrv.93.2022.09.26.15.11.50 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 26 Sep 2022 15:11:50 -0700 (PDT) Message-ID: Date: Tue, 27 Sep 2022 00:11:49 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH v5 03/30] thermal/core: Add a generic thermal_zone_set_trip() function Content-Language: en-US To: "Rafael J. Wysocki" Cc: Linux Kernel Mailing List , Linux PM , "Zhang, Rui" , Amit Kucheria References: <20220926140604.4173723-1-daniel.lezcano@linaro.org> <20220926140604.4173723-4-daniel.lezcano@linaro.org> From: Daniel Lezcano In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham 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 On 26/09/2022 21:25, Rafael J. Wysocki wrote: [ ... ] >> + if ((t.temperature != trip->temperature) && tz->ops->set_trip_temp) { > > The inner parens are not needed here and below. > >> + > > And the extra empty line is not needed here (and below) too IMO. > >> + ret = tz->ops->set_trip_temp(tz, trip_id, trip->temperature); >> + if (ret) >> + goto out; >> + } > Without the parens, the following happens: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation] 1229 | if ((t.temperature != trip->temperature) && tz->ops->set_trip_temp) | ^~ note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘if’ 1231 | if (ret) | ^~ >> + if ((t.hysteresis != trip->hysteresis) && tz->ops->set_trip_hyst) { >> + >> + ret = tz->ops->set_trip_hyst(tz, trip_id, trip->hysteresis); >> + if (ret) >> + goto out; >> + } >> + >> + if (((t.temperature != trip->temperature) || >> + (t.hysteresis != trip->hysteresis)) && tz->trips) >> + tz->trips[trip_id] = *trip; > > I would write this as > > if (tz->trips && (t.temperature != trip->temperature || t.hysteresis > != trip->hysteresis)) > tz->trips[trip_id] = *trip; Ok, sure > But > > 1. Do we want to copy the trip type here too? The function thermal_zone_set_trip() is called from thermal_sysfs.c, it is the unique call site. However, I think it is a good idea to check the type of the trip point is not changed, even if it is not possible with the actual code. > 2. If tz->trips is set, do we still want to invoke ->set_trip_temp() > or ->set_trip_hyst() if they are present? No but there are bogus drivers setting the interrupt with these ops instead of using the set_trips ops (eg. [1][2][3]). So in order to keep those working ATM, I'm keeping them and when all the drivers will be changed, I'll wipe out the set_trip_* ops from everywhere. [1] drivers/thermal/samsung/exynos_tmu.c [2] drivers/thermal/qcom/qcom-spmi-temp-alarm.c [3] drivers/thermal/imx_thermal.c -- Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog