Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp953628rwb; Tue, 27 Sep 2022 06:44:27 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5CQwV2SECDRJ6yR/w6c7mL6q7K/IHUR1KhQmwUM2MqxUsvKUq+Pk1pafwrGX93A0kjd6RA X-Received: by 2002:a17:902:ea11:b0:178:1c19:b0f5 with SMTP id s17-20020a170902ea1100b001781c19b0f5mr27043092plg.152.1664286267075; Tue, 27 Sep 2022 06:44:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664286267; cv=none; d=google.com; s=arc-20160816; b=UbSofN8UYXVj3/kVdThgUzpIfpoDm1wWu1WPpcbqpnQJvWjsd9CihDubhMONEYcIvu ylekYhXQic4J1RQXLI+J+F7LaXbedz35uY2iVJXaMWkIoLEmJ7GW5sMJ9l05ZjvoZsBg NW1MmWt3JfHIvL53G25W1glyPeyYsgtOX6n4/xkHAwNaUP/w1HjqzkjduIvM5ZvU7vTu xwesjISGoPDh3joVC4NllR85T6Upt6772HoM8efH74eaLCVasAXo3+By5//ZdZ3jgEYq 7aN69iN82kwp40856eOJ4gA03j7PtYfBvsKWODoiynedsPch/abXYnFIlbelgmXWNn33 1CtQ== 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=T+ARObPy1nMVAT61WPcL0dvL1PZL65X6x/55j6kdsgc=; b=qulKMusqkf7VPpEoJ1QR79R3umu30bTfiUnDAyjiPTS80vIuwTJVQPAidTLbI3ALUX +WFcry+2cBkbGwGXcPVV5A15G1TXX5kMblSjO61KJ7YEoE1/WcxAoQeG/HSGjy4g1/v4 GyF+y4Q3TXRY//Ezq+SZRgGgw9SeRnMQOZpZmKNAAfLm041SZqHFPlrC3Cb86X1qosyg xN3inszBTamS7xT1l7YbSv4psTdQgBsyPg9R5pI6yqfDUVvQ6Vwt8n8TDIY1eMtASF6H yrFMsyObtAX9bgPMoEebVI3E1T6D09qff3GPtQ/PYln5jhy23sD0MRXb0CdZa5lnHip2 ClPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=sFaS3F7F; 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 k3-20020a170902ce0300b00179eed9bdf2si1564007plg.497.2022.09.27.06.44.15; Tue, 27 Sep 2022 06:44:27 -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=sFaS3F7F; 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 S231800AbiI0MVp (ORCPT + 99 others); Tue, 27 Sep 2022 08:21:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42212 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232349AbiI0MVT (ORCPT ); Tue, 27 Sep 2022 08:21:19 -0400 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 034334E62A for ; Tue, 27 Sep 2022 05:20:43 -0700 (PDT) Received: by mail-wm1-x32e.google.com with SMTP id l8so6417564wmi.2 for ; Tue, 27 Sep 2022 05:20:42 -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=T+ARObPy1nMVAT61WPcL0dvL1PZL65X6x/55j6kdsgc=; b=sFaS3F7F3vuNqMrAh/Zi5jvAh9ijl3kCoru45JWtKFJ9Mau9yHsU9keVhOfbWCUfus v5cB/hLj4eNzgkaSPK235aWJmhQX7fq9ogz5U901Hev6LBqAl/aAqBo1Xth3U4/BceJq 3bX3C32p5uisNrRq6G+eFUQMSaVGfA4SNgL08rMKAbKHOBfAa+lbkOtI21T1/u786Ov7 +UqDeSircO387aVyiCOTO1z/YBCBFzompYhR8diU4DaXdEzNACXROkh00qfr3/v8sScX 0NXIxp/IctPk4gjzWHjSYESpIWdNNTylceRHtly6+qrUxZkbewNj74czv+rplmOwG1I3 fBJQ== 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=T+ARObPy1nMVAT61WPcL0dvL1PZL65X6x/55j6kdsgc=; b=CamRMyJIPYrJdL2OO3JxNCPKkyNLPTtrcRCEkqsmcmNfMCVThkRj1AiDegbKq1Yvo4 s+O9y7+ds2tqgyGdfW/JnlsVzrLMsePAeNaxnEXxtUAwjXzSDXGTxuSrXCIeuIi9abge rNnspwjv+0dVPsQUdsz+fENaTa2CYwvVWrv8OuuM/+MVsDamL6QPXHEcVFiRPrsdHD8K CUn4ZRecGPf6bChQOCJzhiwP22ELD2iM7M/9u7g6ofkvZhXkVaAxmjVlG/kM4hdFgoon 1QkHk1ykrG9Ks1CKlxiLDxSocRtwxuCYZUydwSq56nNHYjAsqfUzxyUujPqXuaJRQ9fJ HAdg== X-Gm-Message-State: ACrzQf2MVEecV40CgoQv3rFkOoKR9U5VEQXgNX+XThmBrxlpZUOHrAcQ v1J/xWqI9X4+HSvVua9GBNzGt5Z/MumkTg== X-Received: by 2002:a05:600c:6003:b0:3b5:aef:d8d7 with SMTP id az3-20020a05600c600300b003b50aefd8d7mr2456240wmb.50.1664281241417; Tue, 27 Sep 2022 05:20:41 -0700 (PDT) Received: from [192.168.10.46] (146725694.box.freepro.com. [130.180.211.218]) by smtp.googlemail.com with ESMTPSA id s14-20020a5d6a8e000000b002252ec781f7sm1788723wru.8.2022.09.27.05.20.40 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 27 Sep 2022 05:20:40 -0700 (PDT) Message-ID: <584a1927-0713-4a6d-a7a6-94bdda30dc0d@linaro.org> Date: Tue, 27 Sep 2022 14:20:39 +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=unavailable 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 27/09/2022 12:38, Rafael J. Wysocki wrote: > On Tue, Sep 27, 2022 at 12:11 AM Daniel Lezcano > wrote: >> >> 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) >> | ^~ > > This is about indentation, though, so it looks like white space is > mangled somehow. > > As a matter of correctness, the inner parens are not needed. Oh, actually I did a confusion with the 'brackets', you meant: (t.temperature != trip->temperature && tz->ops->set_trip_temp) right ? >>>> + 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. > > Do those drivers set tz->trips? If not, the tz->trips check can go > before the ops ones. Unfortunately some are doing that, like the tegra's soctherm driver >> [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