On Sunday 20 May 2007 07:01, Pierre Ossman wrote:Hi Greg,
I'm reworking the sysfs stuff in the MMC layer to be a bit more flexible, but
there is one thing that has me baffled; how do you add attributes to an object
in a race free manner when you have a dynamic set of attributes.
I've looked at other parts of the kernel and they all use:
1. Add object.
2. Add attributes.
To me, it seems like there's a window between 1 and 2 where the object is in
/sys but doesn't have the proper attributes. Life for user space gets very
annoying if it has to add artificial delays to avoid this window.
So how do I do this properly? Something like this would, from my point of view,
be the sane method:
1. Add hidden object.
2. Add attributes.
3. Show object.
1. dev->uevent_suppress = 1;
2. device_register(dev);
3. device_create_file(dev, ...);
4. dev->uevent_suppress = 0;
5. kobject_uevent(&dev->kobj, KOBJ_ADD);