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>,
	Bartosz Golaszewski <brgl@kernel.org>,
	Johan Hovold <johan@kernel.org>,
	Loic Poulain <loic.poulain@oss.qualcomm.com>
Cc: linux-kernel@vger.kernel.org, brgl@kernel.org,
	Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Subject: [PATCH v5 7/9] nvmem: simplify nvmem_sysfs_remove_compat()
Date: Mon, 29 Jun 2026 11:47:52 +0200	[thread overview]
Message-ID: <20260629-nvmem-unbind-v5-7-233212f241c4@oss.qualcomm.com> (raw)
In-Reply-To: <20260629-nvmem-unbind-v5-0-233212f241c4@oss.qualcomm.com>

There's no need for the config argument in nvmem_sysfs_remove_compat().
Once the compat attribute is registered, that information is carried in
nvmem_device::flags. Rework the code to always query that field and drop
the second argument.

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

diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index b6429aae99e0deef502b1929debc47a09986925d..c59c5f0e8a253eaedc0c6b180c7273a6c53ee1ac 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -460,10 +460,9 @@ static int nvmem_sysfs_setup_compat(struct nvmem_device *nvmem,
 	return 0;
 }
 
-static void nvmem_sysfs_remove_compat(struct nvmem_device *nvmem,
-			      const struct nvmem_config *config)
+static void nvmem_sysfs_remove_compat(struct nvmem_device *nvmem)
 {
-	if (config->compat)
+	if (nvmem->flags & FLAG_COMPAT)
 		device_remove_bin_file(nvmem->base_dev, &nvmem->eeprom);
 }
 
@@ -530,8 +529,7 @@ static int nvmem_sysfs_setup_compat(struct nvmem_device *nvmem,
 {
 	return -ENOSYS;
 }
-static void nvmem_sysfs_remove_compat(struct nvmem_device *nvmem,
-				      const struct nvmem_config *config)
+static void nvmem_sysfs_remove_compat(struct nvmem_device *nvmem)
 {
 }
 
@@ -1052,8 +1050,7 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config)
 	device_del(&nvmem->dev);
 err_remove_cells:
 	nvmem_device_remove_all_cells(nvmem);
-	if (config->compat)
-		nvmem_sysfs_remove_compat(nvmem, config);
+	nvmem_sysfs_remove_compat(nvmem);
 err_put_device:
 	put_device(&nvmem->dev);
 
@@ -1069,8 +1066,7 @@ static void nvmem_device_release(struct kref *kref)
 
 	blocking_notifier_call_chain(&nvmem_notifier, NVMEM_REMOVE, nvmem);
 
-	if (nvmem->flags & FLAG_COMPAT)
-		device_remove_bin_file(nvmem->base_dev, &nvmem->eeprom);
+	nvmem_sysfs_remove_compat(nvmem);
 
 	nvmem_device_remove_all_cells(nvmem);
 	nvmem_destroy_layout(nvmem);

-- 
2.47.3


  parent reply	other threads:[~2026-06-29  9:48 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-29  9:47 [PATCH v5 0/9] nvmem: rework nvmem core and allow unbinding with active consumers Bartosz Golaszewski
2026-06-29  9:47 ` [PATCH v5 1/9] nvmem: remove unused field from struct nvmem_device Bartosz Golaszewski
2026-06-29  9:47 ` [PATCH v5 2/9] nvmem: return -EOPNOTSUPP to in-kernel users on missing callbacks Bartosz Golaszewski
2026-06-29  9:47 ` [PATCH v5 3/9] nvmem: check the return value of gpiod_set_value_cansleep() Bartosz Golaszewski
2026-06-29  9:47 ` [PATCH v5 4/9] nvmem: simplify locking with guard() Bartosz Golaszewski
2026-06-29  9:47 ` [PATCH v5 5/9] nvmem: remove unneeded __nvmem_device_put() Bartosz Golaszewski
2026-06-29  9:47 ` [PATCH v5 6/9] nvmem: split out the reg_read/write() callbacks out of struct nvmem_device Bartosz Golaszewski
2026-06-29  9:47 ` Bartosz Golaszewski [this message]
2026-06-29  9:47 ` [PATCH v5 8/9] nvmem: remove duplicated reference counting Bartosz Golaszewski
2026-06-29  9:47 ` [PATCH v5 9/9] nvmem: protect nvmem_device::ops with SRCU Bartosz Golaszewski
2026-07-03 14:37 ` [PATCH v5 0/9] nvmem: rework nvmem core and allow unbinding with active consumers Loic Poulain
2026-07-08 20:26 ` Srinivas Kandagatla

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=20260629-nvmem-unbind-v5-7-233212f241c4@oss.qualcomm.com \
    --to=bartosz.golaszewski@oss.qualcomm.com \
    --cc=brgl@kernel.org \
    --cc=johan@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=loic.poulain@oss.qualcomm.com \
    --cc=srini@kernel.org \
    /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