Re: [PATCH 2/2] nvmem: expose NVMEM cells in sysfs

From: Rafał Miłecki
Date: Tue Dec 21 2021 - 10:33:24 EST


On 21.12.2021 16:18, Greg Kroah-Hartman wrote:
On Tue, Dec 21, 2021 at 04:09:13PM +0100, Rafał Miłecki wrote:
So both: kernel and user space need to access U-Boot environment
variables (NVMEM cells). Each for its own purposes.

Kernel goes first so it needs its own parser of NVMEM content (data).

User space can either: get NVMEM cells exposed by kernel OR parse NVMEM
content on its own. I thought it'd be nice to avoid parsing code
duplication in user space and let kernel expose NVMEM cells.

Ah, so you already have the data parsed, and you just want to also
expose it to userspace. That makes more sense (sorry, it's been a long
day of reviewing crappy patches, not yours of course...)

So sure, you can dynamically create attributes and then add them to the
device before you register it with the driver core. Be sure to
initialize them properly with the call I pointed out previously and you
should be good to go. You will have to keep a list of them around and
then free them yourself when the device is cleaned up, so watch out for
that.

And again, don't use a binary attribute, that's not what it is for.

Thanks for review & discussing this! I really appreciate you getting
this patch details out of me so it's clear how to proceed.

Lesson learnt: spend more time on describing my commits.