From nobody Sun Jul 21 13:14:50 2024 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 4WRkQz2H6hz5RVP5; Sun, 21 Jul 2024 13:14:51 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4WRkQy6s1lz4Rs9; Sun, 21 Jul 2024 13:14:50 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1721567691; 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=yx468r2pKqsIZ9Q4FwNqV5n0xKbjsIGUczgFUbzZelA=; b=UY0QsUD257FEs8qyjpR5gMg+ptPm5KRibA9vHfXmfrW1T29MAuGlbx+nCZqdcHkMKvbgpv jQn8FKo5dY5MSpvbKJvscKwakuk+MbPiFGXWdhyQHboEtquJP7b+djCHsXM9xDEZMQrB4j qEsNFgVVV08dTkfKIYb3JMtyP9FuYvlPXQLUNkP5dh8C1OKsHRoWHeuCvmNWdy22Lc6w44 0jnGjvaFOiot4qgzaAo/ATo/rlOTsGzKTI8mQsNwe1uvEQToMtvsONmw+Y7UcQ0OKsuBRS 2UpKlk0/RNX9l0byt3Wj/ZUZdFbMBypgKyNbEutEGuq+tVthJdPFrbkvbjwH1Q== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1721567691; a=rsa-sha256; cv=none; b=qlULSTs6OliQdOGY1CHIkKAKJ1wq9+UDJpyUI+KpbNvG/TylXcklXbaZYLorIEsmLA8tLg VVbzjU5BS/n7rvMtU7iVsjBem1POATjchpDM9jFgRIx0CXQ5AJy3WgEVYZEIrJ5FPfwkG8 v4KhCjJUnKW/a24AKDJu/t9H+p8JoMSdkOJqZkg3GSPjfa4FdldCa5hwJmZ1TejR2sp0+I T+auXvdt5+0eKWHD4gvVBU7l8+EP/VBe5T0dONXIBBE0VlUhetuJKhpurcyZEryoHBwbws xRiAFaqvdRq8hhPM254ke+lHgBsUln/B9ndKJkeubHMVnpum9RaPtXjINEb0Dw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1721567691; 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=yx468r2pKqsIZ9Q4FwNqV5n0xKbjsIGUczgFUbzZelA=; b=wHXrgCYivRfc4qulF86RZCBBfpm/blogRprQbZnws8YyVEuI5NrHn1ueCBhl5vwKTYuPOQ Jlu1+5vaBW8oAPRCbYaF8JGO30oLwrkv88gks1Z+ntfhGhKNKCnm2BH/aId3FSCBDjbIoA id4FU+kaH2gqvxl+8WVKClgAERnQRyqg2IBKbF4xaTKT47cz6TupUg1N9EUCVqMDkDilU/ UbcmZc8MLLG/sx+Uq3by8bfWHbrB5dzERzgGDA8D/yWr5AQLXaWRfeGkck6YZTiaF6IlGE rPw6l3tAz4rWJf8nhPAq6XoTq82kLrnFlSWRzz6dbx3VOYAj9mYeFu63D2154A== 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 4WRkQy4tvsz12Bj; Sun, 21 Jul 2024 13:14:50 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 46LDEoDo023110; Sun, 21 Jul 2024 13:14:50 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 46LDEoW4023107; Sun, 21 Jul 2024 13:14:50 GMT (envelope-from git) Date: Sun, 21 Jul 2024 13:14:50 GMT Message-Id: <202407211314.46LDEoW4023107@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Vladimir Kondratyev Subject: git: a1181662d370 - main - LinuxKPI: Add devm_device_add_group to linux/device.h 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wulf X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: a1181662d3707d8165d7153a0aa5d76ea1ddc11a Auto-Submitted: auto-generated The branch main has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=a1181662d3707d8165d7153a0aa5d76ea1ddc11a commit a1181662d3707d8165d7153a0aa5d76ea1ddc11a Author: Vladimir Kondratyev AuthorDate: 2024-07-21 13:09:12 +0000 Commit: Vladimir Kondratyev CommitDate: 2024-07-21 13:09:12 +0000 LinuxKPI: Add devm_device_add_group to linux/device.h devm_device_add_group creates a managed attribute group for a device. Sponsored by: Serenity Cyber Security, LLC MFC after: 1 week Reviewed by: manu Differential Revision: https://reviews.freebsd.org/D45845 --- sys/compat/linuxkpi/common/include/linux/device.h | 4 +++ sys/compat/linuxkpi/common/src/linux_compat.c | 30 +++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/sys/compat/linuxkpi/common/include/linux/device.h b/sys/compat/linuxkpi/common/include/linux/device.h index 00c55b31b248..912be8fbae8b 100644 --- a/sys/compat/linuxkpi/common/include/linux/device.h +++ b/sys/compat/linuxkpi/common/include/linux/device.h @@ -701,4 +701,8 @@ int lkpi_devm_add_action_or_reset(struct device *dev, void (*action)(void *), vo #define devm_add_action_or_reset(dev, action, data) \ lkpi_devm_add_action_or_reset(dev, action, data) +int lkpi_devm_device_add_group(struct device *dev, const struct attribute_group *group); +#define devm_device_add_group(dev, group) \ + lkpi_devm_device_add_group(dev, group) + #endif /* _LINUXKPI_LINUX_DEVICE_H_ */ diff --git a/sys/compat/linuxkpi/common/src/linux_compat.c b/sys/compat/linuxkpi/common/src/linux_compat.c index 90d03d480089..ec4e59f66e7f 100644 --- a/sys/compat/linuxkpi/common/src/linux_compat.c +++ b/sys/compat/linuxkpi/common/src/linux_compat.c @@ -2615,6 +2615,36 @@ device_can_wakeup(struct device *dev) return (false); } +static void +devm_device_group_remove(struct device *dev, void *p) +{ + const struct attribute_group **dr = p; + const struct attribute_group *group = *dr; + + sysfs_remove_group(&dev->kobj, group); +} + +int +lkpi_devm_device_add_group(struct device *dev, + const struct attribute_group *group) +{ + const struct attribute_group **dr; + int ret; + + dr = devres_alloc(devm_device_group_remove, sizeof(*dr), GFP_KERNEL); + if (dr == NULL) + return (-ENOMEM); + + ret = sysfs_create_group(&dev->kobj, group); + if (ret == 0) { + *dr = group; + devres_add(dev, dr); + } else + devres_free(dr); + + return (ret); +} + #if defined(__i386__) || defined(__amd64__) bool linux_cpu_has_clflush; struct cpuinfo_x86 boot_cpu_data;