mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
To: "Srinivas Kandagatla" <srini@kernel.org>,
	"Thomas Weißschuh" <thomas.weissschuh@linutronix.de>
Cc: brgl@kernel.org, linux-kernel@vger.kernel.org,
	Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Subject: [PATCH] nvmem: use const APIs for legacy sysfs attributes
Date: Wed, 21 Oct 2026 14:12:36 +0200	[thread overview]
Message-ID: <20261021-nvmem-sysfs-const-v1-1-a35251dcdef6@oss.qualcomm.com> (raw)

Replace the deprecated non-const sysfs attribute APIs with modern const
variants.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
 drivers/nvmem/core.c | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index 7d4cce8e27424a032fff59a1189847adb1898168..f84f664deb84280871411c33f67ac846f7642161 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -193,24 +193,25 @@ static struct lock_class_key eeprom_lock_key;
 #endif
 
 static ssize_t type_show(struct device *dev,
-			 struct device_attribute *attr, char *buf)
+			 const struct device_attribute *attr, char *buf)
 {
 	struct nvmem_device *nvmem = to_nvmem_device(dev);
 
 	return sysfs_emit(buf, "%s\n", nvmem_type_str[nvmem->type]);
 }
 
-static DEVICE_ATTR_RO(type);
+static const DEVICE_ATTR_RO(type);
 
-static ssize_t force_ro_show(struct device *dev, struct device_attribute *attr,
-			     char *buf)
+static ssize_t force_ro_show(struct device *dev,
+			     const struct device_attribute *attr, char *buf)
 {
 	struct nvmem_device *nvmem = to_nvmem_device(dev);
 
 	return sysfs_emit(buf, "%d\n", nvmem->read_only);
 }
 
-static ssize_t force_ro_store(struct device *dev, struct device_attribute *attr,
+static ssize_t force_ro_store(struct device *dev,
+			      const struct device_attribute *attr,
 			      const char *buf, size_t count)
 {
 	struct nvmem_device *nvmem = to_nvmem_device(dev);
@@ -222,9 +223,9 @@ static ssize_t force_ro_store(struct device *dev, struct device_attribute *attr,
 	return count;
 }
 
-static DEVICE_ATTR_RW(force_ro);
+static const DEVICE_ATTR_RW(force_ro);
 
-static struct attribute *nvmem_attrs[] = {
+static const struct attribute *const nvmem_attrs[] = {
 	&dev_attr_force_ro.attr,
 	&dev_attr_type.attr,
 	NULL,
@@ -339,7 +340,7 @@ static size_t nvmem_bin_attr_size(struct kobject *kobj,
 }
 
 static umode_t nvmem_attr_is_visible(struct kobject *kobj,
-				     struct attribute *attr, int i)
+				     const struct attribute *attr, int i)
 {
 	struct device *dev = kobj_to_dev(kobj);
 	struct nvmem_device *nvmem = to_nvmem_device(dev);
@@ -412,10 +413,10 @@ static const struct bin_attribute *const nvmem_bin_attributes[] = {
 
 static const struct attribute_group nvmem_bin_group = {
 	.bin_attrs	= nvmem_bin_attributes,
-	.attrs		= nvmem_attrs,
+	.attrs_const	= nvmem_attrs,
 	.is_bin_visible = nvmem_bin_attr_is_visible,
 	.bin_size	= nvmem_bin_attr_size,
-	.is_visible	= nvmem_attr_is_visible,
+	.is_visible_const = nvmem_attr_is_visible,
 };
 
 static const struct attribute_group *nvmem_dev_groups[] = {

---
base-commit: 8f7df005a7564bd7ffa75da9c3085d5b996f1e16
change-id: 20261021-nvmem-sysfs-const-4f5754263444

Best regards,
-- 
Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>


             reply	other threads:[~2026-10-21 12:12 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-21 12:12 Bartosz Golaszewski [this message]
2026-10-21 12:24 ` Thomas Weißschuh

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=20261021-nvmem-sysfs-const-v1-1-a35251dcdef6@oss.qualcomm.com \
    --to=bartosz.golaszewski@oss.qualcomm.com \
    --cc=brgl@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=srini@kernel.org \
    --cc=thomas.weissschuh@linutronix.de \
    /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

all inboxes | Powered by JetHome®