sound/pci/asihpi/hpimsginit.c
Source file repositories/reference/linux-study-clean/sound/pci/asihpi/hpimsginit.c
File Facts
- System
- Linux kernel
- Corpus path
sound/pci/asihpi/hpimsginit.c- Extension
.c- Size
- 3214 bytes
- Lines
- 121
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
hpi_internal.hhpimsginit.hlinux/nospec.h
Detected Declarations
function hpi_init_messagefunction hpi_init_responsefunction hpi_init_message_responsefunction hpi_init_messageV1function hpi_init_responseV1function hpi_init_message_responseV1
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
/******************************************************************************
AudioScience HPI driver
Copyright (C) 1997-2014 AudioScience Inc. <support@audioscience.com>
Hardware Programming Interface (HPI) Utility functions.
(C) Copyright AudioScience Inc. 2007
*******************************************************************************/
#include "hpi_internal.h"
#include "hpimsginit.h"
#include <linux/nospec.h>
/* The actual message size for each object type */
static u16 msg_size[HPI_OBJ_MAXINDEX + 1] = HPI_MESSAGE_SIZE_BY_OBJECT;
/* The actual response size for each object type */
static u16 res_size[HPI_OBJ_MAXINDEX + 1] = HPI_RESPONSE_SIZE_BY_OBJECT;
/* Flag to enable alternate message type for SSX2 bypass. */
static u16 gwSSX2_bypass;
/** \internal
* initialize the HPI message structure
*/
static void hpi_init_message(struct hpi_message *phm, u16 object,
u16 function)
{
u16 size;
if ((object > 0) && (object <= HPI_OBJ_MAXINDEX)) {
object = array_index_nospec(object, HPI_OBJ_MAXINDEX + 1);
size = msg_size[object];
} else {
size = sizeof(*phm);
}
memset(phm, 0, size);
phm->size = size;
if (gwSSX2_bypass)
phm->type = HPI_TYPE_SSX2BYPASS_MESSAGE;
else
phm->type = HPI_TYPE_REQUEST;
phm->object = object;
phm->function = function;
phm->version = 0;
phm->adapter_index = HPI_ADAPTER_INDEX_INVALID;
/* Expect actual adapter index to be set by caller */
}
/** \internal
* initialize the HPI response structure
*/
void hpi_init_response(struct hpi_response *phr, u16 object, u16 function,
u16 error)
{
u16 size;
if ((object > 0) && (object <= HPI_OBJ_MAXINDEX)) {
object = array_index_nospec(object, HPI_OBJ_MAXINDEX + 1);
size = res_size[object];
} else {
size = sizeof(*phr);
}
memset(phr, 0, sizeof(*phr));
phr->size = size;
phr->type = HPI_TYPE_RESPONSE;
phr->object = object;
phr->function = function;
phr->error = error;
phr->specific_error = 0;
phr->version = 0;
}
void hpi_init_message_response(struct hpi_message *phm,
struct hpi_response *phr, u16 object, u16 function)
{
hpi_init_message(phm, object, function);
/* default error return if the response is
not filled in by the callee */
hpi_init_response(phr, object, function,
HPI_ERROR_PROCESSING_MESSAGE);
}
static void hpi_init_messageV1(struct hpi_message_header *phm, u16 size,
u16 object, u16 function)
{
Annotation
- Immediate include surface: `hpi_internal.h`, `hpimsginit.h`, `linux/nospec.h`.
- Detected declarations: `function hpi_init_message`, `function hpi_init_response`, `function hpi_init_message_response`, `function hpi_init_messageV1`, `function hpi_init_responseV1`, `function hpi_init_message_responseV1`.
- 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.