Hi Greg,
On 20.12.2021 09:00, Greg Kroah-Hartman wrote:
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?
I'm sorry I really don't see how you suggest to get it done.
I can use .is_bin_visible() callback indeed to respect nvmem->root_only.
I don't understand addig-after-the-fact part. How is .is_bin_visible()
related to adding attributes for newly created cells? Do you mean I can
avoid calling sysfs_add_bin_file_to_group()? Do you recall any existing
example of such solution?