drivers/soc/qcom/apr.c
Source file repositories/reference/linux-study-clean/drivers/soc/qcom/apr.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/soc/qcom/apr.c- Extension
.c- Size
- 17337 bytes
- Lines
- 734
- Domain
- Driver Families
- Bucket
- drivers/soc
- 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/kernel.hlinux/module.hlinux/device.hlinux/spinlock.hlinux/idr.hlinux/slab.hlinux/workqueue.hlinux/of_device.hlinux/soc/qcom/apr.hlinux/soc/qcom/pdr.hlinux/rpmsg.hlinux/of.h
Detected Declarations
struct packet_routerstruct apr_rx_buffunction apr_send_pktfunction gpr_free_portfunction pkt_router_send_svc_pktfunction gpr_send_pktfunction gpr_send_port_pktfunction apr_dev_releasefunction apr_callbackfunction apr_do_rx_callbackfunction gpr_do_rx_callbackfunction apr_rxwqfunction apr_device_matchfunction apr_device_probefunction apr_device_removefunction apr_ueventfunction apr_add_devicefunction of_apr_add_pd_lookupsfunction for_each_child_of_node_scopedfunction of_register_apr_devicesfunction for_each_child_of_nodefunction apr_remove_devicefunction apr_pd_statusfunction apr_probefunction apr_removefunction __apr_driver_registerfunction apr_driver_unregisterfunction apr_initfunction apr_exitmodule init apr_initexport apr_send_pktexport gpr_free_portexport gpr_alloc_portexport gpr_send_pktexport gpr_send_port_pktexport aprbusexport __apr_driver_registerexport apr_driver_unregister
Annotated Snippet
static int apr_device_match(struct device *dev, const struct device_driver *drv)
{
struct apr_device *adev = to_apr_device(dev);
const struct apr_driver *adrv = to_apr_driver(drv);
const struct apr_device_id *id = adrv->id_table;
/* Attempt an OF style match first */
if (of_driver_match_device(dev, drv))
return 1;
if (!id)
return 0;
while (id->domain_id != 0 || id->svc_id != 0) {
if (id->domain_id == adev->domain_id &&
id->svc_id == adev->svc.id)
return 1;
id++;
}
return 0;
}
static int apr_device_probe(struct device *dev)
{
struct apr_device *adev = to_apr_device(dev);
struct apr_driver *adrv = to_apr_driver(dev->driver);
int ret;
ret = adrv->probe(adev);
if (!ret)
adev->svc.callback = adrv->gpr_callback;
return ret;
}
static void apr_device_remove(struct device *dev)
{
struct apr_device *adev = to_apr_device(dev);
struct apr_driver *adrv = to_apr_driver(dev->driver);
struct packet_router *apr = dev_get_drvdata(adev->dev.parent);
if (adrv->remove)
adrv->remove(adev);
spin_lock(&apr->svcs_lock);
idr_remove(&apr->svcs_idr, adev->svc.id);
spin_unlock(&apr->svcs_lock);
}
static int apr_uevent(const struct device *dev, struct kobj_uevent_env *env)
{
const struct apr_device *adev = to_apr_device(dev);
int ret;
ret = of_device_uevent_modalias(dev, env);
if (ret != -ENODEV)
return ret;
return add_uevent_var(env, "MODALIAS=apr:%s", adev->name);
}
const struct bus_type aprbus = {
.name = "aprbus",
.match = apr_device_match,
.probe = apr_device_probe,
.uevent = apr_uevent,
.remove = apr_device_remove,
};
EXPORT_SYMBOL_GPL(aprbus);
static int apr_add_device(struct device *dev, struct device_node *np,
u32 svc_id, u32 domain_id)
{
struct packet_router *apr = dev_get_drvdata(dev);
struct apr_device *adev = NULL;
struct pkt_router_svc *svc;
int ret;
adev = kzalloc_obj(*adev);
if (!adev)
return -ENOMEM;
adev->svc_id = svc_id;
svc = &adev->svc;
svc->id = svc_id;
svc->pr = apr;
svc->priv = adev;
svc->dev = dev;
spin_lock_init(&svc->lock);
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/device.h`, `linux/spinlock.h`, `linux/idr.h`, `linux/slab.h`, `linux/workqueue.h`, `linux/of_device.h`.
- Detected declarations: `struct packet_router`, `struct apr_rx_buf`, `function apr_send_pkt`, `function gpr_free_port`, `function pkt_router_send_svc_pkt`, `function gpr_send_pkt`, `function gpr_send_port_pkt`, `function apr_dev_release`, `function apr_callback`, `function apr_do_rx_callback`.
- Atlas domain: Driver Families / drivers/soc.
- 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.