drivers/bus/mips_cdmm.c
Source file repositories/reference/linux-study-clean/drivers/bus/mips_cdmm.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/bus/mips_cdmm.c- Extension
.c- Size
- 19922 bytes
- Lines
- 699
- Domain
- Driver Families
- Bucket
- drivers/bus
- 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.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/atomic.hlinux/err.hlinux/cpu.hlinux/cpumask.hlinux/io.hlinux/of_address.hlinux/of.hlinux/platform_device.hlinux/slab.hlinux/smp.hasm/cdmm.hasm/hazards.hasm/mipsregs.h
Detected Declarations
struct mips_cdmm_work_devstruct mips_cdmm_busfunction mips_cdmm_lookupfunction mips_cdmm_matchfunction mips_cdmm_ueventfunction mips_cdmm_void_workfunction mips_cdmm_int_workfunction mips_cdmm_driver_registerfunction mips_cdmm_driver_unregisterfunction mips_cdmm_get_busfunction mips_cdmm_cur_basefunction mips_cdmm_phys_basefunction mips_cdmm_setupfunction mips_cdmm_early_probefunction mips_cdmm_releasefunction mips_cdmm_bus_discoverfunction mips_cdmm_cpu_down_prepfunction mips_cdmm_cpu_onlinefunction mips_cdmm_initmodule init mips_cdmm_initexport mips_cdmm_bustypeexport mips_cdmm_driver_registerexport mips_cdmm_driver_unregisterexport mips_cdmm_early_probe
Annotated Snippet
static int mips_cdmm_match(struct device *dev, const struct device_driver *drv)
{
struct mips_cdmm_device *cdev = to_mips_cdmm_device(dev);
const struct mips_cdmm_driver *cdrv = to_mips_cdmm_driver(drv);
return mips_cdmm_lookup(cdrv->id_table, cdev) != NULL;
}
static int mips_cdmm_uevent(const struct device *dev, struct kobj_uevent_env *env)
{
const struct mips_cdmm_device *cdev = to_mips_cdmm_device(dev);
int retval = 0;
retval = add_uevent_var(env, "CDMM_CPU=%u", cdev->cpu);
if (retval)
return retval;
retval = add_uevent_var(env, "CDMM_TYPE=0x%02x", cdev->type);
if (retval)
return retval;
retval = add_uevent_var(env, "CDMM_REV=%u", cdev->rev);
if (retval)
return retval;
retval = add_uevent_var(env, "MODALIAS=mipscdmm:t%02X", cdev->type);
return retval;
}
/* Device attributes */
#define CDMM_ATTR(name, fmt, arg...) \
static ssize_t name##_show(struct device *_dev, \
struct device_attribute *attr, char *buf) \
{ \
struct mips_cdmm_device *dev = to_mips_cdmm_device(_dev); \
return sprintf(buf, fmt, arg); \
} \
static DEVICE_ATTR_RO(name);
CDMM_ATTR(cpu, "%u\n", dev->cpu);
CDMM_ATTR(type, "0x%02x\n", dev->type);
CDMM_ATTR(revision, "%u\n", dev->rev);
CDMM_ATTR(modalias, "mipscdmm:t%02X\n", dev->type);
CDMM_ATTR(resource, "\t%016llx\t%016llx\t%016lx\n",
(unsigned long long)dev->res.start,
(unsigned long long)dev->res.end,
dev->res.flags);
static struct attribute *mips_cdmm_dev_attrs[] = {
&dev_attr_cpu.attr,
&dev_attr_type.attr,
&dev_attr_revision.attr,
&dev_attr_modalias.attr,
&dev_attr_resource.attr,
NULL,
};
ATTRIBUTE_GROUPS(mips_cdmm_dev);
const struct bus_type mips_cdmm_bustype = {
.name = "cdmm",
.dev_groups = mips_cdmm_dev_groups,
.match = mips_cdmm_match,
.uevent = mips_cdmm_uevent,
};
EXPORT_SYMBOL_GPL(mips_cdmm_bustype);
/*
* Standard driver callback helpers.
*
* All the CDMM driver callbacks need to be executed on the appropriate CPU from
* workqueues. For the standard driver callbacks we need a work function
* (mips_cdmm_{void,int}_work()) to do the actual call from the right CPU, and a
* wrapper function (generated with BUILD_PERCPU_HELPER) to arrange for the work
* function to be called on that CPU.
*/
/**
* struct mips_cdmm_work_dev - Data for per-device call work.
* @fn: CDMM driver callback function to call for the device.
* @dev: CDMM device to pass to @fn.
*/
struct mips_cdmm_work_dev {
void *fn;
struct mips_cdmm_device *dev;
};
/**
* mips_cdmm_void_work() - Call a void returning CDMM driver callback.
* @data: struct mips_cdmm_work_dev pointer.
Annotation
- Immediate include surface: `linux/atomic.h`, `linux/err.h`, `linux/cpu.h`, `linux/cpumask.h`, `linux/io.h`, `linux/of_address.h`, `linux/of.h`, `linux/platform_device.h`.
- Detected declarations: `struct mips_cdmm_work_dev`, `struct mips_cdmm_bus`, `function mips_cdmm_lookup`, `function mips_cdmm_match`, `function mips_cdmm_uevent`, `function mips_cdmm_void_work`, `function mips_cdmm_int_work`, `function mips_cdmm_driver_register`, `function mips_cdmm_driver_unregister`, `function mips_cdmm_get_bus`.
- Atlas domain: Driver Families / drivers/bus.
- 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.