diff options
Diffstat (limited to 'drivers/base/base.h')
| -rw-r--r-- | drivers/base/base.h | 109 |
1 files changed, 61 insertions, 48 deletions
diff --git a/drivers/base/base.h b/drivers/base/base.h index 79d031d2d845..30b416588617 100644 --- a/drivers/base/base.h +++ b/drivers/base/base.h @@ -13,27 +13,28 @@ #include <linux/notifier.h> /** - * struct subsys_private - structure to hold the private to the driver core portions of the bus_type/class structure. - * - * @subsys - the struct kset that defines this subsystem - * @devices_kset - the subsystem's 'devices' directory - * @interfaces - list of subsystem interfaces associated - * @mutex - protect the devices, and interfaces lists. - * - * @drivers_kset - the list of drivers associated - * @klist_devices - the klist to iterate over the @devices_kset - * @klist_drivers - the klist to iterate over the @drivers_kset - * @bus_notifier - the bus notifier list for anything that cares about things - * on this bus. - * @bus - pointer back to the struct bus_type that this structure is associated - * with. + * struct subsys_private - structure to hold the private to the driver core + * portions of the bus_type/class structure. + * @subsys: the struct kset that defines this subsystem + * @devices_kset: the subsystem's 'devices' directory + * @interfaces: list of subsystem interfaces associated + * @mutex: protect the devices, and interfaces lists. + * @drivers_kset: the list of drivers associated + * @klist_devices: the klist to iterate over the @devices_kset + * @klist_drivers: the klist to iterate over the @drivers_kset + * @bus_notifier: the bus notifier list for anything that cares about things + * on this bus. + * @drivers_autoprobe: gate whether new devices are automatically attached to + * registered drivers, or new drivers automatically attach + * to existing devices. + * @bus: pointer back to the struct bus_type that this structure is associated + * with. * @dev_root: Default device to use as the parent. - * - * @glue_dirs - "glue" directory to put in-between the parent device to - * avoid namespace conflicts - * @class - pointer back to the struct class that this structure is associated - * with. - * @lock_key: Lock class key for use by the lock validator + * @glue_dirs: "glue" directory to put in-between the parent device to + * avoid namespace conflicts + * @class: pointer back to the struct class that this structure is associated + * with. + * @lock_key: Lock class key for use by the lock validator * * This structure is the one that is the actual kobject allowing struct * bus_type/class to be statically allocated safely. Nothing outside of the @@ -98,24 +99,26 @@ struct driver_type { #endif /** - * struct device_private - structure to hold the private to the driver core portions of the device structure. - * - * @klist_children - klist containing all children of this device - * @knode_parent - node in sibling list - * @knode_driver - node in driver list - * @knode_bus - node in bus list - * @knode_class - node in class list - * @deferred_probe - entry in deferred_probe_list which is used to retry the - * binding of drivers which were unable to get all the resources needed by - * the device; typically because it depends on another driver getting - * probed first. - * @async_driver - pointer to device driver awaiting probe via async_probe - * @device - pointer back to the struct device that this structure is - * associated with. - * @driver_type - The type of the bound Rust driver. - * @dead - This device is currently either in the process of or has been - * removed from the system. Any asynchronous events scheduled for this - * device should exit without taking any action. + * struct device_private - structure to hold the private to the driver core + * portions of the device structure. + * @klist_children: klist containing all children of this device + * @knode_parent: node in sibling list + * @knode_driver: node in driver list + * @knode_bus: node in bus list + * @knode_class: node in class list + * @deferred_probe: entry in deferred_probe_list which is used to retry the + * binding of drivers which were unable to get all the + * resources needed by the device; typically because it depends + * on another driver getting probed first. + * @async_driver: pointer to device driver awaiting probe via async_probe + * @deferred_probe_reason: capture the -EPROBE_DEFER message emitted with + * dev_err_probe() for later retrieval via debugfs + * @device: pointer back to the struct device that this structure is + * associated with. + * @driver_type: The type of the bound Rust driver. + * @dead: This device is currently either in the process of or has been + * removed from the system. Any asynchronous events scheduled for this + * device should exit without taking any action. * * Nothing outside of the driver core should ever touch these fields. */ @@ -179,19 +182,10 @@ void device_release_driver_internal(struct device *dev, const struct device_driv void driver_detach(const struct device_driver *drv); void driver_deferred_probe_del(struct device *dev); void device_set_deferred_probe_reason(const struct device *dev, struct va_format *vaf); -static inline int driver_match_device_locked(const struct device_driver *drv, - struct device *dev) -{ - device_lock_assert(dev); - - return drv->bus->match ? drv->bus->match(dev, drv) : 1; -} - static inline int driver_match_device(const struct device_driver *drv, struct device *dev) { - guard(device)(dev); - return driver_match_device_locked(drv, dev); + return drv->bus->match ? drv->bus->match(dev, drv) : 1; } static inline void dev_sync_state(struct device *dev) @@ -222,6 +216,24 @@ static inline void device_set_driver(struct device *dev, const struct device_dri WRITE_ONCE(dev->driver, (struct device_driver *)drv); } +struct devres_node; +typedef void (*dr_node_release_t)(struct device *dev, struct devres_node *node); +typedef void (*dr_node_free_t)(struct devres_node *node); + +struct devres_node { + struct list_head entry; + dr_node_release_t release; + dr_node_free_t free_node; + const char *name; + size_t size; +}; + +void devres_node_init(struct devres_node *node, dr_node_release_t release, + dr_node_free_t free_node); +void devres_node_add(struct device *dev, struct devres_node *node); +bool devres_node_remove(struct device *dev, struct devres_node *node); +void devres_set_node_dbginfo(struct devres_node *node, const char *name, + size_t size); void devres_for_each_res(struct device *dev, dr_release_t release, dr_match_t match, void *match_data, void (*fn)(struct device *, void *, void *), @@ -300,6 +312,7 @@ static inline int devtmpfs_create_node(struct device *dev) { return 0; } static inline int devtmpfs_delete_node(struct device *dev) { return 0; } #endif +void software_node_init(void); void software_node_notify(struct device *dev); void software_node_notify_remove(struct device *dev); |
