From nobody Tue Apr 05 14:42:27 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 6B6E21A8ECFA; Tue, 5 Apr 2022 14:42:28 +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 4KXr2r1ZK5z4cTT; Tue, 5 Apr 2022 14:42:28 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1649169748; 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=gsdr6g8y7++eUh42ZAyQOk9MKUr4pE0lB4roFoP5264=; b=GzZtLGjy5knJciVAeLJp7AEnhvG71h2ghhPHLYqVQbk/z1NGgYiDVGkGeiv4PTSb5vTYfS KHvKbAY+MXXgnO0G+gFyf+IdTJqfGCE/5py/ldddjZoItvcsrdYr1GGZBfCHWqzZiy/Bz1 GwCxQnvUdkLAN6niRoRkWj90Gh8mA2UmeiU+VmTvLcuT6MwVIBhfKbfkJxRxSpmCSHYQqU r+JLmT/dPbNJlcpd+z38/bCXtWGD4KzhMp3l1QMe5AuHrP8hM21G5sYKwJKXH2kzqa9ly1 6HxLNPj0CCEARtAFnkzk7p76GoV+n0c1RKZCtFwZmWHprN8fVxgOFTScu6atWg== 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 EAE582F9; Tue, 5 Apr 2022 14:42:27 +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 235EgRqk029957; Tue, 5 Apr 2022 14:42:27 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 235EgRPX029956; Tue, 5 Apr 2022 14:42:27 GMT (envelope-from git) Date: Tue, 5 Apr 2022 14:42:27 GMT Message-Id: <202204051442.235EgRPX029956@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Warner Losh Subject: git: 417f1c81491a - stable/13 - 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/stable/13 X-Git-Reftype: branch X-Git-Commit: 417f1c81491ae26643ea7e3f3fc5c08b8e8944a9 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1649169748; 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=gsdr6g8y7++eUh42ZAyQOk9MKUr4pE0lB4roFoP5264=; b=KlEo+s8//JYSZScyCRKXjbdKZNQM1YWqKBuSrRvMSMAYDARVHOsbyeTB3QcenI4PsNHcur WNRNBspyNFGjytKDA7NmSLM/2O8z8dYSKnc0FFwnJzO0bLK+9mZ1WRFs9FF/VQ5y/HF82C DQyiliqAGawSReOFkJZ2OvfJHmpx8bYGi25QKygGsgp0lFll1tBNT+T+Yc8v5YzL9Xw7AO +WIJLGdSdI7cIxaSYxEkq0xAbAGP+BktHqW22wU0WbNqKg5rlgBuAq08cs1AXfmCL2uGYM /oIApTsKLut1NmlMdY3E07HG6asV8n4IltjECBFLn54J7g7ombNMNbLkk4UJ5w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1649169748; a=rsa-sha256; cv=none; b=lTOqPZP2CrVNiRxcKJbI2syKtdEi/g2HlU1Wfo1KSO0y7MYT9dEiRaTzcRhFCyaQ5SECOq 2a06YuNvLsbUZno/38zD5y/QFpDLqsssimo7bq/iPNgloK3odhulojglsKomZAaGAFYaRn 5hF9GE+TzMQooJcpkb22lTwCCjhZjxRm7xDC2Pd1AH8Wefy0669MzCnqNNkFWxll10mkAL 7AZrTZVb+XQLUk229aoh4CuIVraP4UmJgf5H7A2hIXlWroGiL7V7lmrnlEEi8EcI89qlNS m+WLvQbPbCChTtyWsUSXe2z8YUg7YgHHfoqv+yJpZAUfUpRkSt9aoHaushchdg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=417f1c81491ae26643ea7e3f3fc5c08b8e8944a9 commit 417f1c81491ae26643ea7e3f3fc5c08b8e8944a9 Author: Warner Losh AuthorDate: 2022-04-05 05:05:36 +0000 Commit: Warner Losh 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, ...)