The branch main has been updated by wulf:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=04d42cb453888cbda0fb81d38bd722962ca6fc03

commit 04d42cb453888cbda0fb81d38bd722962ca6fc03
Author:     Vladimir Kondratyev <w...@freebsd.org>
AuthorDate: 2021-11-23 09:09:42 +0000
Commit:     Vladimir Kondratyev <w...@freebsd.org>
CommitDate: 2022-01-10 19:49:37 +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
---
 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 f375196aa72e..70e208da428f 100644
--- a/sys/compat/linuxkpi/common/src/linux_compat.c
+++ b/sys/compat/linuxkpi/common/src/linux_compat.c
@@ -282,6 +282,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)
 {

Reply via email to