arch/sh/drivers/platform_early.c
Source file repositories/reference/linux-study-clean/arch/sh/drivers/platform_early.c
File Facts
- System
- Linux kernel
- Corpus path
arch/sh/drivers/platform_early.c- Extension
.c- Size
- 8899 bytes
- Lines
- 337
- Domain
- Architecture Layer
- Bucket
- arch/sh
- Inferred role
- Architecture Layer: operation-table or driver-model contract
- Status
- pattern implementation candidate
Why This File Exists
CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- 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
asm/platform_early.hlinux/mod_devicetable.hlinux/pm.h
Detected Declarations
function platform_match_idfunction platform_matchfunction device_pm_init_commonfunction pm_runtime_early_initfunction pm_runtime_early_initfunction sh_early_platform_add_devicesfunction sh_early_platform_driver_register_allfunction sh_early_platform_matchfunction sh_early_platform_leftfunction sh_early_platform_driver_probe_idfunction list_for_each_entryfunction sh_early_platform_driver_probefunction early_platform_cleanup
Annotated Snippet
static int platform_match(struct device *dev, struct device_driver *drv)
{
struct platform_device *pdev = to_platform_device(dev);
struct platform_driver *pdrv = to_platform_driver(drv);
/* Then try to match against the id table */
if (pdrv->id_table)
return platform_match_id(pdrv->id_table, pdev) != NULL;
/* fall-back to driver name match */
return (strcmp(pdev->name, drv->name) == 0);
}
#ifdef CONFIG_PM
static void device_pm_init_common(struct device *dev)
{
if (!dev->power.early_init) {
spin_lock_init(&dev->power.lock);
dev->power.qos = NULL;
dev->power.early_init = true;
}
}
static void pm_runtime_early_init(struct device *dev)
{
dev->power.disable_depth = 1;
device_pm_init_common(dev);
}
#else
static void pm_runtime_early_init(struct device *dev) {}
#endif
/**
* sh_early_platform_driver_register - register early platform driver
* @epdrv: sh_early_platform driver structure
* @buf: string passed from early_param()
*
* Helper function for sh_early_platform_init() / sh_early_platform_init_buffer()
*/
int __init sh_early_platform_driver_register(struct sh_early_platform_driver *epdrv,
char *buf)
{
char *tmp;
int n;
/* Simply add the driver to the end of the global list.
* Drivers will by default be put on the list in compiled-in order.
*/
if (!epdrv->list.next) {
INIT_LIST_HEAD(&epdrv->list);
list_add_tail(&epdrv->list, &sh_early_platform_driver_list);
}
/* If the user has specified device then make sure the driver
* gets prioritized. The driver of the last device specified on
* command line will be put first on the list.
*/
n = strlen(epdrv->pdrv->driver.name);
if (buf && !strncmp(buf, epdrv->pdrv->driver.name, n)) {
list_move(&epdrv->list, &sh_early_platform_driver_list);
/* Allow passing parameters after device name */
if (buf[n] == '\0' || buf[n] == ',')
epdrv->requested_id = -1;
else {
epdrv->requested_id = simple_strtoul(&buf[n + 1],
&tmp, 10);
if (buf[n] != '.' || (tmp == &buf[n + 1])) {
epdrv->requested_id = EARLY_PLATFORM_ID_ERROR;
n = 0;
} else
n += strcspn(&buf[n + 1], ",") + 1;
}
if (buf[n] == ',')
n++;
if (epdrv->bufsize) {
memcpy(epdrv->buffer, &buf[n],
min_t(int, epdrv->bufsize, strlen(&buf[n]) + 1));
epdrv->buffer[epdrv->bufsize - 1] = '\0';
}
}
return 0;
}
/**
* sh_early_platform_add_devices - adds a number of early platform devices
Annotation
- Immediate include surface: `asm/platform_early.h`, `linux/mod_devicetable.h`, `linux/pm.h`.
- Detected declarations: `function platform_match_id`, `function platform_match`, `function device_pm_init_common`, `function pm_runtime_early_init`, `function pm_runtime_early_init`, `function sh_early_platform_add_devices`, `function sh_early_platform_driver_register_all`, `function sh_early_platform_match`, `function sh_early_platform_left`, `function sh_early_platform_driver_probe_id`.
- Atlas domain: Architecture Layer / arch/sh.
- 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.