From nobody Sat Jan 22 19:36:22 2022 X-Original-To: dev-commits-src-branches@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 8ABB6196B486; Sat, 22 Jan 2022 19:36:25 +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 4Jh61h6JMVz3RJ5; Sat, 22 Jan 2022 19:36:24 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1642880185; 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=EnrIsPBZ8c3+xSkxjv6EQEHpaI3X6nTSFxNVmroXsXo=; b=QvqBVriMv4Fe39Uu3oQ4Tg5aIU9RxW53M3Ol4wlvVIRYPpEWWecMTLRfBACU0nPwtKxNX7 WNIloyX7R4Y0mSIoD8tBYnGUDOuex69nGqjRUlgkXE9Ddjg9GjWrgrr52Vg+7xmE6YjCli qAMUJAD+Lq3a6kmTM6TiXmyC3XVrDldzen7lJ917sCC+JBr7bC/484iUQoayMYIShw87bh XurKxr5U5Px7ZvDExL36oC8aWxqW+yfzG2aoCAnxaooW5lXyltoXRExlEM8TYXtdN/oXTW VveaDEgrCjpXuQezKfLdO3DFlniZtGqVcz16pOhC4gwxEpsJvqtgVmDfK+CHww== 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 AF37615034; Sat, 22 Jan 2022 19:36:22 +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 20MJaMga099942; Sat, 22 Jan 2022 19:36:22 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 20MJaM59099941; Sat, 22 Jan 2022 19:36:22 GMT (envelope-from git) Date: Sat, 22 Jan 2022 19:36:22 GMT Message-Id: <202201221936.20MJaM59099941@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: 9e736b8b8a1e - stable/13 - LinuxKPI: Implement default sysfs kobject attribute operations List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@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/13 X-Git-Reftype: branch X-Git-Commit: 9e736b8b8a1ec017a4c977385a3e2a33e4b54670 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1642880185; 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=EnrIsPBZ8c3+xSkxjv6EQEHpaI3X6nTSFxNVmroXsXo=; b=Rh33eb5PC89ydoxqhHDV7ijfTZPc+Jt1mdF+rC499fj3AjqMEbC7WCQz8/crwXE373IJk8 iCrptsPI1QfH22mqjzXBVMk/3HcjUjpjDOVNmxVhAxXJLLmxY+qPzN7Vm4Is/g5h3Yha2f pSb7P94E6v/j1+SSa7v/tmZ+rnESMy3GQnnHFF0JJByCguI2vCIs557VfMap4o1FsoR8LH VD7RS9nVtcT2/o8KmbqQhtYnBfXCeLN6ioM7bYHladns3g0MZHzkoViGsssQy9zahReSNa nCnIL3jd1MSdl8czfQKiIdYdw9Qj1uVBta4pLZCvwTvANv/iuhTzNFw/d0gxIA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1642880185; a=rsa-sha256; cv=none; b=e9zVUcEUweTEGyvvTpvkXLbO7cYutJ1SHxXex0po3pvH5k37+ZOeg/BiWOhyi/ZR/vYOci JJsPcm0IBq5dYshKR8M7mBtqiE/tmmWEOPbjYlvlw3WtH8b7d7ki0H2cVJb/tXc9ZIMcwN MGZMGC1FyIEepUpVqhodXKwBRU3Woz+8mSTt26iJNcwdAyQ2sEbuRUs9VQTrw4g8VSOzUS x+4/nCprkH6iseNKfRhfBezu0wn7zmfPz5GZvQdvx6AGpfUG9MX3z4YapgjCmBWL5+9bQ/ Gwia+QvfSIjK02w/BUDHJZtqHD3XvJIugikQ+PRybCmbvDJw+mahZ6UFuiLVkw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=9e736b8b8a1ec017a4c977385a3e2a33e4b54670 commit 9e736b8b8a1ec017a4c977385a3e2a33e4b54670 Author: Vladimir Kondratyev AuthorDate: 2021-11-23 09:09:42 +0000 Commit: Vladimir Kondratyev CommitDate: 2022-01-22 19:34:36 +0000 LinuxKPI: Implement default sysfs kobject attribute operations Required by drm-kmod 5.7 MFC after: 1 week Reviewed by: hselasky Differential Revision: https://reviews.freebsd.org/D33292 (cherry picked from commit 04d42cb453888cbda0fb81d38bd722962ca6fc03) --- sys/compat/linuxkpi/common/include/linux/kobject.h | 2 ++ sys/compat/linuxkpi/common/src/linux_compat.c | 30 ++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/sys/compat/linuxkpi/common/include/linux/kobject.h b/sys/compat/linuxkpi/common/include/linux/kobject.h index 403ec1495c32..8108375ed07e 100644 --- a/sys/compat/linuxkpi/common/include/linux/kobject.h +++ b/sys/compat/linuxkpi/common/include/linux/kobject.h @@ -68,6 +68,8 @@ struct attribute { mode_t mode; }; +extern const struct sysfs_ops kobj_sysfs_ops; + struct kobj_attribute { struct attribute attr; ssize_t (*show)(struct kobject *kobj, struct kobj_attribute *attr, diff --git a/sys/compat/linuxkpi/common/src/linux_compat.c b/sys/compat/linuxkpi/common/src/linux_compat.c index 9c6ed96c19b6..666a1bd07970 100644 --- a/sys/compat/linuxkpi/common/src/linux_compat.c +++ b/sys/compat/linuxkpi/common/src/linux_compat.c @@ -281,6 +281,36 @@ const struct kobj_type linux_kfree_type = { .release = linux_kobject_kfree }; +static ssize_t +lkpi_kobj_attr_show(struct kobject *kobj, struct attribute *attr, char *buf) +{ + struct kobj_attribute *ka = + container_of(attr, struct kobj_attribute, attr); + + if (ka->show == NULL) + return (-EIO); + + return (ka->show(kobj, ka, buf)); +} + +static ssize_t +lkpi_kobj_attr_store(struct kobject *kobj, struct attribute *attr, + const char *buf, size_t count) +{ + struct kobj_attribute *ka = + container_of(attr, struct kobj_attribute, attr); + + if (ka->store == NULL) + return (-EIO); + + return (ka->store(kobj, ka, buf, count)); +} + +const struct sysfs_ops kobj_sysfs_ops = { + .show = lkpi_kobj_attr_show, + .store = lkpi_kobj_attr_store, +}; + static void linux_device_release(struct device *dev) {