Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp1321091rwb; Thu, 19 Jan 2023 09:09:51 -0800 (PST) X-Google-Smtp-Source: AMrXdXtt7LfxSArdHMpGCBhGXw6m9TLQgbnpyRXPgYGg+A1G+s9zM7L7SB6fezrHOYzF77zSvaUI X-Received: by 2002:a17:90b:4a41:b0:229:fd18:cb9c with SMTP id lb1-20020a17090b4a4100b00229fd18cb9cmr719543pjb.34.1674148191710; Thu, 19 Jan 2023 09:09:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674148191; cv=none; d=google.com; s=arc-20160816; b=WVDAznxq5SmZ9Ddoz8DsTK4gBugGwRN1uDKViiI9FdoRC3Mjf/ebhNfp4otNaoh5DX DhORt2U1FFqC1UVqtcVEeuXvlpqk1W+8d3AYXyJyKnTTRHewVPijBjoAXn8UH7UiLFJo O/WSAB67rfAvswAhYvUTPuGDbUrX/EJDY/sVdl+I0gcjVu3d6ytkk3tQ5L884jW54YXD A9bi/VtTmEIGyX1oKatPpmIm/sMsX7SR3maDoOSzkg+UpIzyymNFIU7CydfaIsFSfq6y nz5dTyze9JIt44NDveSldh7/IsVW/b/WhwDcn36PvhvTiV91t7Dc2SO0bMFj4/e81V+v KNvA== 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=flCnIliu3iTWinWqZKjSC4lmc9rb7ayevnIotzFYCWI=; b=PfyBjGsfM2gaqfBNAKv9vLVEBpEecqUs98NoymYbx0rgeWrwb+99U6rkofiM446FDs HMye5/W/e0zBrDecXxQEpbiBhmsMY4AWTVRyDujqS6JruQvgkD10X8B977Z9PfCjqfcm e3EaeLlFUHZz9+hWe/G169ZGTTmVzMsAP4s+6aE/Er0b5pET981N+ii8OEQGoeHQBirq 3kw8KS/hfYPLGuOcV4TgAK+ZfI3gqH851kxx9H14dWnZxDz/uY9fyH9+FAjWXfFt3zti b/l2AZ7lYPalnaCGgjzOLA6hht9eGcMBWnENMazDVisL8IzlHanPKGnrEBs1MV0etscD TmWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Hy2CExWu; 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 v7-20020a17090abb8700b00205da45d8a5si5202372pjr.124.2023.01.19.09.09.45; Thu, 19 Jan 2023 09:09:51 -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=Hy2CExWu; 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 S229750AbjASQji (ORCPT + 45 others); Thu, 19 Jan 2023 11:39:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34016 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230211AbjASQje (ORCPT ); Thu, 19 Jan 2023 11:39:34 -0500 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E74B4ED19 for ; Thu, 19 Jan 2023 08:39:32 -0800 (PST) Received: by mail-wm1-x32f.google.com with SMTP id f25-20020a1c6a19000000b003da221fbf48so1701653wmc.1 for ; Thu, 19 Jan 2023 08:39:32 -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=flCnIliu3iTWinWqZKjSC4lmc9rb7ayevnIotzFYCWI=; b=Hy2CExWui+HpZKSlyvCRqhCmkhM0iYSBz3Gujxv6sd/OSmc/V2uCkvVZgrfNAhkEBg JCSejuljnFRtHsmJRiz+ZRmQmbJoFrqndEamihTkusk+8r73akv48Xu6O4ij9D3PufSf 4xcwSa53Crwv8fclWb5YuzW8gM7oc96LbQPjN0xgtzgpUlZa/LRqJOZeAS0KRF7TNVSw wqleFX5leMPIGhBFUarwc934JnYZCPR7zCpNy9kbHRnEGP4A6KOW+Gej/cbQKcHLeTTF Wh/XSY/qwZetU44VSZUsmzrRRTTtjEzC5P8H9YEzv/WqonY1suEwQGLkTvCsmVrXfR4R +WnQ== 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=flCnIliu3iTWinWqZKjSC4lmc9rb7ayevnIotzFYCWI=; b=ZfdXqd/YMegojzXF1nv3vItGFDwsSjaQUb06lY7FBlWpydBkPcEODMt/hV4HJuXSr0 k23BfocYulKmWrEuUWM6h51LnV9AD/Ht/p70zhux8UhEd4O/3U4sDsZl7NfN5Y5O01WO VVECB0ShxoUMlNd+sGfcRsFfHavClHwUygMkkgjdlaIeHMWWCSwYOvnLfoUQF3pqdFVB 36hwfGKgG4Zawemcrs51AliQkJ9SpBr5wVVrqvPFWMb6mT5T4jMzA90fz8crsA/9ndf5 89DqO0Ft9Hy/rdrSqFH5ivkS09g+DxE49esXlWH5GPgnDZxFHbygjaDdkcOlY3lTV/fL w1cA== X-Gm-Message-State: AFqh2kqCOqmkd4MHwmZX4gaVLrcyuobFCoe/0FeCAFtJ2EAzueXbIWtj oJJjGgePQD3KX5ngEi47A827FA== X-Received: by 2002:a05:600c:1906:b0:3da:1d51:ef9d with SMTP id j6-20020a05600c190600b003da1d51ef9dmr11323730wmq.15.1674146370951; Thu, 19 Jan 2023 08:39:30 -0800 (PST) Received: from [192.168.10.46] (146725694.box.freepro.com. [130.180.211.218]) by smtp.googlemail.com with ESMTPSA id l36-20020a05600c1d2400b003d1e1f421bfsm6274378wms.10.2023.01.19.08.39.30 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 19 Jan 2023 08:39:30 -0800 (PST) Message-ID: <54674d67-7be3-0abc-4252-e7f4158f56f2@linaro.org> Date: Thu, 19 Jan 2023 17:39:29 +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> <1313b9b6-45f0-aad1-9a3f-c5e1e3636697@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 16:05, Rafael J. Wysocki wrote: > On Thu, Jan 19, 2023 at 3:13 PM Daniel Lezcano > wrote: >> >> 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 ? > > I suppose so. > > And we'd like it to be used some places like > thermal_zone_device_register_with_trips(), wouldn't we? Yes, in thermal_zone_device_register_with_trips() and thermal_cooling_device_register(). -- Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog