drivers/base/dd.c
Source file repositories/reference/linux-study-clean/drivers/base/dd.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/base/dd.c- Extension
.c- Size
- 38829 bytes
- Lines
- 1439
- 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.
- 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/debugfs.hlinux/device.hlinux/delay.hlinux/dma-map-ops.hlinux/init.hlinux/module.hlinux/kthread.hlinux/wait.hlinux/async.hlinux/pm_domain.hlinux/pm_runtime.hlinux/pinctrl/devinfo.hlinux/slab.hbase.hpower/power.h
Detected Declarations
struct device_attach_datafunction __device_set_deferred_probe_reasonfunction deferred_probe_work_funcfunction driver_deferred_probe_addfunction driver_deferred_probe_delfunction driver_deferred_probe_triggerfunction device_block_probingfunction device_unblock_probingfunction device_set_deferred_probe_reasonfunction deferred_devs_showfunction deferred_probe_timeout_setupfunction driver_deferred_probe_check_statefunction deferred_probe_timeout_work_funcfunction deferred_probe_extend_timeoutfunction deferred_probe_initcallfunction deferred_probe_exitfunction __device_set_driver_overridefunction scoped_guardfunction device_is_boundfunction driver_boundfunction coredump_storefunction driver_sysfs_addfunction driver_sysfs_removefunction device_driver_attachfunction state_synced_storefunction state_synced_showfunction device_unbind_cleanupfunction device_removefunction call_driver_probefunction really_probefunction really_probe_debugfunction driver_probe_donefunction wait_for_device_probefunction __driver_probe_devicefunction driver_probe_devicefunction cmdline_requested_async_probingfunction save_async_optionsfunction driver_allows_async_probingfunction __device_attach_driverfunction __device_attach_async_helperfunction __device_attachfunction device_attachfunction device_initial_probefunction __device_driver_lockfunction __device_driver_unlockfunction device_driver_attachfunction __driver_attach_async_helperfunction __driver_attach
Annotated Snippet
* strictly code just for the 'struct bus_type'.
*
* Copyright (c) 2002-5 Patrick Mochel
* Copyright (c) 2002-3 Open Source Development Labs
* Copyright (c) 2007-2009 Greg Kroah-Hartman <gregkh@suse.de>
* Copyright (c) 2007-2009 Novell Inc.
*/
#include <linux/debugfs.h>
#include <linux/device.h>
#include <linux/delay.h>
#include <linux/dma-map-ops.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/kthread.h>
#include <linux/wait.h>
#include <linux/async.h>
#include <linux/pm_domain.h>
#include <linux/pm_runtime.h>
#include <linux/pinctrl/devinfo.h>
#include <linux/slab.h>
#include "base.h"
#include "power/power.h"
/*
* Deferred Probe infrastructure.
*
* Sometimes driver probe order matters, but the kernel doesn't always have
* dependency information which means some drivers will get probed before a
* resource it depends on is available. For example, an SDHCI driver may
* first need a GPIO line from an i2c GPIO controller before it can be
* initialized. If a required resource is not available yet, a driver can
* request probing to be deferred by returning -EPROBE_DEFER from its probe hook
*
* Deferred probe maintains two lists of devices, a pending list and an active
* list. A driver returning -EPROBE_DEFER causes the device to be added to the
* pending list. A successful driver probe will trigger moving all devices
* from the pending to the active list so that the workqueue will eventually
* retry them.
*
* The deferred_probe_mutex must be held any time the deferred_probe_*_list
* of the (struct device*)->p->deferred_probe pointers are manipulated
*/
static DEFINE_MUTEX(deferred_probe_mutex);
static LIST_HEAD(deferred_probe_pending_list);
static LIST_HEAD(deferred_probe_active_list);
static atomic_t deferred_trigger_count = ATOMIC_INIT(0);
static bool initcalls_done;
/* Save the async probe drivers' name from kernel cmdline */
#define ASYNC_DRV_NAMES_MAX_LEN 256
static char async_probe_drv_names[ASYNC_DRV_NAMES_MAX_LEN];
static bool async_probe_default;
/*
* In some cases, like suspend to RAM or hibernation, It might be reasonable
* to prohibit probing of devices as it could be unsafe.
* Once defer_all_probes is true all drivers probes will be forcibly deferred.
*/
static bool defer_all_probes;
static void __device_set_deferred_probe_reason(const struct device *dev, char *reason)
{
kfree(dev->p->deferred_probe_reason);
dev->p->deferred_probe_reason = reason;
}
/*
* deferred_probe_work_func() - Retry probing devices in the active list.
*/
static void deferred_probe_work_func(struct work_struct *work)
{
struct device *dev;
struct device_private *private;
/*
* This block processes every device in the deferred 'active' list.
* Each device is removed from the active list and passed to
* bus_probe_device() to re-attempt the probe. The loop continues
* until every device in the active list is removed and retried.
*
* Note: Once the device is removed from the list and the mutex is
* released, it is possible for the device get freed by another thread
* and cause a illegal pointer dereference. This code uses
* get/put_device() to ensure the device structure cannot disappear
* from under our feet.
*/
mutex_lock(&deferred_probe_mutex);
while (!list_empty(&deferred_probe_active_list)) {
private = list_first_entry(&deferred_probe_active_list,
Annotation
- Immediate include surface: `linux/debugfs.h`, `linux/device.h`, `linux/delay.h`, `linux/dma-map-ops.h`, `linux/init.h`, `linux/module.h`, `linux/kthread.h`, `linux/wait.h`.
- Detected declarations: `struct device_attach_data`, `function __device_set_deferred_probe_reason`, `function deferred_probe_work_func`, `function driver_deferred_probe_add`, `function driver_deferred_probe_del`, `function driver_deferred_probe_trigger`, `function device_block_probing`, `function device_unblock_probing`, `function device_set_deferred_probe_reason`, `function deferred_devs_show`.
- Atlas domain: Driver Families / drivers/base.
- Implementation status: pattern implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.