drivers/rapidio/rio-scan.c
Source file repositories/reference/linux-study-clean/drivers/rapidio/rio-scan.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/rapidio/rio-scan.c- Extension
.c- Size
- 31890 bytes
- Lines
- 1161
- Domain
- Driver Families
- Bucket
- drivers/rapidio
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- 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/types.hlinux/kernel.hlinux/delay.hlinux/dma-mapping.hlinux/init.hlinux/rio.hlinux/rio_drv.hlinux/rio_ids.hlinux/rio_regs.hlinux/module.hlinux/spinlock.hlinux/timer.hlinux/sched.hlinux/jiffies.hlinux/slab.hrio.h
Detected Declarations
struct rio_id_tablefunction rio_destid_allocfunction rio_destid_reservefunction rio_destid_freefunction rio_destid_firstfunction rio_destid_nextfunction rio_get_device_idfunction rio_set_device_idfunction rio_clear_locksfunction rio_enum_hostfunction rio_device_has_destidfunction rio_release_devfunction rio_is_switchfunction rio_sport_is_activefunction rio_get_host_deviceid_lockfunction rio_enum_peerfunction rio_enum_completefunction rio_disc_peerfunction rio_mport_is_activefunction rio_scan_release_netfunction rio_scan_release_devfunction itfunction rio_update_route_tablesfunction list_for_each_entryfunction list_for_each_entryfunction routinefunction rio_enum_mportfunction rio_build_route_tablesfunction list_for_each_entryfunction completefunction rio_basic_attach
Annotated Snippet
struct rio_id_table {
u16 start; /* logical minimal id */
u32 max; /* max number of IDs in table */
spinlock_t lock;
unsigned long table[];
};
static int next_destid = 0;
static int next_comptag = 1;
/**
* rio_destid_alloc - Allocate next available destID for given network
* @net: RIO network
*
* Returns next available device destination ID for the specified RIO network.
* Marks allocated ID as one in use.
* Returns RIO_INVALID_DESTID if new destID is not available.
*/
static u16 rio_destid_alloc(struct rio_net *net)
{
int destid;
struct rio_id_table *idtab = (struct rio_id_table *)net->enum_data;
spin_lock(&idtab->lock);
destid = find_first_zero_bit(idtab->table, idtab->max);
if (destid < idtab->max) {
set_bit(destid, idtab->table);
destid += idtab->start;
} else
destid = RIO_INVALID_DESTID;
spin_unlock(&idtab->lock);
return (u16)destid;
}
/**
* rio_destid_reserve - Reserve the specified destID
* @net: RIO network
* @destid: destID to reserve
*
* Tries to reserve the specified destID.
* Returns 0 if successful.
*/
static int rio_destid_reserve(struct rio_net *net, u16 destid)
{
int oldbit;
struct rio_id_table *idtab = (struct rio_id_table *)net->enum_data;
destid -= idtab->start;
spin_lock(&idtab->lock);
oldbit = test_and_set_bit(destid, idtab->table);
spin_unlock(&idtab->lock);
return oldbit;
}
/**
* rio_destid_free - free a previously allocated destID
* @net: RIO network
* @destid: destID to free
*
* Makes the specified destID available for use.
*/
static void rio_destid_free(struct rio_net *net, u16 destid)
{
struct rio_id_table *idtab = (struct rio_id_table *)net->enum_data;
destid -= idtab->start;
spin_lock(&idtab->lock);
clear_bit(destid, idtab->table);
spin_unlock(&idtab->lock);
}
/**
* rio_destid_first - return first destID in use
* @net: RIO network
*/
static u16 rio_destid_first(struct rio_net *net)
{
int destid;
struct rio_id_table *idtab = (struct rio_id_table *)net->enum_data;
spin_lock(&idtab->lock);
destid = find_first_bit(idtab->table, idtab->max);
if (destid >= idtab->max)
destid = RIO_INVALID_DESTID;
else
destid += idtab->start;
spin_unlock(&idtab->lock);
return (u16)destid;
Annotation
- Immediate include surface: `linux/types.h`, `linux/kernel.h`, `linux/delay.h`, `linux/dma-mapping.h`, `linux/init.h`, `linux/rio.h`, `linux/rio_drv.h`, `linux/rio_ids.h`.
- Detected declarations: `struct rio_id_table`, `function rio_destid_alloc`, `function rio_destid_reserve`, `function rio_destid_free`, `function rio_destid_first`, `function rio_destid_next`, `function rio_get_device_id`, `function rio_set_device_id`, `function rio_clear_locks`, `function rio_enum_host`.
- Atlas domain: Driver Families / drivers/rapidio.
- Implementation status: source 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.