linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Rafał Miłecki" <zajec5@gmail.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "Srinivas Kandagatla" <srinivas.kandagatla@linaro.org>,
	"Rafael J . Wysocki" <rafael@kernel.org>,
	"Jonathan Corbet" <corbet@lwn.net>,
	"Daniel Vetter" <daniel.vetter@ffwll.ch>,
	"Dan Williams" <dan.j.williams@intel.com>,
	"Bjorn Helgaas" <bhelgaas@google.com>,
	"Krzysztof Wilczyński" <kw@linux.com>,
	"Heiner Kallweit" <hkallweit1@gmail.com>,
	linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Rafał Miłecki" <rafal@milecki.pl>
Subject: Re: [PATCH 2/2] nvmem: expose NVMEM cells in sysfs
Date: Mon, 20 Dec 2021 21:39:43 +0100	[thread overview]
Message-ID: <c49f2d6d-7974-5bc7-9bc1-ac265a23c2c0@gmail.com> (raw)
In-Reply-To: <YcA4ArALDTjUedrb@kroah.com>

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?

  reply	other threads:[~2021-12-20 20:39 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-20  6:47 [PATCH 1/2] sysfs: add sysfs_add_bin_file_to_group() Rafał Miłecki
2021-12-20  6:47 ` [PATCH 2/2] nvmem: expose NVMEM cells in sysfs Rafał Miłecki
2021-12-20  8:00   ` Greg Kroah-Hartman
2021-12-20 20:39     ` Rafał Miłecki [this message]
2021-12-21  6:33       ` Greg Kroah-Hartman
2021-12-21  6:39         ` Rafał Miłecki
2021-12-21  6:45           ` Greg Kroah-Hartman
2021-12-21  6:53             ` Rafał Miłecki
2021-12-21  7:13               ` Greg Kroah-Hartman
2021-12-21 12:24                 ` Rafał Miłecki
2021-12-21 12:56                   ` Greg Kroah-Hartman
2021-12-21 13:05                     ` Rafał Miłecki
2021-12-21 13:27                       ` Greg Kroah-Hartman
2021-12-21 13:52                         ` Rafał Miłecki
2021-12-21 14:27                           ` Greg Kroah-Hartman
2021-12-21 15:09                             ` Rafał Miłecki
2021-12-21 15:18                               ` Greg Kroah-Hartman
2021-12-21 15:33                                 ` Rafał Miłecki
2021-12-22  0:11   ` John Thomson
2021-12-20  8:01 ` [PATCH 1/2] sysfs: add sysfs_add_bin_file_to_group() Greg Kroah-Hartman

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=c49f2d6d-7974-5bc7-9bc1-ac265a23c2c0@gmail.com \
    --to=zajec5@gmail.com \
    --cc=bhelgaas@google.com \
    --cc=corbet@lwn.net \
    --cc=dan.j.williams@intel.com \
    --cc=daniel.vetter@ffwll.ch \
    --cc=gregkh@linuxfoundation.org \
    --cc=hkallweit1@gmail.com \
    --cc=kw@linux.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=rafal@milecki.pl \
    --cc=srinivas.kandagatla@linaro.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;
as well as URLs for NNTP newsgroup(s).