Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp1084057rwb; Thu, 19 Jan 2023 06:29:41 -0800 (PST) X-Google-Smtp-Source: AMrXdXv/9L12GlvnGa2SpXgCB6Su8DThVKc1HQWzMzhGflAgED/x26awoSCRgraFwKMjfGez3qVd X-Received: by 2002:a17:90a:5793:b0:229:1f6d:47fc with SMTP id g19-20020a17090a579300b002291f6d47fcmr11601195pji.41.1674138581726; Thu, 19 Jan 2023 06:29:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674138581; cv=none; d=google.com; s=arc-20160816; b=UrSdQ7mcUJ9h2DtMe5wW7DpKeKv3uKBXD5GBVZKK4gVQ7wT+xUAIBsVCN4B9I0iXZM qXpVswTF8dS3SndloeBIfPysTwY2ojCT46MTDqPoJIINwBU7UFqmtkuhnbtLiAtn98mN P6ERI2eoeapdyXPqV4U9MCjYmFbaVTUjg5r1dhdvDQgNsgdEwvVlFtOPgJTerv/aHn2j T6WerfaY/o0bRrLxezrCtpXG0lc4oEzfX/Pha9Y7AvS17HizsspGH0VyeyOnLBvD5Fix fD6zqhAJXlMBv/GvwGTNlCVcNZ6WLxr3h5WDZjOk9jECBt+KLXiJZjvtmyobb6jVKLZD rdUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=VcW98M++UJwEIqM4eSdAQ11GlW76h6H4x45phYJn7Ls=; b=ZHENt4PwhhJ/IsnfVf8a0h0ri7Iyo/OblvAifI1pQaXMHoHvgsu4/IvblZa3Ha0GIc XT2SSP4Fmy+ZeN9P3RAlGxk/JwGo1bpGotEByj6/0pDzrSZ1pHjRzl/O0GEyuzBsQJDP EEqO3D9Bc6XS847m5Ti5+VuQ67zVqYY+nacPqMi7c5AA76K34EccgFe4YZh6vXEck3bq 4BvhZAzwI4V/PmsIlQlGYyFkSZa+Z9Kutfg9tWQk+pncd+VYA7QjvNEquazG7DxhibVt EUj0Iid3eWz+lR4DVPIOTiCW4BuYDUZVFpqokxulld1oJ3ggG0B1TdTTLOkr66q1Gt56 LV8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FrZAj8M3; 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=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z23-20020a17090acb1700b00223f3998ce8si5287076pjt.43.2023.01.19.06.29.33; Thu, 19 Jan 2023 06:29:41 -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; dkim=pass header.i=@linaro.org header.s=google header.b=FrZAj8M3; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231438AbjASOPb (ORCPT + 45 others); Thu, 19 Jan 2023 09:15:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231518AbjASOO0 (ORCPT ); Thu, 19 Jan 2023 09:14:26 -0500 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28EDC3ABA for ; Thu, 19 Jan 2023 06:13:49 -0800 (PST) Received: by mail-wr1-x42e.google.com with SMTP id r30so1985241wrr.10 for ; Thu, 19 Jan 2023 06:13:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=VcW98M++UJwEIqM4eSdAQ11GlW76h6H4x45phYJn7Ls=; b=FrZAj8M3rvUJfZUInC9OaoJg3z80i+JPUCrlAcVqxaUwhfFDChfp5f4kmWXRb4nzk8 /84Y1q+O/qc+92b9AWMNpyzHBosnFNzUvCitXQyDRNQWkpMnutq+ym6+2hbaVxLZb260 qQmJwiFkL1LfsLHPs3qFFjjRMYbRSz3CfnF5qPdIPE1ardKh15+zNSvJ+W+eHL5jdd7M a44lBbyr+Lm7DGLb26Evt5eX9qntJFYcIixYOpYhmIBeUkUokSB9elRZtsBPL6WAp2F1 oljuazmm4Hb2EjFDNrJET/f3QkUHmoU9rOn92t9lNssYDHR1rBZ9LQteXkuzhQC3RCrV FwZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=VcW98M++UJwEIqM4eSdAQ11GlW76h6H4x45phYJn7Ls=; b=CBdJpXKEKttCmbzkvC6buSyGu/u8BNwXETHRq2HMGVu0YqG/OjkVudcYMQ/Drq+M+M 9P6LexAgNlhXaFWw+pzZnQH1namBSs19KE8gpLwVjMDD0K0IKMqwZqz7uXo+NIg0ajbc 4aw9UzxNK1QGSt4766FgqNb+HuFQTkF2RfzKllKlKluOR/nYA+8Z2TKkOqPqiLdglOYO hiqiJYGxsWsA6ETMTJTfeOPvqRV0E3cupVPlW84EIvQHbhrLKGACSEkau2I9Ao2Gv7fx GysbEdOHtzMdHujil70kL2RiQBuzIYfCbzrk87+MZsU+oG1TZLA+XFXN/t0IxUow4VWO FH8A== X-Gm-Message-State: AFqh2kohFrqhxUeFRZ7nneFdOZ4RO4XQ3DsK+Gv82xSlIxfYxbMLUWI0 gNydXOSWSQaSoaONk3Xka7r3yg== X-Received: by 2002:a05:6000:386:b0:2be:c41:4758 with SMTP id u6-20020a056000038600b002be0c414758mr11490635wrf.38.1674137627563; Thu, 19 Jan 2023 06:13:47 -0800 (PST) Received: from [192.168.10.46] (146725694.box.freepro.com. [130.180.211.218]) by smtp.googlemail.com with ESMTPSA id b11-20020a05600018ab00b002be2279f100sm8227275wri.96.2023.01.19.06.13.46 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 19 Jan 2023 06:13:47 -0800 (PST) Message-ID: <1313b9b6-45f0-aad1-9a3f-c5e1e3636697@linaro.org> Date: Thu, 19 Jan 2023 15:13:46 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: [PATCH 3/5] thermal/core: Remove unneeded mutex_destroy() Content-Language: en-US To: "Rafael J. Wysocki" Cc: "Zhang, Rui" , "linux-pm@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "amitk@kernel.org" 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> From: Daniel Lezcano In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_NONE, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: * 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 19/01/2023 14:24, Rafael J. Wysocki wrote: > 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. It should be in class_unregister() too, right ? And is it possible to add a class_is_registered() ? in order to prevent accessing class structure internals ? -- Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog