From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from fhigh-b1-smtp.messagingengine.com (fhigh-b1-smtp.messagingengine.com [202.12.124.152]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6AD921CCB34; Mon, 28 Oct 2024 10:10:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.152 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730110254; cv=none; b=egklRHEg1vz68pEP7VkC3TSP9p8sOi+iflXHm9QRXfx2i9qFOPNBBwtOm2cHasYFSoPVNhWWQmbYyKMng/4GOAraFKl+0rATIzr/JU66GwZZ5zfg2kGEjk7aHL2x/1kXwvlZO5IMT1tSN+DID1AoN5f9UrqeGnpErKtitojY7NQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730110254; c=relaxed/simple; bh=suhY7JzHcnxAB4X0N8051t7f613gB6CeMqDIXcWYUw4=; h=MIME-Version:Date:From:To:Cc:Message-Id:In-Reply-To:References: Subject:Content-Type; b=rxFsbCO3QEG4zvwUAb5MzGNlPS7i+cje5JbVdkfOUi0999R4eHzy3DYuwCMLq4pHiWFbTGKmFXPMnOJpIXwnAb5bJ0bFdXCEN1AVAzcm/iAkAn/huFZ0Vu8NpUQPsoMORiuXny5BZYl1j5936ZVKK4FKfNa6c3xLwuUY+ihx8do= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=squebb.ca; spf=pass smtp.mailfrom=squebb.ca; dkim=pass (2048-bit key) header.d=squebb.ca header.i=@squebb.ca header.b=G1uZnGi8; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=ItjedI2I; arc=none smtp.client-ip=202.12.124.152 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=squebb.ca Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=squebb.ca Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=squebb.ca header.i=@squebb.ca header.b="G1uZnGi8"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="ItjedI2I" Received: from phl-compute-02.internal (phl-compute-02.phl.internal [10.202.2.42]) by mailfhigh.stl.internal (Postfix) with ESMTP id 3DC4625400C4; Mon, 28 Oct 2024 06:10:51 -0400 (EDT) Received: from phl-imap-10 ([10.202.2.85]) by phl-compute-02.internal (MEProxy); Mon, 28 Oct 2024 06:10:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=squebb.ca; h=cc :cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm1; t=1730110251; x=1730196651; bh=mkCCNsasirTb2gwbpaxzIv4zvvheu4d4dmMbXzeZbwM=; b= G1uZnGi8tOj2Tc0gOX4lv35M0u9wABHEpAeWLLB54RrVLtA3zPREUXHnQi2Vi5lb esiIL2QcHagSih6gyl+R4vt4j2CP4Kk1leJkbILlSRXN8vNBrZDM1RgSzt9hGQq9 wJIPIgooOzZHUmkvngwQaNn7DZ7za3xyM8AB7B9+Nl5+vhmIOFlVV33cqutIdCiS vZmy+SBxwp4OywZJ+RidSZN0AK2qcCzGHRVQTtIX5vWscaux0dIg6ctUZl+ik1h3 dz/5TycMKy57lDBX4Wj6xqWKGVNd9TGghSzlRgbkfKwNskIWZUzZYn2mJuHOpC8c MHbiwDs9l0GafbklAPCC8Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1730110251; x= 1730196651; bh=mkCCNsasirTb2gwbpaxzIv4zvvheu4d4dmMbXzeZbwM=; b=I tjedI2IVm6uDHa4PAaYKBF9DRtLQ7iaiTVs3dwVUQ5FHCDzH0Pr8df3s1VPrNEoz C0d4HzXKjywmNZUsY7K2YGuDG9TMAI2Xp2V+h7aTFknHp7+yox7HtVOEuiLyASkG noZtn+tLJUuVL5F0CMSddca4MhO2Zeg9+GS5QoBInnBA4yQWaQsaIru8QZxXUA2x fRp5KOb2h12QO7Z52KbVoR4+MQ1tzj3uWaXDIIVWUBOTR9Ny6fxjhjR3RL6q7NLX 4KyEgAPmKe9G954ax5wC1Ku+nZImUy2JjqWhEl9fKPix0mVy7Niei/erd/hfPiLb AoL0F5prxmzFuRaXZIzGw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrvdejkedgudduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnh htshculddquddttddmnecujfgurhepofggfffhvfevkfgjfhfutgfgsehtjeertdertddt necuhfhrohhmpedfofgrrhhkucfrvggrrhhsohhnfdcuoehmphgvrghrshhonhdqlhgvnh hovhhosehsqhhuvggssgdrtggrqeenucggtffrrghtthgvrhhnpefhuedvheetgeehtdeh tdevheduvdejjefggfeijedvgeekhfefleehkeehvdffheenucevlhhushhtvghrufhiii gvpeefnecurfgrrhgrmhepmhgrihhlfhhrohhmpehmphgvrghrshhonhdqlhgvnhhovhho sehsqhhuvggssgdrtggrpdhnsggprhgtphhtthhopedvuddpmhhouggvpehsmhhtphhouh htpdhrtghpthhtohepshhhhigrmhdqshhunhgurghrrdhsqdhksegrmhgurdgtohhmpdhr tghpthhtohepmhgrrhhiohdrlhhimhhonhgtihgvlhhlohesrghmugdrtghomhdprhgtph htthhopehikhgvrdhprghnsegtrghnohhnihgtrghlrdgtohhmpdhrtghpthhtoheprghl vgigsggvlhhmgeeksehgmhgrihhlrdgtohhmpdhrtghpthhtoheptghorhgvnhhtihhnrd gthhgrrhihsehgmhgrihhlrdgtohhmpdhrtghpthhtoheplhhuiihmrgigihhmihhlihgr nhesghhmrghilhdrtghomhdprhgtphhtthhopehhmhhhsehhmhhhrdgvnhhgrdgsrhdprh gtphhtthhopehsohihvghrsehirhhlrdhhuhdprhgtphhtthhopehlvghnsgeskhgvrhhn vghlrdhorhhg X-ME-Proxy: Feedback-ID: ibe194615:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id E16813C0066; Mon, 28 Oct 2024 06:10:49 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Mon, 28 Oct 2024 06:10:29 -0400 From: "Mark Pearson" To: "Limonciello, Mario" , "Hans de Goede" , =?UTF-8?Q?Ilpo_J=C3=A4rvinen?= Cc: "Rafael J. Wysocki" , "Len Brown" , "Maximilian Luz" , "Lee Chun-Yi" , "Shyam Sundar S K" , "Corentin Chary" , "Luke D . Jones" , "Ike Panhc" , "Henrique de Moraes Holschuh" , "Alexis Belmonte" , =?UTF-8?Q?Uwe_Kleine-K=C3=B6nig?= , "Ai Chao" , "Gergo Koteles" , "open list" , "linux-acpi@vger.kernel.org" , "platform-driver-x86@vger.kernel.org" , "open list:THINKPAD ACPI EXTRAS DRIVER" , "Matthew Schwartz" Message-Id: In-Reply-To: <20241025193055.2235-6-mario.limonciello@amd.com> References: <20241025193055.2235-1-mario.limonciello@amd.com> <20241025193055.2235-6-mario.limonciello@amd.com> Subject: Re: [PATCH 5/8] ACPI: platform_profile: Use guard(mutex) for register/unregister Content-Type: text/plain Content-Transfer-Encoding: 7bit On Fri, Oct 25, 2024, at 3:30 PM, Mario Limonciello wrote: > guard(mutex) can be used to automatically release mutexes when going > out of scope. > > Tested-by: Matthew Schwartz > Signed-off-by: Mario Limonciello > --- > drivers/acpi/platform_profile.c | 19 ++++++------------- > 1 file changed, 6 insertions(+), 13 deletions(-) > > diff --git a/drivers/acpi/platform_profile.c > b/drivers/acpi/platform_profile.c > index 0c60fc970b6e8..81928adccfade 100644 > --- a/drivers/acpi/platform_profile.c > +++ b/drivers/acpi/platform_profile.c > @@ -180,41 +180,34 @@ int platform_profile_register(struct > platform_profile_handler *pprof) > { > int err; > > - mutex_lock(&profile_lock); > + guard(mutex)(&profile_lock); > /* We can only have one active profile */ > - if (cur_profile) { > - mutex_unlock(&profile_lock); > + if (cur_profile) > return -EEXIST; > - } > > /* Sanity check the profile handler field are set */ > if (!pprof || bitmap_empty(pprof->choices, PLATFORM_PROFILE_LAST) || > - !pprof->profile_set || !pprof->profile_get) { > - mutex_unlock(&profile_lock); > + !pprof->profile_set || !pprof->profile_get) > return -EINVAL; > - } > > err = sysfs_create_group(acpi_kobj, &platform_profile_group); > - if (err) { > - mutex_unlock(&profile_lock); > + if (err) > return err; > - } > list_add_tail(&pprof->list, &platform_profile_handler_list); > > cur_profile = pprof; > - mutex_unlock(&profile_lock); > return 0; > } > EXPORT_SYMBOL_GPL(platform_profile_register); > > int platform_profile_remove(struct platform_profile_handler *pprof) > { > + guard(mutex)(&profile_lock); > + > list_del(&pprof->list); > > sysfs_remove_group(acpi_kobj, &platform_profile_group); > - mutex_lock(&profile_lock); > cur_profile = NULL; > - mutex_unlock(&profile_lock); > return 0; > } > EXPORT_SYMBOL_GPL(platform_profile_remove); > -- > 2.43.0 Looks good to me. Reviewed-by: Mark Pearson Mark