This is a simple and straight forward cleanup series that aims to make the
class structures in drm constant. This has been possible since 2023 [1].
[1]: https://lore.kernel.org/all/2023040248-customary-release-4aec@gregkh/
Signed-off-by: Ricardo B. Marliere <[email protected]>
---
Ricardo B. Marliere (4):
drm/dp: make drm_dp_aux_dev_class constant
drm/sysfs: make drm_class constant
drm/fbdev/core: make fb_class constant
dma-buf: heaps: make dma_heap_class constant
drivers/dma-buf/dma-heap.c | 26 ++++++++++---------
drivers/gpu/drm/display/drm_dp_aux_dev.c | 22 ++++++++--------
drivers/gpu/drm/drm_internal.h | 2 +-
drivers/gpu/drm/drm_privacy_screen.c | 2 +-
drivers/gpu/drm/drm_sysfs.c | 44 ++++++++++++++------------------
drivers/video/fbdev/core/fb_internal.h | 2 +-
drivers/video/fbdev/core/fbcon.c | 4 +--
drivers/video/fbdev/core/fbmem.c | 17 ++++++------
drivers/video/fbdev/core/fbsysfs.c | 4 +--
9 files changed, 60 insertions(+), 63 deletions(-)
---
base-commit: 4a0e7b3c37531aabddf6f144b83ae9b65ec809fd
change-id: 20240305-class_cleanup-drm-591ca73b31f2
Best regards,
--
Ricardo B. Marliere <[email protected]>
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_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 <[email protected]>
Suggested-by: Greg Kroah-Hartman <[email protected]>
Signed-off-by: Ricardo B. Marliere <[email protected]>
---
drivers/gpu/drm/drm_internal.h | 2 +-
drivers/gpu/drm/drm_privacy_screen.c | 2 +-
drivers/gpu/drm/drm_sysfs.c | 44 ++++++++++++++++--------------------
3 files changed, 21 insertions(+), 27 deletions(-)
diff --git a/drivers/gpu/drm/drm_internal.h b/drivers/gpu/drm/drm_internal.h
index 8e4faf0a28e6..a881cd442a9b 100644
--- a/drivers/gpu/drm/drm_internal.h
+++ b/drivers/gpu/drm/drm_internal.h
@@ -142,7 +142,7 @@ bool drm_master_internal_acquire(struct drm_device *dev);
void drm_master_internal_release(struct drm_device *dev);
/* drm_sysfs.c */
-extern struct class *drm_class;
+extern const struct class drm_class;
int drm_sysfs_init(void);
void drm_sysfs_destroy(void);
diff --git a/drivers/gpu/drm/drm_privacy_screen.c b/drivers/gpu/drm/drm_privacy_screen.c
index 6cc39e30781f..2fbd24ba5818 100644
--- a/drivers/gpu/drm/drm_privacy_screen.c
+++ b/drivers/gpu/drm/drm_privacy_screen.c
@@ -401,7 +401,7 @@ struct drm_privacy_screen *drm_privacy_screen_register(
mutex_init(&priv->lock);
BLOCKING_INIT_NOTIFIER_HEAD(&priv->notifier_head);
- priv->dev.class = drm_class;
+ priv->dev.class = &drm_class;
priv->dev.type = &drm_privacy_screen_type;
priv->dev.parent = parent;
priv->dev.release = drm_privacy_screen_device_release;
diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c
index a953f69a34b6..90145f9256a2 100644
--- a/drivers/gpu/drm/drm_sysfs.c
+++ b/drivers/gpu/drm/drm_sysfs.c
@@ -58,7 +58,15 @@ static struct device_type drm_sysfs_device_connector = {
.name = "drm_connector",
};
-struct class *drm_class;
+static char *drm_devnode(const struct device *dev, umode_t *mode)
+{
+ return kasprintf(GFP_KERNEL, "dri/%s", dev_name(dev));
+}
+
+const struct class drm_class = {
+ .name = "drm",
+ .devnode = drm_devnode,
+};
#ifdef CONFIG_ACPI
static bool drm_connector_acpi_bus_match(struct device *dev)
@@ -93,11 +101,6 @@ static void drm_sysfs_acpi_register(void) { }
static void drm_sysfs_acpi_unregister(void) { }
#endif
-static char *drm_devnode(const struct device *dev, umode_t *mode)
-{
- return kasprintf(GFP_KERNEL, "dri/%s", dev_name(dev));
-}
-
static int typec_connector_bind(struct device *dev,
struct device *typec_connector, void *data)
{
@@ -142,19 +145,16 @@ int drm_sysfs_init(void)
{
int err;
- drm_class = class_create("drm");
- if (IS_ERR(drm_class))
- return PTR_ERR(drm_class);
+ err = class_register(&drm_class);
+ if (err)
+ return err;
- err = class_create_file(drm_class, &class_attr_version.attr);
+ err = class_create_file(&drm_class, &class_attr_version.attr);
if (err) {
- class_destroy(drm_class);
- drm_class = NULL;
+ class_unregister(&drm_class);
return err;
}
- drm_class->devnode = drm_devnode;
-
drm_sysfs_acpi_register();
return 0;
}
@@ -166,12 +166,9 @@ int drm_sysfs_init(void)
*/
void drm_sysfs_destroy(void)
{
- if (IS_ERR_OR_NULL(drm_class))
- return;
drm_sysfs_acpi_unregister();
- class_remove_file(drm_class, &class_attr_version.attr);
- class_destroy(drm_class);
- drm_class = NULL;
+ class_remove_file(&drm_class, &class_attr_version.attr);
+ class_unregister(&drm_class);
}
static void drm_sysfs_release(struct device *dev)
@@ -372,7 +369,7 @@ int drm_sysfs_connector_add(struct drm_connector *connector)
return -ENOMEM;
device_initialize(kdev);
- kdev->class = drm_class;
+ kdev->class = &drm_class;
kdev->type = &drm_sysfs_device_connector;
kdev->parent = dev->primary->kdev;
kdev->groups = connector_dev_groups;
@@ -550,7 +547,7 @@ struct device *drm_sysfs_minor_alloc(struct drm_minor *minor)
minor_str = "card%d";
kdev->devt = MKDEV(DRM_MAJOR, minor->index);
- kdev->class = drm_class;
+ kdev->class = &drm_class;
kdev->type = &drm_sysfs_device_minor;
}
@@ -579,10 +576,7 @@ struct device *drm_sysfs_minor_alloc(struct drm_minor *minor)
*/
int drm_class_device_register(struct device *dev)
{
- if (!drm_class || IS_ERR(drm_class))
- return -ENOENT;
-
- dev->class = drm_class;
+ dev->class = &drm_class;
return device_register(dev);
}
EXPORT_SYMBOL_GPL(drm_class_device_register);
--
2.43.0
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 fb_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 <[email protected]>
Suggested-by: Greg Kroah-Hartman <[email protected]>
Signed-off-by: Ricardo B. Marliere <[email protected]>
---
drivers/video/fbdev/core/fb_internal.h | 2 +-
drivers/video/fbdev/core/fbcon.c | 4 ++--
drivers/video/fbdev/core/fbmem.c | 17 ++++++++---------
drivers/video/fbdev/core/fbsysfs.c | 4 ++--
4 files changed, 13 insertions(+), 14 deletions(-)
diff --git a/drivers/video/fbdev/core/fb_internal.h b/drivers/video/fbdev/core/fb_internal.h
index 613832d335fe..f1c0f1386675 100644
--- a/drivers/video/fbdev/core/fb_internal.h
+++ b/drivers/video/fbdev/core/fb_internal.h
@@ -38,7 +38,7 @@ static inline int fb_show_logo(struct fb_info *info, int rotate)
#endif /* CONFIG_LOGO */
/* fbmem.c */
-extern struct class *fb_class;
+extern const struct class fb_class;
extern struct mutex registration_lock;
extern struct fb_info *registered_fb[FB_MAX];
extern int num_registered_fb;
diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fbcon.c
index 1183e7a871f8..4d87a6ebdbdf 100644
--- a/drivers/video/fbdev/core/fbcon.c
+++ b/drivers/video/fbdev/core/fbcon.c
@@ -3380,7 +3380,7 @@ void __init fb_console_init(void)
int i;
console_lock();
- fbcon_device = device_create(fb_class, NULL, MKDEV(0, 0), NULL,
+ fbcon_device = device_create(&fb_class, NULL, MKDEV(0, 0), NULL,
"fbcon");
if (IS_ERR(fbcon_device)) {
@@ -3425,7 +3425,7 @@ void __exit fb_console_exit(void)
console_lock();
fbcon_deinit_device();
- device_destroy(fb_class, MKDEV(0, 0));
+ device_destroy(&fb_class, MKDEV(0, 0));
do_unregister_con_driver(&fb_con);
console_unlock();
diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c
index 48287366e0d4..d868194499fb 100644
--- a/drivers/video/fbdev/core/fbmem.c
+++ b/drivers/video/fbdev/core/fbmem.c
@@ -26,7 +26,9 @@
#define FBPIXMAPSIZE (1024 * 8)
-struct class *fb_class;
+const struct class fb_class = {
+ .name = "graphics",
+};
DEFINE_MUTEX(registration_lock);
struct fb_info *registered_fb[FB_MAX] __read_mostly;
@@ -571,11 +573,10 @@ static int __init fbmem_init(void)
{
int ret;
- fb_class = class_create("graphics");
- if (IS_ERR(fb_class)) {
- ret = PTR_ERR(fb_class);
+ ret = class_register(&fb_class);
+ if (ret) {
pr_err("Unable to create fb class; errno = %d\n", ret);
- goto err_fb_class;
+ return ret;
}
ret = fb_init_procfs();
@@ -593,9 +594,7 @@ static int __init fbmem_init(void)
err_fb_cleanup_procfs:
fb_cleanup_procfs();
err_class_destroy:
- class_destroy(fb_class);
-err_fb_class:
- fb_class = NULL;
+ class_unregister(&fb_class);
return ret;
}
@@ -605,7 +604,7 @@ static void __exit fbmem_exit(void)
fb_console_exit();
fb_unregister_chrdev();
fb_cleanup_procfs();
- class_destroy(fb_class);
+ class_unregister(&fb_class);
}
module_init(fbmem_init);
diff --git a/drivers/video/fbdev/core/fbsysfs.c b/drivers/video/fbdev/core/fbsysfs.c
index 1b3c9958ef5c..aac013dfe06a 100644
--- a/drivers/video/fbdev/core/fbsysfs.c
+++ b/drivers/video/fbdev/core/fbsysfs.c
@@ -476,7 +476,7 @@ int fb_device_create(struct fb_info *fb_info)
dev_t devt = MKDEV(FB_MAJOR, node);
int ret;
- fb_info->dev = device_create(fb_class, fb_info->device, devt, NULL, "fb%d", node);
+ fb_info->dev = device_create(&fb_class, fb_info->device, devt, NULL, "fb%d", node);
if (IS_ERR(fb_info->dev)) {
/* Not fatal */
ret = PTR_ERR(fb_info->dev);
@@ -497,6 +497,6 @@ void fb_device_destroy(struct fb_info *fb_info)
return;
fb_cleanup_device(fb_info);
- device_destroy(fb_class, devt);
+ device_destroy(&fb_class, devt);
fb_info->dev = NULL;
}
--
2.43.0
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 dma_heap_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 <[email protected]>
Suggested-by: Greg Kroah-Hartman <[email protected]>
Signed-off-by: Ricardo B. Marliere <[email protected]>
---
drivers/dma-buf/dma-heap.c | 26 ++++++++++++++------------
1 file changed, 14 insertions(+), 12 deletions(-)
diff --git a/drivers/dma-buf/dma-heap.c b/drivers/dma-buf/dma-heap.c
index 84ae708fafe7..bcca6a2bbce8 100644
--- a/drivers/dma-buf/dma-heap.c
+++ b/drivers/dma-buf/dma-heap.c
@@ -43,10 +43,18 @@ struct dma_heap {
struct cdev heap_cdev;
};
+static char *dma_heap_devnode(const struct device *dev, umode_t *mode)
+{
+ return kasprintf(GFP_KERNEL, "dma_heap/%s", dev_name(dev));
+}
+
static LIST_HEAD(heap_list);
static DEFINE_MUTEX(heap_list_lock);
static dev_t dma_heap_devt;
-static struct class *dma_heap_class;
+static struct class dma_heap_class = {
+ .name = DEVNAME,
+ .devnode = dma_heap_devnode,
+};
static DEFINE_XARRAY_ALLOC(dma_heap_minors);
static int dma_heap_buffer_alloc(struct dma_heap *heap, size_t len,
@@ -261,7 +269,7 @@ struct dma_heap *dma_heap_add(const struct dma_heap_export_info *exp_info)
goto err1;
}
- dev_ret = device_create(dma_heap_class,
+ dev_ret = device_create(&dma_heap_class,
NULL,
heap->heap_devt,
NULL,
@@ -291,7 +299,7 @@ struct dma_heap *dma_heap_add(const struct dma_heap_export_info *exp_info)
return heap;
err3:
- device_destroy(dma_heap_class, heap->heap_devt);
+ device_destroy(&dma_heap_class, heap->heap_devt);
err2:
cdev_del(&heap->heap_cdev);
err1:
@@ -301,11 +309,6 @@ struct dma_heap *dma_heap_add(const struct dma_heap_export_info *exp_info)
return err_ret;
}
-static char *dma_heap_devnode(const struct device *dev, umode_t *mode)
-{
- return kasprintf(GFP_KERNEL, "dma_heap/%s", dev_name(dev));
-}
-
static int dma_heap_init(void)
{
int ret;
@@ -314,12 +317,11 @@ static int dma_heap_init(void)
if (ret)
return ret;
- dma_heap_class = class_create(DEVNAME);
- if (IS_ERR(dma_heap_class)) {
+ ret = class_register(&dma_heap_class);
+ if (ret) {
unregister_chrdev_region(dma_heap_devt, NUM_HEAP_MINORS);
- return PTR_ERR(dma_heap_class);
+ return ret;
}
- dma_heap_class->devnode = dma_heap_devnode;
return 0;
}
--
2.43.0
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 <[email protected]>
Suggested-by: Greg Kroah-Hartman <[email protected]>
Signed-off-by: Ricardo B. Marliere <[email protected]>
---
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
On Tue, Mar 5, 2024 at 3:34 AM Ricardo B. Marliere <[email protected]> wrote:
>
> 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 dma_heap_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 <[email protected]>
> Suggested-by: Greg Kroah-Hartman <[email protected]>
> Signed-off-by: Ricardo B. Marliere <[email protected]>
> ---
> drivers/dma-buf/dma-heap.c | 26 ++++++++++++++------------
> 1 file changed, 14 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/dma-buf/dma-heap.c b/drivers/dma-buf/dma-heap.c
> index 84ae708fafe7..bcca6a2bbce8 100644
> --- a/drivers/dma-buf/dma-heap.c
> +++ b/drivers/dma-buf/dma-heap.c
> @@ -43,10 +43,18 @@ struct dma_heap {
> struct cdev heap_cdev;
> };
>
> +static char *dma_heap_devnode(const struct device *dev, umode_t *mode)
> +{
> + return kasprintf(GFP_KERNEL, "dma_heap/%s", dev_name(dev));
> +}
> +
> static LIST_HEAD(heap_list);
> static DEFINE_MUTEX(heap_list_lock);
> static dev_t dma_heap_devt;
> -static struct class *dma_heap_class;
> +static struct class dma_heap_class = {
> + .name = DEVNAME,
> + .devnode = dma_heap_devnode,
> +};
> static DEFINE_XARRAY_ALLOC(dma_heap_minors);
>
> static int dma_heap_buffer_alloc(struct dma_heap *heap, size_t len,
> @@ -261,7 +269,7 @@ struct dma_heap *dma_heap_add(const struct dma_heap_export_info *exp_info)
> goto err1;
> }
>
> - dev_ret = device_create(dma_heap_class,
> + dev_ret = device_create(&dma_heap_class,
> NULL,
> heap->heap_devt,
> NULL,
> @@ -291,7 +299,7 @@ struct dma_heap *dma_heap_add(const struct dma_heap_export_info *exp_info)
> return heap;
>
> err3:
> - device_destroy(dma_heap_class, heap->heap_devt);
> + device_destroy(&dma_heap_class, heap->heap_devt);
> err2:
> cdev_del(&heap->heap_cdev);
> err1:
> @@ -301,11 +309,6 @@ struct dma_heap *dma_heap_add(const struct dma_heap_export_info *exp_info)
> return err_ret;
> }
>
> -static char *dma_heap_devnode(const struct device *dev, umode_t *mode)
> -{
> - return kasprintf(GFP_KERNEL, "dma_heap/%s", dev_name(dev));
> -}
> -
> static int dma_heap_init(void)
> {
> int ret;
> @@ -314,12 +317,11 @@ static int dma_heap_init(void)
> if (ret)
> return ret;
>
> - dma_heap_class = class_create(DEVNAME);
> - if (IS_ERR(dma_heap_class)) {
> + ret = class_register(&dma_heap_class);
> + if (ret) {
> unregister_chrdev_region(dma_heap_devt, NUM_HEAP_MINORS);
> - return PTR_ERR(dma_heap_class);
> + return ret;
> }
> - dma_heap_class->devnode = dma_heap_devnode;
>
> return 0;
> }
>
> --
> 2.43.0
Reviewed-by: T.J. Mercier <[email protected]>
Is this really a resend? I don't see anything on lore and I can't
recall seeing this patch in my inbox before.
On Tue, Mar 5, 2024 at 10:02 AM Ricardo B. Marliere
<[email protected]> wrote:
>
> On 5 Mar 09:07, T.J. Mercier wrote:
> >
> > Reviewed-by: T.J. Mercier <[email protected]>
> >
> > Is this really a resend? I don't see anything on lore and I can't
> > recall seeing this patch in my inbox before.
>
> Hi T.J. thanks for reviewing!
>
> I'm sorry about that, I sent the series only to Greg before but I
> thought it had Cc'ed the lists as well. Then I realized it was sent
> publicly only once. Double mistake :(
>
> Best regards,
> - Ricardo.
Cheers, glad I don't have to try to rework my email filters. :)
On 5 Mar 09:07, T.J. Mercier wrote:
>
> Reviewed-by: T.J. Mercier <[email protected]>
>
> Is this really a resend? I don't see anything on lore and I can't
> recall seeing this patch in my inbox before.
Hi T.J. thanks for reviewing!
I'm sorry about that, I sent the series only to Greg before but I
thought it had Cc'ed the lists as well. Then I realized it was sent
publicly only once. Double mistake :(
Best regards,
- Ricardo.
Hello Ricardo,
On Tue, 5 Mar 2024 at 22:37, T.J. Mercier <[email protected]> wrote:
>
> On Tue, Mar 5, 2024 at 3:34 AM Ricardo B. Marliere <[email protected]> wrote:
> >
> > 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 dma_heap_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 <[email protected]>
> > Suggested-by: Greg Kroah-Hartman <[email protected]>
> > Signed-off-by: Ricardo B. Marliere <[email protected]>
> > ---
> > drivers/dma-buf/dma-heap.c | 26 ++++++++++++++------------
> > 1 file changed, 14 insertions(+), 12 deletions(-)
> >
> > diff --git a/drivers/dma-buf/dma-heap.c b/drivers/dma-buf/dma-heap.c
> > index 84ae708fafe7..bcca6a2bbce8 100644
> > --- a/drivers/dma-buf/dma-heap.c
> > +++ b/drivers/dma-buf/dma-heap.c
> > @@ -43,10 +43,18 @@ struct dma_heap {
> > struct cdev heap_cdev;
> > };
> >
> > +static char *dma_heap_devnode(const struct device *dev, umode_t *mode)
> > +{
> > + return kasprintf(GFP_KERNEL, "dma_heap/%s", dev_name(dev));
> > +}
> > +
> > static LIST_HEAD(heap_list);
> > static DEFINE_MUTEX(heap_list_lock);
> > static dev_t dma_heap_devt;
> > -static struct class *dma_heap_class;
> > +static struct class dma_heap_class = {
> > + .name = DEVNAME,
> > + .devnode = dma_heap_devnode,
> > +};
> > static DEFINE_XARRAY_ALLOC(dma_heap_minors);
> >
> > static int dma_heap_buffer_alloc(struct dma_heap *heap, size_t len,
> > @@ -261,7 +269,7 @@ struct dma_heap *dma_heap_add(const struct dma_heap_export_info *exp_info)
> > goto err1;
> > }
> >
> > - dev_ret = device_create(dma_heap_class,
> > + dev_ret = device_create(&dma_heap_class,
> > NULL,
> > heap->heap_devt,
> > NULL,
> > @@ -291,7 +299,7 @@ struct dma_heap *dma_heap_add(const struct dma_heap_export_info *exp_info)
> > return heap;
> >
> > err3:
> > - device_destroy(dma_heap_class, heap->heap_devt);
> > + device_destroy(&dma_heap_class, heap->heap_devt);
> > err2:
> > cdev_del(&heap->heap_cdev);
> > err1:
> > @@ -301,11 +309,6 @@ struct dma_heap *dma_heap_add(const struct dma_heap_export_info *exp_info)
> > return err_ret;
> > }
> >
> > -static char *dma_heap_devnode(const struct device *dev, umode_t *mode)
> > -{
> > - return kasprintf(GFP_KERNEL, "dma_heap/%s", dev_name(dev));
> > -}
> > -
> > static int dma_heap_init(void)
> > {
> > int ret;
> > @@ -314,12 +317,11 @@ static int dma_heap_init(void)
> > if (ret)
> > return ret;
> >
> > - dma_heap_class = class_create(DEVNAME);
> > - if (IS_ERR(dma_heap_class)) {
> > + ret = class_register(&dma_heap_class);
> > + if (ret) {
> > unregister_chrdev_region(dma_heap_devt, NUM_HEAP_MINORS);
> > - return PTR_ERR(dma_heap_class);
> > + return ret;
> > }
> > - dma_heap_class->devnode = dma_heap_devnode;
> >
> > return 0;
> > }
> >
> > --
> > 2.43.0
>
> Reviewed-by: T.J. Mercier <[email protected]>
FWIW, please free to add my
Acked-by: Sumit Semwal <[email protected]>
>
>
> Is this really a resend? I don't see anything on lore and I can't
> recall seeing this patch in my inbox before.
Best,
Sumit.
--
Thanks and regards,
Sumit Semwal (he / him)
Tech Lead - LCG, Vertical Technologies
Linaro.org │ Open source software for ARM SoCs