[PATCH v3 7/9] nvmem: simplify nvmem_sysfs_remove_compat()
From: Bartosz Golaszewski
Date: Wed Apr 29 2026 - 11:50:43 EST
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@xxxxxxxxxxxxxxxx>
---
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 83ef4858939c471daabd4641f9746d92b43daf5d..32fe048a4a9152b7a5ec465ae5bbf04e30319554 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -454,10 +454,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);
}
@@ -524,8 +523,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)
{
}
@@ -1046,8 +1044,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);
@@ -1063,8 +1060,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