From nobody Thu Aug 01 22:28:01 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 4WZkBB5RBpz5RZwm; Thu, 01 Aug 2024 22:28:02 +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 4WZkBB09swz4Zdy; Thu, 1 Aug 2024 22:28:02 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1722551282; 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=mnpvqyonL6E/Hx3V8qgLfYtR4SDPazpMfYWQYNfsvG0=; b=IS5qcwdzNUYV5mYsbQDGJGs6ol2Qsa0E3AtapLAFPvQbGNdNfCIBgsvED/wLGnDkc4g1rB hQcemQtN1Rt1N5QvE10FTIJRjstpWgTLVzMMhZap1CdjCgXkDVfxzLsTU0z6YjutBmle64 U7SDbwcrex1ezTOoPgj/bFjJfDgbSLwO59Z6A6WqVOkjpwDcabP/ciQ940RxP79981PFuw /Jop9VWUTHV0hF9X9l8U9LjkZWFJ56MVsLLFzUbUHFb1LphT64f8lkT0oKuf6zFyjvG6gA V3FNROsSKj9WyuptUr4SP29rW5NdwCxQ207WeRtxFcSb3vkBhbJChj9105QMOg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1722551282; a=rsa-sha256; cv=none; b=Bw+WSn6V1nES3PbrNse92XgMzEJGOckw2X7lvuTm+mluQiQ627iHweX0Jj9AuzqOqCKpGF +fZuhmfTkVysEfG6g8+rw2ef2VWh5lXUzQxeotFMEjxdpTfqoErgEKZYKifG5j2lSycjTB 7FLysfYOUADg56N3t+Frg5rAO2WaUgqFUmqYMcfvnPPJQF0X5SUDc26Jm7zcFm6fpK0IQF ATPlJ3AMp7BazYl73DHoQf37qvHWb+xzgoIPpexx0eyoUFmkCD5WOeU8qc22GNKLCs+pkk CbL3EKyWBDebpns1cNCj5IjE/mXRuYB6KpFfjWXLZhCoFgfbA6F8BWbKgWcCmQ== 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=1722551282; 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=mnpvqyonL6E/Hx3V8qgLfYtR4SDPazpMfYWQYNfsvG0=; b=fkk19JDbg7c0dEYhTA8B+Mzw4tg6vE/s4VS5ng/AP2cSXBitA6JduqFZ23rhoDrZzEmZsc hFZTP41tcyiDeqGiFYmTNDHW3wEJas1nE7zAhQI+axodYqX5/wd69sz4uEDcJ6AdOzaKy3 EClbO5Wk0WyjpjFBO52zR231KtIx2Z2Gb5lo4pI2cDHhDd+KEz0YVON/px6EQGv1ob/m/Y 52AHKheBEk2nAfhJ9RBQJDfYcwZ+LqV6pg9KctrfzT/hhkTtk0kiSU5lYFM64R2Yn6Dzrz weBEghosndxqJCASDJE8RQiSDEUxGOCjYEq88OyEbgBM1h6sZ7Dy6dZpQk4+OA== 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 4WZkB96Pvkz12lB; Thu, 1 Aug 2024 22:28:01 +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 471MS1Vk028549; Thu, 1 Aug 2024 22:28:01 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 471MS1NO028546; Thu, 1 Aug 2024 22:28:01 GMT (envelope-from git) Date: Thu, 1 Aug 2024 22:28:01 GMT Message-Id: <202408012228.471MS1NO028546@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Vladimir Kondratyev Subject: git: b71e429d5478 - stable/14 - 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/stable/14 X-Git-Reftype: branch X-Git-Commit: b71e429d54780ddc447b74d551eac38761847360 Auto-Submitted: auto-generated The branch stable/14 has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=b71e429d54780ddc447b74d551eac38761847360 commit b71e429d54780ddc447b74d551eac38761847360 Author: Vladimir Kondratyev AuthorDate: 2024-07-21 13:09:12 +0000 Commit: Vladimir Kondratyev CommitDate: 2024-08-01 21:15:28 +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 (cherry picked from commit a1181662d3707d8165d7153a0aa5d76ea1ddc11a) --- 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 98c16212512d..de7e66d9a4ad 100644 --- a/sys/compat/linuxkpi/common/include/linux/device.h +++ b/sys/compat/linuxkpi/common/include/linux/device.h @@ -700,4 +700,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;