1a1bdc7aaSBen Dooks 2c6f7e72aSGreg Kroah-Hartman /** 36b6e39a6SKay Sievers * struct subsys_private - structure to hold the private to the driver core portions of the bus_type/class structure. 4c6f7e72aSGreg Kroah-Hartman * 56b6e39a6SKay Sievers * @subsys - the struct kset that defines this subsystem 66b6e39a6SKay Sievers * @devices_kset - the list of devices associated 76b6e39a6SKay Sievers * 86b6e39a6SKay Sievers * @drivers_kset - the list of drivers associated 9c6f7e72aSGreg Kroah-Hartman * @klist_devices - the klist to iterate over the @devices_kset 10c6f7e72aSGreg Kroah-Hartman * @klist_drivers - the klist to iterate over the @drivers_kset 11c6f7e72aSGreg Kroah-Hartman * @bus_notifier - the bus notifier list for anything that cares about things 12c6f7e72aSGreg Kroah-Hartman * on this bus. 13c6f7e72aSGreg Kroah-Hartman * @bus - pointer back to the struct bus_type that this structure is associated 14c6f7e72aSGreg Kroah-Hartman * with. 15c6f7e72aSGreg Kroah-Hartman * 166b6e39a6SKay Sievers * @class_interfaces - list of class_interfaces associated 176b6e39a6SKay Sievers * @glue_dirs - "glue" directory to put in-between the parent device to 186b6e39a6SKay Sievers * avoid namespace conflicts 196b6e39a6SKay Sievers * @class_mutex - mutex to protect the children, devices, and interfaces lists. 206b6e39a6SKay Sievers * @class - pointer back to the struct class that this structure is associated 216b6e39a6SKay Sievers * with. 226b6e39a6SKay Sievers * 23c6f7e72aSGreg Kroah-Hartman * This structure is the one that is the actual kobject allowing struct 246b6e39a6SKay Sievers * bus_type/class to be statically allocated safely. Nothing outside of the 256b6e39a6SKay Sievers * driver core should ever touch these fields. 26c6f7e72aSGreg Kroah-Hartman */ 276b6e39a6SKay Sievers struct subsys_private { 28c6f7e72aSGreg Kroah-Hartman struct kset subsys; 29c6f7e72aSGreg Kroah-Hartman struct kset *devices_kset; 306b6e39a6SKay Sievers 316b6e39a6SKay Sievers struct kset *drivers_kset; 32c6f7e72aSGreg Kroah-Hartman struct klist klist_devices; 33c6f7e72aSGreg Kroah-Hartman struct klist klist_drivers; 34c6f7e72aSGreg Kroah-Hartman struct blocking_notifier_head bus_notifier; 35c6f7e72aSGreg Kroah-Hartman unsigned int drivers_autoprobe:1; 36c6f7e72aSGreg Kroah-Hartman struct bus_type *bus; 376b6e39a6SKay Sievers 386b6e39a6SKay Sievers struct list_head class_interfaces; 396b6e39a6SKay Sievers struct kset glue_dirs; 406b6e39a6SKay Sievers struct mutex class_mutex; 416b6e39a6SKay Sievers struct class *class; 42c6f7e72aSGreg Kroah-Hartman }; 436b6e39a6SKay Sievers #define to_subsys_private(obj) container_of(obj, struct subsys_private, subsys.kobj) 44a1bdc7aaSBen Dooks 45e5dd1278SGreg Kroah-Hartman struct driver_private { 46e5dd1278SGreg Kroah-Hartman struct kobject kobj; 47e5dd1278SGreg Kroah-Hartman struct klist klist_devices; 48e5dd1278SGreg Kroah-Hartman struct klist_node knode_bus; 49e5dd1278SGreg Kroah-Hartman struct module_kobject *mkobj; 50e5dd1278SGreg Kroah-Hartman struct device_driver *driver; 51e5dd1278SGreg Kroah-Hartman }; 52e5dd1278SGreg Kroah-Hartman #define to_driver(obj) container_of(obj, struct driver_private, kobj) 53c6f7e72aSGreg Kroah-Hartman 54fb069a5dSGreg Kroah-Hartman /** 55fb069a5dSGreg Kroah-Hartman * struct device_private - structure to hold the private to the driver core portions of the device structure. 56fb069a5dSGreg Kroah-Hartman * 57f791b8c8SGreg Kroah-Hartman * @klist_children - klist containing all children of this device 58f791b8c8SGreg Kroah-Hartman * @knode_parent - node in sibling list 598940b4f3SGreg Kroah-Hartman * @knode_driver - node in driver list 60ae1b4171SGreg Kroah-Hartman * @knode_bus - node in bus list 61b4028437SGreg Kroah-Hartman * @driver_data - private pointer for driver specific info. Will turn into a 62b4028437SGreg Kroah-Hartman * list soon. 63fb069a5dSGreg Kroah-Hartman * @device - pointer back to the struct class that this structure is 64fb069a5dSGreg Kroah-Hartman * associated with. 65fb069a5dSGreg Kroah-Hartman * 66fb069a5dSGreg Kroah-Hartman * Nothing outside of the driver core should ever touch these fields. 67fb069a5dSGreg Kroah-Hartman */ 68fb069a5dSGreg Kroah-Hartman struct device_private { 69f791b8c8SGreg Kroah-Hartman struct klist klist_children; 70f791b8c8SGreg Kroah-Hartman struct klist_node knode_parent; 718940b4f3SGreg Kroah-Hartman struct klist_node knode_driver; 72ae1b4171SGreg Kroah-Hartman struct klist_node knode_bus; 73b4028437SGreg Kroah-Hartman void *driver_data; 74fb069a5dSGreg Kroah-Hartman struct device *device; 75fb069a5dSGreg Kroah-Hartman }; 76f791b8c8SGreg Kroah-Hartman #define to_device_private_parent(obj) \ 77f791b8c8SGreg Kroah-Hartman container_of(obj, struct device_private, knode_parent) 788940b4f3SGreg Kroah-Hartman #define to_device_private_driver(obj) \ 798940b4f3SGreg Kroah-Hartman container_of(obj, struct device_private, knode_driver) 80ae1b4171SGreg Kroah-Hartman #define to_device_private_bus(obj) \ 81ae1b4171SGreg Kroah-Hartman container_of(obj, struct device_private, knode_bus) 82fb069a5dSGreg Kroah-Hartman 83b4028437SGreg Kroah-Hartman extern int device_private_init(struct device *dev); 84b4028437SGreg Kroah-Hartman 85c6f7e72aSGreg Kroah-Hartman /* initialisation functions */ 86a1bdc7aaSBen Dooks extern int devices_init(void); 87a1bdc7aaSBen Dooks extern int buses_init(void); 88a1bdc7aaSBen Dooks extern int classes_init(void); 89a1bdc7aaSBen Dooks extern int firmware_init(void); 904039483fSMichael Holzheu #ifdef CONFIG_SYS_HYPERVISOR 914039483fSMichael Holzheu extern int hypervisor_init(void); 924039483fSMichael Holzheu #else 934039483fSMichael Holzheu static inline int hypervisor_init(void) { return 0; } 944039483fSMichael Holzheu #endif 95a1bdc7aaSBen Dooks extern int platform_bus_init(void); 96a1bdc7aaSBen Dooks extern int system_bus_init(void); 97a1bdc7aaSBen Dooks extern int cpu_dev_init(void); 98a1bdc7aaSBen Dooks 991da177e4SLinus Torvalds extern int bus_add_device(struct device *dev); 1002023c610SAlan Stern extern void bus_probe_device(struct device *dev); 1011da177e4SLinus Torvalds extern void bus_remove_device(struct device *dev); 1021da177e4SLinus Torvalds 1034a3ad20cSGreg Kroah-Hartman extern int bus_add_driver(struct device_driver *drv); 1044a3ad20cSGreg Kroah-Hartman extern void bus_remove_driver(struct device_driver *drv); 1051da177e4SLinus Torvalds 10607e4a3e2Smochel@digitalimplant.org extern void driver_detach(struct device_driver *drv); 1074a3ad20cSGreg Kroah-Hartman extern int driver_probe_device(struct device_driver *drv, struct device *dev); 10849b420a1SMing Lei static inline int driver_match_device(struct device_driver *drv, 10949b420a1SMing Lei struct device *dev) 11049b420a1SMing Lei { 1115247aecfSMing Lei return drv->bus->match ? drv->bus->match(dev, drv) : 1; 11249b420a1SMing Lei } 11307e4a3e2Smochel@digitalimplant.org 114f67d115fSAdrian Bunk extern void sysdev_shutdown(void); 115f67d115fSAdrian Bunk 116aa49b913SGreg Kroah-Hartman extern char *make_class_name(const char *name, struct kobject *kobj); 1171da177e4SLinus Torvalds 1182a013455SAdrian Bunk extern int devres_release_all(struct device *dev); 119823bccfcSGreg Kroah-Hartman 120881c6cfdSGreg Kroah-Hartman extern struct kset *devices_kset; 121c63469a3SGreg Kroah-Hartman 12292b42141SRandy Dunlap #if defined(CONFIG_MODULES) && defined(CONFIG_SYSFS) 123c63469a3SGreg Kroah-Hartman extern void module_add_driver(struct module *mod, struct device_driver *drv); 124c63469a3SGreg Kroah-Hartman extern void module_remove_driver(struct device_driver *drv); 125c63469a3SGreg Kroah-Hartman #else 126c63469a3SGreg Kroah-Hartman static inline void module_add_driver(struct module *mod, 127c63469a3SGreg Kroah-Hartman struct device_driver *drv) { } 128c63469a3SGreg Kroah-Hartman static inline void module_remove_driver(struct device_driver *drv) { } 129c63469a3SGreg Kroah-Hartman #endif 1302b2af54aSKay Sievers 1312b2af54aSKay Sievers #ifdef CONFIG_DEVTMPFS 1322b2af54aSKay Sievers extern int devtmpfs_init(void); 1332b2af54aSKay Sievers #else 1342b2af54aSKay Sievers static inline int devtmpfs_init(void) { return 0; } 1352b2af54aSKay Sievers #endif 136