On Fri, Apr 29, 2005 at 12:28:30PM -0700, David Brownell wrote: > On Friday 29 April 2005 11:23 am, Roman Kagan wrote: > > > > ... instead of trying to make sure the attributes are available via > > sysfs at hotplug time, we can use another means to pass them to hotplug: > > we can add a routine, which, when called from the .hotplug function > > and given pointers to struct attribute and struct device, would add > > environment variable > > > > SYSFS_attrName=attrValue > > Color me amused. That was the original way to pass information > to hotplug agents ... back then (2.4.0.test10 or so), there was > usually no other way to export the relevant data. > > I'd rather just guarantee that the sysfs device were fully > constructed (attributes and all) before the driver binding and > hotplug stages of enumeration started.
I must have been unclear in what I was proposing. I don't suggest to use the technique of 2.4 age to create a set of environment variables in each .hotplug method, not related to the sysfs attributes, like usb $PRODUCT, $TYPE, $INTERFACE which are quite different from the names in sysfs, although they are supposed to convey the same information. Rather, _in_addition_ to exporting the attribute values in sysfs_dir/attrName, one can export (a subset of) them as SYSFS_attrName environment variables, using _sysfs_ facilities - .show methods - to generate their values. Although redundant to some extent, it will be free from lifetime issues, while requiring very little and absolutely generic extra code. And the userspace will be very easy to adjust too, e.g.: const char *get_attr_val(const char *attr_name) { char var_name[ENVNAME_MAX]; const char *attr_val; snprintf(var_name, ENVNAME_MAX, "SYSFS_%s", attr_name); if ((attr_val = getenv(var_name))) return attr_val; else return get_attr_val_from_sysfs(attr_name); } It'd also save 3 syscalls (open/read/close) per attribute most of the time. Cheers, Roman. ------------------------------------------------------- This SF.Net email is sponsored by: NEC IT Guy Games. Get your fingers limbered up and give it your best shot. 4 great events, 4 opportunities to win big! Highest score wins.NEC IT Guy Games. Play to win an NEC 61 plasma display. Visit http://www.necitguy.com/?r=20 _______________________________________________ linux-usb-devel@lists.sourceforge.net To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel