sound/pci/asihpi/hpicmn.c
Source file repositories/reference/linux-study-clean/sound/pci/asihpi/hpicmn.c
File Facts
- System
- Linux kernel
- Corpus path
sound/pci/asihpi/hpicmn.c- Extension
.c- Size
- 18455 bytes
- Lines
- 711
- Domain
- Driver Families
- Bucket
- sound/pci
- 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.
- 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
hpi_internal.hhpidebug.hhpimsginit.hhpicmn.h
Detected Declarations
struct hpi_adapters_liststruct pad_ofs_sizefunction hpi_validate_responsefunction hpi_add_adapterfunction hpi_delete_adapterfunction wipe_adapter_listfunction subsys_get_adapterfunction control_cache_alloc_checkfunction find_controlfunction hpi_check_control_cache_singlefunction hpi_check_control_cachefunction hpi_cmn_control_cache_sync_to_msg_singlefunction hpi_cmn_control_cache_sync_to_msgfunction hpi_free_control_cachefunction subsys_messagefunction HPI_COMMON
Annotated Snippet
struct hpi_adapters_list {
struct hpios_spinlock list_lock;
struct hpi_adapter_obj adapter[HPI_MAX_ADAPTERS];
u16 gw_num_adapters;
};
static struct hpi_adapters_list adapters;
/**
* hpi_validate_response - Given an HPI Message that was sent out and
* a response that was received, validate that the response has the
* correct fields filled in, i.e ObjectType, Function etc
* @phm: message
* @phr: response
*/
u16 hpi_validate_response(struct hpi_message *phm, struct hpi_response *phr)
{
if (phr->type != HPI_TYPE_RESPONSE) {
HPI_DEBUG_LOG(ERROR, "header type %d invalid\n", phr->type);
return HPI_ERROR_INVALID_RESPONSE;
}
if (phr->object != phm->object) {
HPI_DEBUG_LOG(ERROR, "header object %d invalid\n",
phr->object);
return HPI_ERROR_INVALID_RESPONSE;
}
if (phr->function != phm->function) {
HPI_DEBUG_LOG(ERROR, "header function %d invalid\n",
phr->function);
return HPI_ERROR_INVALID_RESPONSE;
}
return 0;
}
u16 hpi_add_adapter(struct hpi_adapter_obj *pao)
{
u16 retval = 0;
/*HPI_ASSERT(pao->type); */
hpios_alistlock_lock(&adapters);
if (pao->index >= HPI_MAX_ADAPTERS) {
retval = HPI_ERROR_BAD_ADAPTER_NUMBER;
goto unlock;
}
if (adapters.adapter[pao->index].type) {
int a;
for (a = HPI_MAX_ADAPTERS - 1; a >= 0; a--) {
if (!adapters.adapter[a].type) {
HPI_DEBUG_LOG(WARNING,
"ASI%X duplicate index %d moved to %d\n",
pao->type, pao->index, a);
pao->index = a;
break;
}
}
if (a < 0) {
retval = HPI_ERROR_DUPLICATE_ADAPTER_NUMBER;
goto unlock;
}
}
adapters.adapter[pao->index] = *pao;
hpios_dsplock_init(&adapters.adapter[pao->index]);
adapters.gw_num_adapters++;
unlock:
hpios_alistlock_unlock(&adapters);
return retval;
}
void hpi_delete_adapter(struct hpi_adapter_obj *pao)
{
if (!pao->type) {
HPI_DEBUG_LOG(ERROR, "removing null adapter?\n");
return;
}
hpios_alistlock_lock(&adapters);
if (adapters.adapter[pao->index].type)
adapters.gw_num_adapters--;
memset(&adapters.adapter[pao->index], 0, sizeof(adapters.adapter[0]));
hpios_alistlock_unlock(&adapters);
}
/**
* hpi_find_adapter - FindAdapter returns a pointer to the struct
Annotation
- Immediate include surface: `hpi_internal.h`, `hpidebug.h`, `hpimsginit.h`, `hpicmn.h`.
- Detected declarations: `struct hpi_adapters_list`, `struct pad_ofs_size`, `function hpi_validate_response`, `function hpi_add_adapter`, `function hpi_delete_adapter`, `function wipe_adapter_list`, `function subsys_get_adapter`, `function control_cache_alloc_check`, `function find_control`, `function hpi_check_control_cache_single`.
- Atlas domain: Driver Families / sound/pci.
- Implementation status: source implementation candidate.
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.