Archive-only list for patches
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@nvidia.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Ard Biesheuvel <ardb@kernel.org>,
	linux-kernel@vger.kernel.org, Lukas Wunner <lukas@wunner.de>,
	patches@lists.linux.dev,
	"Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
Subject: [PATCH] sysfs: Add stub sysfs_bin_attr_simple_read() for !CONFIG_SYSFS
Date: Mon,  3 Jun 2024 14:30:45 -0300	[thread overview]
Message-ID: <0-v1-44baae71b833+ab-sysfs_simple_read_jgg@nvidia.com> (raw)

At least dmi_scan.c fails to compile:

../drivers/firmware/dmi_scan.c:764:8: error: use of undeclared identifier 'sysfs_bin_attr_simple_read'
  764 | static BIN_ATTR_SIMPLE_ADMIN_RO(smbios_entry_point);
      |        ^
../include/linux/sysfs.h:383:41: note: expanded from macro 'BIN_ATTR_SIMPLE_ADMIN_RO'
  383 | struct bin_attribute bin_attr_##_name = __BIN_ATTR_SIMPLE_RO(_name, 0400)
      |                                         ^
../include/linux/sysfs.h:376:10: note: expanded from macro '__BIN_ATTR_SIMPLE_RO'
  376 |         .read   = sysfs_bin_attr_simple_read,                           \
      |                   ^
../drivers/firmware/dmi_scan.c:765:8: error: use of undeclared identifier 'sysfs_bin_attr_simple_read'
  765 | static BIN_ATTR_SIMPLE_ADMIN_RO(DMI);
      |        ^
../include/linux/sysfs.h:383:41: note: expanded from macro 'BIN_ATTR_SIMPLE_ADMIN_RO'
  383 | struct bin_attribute bin_attr_##_name = __BIN_ATTR_SIMPLE_RO(_name, 0400)
      |                                         ^
../include/linux/sysfs.h:376:10: note: expanded from macro '__BIN_ATTR_SIMPLE_RO'
  376 |         .read   = sysfs_bin_attr_simple_read,                           \
      |                   ^

Since the only declaration for sysfs_bin_attr_simple_read() is inside the
"#ifdef CONFIG_SYSFS". Add a stub to the #else section too.

Fixes: d48c03198a92 ("sysfs: Add sysfs_bin_attr_simple_read() helper")
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
---
 include/linux/sysfs.h | 9 +++++++++
 1 file changed, 9 insertions(+)

I don't see a patch for this yet, but I did find a 0-day robot complaint:

https://lore.kernel.org/all/202404200345.eGdn5uxW-lkp@intel.com/

diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
index a7d725fbf73937..e672a927d650a3 100644
--- a/include/linux/sysfs.h
+++ b/include/linux/sysfs.h
@@ -750,6 +750,15 @@ static inline int sysfs_emit_at(char *buf, int at, const char *fmt, ...)
 {
 	return 0;
 }
+
+static inline ssize_t sysfs_bin_attr_simple_read(struct file *file,
+						 struct kobject *kobj,
+						 struct bin_attribute *attr,
+						 char *buf, loff_t off,
+						 size_t count)
+{
+	return -EINVAL;
+}
 #endif /* CONFIG_SYSFS */
 
 static inline int __must_check sysfs_create_file(struct kobject *kobj,

base-commit: c58a77fe0ba1b708759338ad8bd3828b75a26035
-- 
2.45.2


             reply	other threads:[~2024-06-03 17:30 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-03 17:30 Jason Gunthorpe [this message]
2024-06-03 20:46 ` [PATCH] sysfs: Add stub sysfs_bin_attr_simple_read() for !CONFIG_SYSFS Lukas Wunner
2024-06-03 22:15   ` Jason Gunthorpe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0-v1-44baae71b833+ab-sysfs_simple_read_jgg@nvidia.com \
    --to=jgg@nvidia.com \
    --cc=ardb@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lukas@wunner.de \
    --cc=patches@lists.linux.dev \
    --cc=rafael.j.wysocki@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox