Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp1102645rwb; Thu, 19 Jan 2023 06:42:34 -0800 (PST) X-Google-Smtp-Source: AMrXdXvCajsqJcTqmcWse8chofO05l3RC7/KJLf+HPJ59a5fl+uQorVjy8Z1P7rsp8bkZ1tIFiTA X-Received: by 2002:a17:906:348b:b0:84d:3a95:cdf9 with SMTP id g11-20020a170906348b00b0084d3a95cdf9mr11528984ejb.50.1674139353828; Thu, 19 Jan 2023 06:42:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674139353; cv=none; d=google.com; s=arc-20160816; b=KVCJwu53Xba6ngfpJVMgmsMhHO9BdGyCILqRStVx2J/QidKgNSPVzUHhUsOTaScpOI K0Vbz/+xePDFN0GS+B/d5qqYiz56kgGQdiiv79eoVAp4AJAKuXr4C1O5TpUNTXuAUbyQ EX+BiU2So3wNVjWVpIzZB1gH9yQ+8TJr3CBzYzPEkzZkHaHstPr0nGZCvG1PmwByD/8e 8QYeWuTBbwyDlp7VPkbijsMswFLeBYNlTmVmiA8yByXwfef2SFKAWFGgnA9qz12qXFrq 0ygDzIFOtiAUJadylg9cIta2qJiWQynG2WHlJyZt2SDqobqW06LkfWNNPleMwTNZO5Dq iZZg== 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=rH1KCn8JjO7OsLFRLoHWM7ALUs/KihPCdUMgdMIvr+Y=; b=V3CgTSSrWdBp6mEBsziMvR/XFQm9ReQPNEnxaT9QxNBriHowMJ8Pwa+b2ImK+Uihrq KIS2uOrsV4l002+64ia65OKLoRmlAAxOo3IjbcyfPszNpt0oge8TcdT9vwF1ceW+KMGM oqd+mkm5S7asdN/6tE/acjEQ5JqmyIgSEqqIF795I+QnwZSMAq2cBm6Gb5jxQSfHXwL/ fZJOMrY/S5cwcHWqEs8HeuvJ9Bgkzi1GnOpPDfLzqLqbOeiHO6JeJ9fNjOTih8V2Iz/v LnzZx7/cuJ/9ehUgxnQbf/utEHS6b4ajlcLKoAMbeiT7+HaNCVubCJk31EUXaca1m+3B EVdQ== 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 hc41-20020a17090716a900b0084cdfa2621asi41740920ejc.456.2023.01.19.06.42.22; Thu, 19 Jan 2023 06:42:33 -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 S230348AbjASNZD (ORCPT + 44 others); Thu, 19 Jan 2023 08:25:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35372 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230388AbjASNYw (ORCPT ); Thu, 19 Jan 2023 08:24:52 -0500 Received: from mail-ej1-f54.google.com (mail-ej1-f54.google.com [209.85.218.54]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3309474E9F; Thu, 19 Jan 2023 05:24:47 -0800 (PST) Received: by mail-ej1-f54.google.com with SMTP id az20so5679713ejc.1; Thu, 19 Jan 2023 05:24:46 -0800 (PST) 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:message-id :reply-to; bh=rH1KCn8JjO7OsLFRLoHWM7ALUs/KihPCdUMgdMIvr+Y=; b=KYrZN7kOZyIBHtxhQsf3N+QSeQgTWm7gCsUPR61s2c0qYpq+XeQ/hZqwR2pHMCU/7q fQdivk0oCsl6JMqKyXPrZmMd0YW4yQkwnOD+k6qbJV+tkpmbvfOd5bOfpeU3a9fUtN20 g3AMQTsZBsAZTovW032iYPYv7TPYAFS5UdELcsU+KI4PY1L0SyCzFEmy8mDvXzsGGwwO 3DIvazd0QwqTbasnkvQUjJ0qhcf2e4mZtlE3s4W0q4EXnMCbZN/tPwJ3qpSF3Wzd340Y 40gCmR2ne5Pa4uDcm2+kFvFX7HWuzDoC8yTEaqvV8aLSDzmBirPDzUIjxBevOVuE/OK6 bq1g== X-Gm-Message-State: AFqh2kr/LgED9hFx/Sjaa7us9K8FGqNFyChKlAUlm47C5WGNrjkVTZpM 0qXvtcCx7Hw9kNfqDJSbS83IHcxZDmOUjjBsA94Q2Qag54M= X-Received: by 2002:a17:906:64a:b0:84d:3c6a:4c55 with SMTP id t10-20020a170906064a00b0084d3c6a4c55mr1454744ejb.509.1674134685527; Thu, 19 Jan 2023 05:24:45 -0800 (PST) MIME-Version: 1.0 References: <20230118211123.111493-1-daniel.lezcano@linaro.org> <20230118211123.111493-3-daniel.lezcano@linaro.org> <92a6e8494b92f0bb8cb36c98d2237ee3d347c358.camel@intel.com> <85e0a85d-6935-11cc-8396-4c3e425188f2@linaro.org> In-Reply-To: <85e0a85d-6935-11cc-8396-4c3e425188f2@linaro.org> From: "Rafael J. Wysocki" Date: Thu, 19 Jan 2023 14:24:34 +0100 Message-ID: Subject: Re: [PATCH 3/5] thermal/core: Remove unneeded mutex_destroy() To: Daniel Lezcano Cc: "Rafael J. Wysocki" , "Zhang, Rui" , "linux-pm@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "amitk@kernel.org" 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 Thu, Jan 19, 2023 at 1:48 PM Daniel Lezcano wrote: > > On 19/01/2023 13:11, Rafael J. Wysocki wrote: > > On Thu, Jan 19, 2023 at 10:30 AM Daniel Lezcano > > wrote: > >> > >> On 19/01/2023 08:41, Zhang, Rui wrote: > >>> On Wed, 2023-01-18 at 22:11 +0100, Daniel Lezcano wrote: > >>>> If the thermal framework fails to initialize, the mutex can be used > >>>> by > >>>> the different functions registering a thermal zone anyway. > >>> > >>> Hmm, even with no governors and unregistered thermal sysfs class? > >>> > >>> IMO, thermal APIs for registering a thermal_zone/cooling_device should > >>> yield early if thermal_init fails. > >>> For other APIs that relies on a valid > >>> thermal_zone_device/thermal_cooling_device pointer, nothing needs to > >>> be changed. > >>> > >>> what do you think? > >> > >> I think you are right. > >> > >> It would be nice if we can check if the thermal class is registered and > >> bail out if not. But there is no function to check that AFAICS. > >> > >> Alternatively we can convert the thermal class static structure to a > >> pointer and set it to NULL in case of error in thermal_init() ? > > > > It doesn't matter if this is a NULL pointer or a static object that's > > clearly marked as unused. > > Without introducing another global variable, is it possible to know if > the class is used or not ? If thermal_class.p is cleared to NULL on class_register() failures in thermal_init() (unfortunately, the driver core doesn't do that, but maybe it should - let me cut a patch for that), then it can be used for that.