On Mon, Dec 20, 2021 at 07:47:30AM +0100, Rafał Miłecki wrote:
static void nvmem_cell_entry_add(struct nvmem_cell_entry *cell)
{
+ struct device *dev = &cell->nvmem->dev;
+ int err;
+
mutex_lock(&nvmem_mutex);
list_add_tail(&cell->node, &cell->nvmem->cells);
mutex_unlock(&nvmem_mutex);
+
+ sysfs_attr_init(&cell->battr.attr);
+ cell->battr.attr.name = cell->name;
+ cell->battr.attr.mode = 0400;
+ cell->battr.read = nvmem_cell_attr_read;
+ err = sysfs_add_bin_file_to_group(&dev->kobj, &cell->battr,
+ nvmem_cells_group.name);
Why not just use the is_bin_visible attribute instead to determine if
the attribute should be shown or not instead of having to add it
after-the-fact which will race with userspace and loose?