Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1114932rwl; Fri, 24 Mar 2023 06:32:34 -0700 (PDT) X-Google-Smtp-Source: AKy350b+3E1Xk16nFm2t+G4B1L8h/ZXDzJUAEcZE5UPm39DEx/zbfYC7SgaewC9KeLZ2GRsypg62 X-Received: by 2002:a17:903:64b:b0:1a1:cc9d:3d55 with SMTP id kh11-20020a170903064b00b001a1cc9d3d55mr2137034plb.20.1679664753866; Fri, 24 Mar 2023 06:32:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679664753; cv=none; d=google.com; s=arc-20160816; b=ooap4NJ/Alnrjz64AqvELUU3dhT/ePyLaPXiswoLwCYAR0zfNTIRmHcr2i0PspSbv8 wy4O6SlU6bTb51alrEkyvkDBSJ/nhNgSVSglAcr/cAlxgTGHwJVYYPwzvJEXVSxM2RxZ RYtwPvNPlxcyyGU9/64FoJwmAdcCdf6cF5DzFId+gNN9Dc2k3YlVQrBLqr99PubUj3Iv iv2PXfnwVZA1bcG0LwepEzjHw9aFa3swr+iVbTILQMqnONRx7oeWknT2+K2WpUrEskm4 eIntzkJ8noLrk0nyeGcz5olcG/7O2RIxkETRzy1Na1RO44SqCPaB7Iw+kRj81M/fbDof 2g8Q== 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=mMnGBIsRsQZtZGqikYNlK9C5aAkwikRrj37dNJlSgLc=; b=qduC6F9Yoto9B62gkRrz+4YN5VuLOrd3T0hDZC6jXVVeK1kDtPszhc0VoFqei4Jk9a Sx7sCy28R7aVrkOAzqLkPAUeIYu8hv0kn7YvpnKOzuq8d06Tt3CwCeGFnMj+TkepaLFf JFSj6c9sfvlOGO0Ese9Axsud8bvd/OdVMtqeaSIk57RjZ+QfdWh3Lw2cg0APAfybyvoJ leqwMaNQ/f5tsiObjipCWTQdQspqAGa7nlItOWarwHiJi4/2/7Nldxe1zj+2zv6VF1tQ DFa7VJ3MNF8UjlpIacl+Rp1SEHCIMbueJiXRM8Bjw89FCyeVQbxdPNtiSvcbEnNPx7zC Sbww== 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 q11-20020a63504b000000b004fbe30d869esi3877691pgl.268.2023.03.24.06.32.21; Fri, 24 Mar 2023 06:32:33 -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 S231934AbjCXNZw convert rfc822-to-8bit (ORCPT + 99 others); Fri, 24 Mar 2023 09:25:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231761AbjCXNZv (ORCPT ); Fri, 24 Mar 2023 09:25:51 -0400 Received: from mail-ed1-f51.google.com (mail-ed1-f51.google.com [209.85.208.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E23E8F970; Fri, 24 Mar 2023 06:25:47 -0700 (PDT) Received: by mail-ed1-f51.google.com with SMTP id o12so7888907edb.9; Fri, 24 Mar 2023 06:25:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679664346; 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=Zs5p7KU8MZDhgEPLIw4GctxFoYHSsWDkapBxgIg25mM=; b=odztf994hdS2N6EDatW+qGQrvWGmF4Wa8TtQGvJZn9w0RxtMVd6B+TsYNFd4w3/Who thJyVJtiuP2i5hvqa78LwXPpJwi/HRqfZgRFK/CPFaXnMj5RPP7TRG12zAUgn+vGbjwm zwO3vC2ch4dEZgRbhRQ3ljPL8JoVF89L+TiEbRhBlyqkqx3E3byYuok2e6golbZ7SgSa l9OtZ5Z8/R0HGEdHpCKN571xwMBDUo2Uc358/m1W28uEA3y/gxgDUA08S3U/+Ruz3G8A wffSede2FNqUL/mUWuYwyfhAD9VwE29/OCCZZo0LaQCiyqKU22VAgWsSFHKlXLLvFyEW aUiA== X-Gm-Message-State: AAQBX9fHDD04s9/IJ3GVpSdoOO0g73jfwgRkumbMdSiSWlnfIAVOL/ro 9srbH0/SRcnhVTQ2Rqxied412nFRkHbAJarFKEc= X-Received: by 2002:a17:906:37c8:b0:934:b5d6:14d0 with SMTP id o8-20020a17090637c800b00934b5d614d0mr1441550ejc.2.1679664346366; Fri, 24 Mar 2023 06:25:46 -0700 (PDT) MIME-Version: 1.0 References: <20230324070807.6342-1-rui.zhang@intel.com> <20230324070807.6342-4-rui.zhang@intel.com> In-Reply-To: From: "Rafael J. Wysocki" Date: Fri, 24 Mar 2023 14:25:35 +0100 Message-ID: Subject: Re: [PATCH 4/5] thermal/core: Enforce paired .bind/.unbind callbacks To: Zhang Rui Cc: linux-pm@vger.kernel.org, rafael.j.wysocki@intel.com, daniel.lezcano@linaro.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=0.5 required=5.0 tests=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 Fri, Mar 24, 2023 at 2:24 PM Rafael J. Wysocki wrote: > > On Fri, Mar 24, 2023 at 8:08 AM Zhang Rui wrote: > > > > The .bind/.unbind callbacks are designed to allow the thermal zone > > device to bind to/unbind from a matched cooling device, with thermal > > instances created/deleted. > > > > In this sense, .bind/.unbind callbacks must exist in pairs. > > > > Signed-off-by: Zhang Rui > > --- > > drivers/thermal/thermal_core.c | 5 +++++ > > 1 file changed, 5 insertions(+) > > > > diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c > > index 5225d65fb0e0..9c447f22cb39 100644 > > --- a/drivers/thermal/thermal_core.c > > +++ b/drivers/thermal/thermal_core.c > > @@ -1258,6 +1258,11 @@ thermal_zone_device_register_with_trips(const char *type, struct thermal_trip *t > > if (num_trips > 0 && (!ops->get_trip_type || !ops->get_trip_temp) && !trips) > > return ERR_PTR(-EINVAL); > > > > + if ((ops->bind && !ops->unbind) || (!ops->bind && ops->unbind)) { > > This can be written as > > if (!!ops->bind != !!ops->unbind) { Or even if (!ops->bind != !ops->unbind) { for that matter. > > > + pr_err("Thermal zone device .bind/.unbind not paired\n"); > > And surely none of the existing drivers do that? Because it would be > a functional regression if they did. > > > + return ERR_PTR(-EINVAL); > > + } > > + > > if (!thermal_class) > > return ERR_PTR(-ENODEV); > > > > --