From patchwork Fri Jan 3 23:05:09 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 13926003 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (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 7CD4D1C3F13; Fri, 3 Jan 2025 23:05:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735945523; cv=none; b=Pv+kNBl45qGPYttma3L2YVWhYdFy+fFmZz+7uzTbRj6B+2B2TI1oIMB0mC7vNAIvPdau9NbMmJWIjFV/tbNqvJsxBFvFFHdAAYpKGkJyJWfKksiaufFnzN5/8+vN6DmpVLMFF6WiPKy6Ms2IUOVoDIb1rZh4FNH/BH2muLJn4rU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735945523; c=relaxed/simple; bh=KY+VV+ArU3kCRd4UFRbhENoyrPPNBvUKfm4XfLamlco=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=R/2YT2uF5pzAkYETyGI+pMJMMjCCGVqMaMZNelEm32pey+8Ylb2fIwixve81oizgszvZJs11ujYLgUOT++8/+XMabpWVSY3mPHh6bUAJ0uPFmDed9ijDnbbTQNpj3iP0q24qdXZ8c6rrpbwCrdTG2DiaOYPB8VvjFS2xafEbmVo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=Df2UYJkv; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="Df2UYJkv" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1735945513; bh=KY+VV+ArU3kCRd4UFRbhENoyrPPNBvUKfm4XfLamlco=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Df2UYJkvioy5sqOhka7k7Xwk96fbJD/tYsaT1J3ikVJ3elJI2olIk0+Y8Aegvxbp+ qZvDnMUkuzMOwX3t4jL77zgJ33QesJO72EYTww+obOQzP17XE9AYlSjJR+KebopDaM sW/HTnrNzdHloMuyuz/EKAu4dTA09lhj12JNq15g= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Sat, 04 Jan 2025 00:05:09 +0100 Subject: [PATCH 1/6] platform/x86: firmware_attributes_class: Move include linux/device/class.h Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250104-firmware-attributes-simplify-v1-1-949f9709e405@weissschuh.net> References: <20250104-firmware-attributes-simplify-v1-0-949f9709e405@weissschuh.net> In-Reply-To: <20250104-firmware-attributes-simplify-v1-0-949f9709e405@weissschuh.net> To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Mark Pearson , Jorge Lopez , Prasanth Ksr Cc: Joshua Grisham , platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, Dell.Client.Kernel@dell.com, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1735945513; l=1427; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=KY+VV+ArU3kCRd4UFRbhENoyrPPNBvUKfm4XfLamlco=; b=4jiawZNmyM8uz291smGk0DmOykhs15VQTG/FymhGUPRv/nUeBWyfRglsqJ5eR3XEKnIsHv8GB S9NlgJk6yy4AvPwrtwu8Jzegr86Cwmb6/yzU+mYiaE4KpzMFEwJIThP X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= The header firmware_attributes_class.h uses 'struct class'. It should also include the necessary dependency header. Signed-off-by: Thomas Weißschuh Reviewed-by: Armin Wolf --- drivers/platform/x86/firmware_attributes_class.c | 1 - drivers/platform/x86/firmware_attributes_class.h | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/platform/x86/firmware_attributes_class.c b/drivers/platform/x86/firmware_attributes_class.c index 182a07d8ae3dfa8925bb5b71a43d0219c3cf0fa0..cbc56e5db59283ba99ac0b915ac5fb2432afbdc9 100644 --- a/drivers/platform/x86/firmware_attributes_class.c +++ b/drivers/platform/x86/firmware_attributes_class.c @@ -3,7 +3,6 @@ /* Firmware attributes class helper module */ #include -#include #include #include "firmware_attributes_class.h" diff --git a/drivers/platform/x86/firmware_attributes_class.h b/drivers/platform/x86/firmware_attributes_class.h index 363c75f1ac1b89df879a8689b070e6b11d3bb7fd..8e0f47cfdf92eb4dc8722b7d8371916af0d84efa 100644 --- a/drivers/platform/x86/firmware_attributes_class.h +++ b/drivers/platform/x86/firmware_attributes_class.h @@ -5,6 +5,8 @@ #ifndef FW_ATTR_CLASS_H #define FW_ATTR_CLASS_H +#include + int fw_attributes_class_get(const struct class **fw_attr_class); int fw_attributes_class_put(void); From patchwork Fri Jan 3 23:05:10 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 13926001 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (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 B1B5A1C1F25; Fri, 3 Jan 2025 23:05:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735945520; cv=none; b=h7oahFUhFwCQX6LPd0krhmHRd0HF+38+bPrdi6fbvNyo/RMwdeeE0u9rDM1SDkYWgohcrX4zGD1RPo0v9XDSOdW7LnIvnBD+9olf7z5nJ3mEd/oF5HC3wliETm52OzNs6i5xl/uXq07Dy1wXtHLTAqwq5mjQmASSFob0cxQzpx0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735945520; c=relaxed/simple; bh=h/7xxDMHCuHgQRO1fVetToEREOiCIlqUj4Ypa1zfWFc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=aFQZeVdWVcB33pMoFmORYjdSldBzMR95ffA7c3Q8BX5bsEvxG4aaGShQ2sB9mgneZFpVXcqgnjD/hyJqibGBrwd2Db+IJJC+3fLWMjEprw5R9uclQMQ24oKbYbEbIe0a/raEHCrqm4stZCwzSW9RxXKg5Sg6MjBgIn9muDXTAAw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=p2UlfER/; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="p2UlfER/" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1735945513; bh=h/7xxDMHCuHgQRO1fVetToEREOiCIlqUj4Ypa1zfWFc=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=p2UlfER/g9QxyczO9XH5crGFBhuM31PodSossURTo7mcAAnCwpd9d76NzSbs3xfHc ZOzk7ncuRG2d387m4LYzyA0aTXGorHmTmUFbixSsX3Ke30voadjpC9C/XTuwCAnDM7 +HvtLyNaawD/hPg2uDTSIeqJUgWHPxXFflLYPWpo= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Sat, 04 Jan 2025 00:05:10 +0100 Subject: [PATCH 2/6] platform/x86: firmware_attributes_class: Simplify API Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250104-firmware-attributes-simplify-v1-2-949f9709e405@weissschuh.net> References: <20250104-firmware-attributes-simplify-v1-0-949f9709e405@weissschuh.net> In-Reply-To: <20250104-firmware-attributes-simplify-v1-0-949f9709e405@weissschuh.net> To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Mark Pearson , Jorge Lopez , Prasanth Ksr Cc: Joshua Grisham , platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, Dell.Client.Kernel@dell.com, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1735945513; l=3277; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=h/7xxDMHCuHgQRO1fVetToEREOiCIlqUj4Ypa1zfWFc=; b=qvZ9Cf05LaRkooqj+2iTwvqEowZaXfrVuv690CFopE/BSQ4kJYhyOVdyN8vbLtdrYv5Tdnx5E Peb6eqT1s1BCRMxrtRYPJafRMKPHFixBwIh8XI3XpvACRGOujRINtn8 X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= The module core already guarantees that a module can only be unloaded after all other modules using its symbols have been unloaded. As it's already the responsibility of the drivers using firmware_attributes_class to clean up their devices before unloading, the lifetime of the firmware_attributes_class can be bound to the lifetime of the module. This enables the direct usage of firmware_attributes_class from the drivers, without having to go through the lifecycle functions, leading to simplifications for both the subsystem and its users. Signed-off-by: Thomas Weißschuh --- drivers/platform/x86/firmware_attributes_class.c | 40 +++++++++--------------- drivers/platform/x86/firmware_attributes_class.h | 1 + 2 files changed, 15 insertions(+), 26 deletions(-) diff --git a/drivers/platform/x86/firmware_attributes_class.c b/drivers/platform/x86/firmware_attributes_class.c index cbc56e5db59283ba99ac0b915ac5fb2432afbdc9..87672c49e86ae3ef5b99aa99be532c1d84805adc 100644 --- a/drivers/platform/x86/firmware_attributes_class.c +++ b/drivers/platform/x86/firmware_attributes_class.c @@ -2,47 +2,35 @@ /* Firmware attributes class helper module */ -#include #include #include "firmware_attributes_class.h" -static DEFINE_MUTEX(fw_attr_lock); -static int fw_attr_inuse; - -static const struct class firmware_attributes_class = { +const struct class firmware_attributes_class = { .name = "firmware-attributes", }; +EXPORT_SYMBOL_GPL(firmware_attributes_class); + +static __init int fw_attributes_class_init(void) +{ + return class_register(&firmware_attributes_class); +} +module_init(fw_attributes_class_init); + +static __exit void fw_attributes_class_exit(void) +{ + class_unregister(&firmware_attributes_class); +} +module_exit(fw_attributes_class_exit); int fw_attributes_class_get(const struct class **fw_attr_class) { - int err; - - mutex_lock(&fw_attr_lock); - if (!fw_attr_inuse) { /*first time class is being used*/ - err = class_register(&firmware_attributes_class); - if (err) { - mutex_unlock(&fw_attr_lock); - return err; - } - } - fw_attr_inuse++; *fw_attr_class = &firmware_attributes_class; - mutex_unlock(&fw_attr_lock); return 0; } EXPORT_SYMBOL_GPL(fw_attributes_class_get); int fw_attributes_class_put(void) { - mutex_lock(&fw_attr_lock); - if (!fw_attr_inuse) { - mutex_unlock(&fw_attr_lock); - return -EINVAL; - } - fw_attr_inuse--; - if (!fw_attr_inuse) /* No more consumers */ - class_unregister(&firmware_attributes_class); - mutex_unlock(&fw_attr_lock); return 0; } EXPORT_SYMBOL_GPL(fw_attributes_class_put); diff --git a/drivers/platform/x86/firmware_attributes_class.h b/drivers/platform/x86/firmware_attributes_class.h index 8e0f47cfdf92eb4dc8722b7d8371916af0d84efa..ef6c3764a83497ad7e75b0102154c92ce476e5ae 100644 --- a/drivers/platform/x86/firmware_attributes_class.h +++ b/drivers/platform/x86/firmware_attributes_class.h @@ -7,6 +7,7 @@ #include +extern const struct class firmware_attributes_class; int fw_attributes_class_get(const struct class **fw_attr_class); int fw_attributes_class_put(void); From patchwork Fri Jan 3 23:05:11 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 13925999 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (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 576D31C233E; Fri, 3 Jan 2025 23:05:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735945520; cv=none; b=e9xp5hEkgB9L9qIhGaGz1AoJNeAf8i8qSCUCFWT0CpzHIi3nDWuNaasnDZ/uWV1seHRuc8WbPDPa+Z9U5GIJeafL2yXlohirZ+oYZG5yXVCqt5HjwOO6Jno3UwU1yvPeVJZHTbTK82ZuP81oFXE5/olKGSiQe8e1QFOpVx8lajo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735945520; c=relaxed/simple; bh=E7ejxYXjSdZnnJX5sX8/IXcBFjrKTYbqZ98oCMMDu48=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=hhekh3Rnec5RwwI89d5kJCwUaCbRXNBUSvCwlp/bc5Kfkod4rKXT3JTCbVu7LvXyD/WCnno7+ycEH2sDFtJvivbEMu3pR3ZAuhQUeKAtpqTpNMNAQ3R6fjr8tPegNTi6bN+/afB/Ywy7+xqkSHjpYWqI4Dzd4s8fqu4wmtKwzvA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=bMlhSuZ6; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="bMlhSuZ6" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1735945513; bh=E7ejxYXjSdZnnJX5sX8/IXcBFjrKTYbqZ98oCMMDu48=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=bMlhSuZ6jDps3/nGiXZfr8Qo1cpLqmp1nCRQLdpb78V/OL5pgfJcwIYa/CaOvQvD4 DUyCjhGLXdIJBxUKoQ782f00GslGRs4L2khi1OmNRpHcP7UctbELuEWVrJlPfEv+iW J6ayCgEfkwpT5eqzhubEglm7sJPEBGyVQNJhzkvI= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Sat, 04 Jan 2025 00:05:11 +0100 Subject: [PATCH 3/6] platform/x86: think-lmi: Directly use firmware_attributes_class Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250104-firmware-attributes-simplify-v1-3-949f9709e405@weissschuh.net> References: <20250104-firmware-attributes-simplify-v1-0-949f9709e405@weissschuh.net> In-Reply-To: <20250104-firmware-attributes-simplify-v1-0-949f9709e405@weissschuh.net> To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Mark Pearson , Jorge Lopez , Prasanth Ksr Cc: Joshua Grisham , platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, Dell.Client.Kernel@dell.com, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1735945513; l=1895; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=E7ejxYXjSdZnnJX5sX8/IXcBFjrKTYbqZ98oCMMDu48=; b=aWnDEvPI1inx2DMtb915hPLdi+vRiFSrPiA57zezpZyk5AbXtlwqnTtMksLEElPB+sSS5xTza 2Y+cGh2ZIC5CTG/QCKbGYwM91U4j08Z8pJ92ucLCreTybccLMpSPr+y X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= The usage of the lifecycle functions is not necessary anymore. Signed-off-by: Thomas Weißschuh --- drivers/platform/x86/think-lmi.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/drivers/platform/x86/think-lmi.c b/drivers/platform/x86/think-lmi.c index 38de0cb20d7785d4e3b490e07edaf4d02f8f3370..323316ac6783aa343c4c6430040a4af648786880 100644 --- a/drivers/platform/x86/think-lmi.c +++ b/drivers/platform/x86/think-lmi.c @@ -194,7 +194,6 @@ static const char * const level_options[] = { [TLMI_LEVEL_MASTER] = "master", }; static struct think_lmi tlmi_priv; -static const struct class *fw_attr_class; static DEFINE_MUTEX(tlmi_mutex); static inline struct tlmi_pwd_setting *to_tlmi_pwd_setting(struct kobject *kobj) @@ -1446,11 +1445,7 @@ static int tlmi_sysfs_init(void) { int i, ret; - ret = fw_attributes_class_get(&fw_attr_class); - if (ret) - return ret; - - tlmi_priv.class_dev = device_create(fw_attr_class, NULL, MKDEV(0, 0), + tlmi_priv.class_dev = device_create(&firmware_attributes_class, NULL, MKDEV(0, 0), NULL, "%s", "thinklmi"); if (IS_ERR(tlmi_priv.class_dev)) { ret = PTR_ERR(tlmi_priv.class_dev); @@ -1563,9 +1558,8 @@ static int tlmi_sysfs_init(void) fail_create_attr: tlmi_release_attr(); fail_device_created: - device_destroy(fw_attr_class, MKDEV(0, 0)); + device_destroy(&firmware_attributes_class, MKDEV(0, 0)); fail_class_created: - fw_attributes_class_put(); return ret; } @@ -1788,8 +1782,7 @@ static int tlmi_analyze(void) static void tlmi_remove(struct wmi_device *wdev) { tlmi_release_attr(); - device_destroy(fw_attr_class, MKDEV(0, 0)); - fw_attributes_class_put(); + device_destroy(&firmware_attributes_class, MKDEV(0, 0)); } static int tlmi_probe(struct wmi_device *wdev, const void *context) From patchwork Fri Jan 3 23:05:12 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 13926002 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (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 B1AAC1BEF99; Fri, 3 Jan 2025 23:05:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735945520; cv=none; b=BfJRcBQ8FlGhXdtJo9qz79N6p5P09uOJoB9HwDvtkgD+sQrIbTj49vt+q7jV8/EQx+Dar1jU9KFBLHoiPZeDNKF2W8x7mpvrnC4QYIE1y8W9dkzeO9aSpiGKn/yOvAohPd/YnaaZvcmX4xcKmRwmGf41bNMNtahxMysIH9mC7bk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735945520; c=relaxed/simple; bh=GuO0NT1ncu1pG9y3++xbJrVIn8xZ+9gpWgAO8XU1H5g=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=kZq+bo8LQmPRylWGMe+TeV7i0KgXXSrIzXgEg8cAIvpWBBr6s+9NcmuejEgq2WOIupKZH2qDY6Py8ynxFTqdAWDnk9LZAzLOjriPJJdJgG/A3UzqSp41zZhx6M5wVrYelQpJIi2CHsTb810sf9gly3VxY2W91qjCgktvNItJNc0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=dGZHS1uy; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="dGZHS1uy" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1735945513; bh=GuO0NT1ncu1pG9y3++xbJrVIn8xZ+9gpWgAO8XU1H5g=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=dGZHS1uy2/SkVeXiAgHzNhc5u6tYWIdw8tT/4aZAuPBsLuKbhtKCjQiEvSxO4X2k8 Xmd7DFs0ZF5iXcEQG8/49fVQ8ja4SHmZ4mrbYQErfA8CFJ8qmsMX0Qg66UIZ81/RJp ePpHuWDMajr5NK82Kg9Y/AvqUYWJ2XpQZEuVRumU= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Sat, 04 Jan 2025 00:05:12 +0100 Subject: [PATCH 4/6] platform/x86: hp-bioscfg: Directly use firmware_attributes_class Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250104-firmware-attributes-simplify-v1-4-949f9709e405@weissschuh.net> References: <20250104-firmware-attributes-simplify-v1-0-949f9709e405@weissschuh.net> In-Reply-To: <20250104-firmware-attributes-simplify-v1-0-949f9709e405@weissschuh.net> To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Mark Pearson , Jorge Lopez , Prasanth Ksr Cc: Joshua Grisham , platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, Dell.Client.Kernel@dell.com, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1735945513; l=1947; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=GuO0NT1ncu1pG9y3++xbJrVIn8xZ+9gpWgAO8XU1H5g=; b=XW5xd5Jjy8GU3IJVZBlrzRfA0vP5auYjrcB0KajssKlXjVx5y1qNf73XzvX//ZVCaNWSHYmte 3TcWQbhFraFCiV4hTJ2YxdSim5/5AACPjaUrBrpF50L8tp6wC6RmPUu X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= The usage of the lifecycle functions is not necessary anymore. Signed-off-by: Thomas Weißschuh --- drivers/platform/x86/hp/hp-bioscfg/bioscfg.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/drivers/platform/x86/hp/hp-bioscfg/bioscfg.c b/drivers/platform/x86/hp/hp-bioscfg/bioscfg.c index 2dc50152158a3dd0401d9d9e1de288c0d76ef937..0b277b7e37dd6b598e4fe5de6dc0ac47300a8e3b 100644 --- a/drivers/platform/x86/hp/hp-bioscfg/bioscfg.c +++ b/drivers/platform/x86/hp/hp-bioscfg/bioscfg.c @@ -24,8 +24,6 @@ struct bioscfg_priv bioscfg_drv = { .mutex = __MUTEX_INITIALIZER(bioscfg_drv.mutex), }; -static const struct class *fw_attr_class; - ssize_t display_name_language_code_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) @@ -972,11 +970,7 @@ static int __init hp_init(void) if (ret) return ret; - ret = fw_attributes_class_get(&fw_attr_class); - if (ret) - goto err_unregister_class; - - bioscfg_drv.class_dev = device_create(fw_attr_class, NULL, MKDEV(0, 0), + bioscfg_drv.class_dev = device_create(&firmware_attributes_class, NULL, MKDEV(0, 0), NULL, "%s", DRIVER_NAME); if (IS_ERR(bioscfg_drv.class_dev)) { ret = PTR_ERR(bioscfg_drv.class_dev); @@ -1043,10 +1037,9 @@ static int __init hp_init(void) release_attributes_data(); err_destroy_classdev: - device_destroy(fw_attr_class, MKDEV(0, 0)); + device_destroy(&firmware_attributes_class, MKDEV(0, 0)); err_unregister_class: - fw_attributes_class_put(); hp_exit_attr_set_interface(); return ret; @@ -1055,9 +1048,8 @@ static int __init hp_init(void) static void __exit hp_exit(void) { release_attributes_data(); - device_destroy(fw_attr_class, MKDEV(0, 0)); + device_destroy(&firmware_attributes_class, MKDEV(0, 0)); - fw_attributes_class_put(); hp_exit_attr_set_interface(); } From patchwork Fri Jan 3 23:05:13 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 13926000 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (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 186A31C2323; Fri, 3 Jan 2025 23:05:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735945520; cv=none; b=LA+BINOZHYsCanTrvQKIkXAJA7GGAbs3OjPjDvJBx2mSmTqAayfCGoSc1/phmsFp2hg3CfL6CZynDvahiZ58uz+iGDAsNyuA7gnm0sJulznfXRtSRcZJ/+P+qZSmMPPcEmMJzHiKZx82S96WvW7XBIMpi4QsEfYocwTetRota30= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735945520; c=relaxed/simple; bh=JQ7kRMXzxNmfVpw6i5f3Vnk2H901HuT/uZam75RPzGw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=UU2BTHafDrGYCxUDWoP7qH5yxc/q6GbBzwh7IzCQdsri7p7ATU5koCa79dVBKoHeBIWgPh2E5Dp0ko/Dij0cmHmzA+CDW6na3myfK6GpMKDcPoEy1K17Z5/l2ZQ2+4xm6Xd4tEyEDHtHpCmWYDqjo3P+PMXF5C4oPtGmqT5G/Mc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=nG9h5CO3; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="nG9h5CO3" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1735945514; bh=JQ7kRMXzxNmfVpw6i5f3Vnk2H901HuT/uZam75RPzGw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=nG9h5CO39Hm1438DnUtDRJirZQxiuJaTzrvEqXoTsavspO2E9Z6WPdhImFnbRzR4P mP5hJcVj5tDAu4Vm5rkPXis0PqB/lqC1EQ1QS83luQKF6PVybmzDLGSq8n5OVhYs7O 3pOMc0bDrCU0dUO5s6+ek01bUtYKWHBfJkskPydk= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Sat, 04 Jan 2025 00:05:13 +0100 Subject: [PATCH 5/6] platform/x86: dell-sysman: Directly use firmware_attributes_class Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250104-firmware-attributes-simplify-v1-5-949f9709e405@weissschuh.net> References: <20250104-firmware-attributes-simplify-v1-0-949f9709e405@weissschuh.net> In-Reply-To: <20250104-firmware-attributes-simplify-v1-0-949f9709e405@weissschuh.net> To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Mark Pearson , Jorge Lopez , Prasanth Ksr Cc: Joshua Grisham , platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, Dell.Client.Kernel@dell.com, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1735945513; l=2211; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=JQ7kRMXzxNmfVpw6i5f3Vnk2H901HuT/uZam75RPzGw=; b=Z84qWVCveD2c/3XaX8A7d+/XmPPsnbrjJLL3Eb4MiP51p+quVTSq54ft9PT0ngivW8AY9Q937 yWO9Kz5pcpHB1nbEcxHspkk1MMVN9bbYMl0VyaIT5KPP90Wr/Ojdg++ X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= The usage of the lifecycle functions is not necessary anymore. Signed-off-by: Thomas Weißschuh --- drivers/platform/x86/dell/dell-wmi-sysman/sysman.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c b/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c index 40ddc6eb75624e713dc4d2f7e92bc5f63fa4fde8..d00389b860e4ea0655c740c78bc3751f323b6370 100644 --- a/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c +++ b/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c @@ -25,7 +25,6 @@ struct wmi_sysman_priv wmi_priv = { /* reset bios to defaults */ static const char * const reset_types[] = {"builtinsafe", "lastknowngood", "factory", "custom"}; static int reset_option = -1; -static const struct class *fw_attr_class; /** @@ -541,15 +540,11 @@ static int __init sysman_init(void) goto err_exit_bios_attr_pass_interface; } - ret = fw_attributes_class_get(&fw_attr_class); - if (ret) - goto err_exit_bios_attr_pass_interface; - - wmi_priv.class_dev = device_create(fw_attr_class, NULL, MKDEV(0, 0), + wmi_priv.class_dev = device_create(&firmware_attributes_class, NULL, MKDEV(0, 0), NULL, "%s", DRIVER_NAME); if (IS_ERR(wmi_priv.class_dev)) { ret = PTR_ERR(wmi_priv.class_dev); - goto err_unregister_class; + goto err_exit_bios_attr_pass_interface; } wmi_priv.main_dir_kset = kset_create_and_add("attributes", NULL, @@ -602,10 +597,7 @@ static int __init sysman_init(void) release_attributes_data(); err_destroy_classdev: - device_destroy(fw_attr_class, MKDEV(0, 0)); - -err_unregister_class: - fw_attributes_class_put(); + device_destroy(&firmware_attributes_class, MKDEV(0, 0)); err_exit_bios_attr_pass_interface: exit_bios_attr_pass_interface(); @@ -619,8 +611,7 @@ static int __init sysman_init(void) static void __exit sysman_exit(void) { release_attributes_data(); - device_destroy(fw_attr_class, MKDEV(0, 0)); - fw_attributes_class_put(); + device_destroy(&firmware_attributes_class, MKDEV(0, 0)); exit_bios_attr_set_interface(); exit_bios_attr_pass_interface(); } From patchwork Fri Jan 3 23:05:14 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 13926004 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (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 7EC1F1D47BB; Fri, 3 Jan 2025 23:05:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735945524; cv=none; b=irC+EoAOJvBHVoTjZ8dNkZNvtnz2FuX6nyF/FpyoOc3oRs+LjvTh6KtqJOO50fJD0uKCL5S70MiG8BFgbND/LPvhRSzx7ptsF0MR3ck86sOX6LdPajDmhV8HygEQ0BETdH18FeeF1XzB45Q8tPBwM4o+G1zZeATQVUnlb/S12DM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735945524; c=relaxed/simple; bh=W4XeiZfPwpakoTQ4XvaiuCcehDB9+lh8TVJ9s6+5frU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=mH1XbKGaDQpmTRUK+9SIeKFedVl9FGfwUTwnP9B4bc8wxVlCGw+xC1pf77pslWu7Xp6yx5NyHi9IY/2MpYc9hBhaiCejSnKSed/+yLZH2uCW+kM7bdIIvETVFczgRVkKkk2Ze6/vpEBsXIJxr6c7SuiYYvLF9iPmcXb70EikT8k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=cFiEke0o; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="cFiEke0o" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1735945514; bh=W4XeiZfPwpakoTQ4XvaiuCcehDB9+lh8TVJ9s6+5frU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=cFiEke0oqjHmwWDWVIEGZ1almMWK5Fu8XVliKdiK1rO0N/itE/GAcZCuhTOoO8aIX ngIxOXxKXyrQyaLR/R03uR5k0SXrwFKuXprooXN72zM3qKe1qNLtKFKD4fZUIW+MfG fpwZwcEVzbhsD//DlH3F1EJp3rkiFfi5oL0QdaHM= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Sat, 04 Jan 2025 00:05:14 +0100 Subject: [PATCH 6/6] platform/x86: firmware_attributes_class: Drop lifecycle functions Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250104-firmware-attributes-simplify-v1-6-949f9709e405@weissschuh.net> References: <20250104-firmware-attributes-simplify-v1-0-949f9709e405@weissschuh.net> In-Reply-To: <20250104-firmware-attributes-simplify-v1-0-949f9709e405@weissschuh.net> To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Mark Pearson , Jorge Lopez , Prasanth Ksr Cc: Joshua Grisham , platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, Dell.Client.Kernel@dell.com, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1735945513; l=1720; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=W4XeiZfPwpakoTQ4XvaiuCcehDB9+lh8TVJ9s6+5frU=; b=SGkkS2bRjd3yedonV3Exlm3KZHfuIHuS4DLWOsIJkuafKdMW0HYy06q4MZXnFvr2bAZaPc3Kg n5ZZj4G9LjFDINHWUFBaVrSe6cuNfsZbvjB+vvRTpb3aLqqmHC0JAge X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= There are no users left. Signed-off-by: Thomas Weißschuh --- drivers/platform/x86/firmware_attributes_class.c | 13 ------------- drivers/platform/x86/firmware_attributes_class.h | 2 -- 2 files changed, 15 deletions(-) diff --git a/drivers/platform/x86/firmware_attributes_class.c b/drivers/platform/x86/firmware_attributes_class.c index 87672c49e86ae3ef5b99aa99be532c1d84805adc..736e96c186d9dc6d945517f090e9af903e93bbf4 100644 --- a/drivers/platform/x86/firmware_attributes_class.c +++ b/drivers/platform/x86/firmware_attributes_class.c @@ -22,19 +22,6 @@ static __exit void fw_attributes_class_exit(void) } module_exit(fw_attributes_class_exit); -int fw_attributes_class_get(const struct class **fw_attr_class) -{ - *fw_attr_class = &firmware_attributes_class; - return 0; -} -EXPORT_SYMBOL_GPL(fw_attributes_class_get); - -int fw_attributes_class_put(void) -{ - return 0; -} -EXPORT_SYMBOL_GPL(fw_attributes_class_put); - MODULE_AUTHOR("Mark Pearson "); MODULE_DESCRIPTION("Firmware attributes class helper module"); MODULE_LICENSE("GPL"); diff --git a/drivers/platform/x86/firmware_attributes_class.h b/drivers/platform/x86/firmware_attributes_class.h index ef6c3764a83497ad7e75b0102154c92ce476e5ae..d27abe54fcf9812a2f0868eec5426bbc8e7eb21c 100644 --- a/drivers/platform/x86/firmware_attributes_class.h +++ b/drivers/platform/x86/firmware_attributes_class.h @@ -8,7 +8,5 @@ #include extern const struct class firmware_attributes_class; -int fw_attributes_class_get(const struct class **fw_attr_class); -int fw_attributes_class_put(void); #endif /* FW_ATTR_CLASS_H */