drivers/base/base.h

Source file repositories/reference/linux-study-clean/drivers/base/base.h

File Facts

System
Linux kernel
Corpus path
drivers/base/base.h
Extension
.h
Size
11259 bytes
Lines
327
Domain
Driver Families
Bucket
drivers/base
Inferred role
Driver Families: operation-table or driver-model contract
Status
pattern implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

* @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
 *
 * This structure is the one that is the actual kobject allowing struct
 * bus_type/class to be statically allocated safely.  Nothing outside of the
 * driver core should ever touch these fields.
 */
struct subsys_private {
	struct kset subsys;
	struct kset *devices_kset;
	struct list_head interfaces;
	struct mutex mutex;

	struct kset *drivers_kset;
	struct klist klist_devices;
	struct klist klist_drivers;
	struct blocking_notifier_head bus_notifier;
	unsigned int drivers_autoprobe:1;
	const struct bus_type *bus;
	struct device *dev_root;

	struct kset glue_dirs;
	const struct class *class;

	struct lock_class_key lock_key;
};
#define to_subsys_private(obj) container_of_const(obj, struct subsys_private, subsys.kobj)

static inline struct subsys_private *subsys_get(struct subsys_private *sp)
{
	if (sp)
		kset_get(&sp->subsys);
	return sp;
}

static inline void subsys_put(struct subsys_private *sp)
{
	if (sp)
		kset_put(&sp->subsys);
}

struct subsys_private *bus_to_subsys(const struct bus_type *bus);
struct subsys_private *class_to_subsys(const struct class *class);

struct driver_private {
	struct kobject kobj;
	struct klist klist_devices;
	struct klist_node knode_bus;
	struct module_kobject *mkobj;
	struct device_driver *driver;
};
#define to_driver(obj) container_of(obj, struct driver_private, kobj)

/**
 * 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.
 * @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.
 */
struct device_private {
	struct klist klist_children;
	struct klist_node knode_parent;
	struct klist_node knode_driver;
	struct klist_node knode_bus;
	struct klist_node knode_class;
	struct list_head deferred_probe;
	const struct device_driver *async_driver;

Annotation

Implementation Notes