From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.16]) (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 115D8187FE0; Tue, 29 Oct 2024 10:06:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.16 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730196404; cv=none; b=d0ozz1oiImF57m5NEciGsBjvdIOPgirWw1hBqOxku4MsNAjhLA9tzHkmRy4JblWYdaXNoegw8197WwjZfbxwpsu8eZgsSFC1T8atlpInBztSE/NfPyUKzzxATovJXM/MCXaXh/hm2UaiVulsZPaozxF3QJf2hRbRxsz/YtMTqco= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730196404; c=relaxed/simple; bh=ALT9A3sQ5Y4md6I1DY1tRYdezpyKZu0ORjTnspRxHZI=; h=From:Date:To:cc:Subject:In-Reply-To:Message-ID:References: MIME-Version:Content-Type; b=Iw2U8ukc7qjGnpqcUgM/L4LNSAnLcmlZDfPjsBZK4kQT462Pcj13nQVuRmA1SV149PzBi+Ssy2xUK7/j78WuPEJUplsddDej+xCCD+R67O++2E1uGjdFZCRNGY0uPEArqI8tzza9UJhniO7JxBcYmYZfZDEZ4RSBZGLg0hxIo1E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=D/mt/1ty; arc=none smtp.client-ip=198.175.65.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="D/mt/1ty" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1730196404; x=1761732404; h=from:date:to:cc:subject:in-reply-to:message-id: references:mime-version; bh=ALT9A3sQ5Y4md6I1DY1tRYdezpyKZu0ORjTnspRxHZI=; b=D/mt/1tyJbYsc8Fvp/cJfbOD4pB9n52/GUkor6VTDIAtJarOfeVxn2MS QegFrTPw7RoGXgVjWmkyfq6N2qXMMTMPu7OrZAq1wkK43O6QsAYvHY7ak AtLMW3GFZlLyo2s6TT6oEQ9MdikxtA82+gCa1wMAvWtSXgzKycIhQ6uYc Axt3vY6TmxxwYaKIWOQCUEDPya+fpJMqFN7eDd/m6f5FfHhftWIVZNZ3C jfJzpmoE+NaBnm0NSYjz+lp0P7w1ZqPf+IzWoQq+AtNtipRHQChAVfvCO Q3kVlu9anWEpCM6YvbIXvTmijuRVADtWWnYTQUe618+4bvWb41TKlyKF/ g==; X-CSE-ConnectionGUID: ZbihmPPsQGWdWxO8jXCwww== X-CSE-MsgGUID: GubRRJv6RvOK6FvTBagjAg== X-IronPort-AV: E=McAfee;i="6700,10204,11222"; a="29966971" X-IronPort-AV: E=Sophos;i="6.11,199,1725346800"; d="scan'208";a="29966971" Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by orvoesa108.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Oct 2024 03:06:43 -0700 X-CSE-ConnectionGUID: /ByS0/uCSJyNAfrJ3/2dmg== X-CSE-MsgGUID: fIHuh1rVR6O5/pjdIVrJRQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,241,1725346800"; d="scan'208";a="82237442" Received: from ijarvine-mobl1.ger.corp.intel.com (HELO localhost) ([10.245.244.83]) by fmviesa010-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Oct 2024 03:06:36 -0700 From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Date: Tue, 29 Oct 2024 12:06:33 +0200 (EET) To: Mario Limonciello cc: Hans de Goede , "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 , =?ISO-8859-15?Q?Uwe_Kleine-K=F6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz Subject: Re: [PATCH 6/8] ACPI: platform_profile: Only remove group when no more handler registered In-Reply-To: <20241025193055.2235-7-mario.limonciello@amd.com> Message-ID: <2816f1b2-b6ea-05eb-f2ce-a0c07093f146@linux.intel.com> References: <20241025193055.2235-1-mario.limonciello@amd.com> <20241025193055.2235-7-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII On Fri, 25 Oct 2024, Mario Limonciello wrote: > As multiple handlers may register for ACPI platform profile handler, > only remove the sysfs group when the last one unregisters. > > Tested-by: Matthew Schwartz > Signed-off-by: Mario Limonciello > --- > drivers/acpi/platform_profile.c | 13 ++++++++++++- > 1 file changed, 12 insertions(+), 1 deletion(-) > > diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c > index 81928adccfade..091ca6941a925 100644 > --- a/drivers/acpi/platform_profile.c > +++ b/drivers/acpi/platform_profile.c > @@ -23,6 +23,15 @@ static const char * const profile_names[] = { > }; > static_assert(ARRAY_SIZE(profile_names) == PLATFORM_PROFILE_LAST); > > +static bool platform_profile_is_registered(void) > +{ > + struct list_head *pos; > + int count = 0; > + list_for_each(pos, &platform_profile_handler_list) > + count++; > + return count > 0; return !list_empty(&platform_profile_handler_list) ? > +} > + > static ssize_t platform_profile_choices_show(struct device *dev, > struct device_attribute *attr, > char *buf) > @@ -206,8 +215,10 @@ int platform_profile_remove(struct platform_profile_handler *pprof) > > list_del(&pprof->list); > > - sysfs_remove_group(acpi_kobj, &platform_profile_group); > cur_profile = NULL; > + if (!platform_profile_is_registered()) > + sysfs_remove_group(acpi_kobj, &platform_profile_group); > + > return 0; > } > EXPORT_SYMBOL_GPL(platform_profile_remove); > -- i.