git: 169aa349594c - releng/13.1 - linuxkpi: Move class_create to .c file

From: Warner Losh <imp_at_FreeBSD.org>
Date: Wed, 06 Apr 2022 17:46:05 UTC
The branch releng/13.1 has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=169aa349594cb8226e53fbefc93a6e857b00015c

commit 169aa349594cb8226e53fbefc93a6e857b00015c
Author:     Warner Losh <imp@FreeBSD.org>
AuthorDate: 2022-04-05 05:05:43 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2022-04-06 17:45:23 +0000

    linuxkpi: Move class_create to .c file
    
    class_create encodes the size of struct class into the generated
    code. Move from .h file to .c file to move this knowledge from the
    client modules that call this into the linuxkpi module.
    
    Approved by:            re@ (gjb)
    Sponsored by:           Netflix
    Reviewed by:            hselasky, emaste
    Differential Revision:  https://reviews.freebsd.org/D34769
    
    (cherry picked from commit 1341ac9f9c111bba4e1ca046c479f32f2d4989c0)
    (cherry picked from commit 98d2b4a158f15d6d971a88315c5c5987036f89a3)
---
 sys/compat/linuxkpi/common/include/linux/device.h | 21 ++-------------------
 sys/compat/linuxkpi/common/src/linux_compat.c     | 19 +++++++++++++++++++
 2 files changed, 21 insertions(+), 19 deletions(-)

diff --git a/sys/compat/linuxkpi/common/include/linux/device.h b/sys/compat/linuxkpi/common/include/linux/device.h
index 2d310953fcd1..a6e735da92bd 100644
--- a/sys/compat/linuxkpi/common/include/linux/device.h
+++ b/sys/compat/linuxkpi/common/include/linux/device.h
@@ -289,6 +289,8 @@ put_device(struct device *dev)
 		kobject_put(&dev->kobj);
 }
 
+struct class *class_create(struct module *owner, const char *name);
+
 static inline int
 class_register(struct class *class)
 {
@@ -525,25 +527,6 @@ linux_class_kfree(struct class *class)
 	kfree(class);
 }
 
-static inline struct class *
-class_create(struct module *owner, const char *name)
-{
-	struct class *class;
-	int error;
-
-	class = kzalloc(sizeof(*class), M_WAITOK);
-	class->owner = owner;
-	class->name = name;
-	class->class_release = linux_class_kfree;
-	error = class_register(class);
-	if (error) {
-		kfree(class);
-		return (NULL);
-	}
-
-	return (class);
-}
-
 static inline void
 class_destroy(struct class *class)
 {
diff --git a/sys/compat/linuxkpi/common/src/linux_compat.c b/sys/compat/linuxkpi/common/src/linux_compat.c
index ed8b8d050e92..7a3378f57b3a 100644
--- a/sys/compat/linuxkpi/common/src/linux_compat.c
+++ b/sys/compat/linuxkpi/common/src/linux_compat.c
@@ -495,6 +495,25 @@ error:
 	return ERR_PTR(retval);
 }
 
+struct class *
+class_create(struct module *owner, const char *name)
+{
+	struct class *class;
+	int error;
+
+	class = kzalloc(sizeof(*class), M_WAITOK);
+	class->owner = owner;
+	class->name = name;
+	class->class_release = linux_class_kfree;
+	error = class_register(class);
+	if (error) {
+		kfree(class);
+		return (NULL);
+	}
+
+	return (class);
+}
+
 int
 kobject_init_and_add(struct kobject *kobj, const struct kobj_type *ktype,
     struct kobject *parent, const char *fmt, ...)