sound/firewire/fireworks/fireworks_transaction.c
Source file repositories/reference/linux-study-clean/sound/firewire/fireworks/fireworks_transaction.c
File Facts
- System
- Linux kernel
- Corpus path
sound/firewire/fireworks/fireworks_transaction.c- Extension
.c- Size
- 7872 bytes
- Lines
- 314
- Domain
- Driver Families
- Bucket
- sound/firewire
- 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
./fireworks.h
Detected Declarations
struct transaction_queueenum transaction_queue_statefunction snd_efw_transaction_cmdfunction snd_efw_transaction_runfunction scoped_guardfunction scoped_guardfunction copy_resp_to_buffunction handle_resp_for_userfunction handle_resp_for_kernelfunction efw_responsefunction snd_efw_transaction_add_instancefunction snd_efw_transaction_remove_instancefunction snd_efw_transaction_bus_resetfunction snd_efw_transaction_registerfunction snd_efw_transaction_unregister
Annotated Snippet
struct transaction_queue {
struct list_head list;
struct fw_unit *unit;
void *buf;
unsigned int size;
u32 seqnum;
enum transaction_queue_state state;
wait_queue_head_t wait;
};
int snd_efw_transaction_cmd(struct fw_unit *unit,
const void *cmd, unsigned int size)
{
return snd_fw_transaction(unit, TCODE_WRITE_BLOCK_REQUEST,
MEMORY_SPACE_EFW_COMMAND,
(void *)cmd, size, 0);
}
int snd_efw_transaction_run(struct fw_unit *unit,
const void *cmd, unsigned int cmd_size,
void *resp, unsigned int resp_size)
{
struct transaction_queue t;
unsigned int tries;
int ret;
t.unit = unit;
t.buf = resp;
t.size = resp_size;
t.seqnum = be32_to_cpu(((struct snd_efw_transaction *)cmd)->seqnum) + 1;
t.state = STATE_PENDING;
init_waitqueue_head(&t.wait);
scoped_guard(spinlock_irq, &transaction_queues_lock) {
list_add_tail(&t.list, &transaction_queues);
}
tries = 0;
do {
ret = snd_efw_transaction_cmd(t.unit, (void *)cmd, cmd_size);
if (ret < 0)
break;
wait_event_timeout(t.wait, t.state != STATE_PENDING,
msecs_to_jiffies(EFC_TIMEOUT_MS));
if (t.state == STATE_COMPLETE) {
ret = t.size;
break;
} else if (t.state == STATE_BUS_RESET) {
msleep(ERROR_DELAY_MS);
} else if (++tries >= ERROR_RETRIES) {
dev_err(&t.unit->device, "EFW transaction timed out\n");
ret = -EIO;
break;
}
} while (1);
scoped_guard(spinlock_irq, &transaction_queues_lock) {
list_del(&t.list);
}
return ret;
}
static void
copy_resp_to_buf(struct snd_efw *efw, void *data, size_t length, int *rcode)
{
size_t capacity, till_end;
struct snd_efw_transaction *t;
t = (struct snd_efw_transaction *)data;
length = min_t(size_t, be32_to_cpu(t->length) * sizeof(u32), length);
guard(spinlock)(&efw->lock);
if (efw->push_ptr < efw->pull_ptr)
capacity = (unsigned int)(efw->pull_ptr - efw->push_ptr);
else
capacity = snd_efw_resp_buf_size -
(unsigned int)(efw->push_ptr - efw->pull_ptr);
/* confirm enough space for this response */
if (capacity < length) {
*rcode = RCODE_CONFLICT_ERROR;
return;
}
/* copy to ring buffer */
while (length > 0) {
Annotation
- Immediate include surface: `./fireworks.h`.
- Detected declarations: `struct transaction_queue`, `enum transaction_queue_state`, `function snd_efw_transaction_cmd`, `function snd_efw_transaction_run`, `function scoped_guard`, `function scoped_guard`, `function copy_resp_to_buf`, `function handle_resp_for_user`, `function handle_resp_for_kernel`, `function efw_response`.
- Atlas domain: Driver Families / sound/firewire.
- 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.