Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp3164517rwb; Fri, 20 Jan 2023 12:07:04 -0800 (PST) X-Google-Smtp-Source: AMrXdXsw0Lu8wuL8XDdOTNLNcryXWUFcf4VwqOs4phkONRKy8xMBn3oYO0qkEeYWTLF9bfEZ7uqa X-Received: by 2002:a05:6402:3709:b0:49e:baf:f6e9 with SMTP id ek9-20020a056402370900b0049e0baff6e9mr18666787edb.9.1674245223634; Fri, 20 Jan 2023 12:07:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674245223; cv=none; d=google.com; s=arc-20160816; b=oWHfd3uXXr8cLOCWCcExk42HTgPlgxKY1skftl1UwCadOa8pMVhWgLZS7ysshHLZJQ VGLcW5NE+nAgQomj7hwIUE2+JzBTdp4qHQ9o1faWEaV8mHyHwvxUnMkec9DUmwY7gwyQ PaBafYbVfhSw9vUkgxa0WSGiVy1grbn8oJ2KwHHuflnC18UFZDIEFXHM10MEKgsG+phy zvtTHwFtWszeNgLUcmziRIbtX1jL2z83JUnLzBvz2ef66GjQwdQfRODlETQSORuI1EWD 7KqniIafrarX7rkXlBEsX30k9T1q/wCeaw0l6YBiJQgmBtP4e0NPTqfJTOw2xOVjPG0R EwtQ== 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=1UNXDm8iFP5YAOjKcZo2dyQ+k2bLry9sD5B1TvI1M/M=; b=kmlFhHbpuMz9/tss1wqGjbD66ZlM/BykYE4c+9865HY+qyfut9v01tKLx9SV5URu14 a9TWoHUrC6qAFR1dkhHkFhks6gOyFyXgafuggYwYVsPPASQe8M+FvUZxGZGJWR4DlaGf Meq33AmBR754W3jCE5Rs4oHDYBgpiaEMbh4o5UYctvAWOAWB7spZhfJSyH7n4erZuja2 qKWwZeZfcOHDiExH6DbKTJrgvDkTWhPyit4OlVa1J8bUBhoNNkh4TlABpLa1thZVnELy d5DSrssZPbRWGQZqwoNkeXDGRF4kFLBCs/ZSz6Ixuu6b0fE9HAvTH9TR5G/hEIvc5sbA guHA== 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 n14-20020a05640205ce00b00483b5bcc9c3si25709332edx.616.2023.01.20.12.06.51; Fri, 20 Jan 2023 12:07:03 -0800 (PST) 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 S230025AbjATSsV convert rfc822-to-8bit (ORCPT + 50 others); Fri, 20 Jan 2023 13:48:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230235AbjATSsR (ORCPT ); Fri, 20 Jan 2023 13:48:17 -0500 Received: from mail-ej1-f49.google.com (mail-ej1-f49.google.com [209.85.218.49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 477BE5FDF; Fri, 20 Jan 2023 10:48:02 -0800 (PST) Received: by mail-ej1-f49.google.com with SMTP id u19so16200959ejm.8; Fri, 20 Jan 2023 10:48:02 -0800 (PST) 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:message-id:reply-to; bh=SGnyRzY1q6uGKHCPbfZjapTbd1fVyDwIxw6QkOwGmkU=; b=kjpSjUoIyi1nX7BOQ6b9j1oM2jEk/t1Wmji8Qe6jOpyneoFPEI3krCAY2aoT5wUHEc pppxTcYC0dCz/1GAO0phQ5jPpgTnmtJzSGwtSyVcmVupz8OX+Bx7VhF1ndPA6diftjC3 e//8MPMHzD6OvdiAiD/S7rmnd9NegEF5TqVz4Zd4CTdoBAyjA2t0Uv3doEqfxnOCTfF2 vfp/hV/XNoWUVOcn74U0KuDz6WSZZiJB4Ttz0nTOIwUKt0bWycfLsVUCwExIGC7HfdzG Ft49yb7w+V45hYKH4SjcMgfH9e4RqN7wLOtd8+tQlnnzfz+TF7skH1MheJbBwrKVcSxD auuQ== X-Gm-Message-State: AFqh2kp5ivyjAUJ/vH5wSJcJuZODgP65lm+J7gEMkEmnvWm2XB7uTLTn GG0MUEK7gFEqyvsoa4S9bfOYVCWRypU4+xPWIMPeisCE X-Received: by 2002:a17:907:7855:b0:855:63bb:d3cb with SMTP id lb21-20020a170907785500b0085563bbd3cbmr1637584ejc.532.1674240480941; Fri, 20 Jan 2023 10:48:00 -0800 (PST) MIME-Version: 1.0 References: <20230113180235.1604526-1-daniel.lezcano@linaro.org> <20230113180235.1604526-2-daniel.lezcano@linaro.org> In-Reply-To: From: "Rafael J. Wysocki" Date: Fri, 20 Jan 2023 19:47:49 +0100 Message-ID: Subject: Re: [PATCH v5 1/3] thermal/acpi: Add ACPI trip point routines To: Daniel Lezcano Cc: "Rafael J. Wysocki" , srinivas.pandruvada@linux.intel.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, rui.zhang@intel.com, christophe.jaillet@wanadoo.fr 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_H3,RCVD_IN_MSPIKE_WL,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 Fri, Jan 20, 2023 at 7:27 PM Daniel Lezcano wrote: > > On 20/01/2023 19:15, Rafael J. Wysocki wrote: > > On Fri, Jan 20, 2023 at 7:08 PM Daniel Lezcano > > wrote: > >> > >> > >> Hi Rafael, > >> > >> > >> On 19/01/2023 14:15, Rafael J. Wysocki wrote: > >> > >> [ ... ] > >> > >>>> +static int thermal_acpi_get_temperature_object(struct acpi_device *adev, > >>>> + char *object, int *temperature) > >>> > >>> So this would become thermal_acpi_get_temp_object(). or even > >>> thermal_acpi_get_temp() because it really returns the temperature > >>> value. > >>> > >>> I also don't particularly like returning values via pointers, which is > >>> entirely avoidable here, because the temperature value obtained from > >>> the ACPI control methods must be a positive number. > >>> > >>> So I would make it > >>> > >>> static int thermal_acpi_get_temp(struct acpi_device *adev, char *object_name) > >>> { > >> > >> We are converting decikelvin -> millicelsius. Even it is very unlikely, > >> the result could be less than zero (eg. -1°C). We won't be able to > >> differentiate -ENODATA with a negative value, no ? > >> > >> In the future, it is possible we will have to deal with cold trip points > >> in order to warm a board. May be we should don't care for now ? > > > > My point is that the ACPI specification mandates that the return > > values be in deciK and so always non-negative. > > I understand that but the code does: > > static int thermal_acpi_get_temp(struct acpi_device *adev, char > *object_name) > { > ... > > return deci_kelvin_to_millicelsius(temp); > } > > All the callers do: > > ... > > ret = thermal_acpi_get_temp(adev, name); > if (ret < 0) > return ret; > /* This could be an error > * or negative millicelsius temperature > */ > > /* here we already have millicelsius */ > trip->temperature = ret; > ... > > So I guess we want to do: > > ... > > ret = thermal_acpi_get_temp(adev, name); > if (ret < 0) > return ret; > > /* we convert here instead in thermal_acpi_get_temp() */ > trip->temperature = deci_kelvin_to_millicelsius(ret); > ... > > Sounds good ? Yes, it does. Convert when it is known to be valid.