lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240305-class_cleanup-drm-v1-1-94f82740525a@marliere.net>
Date: Tue, 05 Mar 2024 08:34:10 -0300
From: "Ricardo B. Marliere" <ricardo@...liere.net>
To: Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>, 
 Maxime Ripard <mripard@...nel.org>, Thomas Zimmermann <tzimmermann@...e.de>, 
 David Airlie <airlied@...il.com>, Daniel Vetter <daniel@...ll.ch>, 
 Hans de Goede <hdegoede@...hat.com>, Helge Deller <deller@....de>, 
 Sumit Semwal <sumit.semwal@...aro.org>, 
 Benjamin Gaignard <benjamin.gaignard@...labora.com>, 
 Brian Starkey <Brian.Starkey@....com>, John Stultz <jstultz@...gle.com>, 
 "T.J. Mercier" <tjmercier@...gle.com>, 
 Christian König <christian.koenig@....com>
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>, 
 dri-devel@...ts.freedesktop.org, linux-kernel@...r.kernel.org, 
 linux-fbdev@...r.kernel.org, linux-media@...r.kernel.org, 
 linaro-mm-sig@...ts.linaro.org, 
 "Ricardo B. Marliere" <ricardo@...liere.net>
Subject: [PATCH RESEND drm-misc 1/4] drm/dp: make drm_dp_aux_dev_class
 constant

Since commit 43a7206b0963 ("driver core: class: make class_register() take
a const *"), the driver core allows for struct class to be in read-only
memory, so move the drm_dp_aux_dev_class structure to be declared at build
time placing it into read-only memory, instead of having to be dynamically
allocated at boot time.

Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Suggested-by: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Signed-off-by: Ricardo B. Marliere <ricardo@...liere.net>
---
 drivers/gpu/drm/display/drm_dp_aux_dev.c | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/display/drm_dp_aux_dev.c b/drivers/gpu/drm/display/drm_dp_aux_dev.c
index 29555b9f03c8..213abde5b09f 100644
--- a/drivers/gpu/drm/display/drm_dp_aux_dev.c
+++ b/drivers/gpu/drm/display/drm_dp_aux_dev.c
@@ -54,7 +54,6 @@ struct drm_dp_aux_dev {
 #define AUX_MAX_OFFSET	(1 << 20)
 static DEFINE_IDR(aux_idr);
 static DEFINE_MUTEX(aux_idr_mutex);
-static struct class *drm_dp_aux_dev_class;
 static int drm_dev_major = -1;
 
 static struct drm_dp_aux_dev *drm_dp_aux_dev_get_by_minor(unsigned index)
@@ -125,6 +124,11 @@ static struct attribute *drm_dp_aux_attrs[] = {
 };
 ATTRIBUTE_GROUPS(drm_dp_aux);
 
+static const struct class drm_dp_aux_dev_class = {
+	.name = "drm_dp_aux_dev",
+	.dev_groups = drm_dp_aux_groups,
+};
+
 static int auxdev_open(struct inode *inode, struct file *file)
 {
 	unsigned int minor = iminor(inode);
@@ -293,7 +297,7 @@ void drm_dp_aux_unregister_devnode(struct drm_dp_aux *aux)
 
 	minor = aux_dev->index;
 	if (aux_dev->dev)
-		device_destroy(drm_dp_aux_dev_class,
+		device_destroy(&drm_dp_aux_dev_class,
 			       MKDEV(drm_dev_major, minor));
 
 	DRM_DEBUG("drm_dp_aux_dev: aux [%s] unregistering\n", aux->name);
@@ -309,7 +313,7 @@ int drm_dp_aux_register_devnode(struct drm_dp_aux *aux)
 	if (IS_ERR(aux_dev))
 		return PTR_ERR(aux_dev);
 
-	aux_dev->dev = device_create(drm_dp_aux_dev_class, aux->dev,
+	aux_dev->dev = device_create(&drm_dp_aux_dev_class, aux->dev,
 				     MKDEV(drm_dev_major, aux_dev->index), NULL,
 				     "drm_dp_aux%d", aux_dev->index);
 	if (IS_ERR(aux_dev->dev)) {
@@ -330,11 +334,9 @@ int drm_dp_aux_dev_init(void)
 {
 	int res;
 
-	drm_dp_aux_dev_class = class_create("drm_dp_aux_dev");
-	if (IS_ERR(drm_dp_aux_dev_class)) {
-		return PTR_ERR(drm_dp_aux_dev_class);
-	}
-	drm_dp_aux_dev_class->dev_groups = drm_dp_aux_groups;
+	res = class_register(&drm_dp_aux_dev_class);
+	if (res)
+		return res;
 
 	res = register_chrdev(0, "aux", &auxdev_fops);
 	if (res < 0)
@@ -343,12 +345,12 @@ int drm_dp_aux_dev_init(void)
 
 	return 0;
 out:
-	class_destroy(drm_dp_aux_dev_class);
+	class_unregister(&drm_dp_aux_dev_class);
 	return res;
 }
 
 void drm_dp_aux_dev_exit(void)
 {
 	unregister_chrdev(drm_dev_major, "aux");
-	class_destroy(drm_dp_aux_dev_class);
+	class_unregister(&drm_dp_aux_dev_class);
 }

-- 
2.43.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ