Linux-fbdev Archive mirror
 help / color / mirror / Atom feed
From: "Ricardo B. Marliere" <ricardo@marliere.net>
To: "Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
	"Maxime Ripard" <mripard@kernel.org>,
	"Thomas Zimmermann" <tzimmermann@suse.de>,
	"David Airlie" <airlied@gmail.com>,
	"Daniel Vetter" <daniel@ffwll.ch>,
	"Hans de Goede" <hdegoede@redhat.com>,
	"Helge Deller" <deller@gmx.de>,
	"Sumit Semwal" <sumit.semwal@linaro.org>,
	"Benjamin Gaignard" <benjamin.gaignard@collabora.com>,
	"Brian Starkey" <Brian.Starkey@arm.com>,
	"John Stultz" <jstultz@google.com>,
	"T.J. Mercier" <tjmercier@google.com>,
	"Christian König" <christian.koenig@amd.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	 dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
	 linux-fbdev@vger.kernel.org, linux-media@vger.kernel.org,
	 linaro-mm-sig@lists.linaro.org,
	 "Ricardo B. Marliere" <ricardo@marliere.net>
Subject: [PATCH RESEND drm-misc 1/4] drm/dp: make drm_dp_aux_dev_class constant
Date: Tue, 05 Mar 2024 08:34:10 -0300	[thread overview]
Message-ID: <20240305-class_cleanup-drm-v1-1-94f82740525a@marliere.net> (raw)
In-Reply-To: <20240305-class_cleanup-drm-v1-0-94f82740525a@marliere.net>

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@linuxfoundation.org>
Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Ricardo B. Marliere <ricardo@marliere.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


  reply	other threads:[~2024-03-05 11:34 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-05 11:34 [PATCH RESEND drm-misc 0/4] drm: constify struct class usage Ricardo B. Marliere
2024-03-05 11:34 ` Ricardo B. Marliere [this message]
2024-03-05 11:34 ` [PATCH RESEND drm-misc 2/4] drm/sysfs: make drm_class constant Ricardo B. Marliere
2024-03-05 11:34 ` [PATCH RESEND drm-misc 3/4] drm/fbdev/core: make fb_class constant Ricardo B. Marliere
2024-03-05 11:34 ` [PATCH RESEND drm-misc 4/4] dma-buf: heaps: make dma_heap_class constant Ricardo B. Marliere
2024-03-05 17:07   ` T.J. Mercier
2024-03-05 18:02     ` Ricardo B. Marliere
2024-03-05 18:36       ` T.J. Mercier
2024-03-07  7:37     ` Sumit Semwal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240305-class_cleanup-drm-v1-1-94f82740525a@marliere.net \
    --to=ricardo@marliere.net \
    --cc=Brian.Starkey@arm.com \
    --cc=airlied@gmail.com \
    --cc=benjamin.gaignard@collabora.com \
    --cc=christian.koenig@amd.com \
    --cc=daniel@ffwll.ch \
    --cc=deller@gmx.de \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=hdegoede@redhat.com \
    --cc=jstultz@google.com \
    --cc=linaro-mm-sig@lists.linaro.org \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=sumit.semwal@linaro.org \
    --cc=tjmercier@google.com \
    --cc=tzimmermann@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).