Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 5 Apr 2022 14:42:27 GMT
From:      Warner Losh <imp@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 417f1c81491a - stable/13 - linuxkpi: Move device_create_groups_vargs to linux_compat.c
Message-ID:  <202204051442.235EgRPX029956@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=417f1c81491ae26643ea7e3f3fc5c08b8e8944a9

commit 417f1c81491ae26643ea7e3f3fc5c08b8e8944a9
Author:     Warner Losh <imp@FreeBSD.org>
AuthorDate: 2022-04-05 05:05:36 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2022-04-05 14:40:10 +0000

    linuxkpi: Move device_create_groups_vargs to linux_compat.c
    
    device_create_groups_vargs encodes the size of struct device. Move
    definition from .h to .c to move this size into the linuxkpi module
    rather than encoding it in all client driver modules.
    
    Sponsored by:           Netflix
    Reviewed by:            hselasky, emaste
    Differential Revision:  https://reviews.freebsd.org/D34768
    
    (cherry picked from commit 702b6875035921252d0f2b72171c7662f28766fb)
---
 sys/compat/linuxkpi/common/include/linux/device.h | 50 +++--------------------
 sys/compat/linuxkpi/common/src/linux_compat.c     | 41 +++++++++++++++++++
 2 files changed, 47 insertions(+), 44 deletions(-)

diff --git a/sys/compat/linuxkpi/common/include/linux/device.h b/sys/compat/linuxkpi/common/include/linux/device.h
index 5bd57a581f4e..2d310953fcd1 100644
--- a/sys/compat/linuxkpi/common/include/linux/device.h
+++ b/sys/compat/linuxkpi/common/include/linux/device.h
@@ -313,6 +313,12 @@ static inline struct device *kobj_to_dev(struct kobject *kobj)
 	return container_of(kobj, struct device, kobj);
 }
 
+struct device *device_create(struct class *class, struct device *parent,
+	    dev_t devt, void *drvdata, const char *fmt, ...);
+struct device *device_create_groups_vargs(struct class *class, struct device *parent,
+    dev_t devt, void *drvdata, const struct attribute_group **groups,
+    const char *fmt, va_list args);
+
 /*
  * Devices are registered and created for exporting to sysfs. Create
  * implies register and register assumes the device fields have been
@@ -372,47 +378,6 @@ device_create_release(struct device *dev)
 	kfree(dev);
 }
 
-static inline struct device *
-device_create_groups_vargs(struct class *class, struct device *parent,
-    dev_t devt, void *drvdata, const struct attribute_group **groups,
-    const char *fmt, va_list args)
-{
-	struct device *dev = NULL;
-	int retval = -ENODEV;
-
-	if (class == NULL || IS_ERR(class))
-		goto error;
-
-	dev = kzalloc(sizeof(*dev), GFP_KERNEL);
-	if (!dev) {
-		retval = -ENOMEM;
-		goto error;
-	}
-
-	dev->devt = devt;
-	dev->class = class;
-	dev->parent = parent;
-	dev->groups = groups;
-	dev->release = device_create_release;
-	/* device_initialize() needs the class and parent to be set */
-	device_initialize(dev);
-	dev_set_drvdata(dev, drvdata);
-
-	retval = kobject_set_name_vargs(&dev->kobj, fmt, args);
-	if (retval)
-		goto error;
-
-	retval = device_add(dev);
-	if (retval)
-		goto error;
-
-	return dev;
-
-error:
-	put_device(dev);
-	return ERR_PTR(retval);
-}
-
 static inline struct device *
 device_create_with_groups(struct class *class,
     struct device *parent, dev_t devt, void *drvdata,
@@ -506,9 +471,6 @@ device_del(struct device *dev)
 	}
 }
 
-struct device *device_create(struct class *class, struct device *parent,
-	    dev_t devt, void *drvdata, const char *fmt, ...);
-
 static inline void
 device_destroy(struct class *class, dev_t devt)
 {
diff --git a/sys/compat/linuxkpi/common/src/linux_compat.c b/sys/compat/linuxkpi/common/src/linux_compat.c
index 88bc1dd355ac..ed8b8d050e92 100644
--- a/sys/compat/linuxkpi/common/src/linux_compat.c
+++ b/sys/compat/linuxkpi/common/src/linux_compat.c
@@ -454,6 +454,47 @@ device_create(struct class *class, struct device *parent, dev_t devt,
 	return (dev);
 }
 
+struct device *
+device_create_groups_vargs(struct class *class, struct device *parent,
+    dev_t devt, void *drvdata, const struct attribute_group **groups,
+    const char *fmt, va_list args)
+{
+	struct device *dev = NULL;
+	int retval = -ENODEV;
+
+	if (class == NULL || IS_ERR(class))
+		goto error;
+
+	dev = kzalloc(sizeof(*dev), GFP_KERNEL);
+	if (!dev) {
+		retval = -ENOMEM;
+		goto error;
+	}
+
+	dev->devt = devt;
+	dev->class = class;
+	dev->parent = parent;
+	dev->groups = groups;
+	dev->release = device_create_release;
+	/* device_initialize() needs the class and parent to be set */
+	device_initialize(dev);
+	dev_set_drvdata(dev, drvdata);
+
+	retval = kobject_set_name_vargs(&dev->kobj, fmt, args);
+	if (retval)
+		goto error;
+
+	retval = device_add(dev);
+	if (retval)
+		goto error;
+
+	return dev;
+
+error:
+	put_device(dev);
+	return ERR_PTR(retval);
+}
+
 int
 kobject_init_and_add(struct kobject *kobj, const struct kobj_type *ktype,
     struct kobject *parent, const char *fmt, ...)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202204051442.235EgRPX029956>