Message ID | 20241015-gpio-class-mountpoint-v2-1-7709301876ef@linaro.org |
---|---|
State | New |
Headers | show |
Series | gpio: create the /sys/class/gpio mount point with GPIO_SYSFS disabled | expand |
On Tue, Oct 15, 2024 at 10:00:23AM +0200, Bartosz Golaszewski wrote: > From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org> > > Export the address of the /sys/class kobject to users that need to > chain off of it by means other than calling register_class(). Ick, no. > This will > be used by the GPIO subsystem to provide a backward compatibility > mount-point for the GPIO sysfs class once it's disabled. Again, ick, no. No "mount point" should be messing with sysfs, don't do that. sysfs is a simple "if the file or directory is not there, don't worry about it" type of interface (i.e. fixing the issues we had with /proc). If a userspace tool can't find something there, then it should just error out or move on. Let's not allow anything to mount anything at /sys/class/ please, that way lies madness for the next 40+ years. If you want to drop a userspace api, drop it, don't paper over it with something that you can't drop either. thanks, greg k-h
diff --git a/drivers/base/class.c b/drivers/base/class.c index cb5359235c70..68474aff53df 100644 --- a/drivers/base/class.c +++ b/drivers/base/class.c @@ -23,6 +23,9 @@ /* /sys/class */ static struct kset *class_kset; +struct kobject *class_kobj; +EXPORT_SYMBOL_GPL(class_kobj); + #define to_class_attr(_attr) container_of(_attr, struct class_attribute, attr) /** @@ -668,5 +671,8 @@ int __init classes_init(void) class_kset = kset_create_and_add("class", NULL, NULL); if (!class_kset) return -ENOMEM; + + class_kobj = &class_kset->kobj; + return 0; } diff --git a/include/linux/device/class.h b/include/linux/device/class.h index 518c9c83d64b..898f7948293d 100644 --- a/include/linux/device/class.h +++ b/include/linux/device/class.h @@ -69,6 +69,12 @@ struct class { const struct dev_pm_ops *pm; }; +/* + * Global /sys/class kobject for creating sub-groups by means other than + * class_register(). + */ +extern struct kobject *class_kobj; + struct class_dev_iter { struct klist_iter ki; const struct device_type *type;