Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp716419rwb; Tue, 27 Sep 2022 03:49:30 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5/F20bPOXX2VqkwNfWloZjTN/LVcahlM1f4KRxncOxO+ADIHtRap4aCXgzzP/QNGEjB/Y+ X-Received: by 2002:a50:ea89:0:b0:453:8b7d:12e8 with SMTP id d9-20020a50ea89000000b004538b7d12e8mr27151227edo.148.1664275770361; Tue, 27 Sep 2022 03:49:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664275770; cv=none; d=google.com; s=arc-20160816; b=MChsQOch+IYHqvfJJwfC44033M/iYnEW7qyRK3aZtiiTtKg0YQn+btVSF8Y3Sicr8x alz2P+7nBFuRWJXU9j7Nl7frCHfMWhoDV5+EJt8xABxiGlRiMQYLDhTt83+BMYAdVvpv iEqyZIlG1DFLv+OHy2VfyoWcZG2ahRXWa7XHtufVLYtIqAujHL5lbuvh9G0BmdZ6CVRp 8U6yaqcC/oOFbTwhrmMYtWF6jfkrNaV5RCMEVkJwfxCo+U+INZAZGfoF1GkaQZ6uOccG j0FR7iRK5aUf/wNa0zUjCWrYXKcYAJSLjpSwZIongCVSxcIXS40Dj+F5tBsnjyuRGNfy 21KQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version; bh=ZphdoS0QvV90E2HQXkIPP3eMYkolncHIRUuYga+fT0Q=; b=ruJYaY0RtlFxYrVgMcK17C024k/5KFFdKk24rEtlyCxXi8r33y8IkP6hFC1ihdlquN TgUQh/gA44UZrUPj75Rsd1uP0f4MA26RAEy3IE66n7wfndGSWrJRpoPkgVM7vVoDrqzE ESL/OSdqoawkbX8TTPEuiqymobsmWaQZZ/wHH3s/DWtsBMIZIAEWLq2isbLzvy3JJ48L YSjYbtLMP3v/RAov8mERyAgsxtLgQoPY+dekdiQtskkMOBHO4bc3cdyS7ewVWZsqRPFI hM5tfwPdCWIwAJf6C9Tl6ZntDwwACUPYJdEPk/xSsAsw6/5w0tLYc9CZqwPayTilPkKT Mrng== ARC-Authentication-Results: i=1; mx.google.com; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g18-20020a1709065d1200b00775326fb2ebsi1005760ejt.665.2022.09.27.03.49.05; Tue, 27 Sep 2022 03:49:30 -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; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230238AbiI0Ki6 convert rfc822-to-8bit (ORCPT + 99 others); Tue, 27 Sep 2022 06:38:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229472AbiI0Ki4 (ORCPT ); Tue, 27 Sep 2022 06:38:56 -0400 Received: from mail-qv1-f49.google.com (mail-qv1-f49.google.com [209.85.219.49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C161498D16; Tue, 27 Sep 2022 03:38:54 -0700 (PDT) Received: by mail-qv1-f49.google.com with SMTP id l14so5941812qvq.8; Tue, 27 Sep 2022 03:38:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date; bh=kX5SsvItwtik0crXdwEH89DQ7N/9bD9yRLz11HcdMMU=; b=GwUiR/oWg15X4N0IBsv9qBqliFaiRJfuKgPMw+uJ9fZ8Gxx0qyCwOwxvReE63FMq6F ml1CscVxDuYH8IVDVC8bgL3mtZnHZAQ4NEqj3dRM3OqqyeBW3s/7HKIxILDee/glGrGg JK5sI+0N6mVHeKFDhE2qrYSvu9oiWM3TJy1fJhD2GULNl2Z57NISmqH2GZxoNbUT4Jkf AgLY33yuvW/eZ264frsNH4pOMhw9JWxivCnqC9qeokV7eyVu6MliJ/bD5rC064kIWbpM PKd1W5gf7hVv7Pvj1zBagr1ezyhLl6BpJqp3gH4RpbDxeOPFID3SoBYuX7A7cf59ZRGt 9lHA== X-Gm-Message-State: ACrzQf2c6RlN74KWDx6OO+dxKkIPNE0+JnSAqnwVtTPDnEXYuUCTNBtC g0G7JsFiXScQs8wBnhQnk5XYIyRy8/+kKmrPgJU= X-Received: by 2002:ad4:4ea3:0:b0:4af:646a:9787 with SMTP id ed3-20020ad44ea3000000b004af646a9787mr9686646qvb.15.1664275133856; Tue, 27 Sep 2022 03:38:53 -0700 (PDT) MIME-Version: 1.0 References: <20220926140604.4173723-1-daniel.lezcano@linaro.org> <20220926140604.4173723-4-daniel.lezcano@linaro.org> In-Reply-To: From: "Rafael J. Wysocki" Date: Tue, 27 Sep 2022 12:38:42 +0200 Message-ID: Subject: Re: [PATCH v5 03/30] thermal/core: Add a generic thermal_zone_set_trip() function To: Daniel Lezcano Cc: "Rafael J. Wysocki" , Linux Kernel Mailing List , Linux PM , "Zhang, Rui" , Amit Kucheria Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS 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 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. > >> + 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. > [1] drivers/thermal/samsung/exynos_tmu.c > [2] drivers/thermal/qcom/qcom-spmi-temp-alarm.c > [3] drivers/thermal/imx_thermal.c