1a1bdc7aaSBen Dooks 2c6f7e72aSGreg Kroah-Hartman /** 3c6f7e72aSGreg Kroah-Hartman * struct bus_type_private - structure to hold the private to the driver core portions of the bus_type structure. 4c6f7e72aSGreg Kroah-Hartman * 5c6f7e72aSGreg Kroah-Hartman * @subsys - the struct kset that defines this bus. This is the main kobject 6c6f7e72aSGreg Kroah-Hartman * @drivers_kset - the list of drivers associated with this bus 7c6f7e72aSGreg Kroah-Hartman * @devices_kset - the list of devices associated with this bus 8c6f7e72aSGreg Kroah-Hartman * @klist_devices - the klist to iterate over the @devices_kset 9c6f7e72aSGreg Kroah-Hartman * @klist_drivers - the klist to iterate over the @drivers_kset 10c6f7e72aSGreg Kroah-Hartman * @bus_notifier - the bus notifier list for anything that cares about things 11c6f7e72aSGreg Kroah-Hartman * on this bus. 12c6f7e72aSGreg Kroah-Hartman * @bus - pointer back to the struct bus_type that this structure is associated 13c6f7e72aSGreg Kroah-Hartman * with. 14c6f7e72aSGreg Kroah-Hartman * 15c6f7e72aSGreg Kroah-Hartman * This structure is the one that is the actual kobject allowing struct 16c6f7e72aSGreg Kroah-Hartman * bus_type to be statically allocated safely. Nothing outside of the driver 17c6f7e72aSGreg Kroah-Hartman * core should ever touch these fields. 18c6f7e72aSGreg Kroah-Hartman */ 19c6f7e72aSGreg Kroah-Hartman struct bus_type_private { 20c6f7e72aSGreg Kroah-Hartman struct kset subsys; 21c6f7e72aSGreg Kroah-Hartman struct kset *drivers_kset; 22c6f7e72aSGreg Kroah-Hartman struct kset *devices_kset; 23c6f7e72aSGreg Kroah-Hartman struct klist klist_devices; 24c6f7e72aSGreg Kroah-Hartman struct klist klist_drivers; 25c6f7e72aSGreg Kroah-Hartman struct blocking_notifier_head bus_notifier; 26c6f7e72aSGreg Kroah-Hartman unsigned int drivers_autoprobe:1; 27c6f7e72aSGreg Kroah-Hartman struct bus_type *bus; 28c6f7e72aSGreg Kroah-Hartman }; 29a1bdc7aaSBen Dooks 30e5dd1278SGreg Kroah-Hartman struct driver_private { 31e5dd1278SGreg Kroah-Hartman struct kobject kobj; 32e5dd1278SGreg Kroah-Hartman struct klist klist_devices; 33e5dd1278SGreg Kroah-Hartman struct klist_node knode_bus; 34e5dd1278SGreg Kroah-Hartman struct module_kobject *mkobj; 35e5dd1278SGreg Kroah-Hartman struct device_driver *driver; 36e5dd1278SGreg Kroah-Hartman }; 37e5dd1278SGreg Kroah-Hartman #define to_driver(obj) container_of(obj, struct driver_private, kobj) 38c6f7e72aSGreg Kroah-Hartman 397c71448bSGreg Kroah-Hartman 407c71448bSGreg Kroah-Hartman /** 417c71448bSGreg Kroah-Hartman * struct class_private - structure to hold the private to the driver core portions of the class structure. 427c71448bSGreg Kroah-Hartman * 431fbfee6cSGreg Kroah-Hartman * @class_subsys - the struct kset that defines this class. This is the main kobject 4497ae69fdSGreg Kroah-Hartman * @class_devices - list of devices associated with this class 45184f1f77SGreg Kroah-Hartman * @class_interfaces - list of class_interfaces associated with this class 461e412508SGreg Kroah-Hartman * @class_dirs - "glue" directory for virtual devices associated with this class 47f75b1c60SDave Young * @class_mutex - mutex to protect the children, devices, and interfaces lists. 487c71448bSGreg Kroah-Hartman * @class - pointer back to the struct class that this structure is associated 497c71448bSGreg Kroah-Hartman * with. 507c71448bSGreg Kroah-Hartman * 517c71448bSGreg Kroah-Hartman * This structure is the one that is the actual kobject allowing struct 527c71448bSGreg Kroah-Hartman * class to be statically allocated safely. Nothing outside of the driver 537c71448bSGreg Kroah-Hartman * core should ever touch these fields. 547c71448bSGreg Kroah-Hartman */ 557c71448bSGreg Kroah-Hartman struct class_private { 561fbfee6cSGreg Kroah-Hartman struct kset class_subsys; 575a3ceb86STejun Heo struct klist class_devices; 58184f1f77SGreg Kroah-Hartman struct list_head class_interfaces; 597c71448bSGreg Kroah-Hartman struct kset class_dirs; 60f75b1c60SDave Young struct mutex class_mutex; 617c71448bSGreg Kroah-Hartman struct class *class; 627c71448bSGreg Kroah-Hartman }; 631fbfee6cSGreg Kroah-Hartman #define to_class(obj) \ 641fbfee6cSGreg Kroah-Hartman container_of(obj, struct class_private, class_subsys.kobj) 657c71448bSGreg Kroah-Hartman 66fb069a5dSGreg Kroah-Hartman /** 67fb069a5dSGreg Kroah-Hartman * struct device_private - structure to hold the private to the driver core portions of the device structure. 68fb069a5dSGreg Kroah-Hartman * 69f791b8c8SGreg Kroah-Hartman * @klist_children - klist containing all children of this device 70f791b8c8SGreg Kroah-Hartman * @knode_parent - node in sibling list 718940b4f3SGreg Kroah-Hartman * @knode_driver - node in driver list 72ae1b4171SGreg Kroah-Hartman * @knode_bus - node in bus list 73b4028437SGreg Kroah-Hartman * @driver_data - private pointer for driver specific info. Will turn into a 74b4028437SGreg Kroah-Hartman * list soon. 75fb069a5dSGreg Kroah-Hartman * @device - pointer back to the struct class that this structure is 76fb069a5dSGreg Kroah-Hartman * associated with. 77fb069a5dSGreg Kroah-Hartman * 78fb069a5dSGreg Kroah-Hartman * Nothing outside of the driver core should ever touch these fields. 79fb069a5dSGreg Kroah-Hartman */ 80fb069a5dSGreg Kroah-Hartman struct device_private { 81f791b8c8SGreg Kroah-Hartman struct klist klist_children; 82f791b8c8SGreg Kroah-Hartman struct klist_node knode_parent; 838940b4f3SGreg Kroah-Hartman struct klist_node knode_driver; 84ae1b4171SGreg Kroah-Hartman struct klist_node knode_bus; 85b4028437SGreg Kroah-Hartman void *driver_data; 86fb069a5dSGreg Kroah-Hartman struct device *device; 87fb069a5dSGreg Kroah-Hartman }; 88f791b8c8SGreg Kroah-Hartman #define to_device_private_parent(obj) \ 89f791b8c8SGreg Kroah-Hartman container_of(obj, struct device_private, knode_parent) 908940b4f3SGreg Kroah-Hartman #define to_device_private_driver(obj) \ 918940b4f3SGreg Kroah-Hartman container_of(obj, struct device_private, knode_driver) 92ae1b4171SGreg Kroah-Hartman #define to_device_private_bus(obj) \ 93ae1b4171SGreg Kroah-Hartman container_of(obj, struct device_private, knode_bus) 94fb069a5dSGreg Kroah-Hartman 95b4028437SGreg Kroah-Hartman extern int device_private_init(struct device *dev); 96b4028437SGreg Kroah-Hartman 97c6f7e72aSGreg Kroah-Hartman /* initialisation functions */ 98a1bdc7aaSBen Dooks extern int devices_init(void); 99a1bdc7aaSBen Dooks extern int buses_init(void); 100a1bdc7aaSBen Dooks extern int classes_init(void); 101a1bdc7aaSBen Dooks extern int firmware_init(void); 1024039483fSMichael Holzheu #ifdef CONFIG_SYS_HYPERVISOR 1034039483fSMichael Holzheu extern int hypervisor_init(void); 1044039483fSMichael Holzheu #else 1054039483fSMichael Holzheu static inline int hypervisor_init(void) { return 0; } 1064039483fSMichael Holzheu #endif 107a1bdc7aaSBen Dooks extern int platform_bus_init(void); 108a1bdc7aaSBen Dooks extern int system_bus_init(void); 109a1bdc7aaSBen Dooks extern int cpu_dev_init(void); 110a1bdc7aaSBen Dooks 1111da177e4SLinus Torvalds extern int bus_add_device(struct device *dev); 1122023c610SAlan Stern extern void bus_probe_device(struct device *dev); 1131da177e4SLinus Torvalds extern void bus_remove_device(struct device *dev); 1141da177e4SLinus Torvalds 1154a3ad20cSGreg Kroah-Hartman extern int bus_add_driver(struct device_driver *drv); 1164a3ad20cSGreg Kroah-Hartman extern void bus_remove_driver(struct device_driver *drv); 1171da177e4SLinus Torvalds 11807e4a3e2Smochel@digitalimplant.org extern void driver_detach(struct device_driver *drv); 1194a3ad20cSGreg Kroah-Hartman extern int driver_probe_device(struct device_driver *drv, struct device *dev); 12049b420a1SMing Lei static inline int driver_match_device(struct device_driver *drv, 12149b420a1SMing Lei struct device *dev) 12249b420a1SMing Lei { 1235247aecfSMing Lei return drv->bus->match ? drv->bus->match(dev, drv) : 1; 12449b420a1SMing Lei } 12507e4a3e2Smochel@digitalimplant.org 126f67d115fSAdrian Bunk extern void sysdev_shutdown(void); 127f67d115fSAdrian Bunk 128aa49b913SGreg Kroah-Hartman extern char *make_class_name(const char *name, struct kobject *kobj); 1291da177e4SLinus Torvalds 1302a013455SAdrian Bunk extern int devres_release_all(struct device *dev); 131823bccfcSGreg Kroah-Hartman 132881c6cfdSGreg Kroah-Hartman extern struct kset *devices_kset; 133c63469a3SGreg Kroah-Hartman 13492b42141SRandy Dunlap #if defined(CONFIG_MODULES) && defined(CONFIG_SYSFS) 135c63469a3SGreg Kroah-Hartman extern void module_add_driver(struct module *mod, struct device_driver *drv); 136c63469a3SGreg Kroah-Hartman extern void module_remove_driver(struct device_driver *drv); 137c63469a3SGreg Kroah-Hartman #else 138c63469a3SGreg Kroah-Hartman static inline void module_add_driver(struct module *mod, 139c63469a3SGreg Kroah-Hartman struct device_driver *drv) { } 140c63469a3SGreg Kroah-Hartman static inline void module_remove_driver(struct device_driver *drv) { } 141c63469a3SGreg Kroah-Hartman #endif 1422b2af54aSKay Sievers 1432b2af54aSKay Sievers #ifdef CONFIG_DEVTMPFS 1442b2af54aSKay Sievers extern int devtmpfs_init(void); 1452b2af54aSKay Sievers #else 1462b2af54aSKay Sievers static inline int devtmpfs_init(void) { return 0; } 1472b2af54aSKay Sievers #endif 148