Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp234362rdb; Thu, 30 Nov 2023 03:32:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IHZcaJsbi5TokIcpQd08P5CBy2y82S+vMsVNyMd09GeKWgzoMalwJEe9UqSAjGc+Fx/3j0i X-Received: by 2002:a17:90b:3e86:b0:285:93f0:b2a4 with SMTP id rj6-20020a17090b3e8600b0028593f0b2a4mr22510646pjb.7.1701343941292; Thu, 30 Nov 2023 03:32:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701343941; cv=none; d=google.com; s=arc-20160816; b=E8aCmjV+RO29B5wvMytefMKYVGKzj38JQV+zjZr0KDYPynefV/MOaalRv/jK8jXoGo pU8UvJbCAelGZO9AYsMuvJZkwocWorEqcUya2lkBOSiaeoyHecxJdn4uI8MiQq0AY2ZD /i1m18XZ68O08NdlcMepJ1lCoLqKoXK7LAqo2r/p/yzipjWBexBhrjsy0tGkzBPRhspp pEpqWAJkKWn/Aukdxxdr8Rxb6yKoYdZGOouCyqtrFztcvdFd1KNO7/DstKlfN38kbYXC dhUyh4RsZGVmpfr0jMrYlwUewlJ1FoCm66Mp/Dr7MLIf4ueJ1eOBMKK3Y8WJwCUIRTEU 3Zhw== 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=kRQhVGlq+UYzzUE51TgQ8o7hYlbmK4rC1BGhuxuNDJ8=; fh=RjkRc/FhKx0ouKQ9JcARy/W3YEos4nBH55yWPTBs/m8=; b=i/cZYBy0xIL/Gs4xUNexUIcVh4YsCR/5rGOAw9twzzeisvGwCMuOlngugUNg6EcFZ2 5hN6JMnlDLEHfAql7MeKGONgfuJsPmt8Gye8TI8UQTcQ3vsxGsW0RlRao0LKy+kEYlQl 8KKl73wctxnkeQXg98M53KXDvLQRHJ7drEuPBERDKMFXNeu7KymOwArijL9X0zB83dPE /5oC+TiDtO54D1tVAp9hGHAiTYngWxfVS0id5U/MTF06Q1N953FldbVuJzsnX8adZvj5 DFrZ0PtZ//MhIGz3c2hW1141T8N6AJTtiLSBbWx951aa1ee40WMSNwP/b5hs8qWNYLk+ 6T6A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id on5-20020a17090b1d0500b0027749a1fe74si1202585pjb.182.2023.11.30.03.32.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 03:32:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 90509823B3DA; Thu, 30 Nov 2023 03:32:18 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345167AbjK3Lbr convert rfc822-to-8bit (ORCPT + 99 others); Thu, 30 Nov 2023 06:31:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60478 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345247AbjK3LbJ (ORCPT ); Thu, 30 Nov 2023 06:31:09 -0500 Received: from mail-oi1-f175.google.com (mail-oi1-f175.google.com [209.85.167.175]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5486D170F; Thu, 30 Nov 2023 03:31:15 -0800 (PST) Received: by mail-oi1-f175.google.com with SMTP id 5614622812f47-3b41132c33aso127523b6e.1; Thu, 30 Nov 2023 03:31:15 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701343874; x=1701948674; 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:message-id:reply-to; bh=nZ7wq3n3DhrJeyQna6lVndn1rATyyoXPNxb3aRmLfHg=; b=CaTy3wzdccr3TV/5KYAycWVgr076E/J9WPXqZSgdAZTWckwRC9ylLOhpcH9+zClx6h x8THO/oiCWYZ0TN4ylP6XGOcgUBU9RA4YLeVGH8U+0zIo5tvpPdzFypkJ6Snuvi2LMfo wIT2HR+A84WCZHDRfOAIqm0KfUbmjRX6s/ULCPJDedSaeC2uxLBbOaGgCXDHAebjo+Ih Ebcv+AdrN882wtbBrf4K9Am1Dt2Vb/fCMWvnj+4HR2xOTo/EGrmxgktjJ8GcgRjS7h50 8Ejo+/RhxDnm0vNl9csqnyV1tVQSGbNslOemDlFHTCw8qNh0dI1x+JQkxKXWa4mCeHuX qiOQ== X-Gm-Message-State: AOJu0YzmA3yWQUUjxi/msurRbeD8AaFQmXXxsRcXVf9u+Qj1jG35nR0g szjSGDTsXkU+giAqpi/0aQVbrdowwhSKe5n38q8= X-Received: by 2002:a05:6870:168d:b0:1fa:132a:ad11 with SMTP id j13-20020a056870168d00b001fa132aad11mr23156531oae.2.1701343874466; Thu, 30 Nov 2023 03:31:14 -0800 (PST) MIME-Version: 1.0 References: <12350772.O9o76ZdvQC@kreacher> <4869676.GXAFRqVoOG@kreacher> In-Reply-To: From: "Rafael J. Wysocki" Date: Thu, 30 Nov 2023 12:31:02 +0100 Message-ID: Subject: Re: [PATCH v3 2/2] thermal: trip: Rework thermal_zone_set_trip() and its callers To: Daniel Lezcano Cc: "Rafael J. Wysocki" , Linux PM , LKML , Srinivas Pandruvada , Zhang Rui , Lukasz Luba Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Thu, 30 Nov 2023 03:32:18 -0800 (PST) On Thu, Nov 30, 2023 at 11:40 AM Daniel Lezcano wrote: > > > Hi Rafael, > > > On 29/11/2023 14:38, Rafael J. Wysocki wrote: > > From: Rafael J. Wysocki > > > > Both trip_point_temp_store() and trip_point_hyst_store() use > > thermal_zone_set_trip() to update a given trip point, but none of them > > actually needs to change more than one field in struct thermal_trip > > representing it. However, each of them effectively calls > > __thermal_zone_get_trip() twice in a row for the same trip index value, > > once directly and once via thermal_zone_set_trip(), which is not > > particularly efficient, and the way in which thermal_zone_set_trip() > > carries out the update is not particularly straightforward. > > > > Moreover, some checks done by them both need not go under the thermal > > zone lock and code duplication between them can be reduced quite a bit > > by moving the majority of logic into thermal_zone_set_trip(). > > > > Rework all of the above functions to address the above. > > The resulting change looks to me over complicate for the code it is > supposed to improve. One new function, one enum and leaking the sysfs > buffer to a function located outside of thermal-sysfs.c. That does not > improve the readability IMO. > > The function thermal_zone_set_trip is only called from thermal_syfs.c > > Why not directly change the trip point temp/hyst value in the array in > the thermal_sysfs functions and remove the function > thermal_zone_set_trip() ? I can do that if you prefer it.