From nobody Mon Jan 10 19:50:35 2022 X-Original-To: dev-commits-src-main@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 6754C19544D5; Mon, 10 Jan 2022 19:50:38 +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 4JXkvc2pH2z3NM1; Mon, 10 Jan 2022 19:50:36 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 DD04C2ED4; Mon, 10 Jan 2022 19:50:35 +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 20AJoZY7008102; Mon, 10 Jan 2022 19:50:35 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 20AJoZIH008093; Mon, 10 Jan 2022 19:50:35 GMT (envelope-from git) Date: Mon, 10 Jan 2022 19:50:35 GMT Message-Id: <202201101950.20AJoZIH008093@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: 04d42cb45388 - main - LinuxKPI: Implement default sysfs kobject attribute operations List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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: 04d42cb453888cbda0fb81d38bd722962ca6fc03 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1641844237; 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=WXaYKsiUKilvOb8ozLIFNCvdEw7btLGo9dp4FMoI+cE=; b=fKB2S7LZnqt90LyeHst/0O8t8vS+gQaXlqEBCQQjeqVYddFcohssRp86fg0pdKeUx3g0qv frMoy4SHpjaZOGHLodkiC+aTeASEBplxKjk31V6P1LhwDkXHJHVRfjE7bmrvKc9Kbl7olz /DaLZTJPTpa2WBmweo1EDoFcT+xLX6h2Kaag5DlwXEGgnpjGa9tNdTFwSryimNGHv1N0WA 77+UHigzTSrOvdDus8pPDuxM+s4hpCRa1xLWNdTHHwr/aNNSWWLMq8KO6gdcJmpv+qSIw5 jZ2R4s4ld3GPdhjTH2k/ghgcVDK+yyR/BSdYvrR9YjhQ15s5jX1FKCJXUWVisg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1641844237; a=rsa-sha256; cv=none; b=tdvVaBXLUmBAzNjIvR81FFCm6TdVmH0/qrH8pbkceGbq8jmjQEQ6hRmh/jbked55zbCLnX qoT2WM+SqfnsHucTi38L+hCQ5F0k9HKeot3WHwOyxDuvU2i+5y4Pk3kchAVfJlqZu+wk3/ jHeyhU8X+bqEuRWQW8aZ2mZi06HX8A+lfKsIDox+Ppu6/UXA2Ctsv2FSOM8n6TmjuQUgHU Mk2s8bO+rsvapVFvPe1aGDWJCrStnw1e8vPCRl+ETfMOuELEM/yXOLksU+fJp6qfFjH+vs DfjOElaUZ57TuvH3q1ZftieNVTXRAmoQDvRouwOyjXBWOAw3eXKb/Ng5EzWISQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=04d42cb453888cbda0fb81d38bd722962ca6fc03 commit 04d42cb453888cbda0fb81d38bd722962ca6fc03 Author: Vladimir Kondratyev AuthorDate: 2021-11-23 09:09:42 +0000 Commit: Vladimir Kondratyev 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) {