From nobody Tue Apr 05 05:10:00 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id BF06D1AA3A01; Tue, 5 Apr 2022 05:10:00 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4KXbLJ4jJhz3hf3; Tue, 5 Apr 2022 05:10:00 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1649135400; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=NiarNDlhnQ98BGsWZgdD9yS5mTg38TG3BjMwWiEJTV4=; b=glfhArO3Yv/KgIo71CAQsa6No8yHjRR648v3pOayO87ST6Q6VFLYqfYtY7C4JbTk8xBxZQ wZnvQ5XeG8gUP0fF+1vdO9U+rrSM2VC/+FJKvR8a4zzUB1NDc/2qZKTFRI7zBYlNGvV9la DYIB427hvbgoX0RjwDDMEQRARzs2ZinxOrgp0Vop3a4JKyupAs2m6yn9RbT4jKlqGowGqU s9Sc/abAKg3ylJBWSEYmqAMvpElcDCpYkBWEtG81Csf1jgoPrkpgm8satZKB3/QTJBTpK5 qkmLVVyCCMIA/bEyyupIaYOvig1ZQsBXz7aCDD8G1gpFrBk0AsK5567t0dJZvg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 6FA9320596; Tue, 5 Apr 2022 05:10:00 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 2355A02B051718; Tue, 5 Apr 2022 05:10:00 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2355A0jU051707; Tue, 5 Apr 2022 05:10:00 GMT (envelope-from git) Date: Tue, 5 Apr 2022 05:10:00 GMT Message-Id: <202204050510.2355A0jU051707@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: 702b68750359 - main - linuxkpi: Move device_create_groups_vargs to linux_compat.c List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 702b6875035921252d0f2b72171c7662f28766fb Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1649135400; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=NiarNDlhnQ98BGsWZgdD9yS5mTg38TG3BjMwWiEJTV4=; b=yt8nxfGsP+6UtHkO8S7drflNemotsjQYsybwXC1CtpQkhKne6nEVF1ZajxCpJqJx8nQW95 HHkDr48IQeZxsqeTh1eg04z9AC99zlse8VdURs7kikTXeUFWdKAYpTACLaOui5h03PBlUm pipYL3flaWXKxZoO9MfThMsrtUIE+pguS6HaKXxhzd08ir/9GFoKDTzQo55A+zxbhWwKcD /6tna7sOzCzQxPcvYiaHWuA2FEJqn7nfK76gLWL5NiAVzXju2yeB4bxn6p6FFxD83h6q9w pd8KgEJfebWLk+DQyIXVH1UtTD4sX844gOQ+lE4C7VAVpC8uy8X2Mnr3k5gARQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1649135400; a=rsa-sha256; cv=none; b=mXQTPTJZpd7lEeKH7CrvCR1z6+Bd++kbwHwn2FEt33SoB+LIwo9oetGQsW9+LXxr7CxLmd 5zrrUEKxnAh86Z9B/3ZBH1FOtbbwShKeZMJsnxuPeLvIbuNRU8EKOn60JfBpfXHyghl0/U 2m/6gPSu/zgwpsM53iOtmztliiNz+NOYpoPk8yFuPrGipzC193K3QU2jfbihrEtedOeHf/ OWd/J9E8tp4P2YMouJv95x5Em82M9Y02tzsUEuMnhEH4kSvXZj0vV6mF6E7XO1ue6w7fld TTyE2XP+XVzqlGg3HSV1a5Ruqcob2wKROyfYm3f6gqPckxSdBVNqapbdH+aIAg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=702b6875035921252d0f2b72171c7662f28766fb commit 702b6875035921252d0f2b72171c7662f28766fb Author: Warner Losh AuthorDate: 2022-04-05 05:05:36 +0000 Commit: Warner Losh CommitDate: 2022-04-05 05:05:36 +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 --- 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 814a58fc6e5a..e11ed0289043 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 37294230c62e..22652e87d20f 100644 --- a/sys/compat/linuxkpi/common/src/linux_compat.c +++ b/sys/compat/linuxkpi/common/src/linux_compat.c @@ -455,6 +455,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, ...)