Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp345502rwb; Mon, 26 Sep 2022 13:13:59 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5cz2ucYNc6e+yZCb2igQQ7zRBYReDB3RbctvC9KioHy1A0458F7nO2YKg6Qh/dSKlODj9m X-Received: by 2002:a63:8641:0:b0:43c:bbbf:d0c4 with SMTP id x62-20020a638641000000b0043cbbbfd0c4mr4949478pgd.272.1664223239135; Mon, 26 Sep 2022 13:13:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664223239; cv=none; d=google.com; s=arc-20160816; b=cvWDFkZCsx2B0UVRzA8Ij7PYR1EtA40hiNwqBk8u0joExcmD/n5fnx3CrMdGT/dceG Irle8zYmgjPS5dgTDEFUeb4ZcPfvFa4R0P6MZr5OZyufKFaG1rAmCbU1rnbyJT5sIPPx 8yRr+CTKc7FbkjxKtF45kQtimDgf3bAFmGXz5+0aL0WQ7VJnlkwrIZT8s9/YUNxaLCAX BAgaZ/uZYoWWqVyZJcsziuT+CFS3PW/So2yZDnR8idIEmV0v9UXW5JAnF7OyzPiAfisw EfR9T5xqWInTqwV0QRTY+7bumPDhlyfi3ZQYAyusa2kFMqvLjHR97p9uLZJOjYHSHGmV zFUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=r/lBYF+GxrGFPkgG3fUr7thtRY0jkylkSgITRGPALVo=; b=aEhXSUqj7TP5GS2HWJpX4YAbXld/BgLKNKmzj/0SnpphYYIPYoNyaCuU+8otZDFMFa N52aK2ve1filA+Jvvlr6N+2mip+xZ9zXmXD/Bg8baHNnz3uXn4btBUR8hoTlcUFL7EOa bVxEkG7vpYvW1gp8hZ6IfC4I29hhnBAx2RiEXIFtUcolaWksC9glkyOlGQpQTRnd51b8 RAFkgrnH4yYEFX0p859JbdzbZeNfKrLo4pymK03mAX9N9RJDo6OURIS/CZVlxIvWQzKm pEFCm1bYr46LAFu+Z+KVT6r8+DqLiEl4pIjtt851q0pmQO4nEJyLbiAXDYVa+ShmLixj 78NQ== 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 126-20020a630084000000b0043c5fa4c118si11109200pga.814.2022.09.26.13.13.24; Mon, 26 Sep 2022 13:13:59 -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 S229720AbiIZTQo (ORCPT + 99 others); Mon, 26 Sep 2022 15:16:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58602 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229588AbiIZTQm (ORCPT ); Mon, 26 Sep 2022 15:16:42 -0400 Received: from mail-qt1-f177.google.com (mail-qt1-f177.google.com [209.85.160.177]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24F9598C9F; Mon, 26 Sep 2022 12:16:42 -0700 (PDT) Received: by mail-qt1-f177.google.com with SMTP id g12so4767442qts.1; Mon, 26 Sep 2022 12:16:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date; bh=r/lBYF+GxrGFPkgG3fUr7thtRY0jkylkSgITRGPALVo=; b=kT9yvpTfZ9jfOKajbS45EXlB6Je/kHQJ2Jnx9Tyma2Ux+2Cs66N4W5hjYRzIgoDCdd VnaHTbMqzsQIQzZsjuXy+U4r+GE5dEaf8yPIn2ajzAX/E0FXEWWza3lzhv5+up9cWABo YX5ybCrdY3BvwxvTWV5jRp1I3jKKqc8/cazGbO8Q+bMyIz14JbB344piB5D/hA3p2sQw eKzADcBMrFuFqQnwmh6dbnoMjDPM3vXwR0qRwbEyqmQPw5feRDUe3IRngUu79WavnSDz bftCMHnnwGFlDCXORmD3F7C/96NK/VMPX88XjLK5p0x7ItOC5zfqxcyFKH8tc9bCGGY1 CK3A== X-Gm-Message-State: ACrzQf3xSSLD7vhWcvkO0TgBAv25MtsOV3GvywaF+RBsUDQkowf7s0xN Nn+CiJXHIHIoJshwZoWAZ5SIRN7399LbZJZ12hE= X-Received: by 2002:a05:622a:1a08:b0:35c:d9b5:144b with SMTP id f8-20020a05622a1a0800b0035cd9b5144bmr19435966qtb.27.1664219801273; Mon, 26 Sep 2022 12:16:41 -0700 (PDT) MIME-Version: 1.0 References: <20220926140604.4173723-1-daniel.lezcano@linaro.org> <20220926140604.4173723-3-daniel.lezcano@linaro.org> In-Reply-To: <20220926140604.4173723-3-daniel.lezcano@linaro.org> From: "Rafael J. Wysocki" Date: Mon, 26 Sep 2022 21:16:29 +0200 Message-ID: Subject: Re: [PATCH v5 02/30] thermal/sysfs: Do not make get_trip_hyst optional To: Daniel Lezcano Cc: "Rafael J. Wysocki" , Linux Kernel Mailing List , Linux PM , "Zhang, Rui" , Amit Kucheria Content-Type: text/plain; charset="UTF-8" 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 Mon, Sep 26, 2022 at 4:06 PM Daniel Lezcano wrote: > > The get_trip_hyst() ops is optional. It results all around the thermal > framework code a check against the ops pointer and different action > adding more complexity and making the code less readable and > understandable. > > A zero hysteresis value is perfectly valid, so instead of adding more > circumvolutions in the code, create unconditionnaly the hysteresis and > use the thermal_zone_get_trip() function which returns a zero > hysteresis if the get_trip_hyst() is not defined. > > Signed-off-by: Daniel Lezcano I would change the subject to something like "thermal/sysfs: Always expose hysteresis attributes", because that's what the patch does IIUC. And in the changelog I would write something like the below: "Instead of avoiding to expose the hysteresis attributes of a thermal zone when its get_trip_hyst() operation is not defined, which is confusing, expose them always and use the default thermal_zone_get_trip() function returning 0 hysteresis when that operation is not present. The hysteresis of 0 is perfectly valid, so this change should not introduce any backwards compatibility issues." > --- > drivers/thermal/thermal_sysfs.c | 25 +++++++++---------------- > 1 file changed, 9 insertions(+), 16 deletions(-) > > diff --git a/drivers/thermal/thermal_sysfs.c b/drivers/thermal/thermal_sysfs.c > index 75f6b151a58b..18cdd7cd0008 100644 > --- a/drivers/thermal/thermal_sysfs.c > +++ b/drivers/thermal/thermal_sysfs.c > @@ -424,23 +424,20 @@ static int create_trip_attrs(struct thermal_zone_device *tz, int mask) > return -ENOMEM; > } > > - if (tz->ops->get_trip_hyst) { > - tz->trip_hyst_attrs = kcalloc(tz->num_trips, > - sizeof(*tz->trip_hyst_attrs), > - GFP_KERNEL); > - if (!tz->trip_hyst_attrs) { > - kfree(tz->trip_type_attrs); > - kfree(tz->trip_temp_attrs); > - return -ENOMEM; > - } > + tz->trip_hyst_attrs = kcalloc(tz->num_trips, > + sizeof(*tz->trip_hyst_attrs), > + GFP_KERNEL); > + if (!tz->trip_hyst_attrs) { > + kfree(tz->trip_type_attrs); > + kfree(tz->trip_temp_attrs); > + return -ENOMEM; > } > > attrs = kcalloc(tz->num_trips * 3 + 1, sizeof(*attrs), GFP_KERNEL); > if (!attrs) { > kfree(tz->trip_type_attrs); > kfree(tz->trip_temp_attrs); > - if (tz->ops->get_trip_hyst) > - kfree(tz->trip_hyst_attrs); > + kfree(tz->trip_hyst_attrs); > return -ENOMEM; > } > > @@ -473,9 +470,6 @@ static int create_trip_attrs(struct thermal_zone_device *tz, int mask) > } > attrs[indx + tz->num_trips] = &tz->trip_temp_attrs[indx].attr.attr; > > - /* create Optional trip hyst attribute */ > - if (!tz->ops->get_trip_hyst) > - continue; > snprintf(tz->trip_hyst_attrs[indx].name, THERMAL_NAME_LENGTH, > "trip_point_%d_hyst", indx); > > @@ -512,8 +506,7 @@ static void destroy_trip_attrs(struct thermal_zone_device *tz) > > kfree(tz->trip_type_attrs); > kfree(tz->trip_temp_attrs); > - if (tz->ops->get_trip_hyst) > - kfree(tz->trip_hyst_attrs); > + kfree(tz->trip_hyst_attrs); > kfree(tz->trips_attribute_group.attrs); > } > > -- > 2.34.1 >