drivers/hid/intel-ish-hid/ishtp/client-buffers.c
Source file repositories/reference/linux-study-clean/drivers/hid/intel-ish-hid/ishtp/client-buffers.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/hid/intel-ish-hid/ishtp/client-buffers.c- Extension
.c- Size
- 6446 bytes
- Lines
- 277
- Domain
- Driver Families
- Bucket
- drivers/hid
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/slab.hclient.h
Detected Declarations
function Copyrightfunction ishtp_cl_alloc_tx_ringfunction ishtp_cl_free_rx_ringfunction ishtp_cl_free_tx_ringfunction ishtp_io_rb_freefunction ishtp_io_rb_initfunction ishtp_io_rb_alloc_buffunction ishtp_cl_io_rb_recyclefunction ishtp_cl_rx_get_rbexport ishtp_cl_io_rb_recycleexport ishtp_cl_rx_get_rb
Annotated Snippet
if (!rb) {
ret = -ENOMEM;
goto out;
}
ret = ishtp_io_rb_alloc_buf(rb, len);
if (ret)
goto out;
spin_lock_irqsave(&cl->free_list_spinlock, flags);
list_add_tail(&rb->list, &cl->free_rb_list.list);
spin_unlock_irqrestore(&cl->free_list_spinlock, flags);
}
return 0;
out:
dev_err(&cl->device->dev, "error in allocating Rx buffers\n");
ishtp_cl_free_rx_ring(cl);
return ret;
}
/**
* ishtp_cl_alloc_tx_ring() - Allocate TX ring buffers
* @cl: client device instance
*
* Allocate and initialize TX ring buffers
*
* Return: 0 on success else -ENOMEM
*/
int ishtp_cl_alloc_tx_ring(struct ishtp_cl *cl)
{
size_t len = cl->device->fw_client->props.max_msg_length;
int j;
unsigned long flags;
cl->tx_ring_free_size = 0;
/* Allocate pool to free Tx bufs */
for (j = 0; j < cl->tx_ring_size; ++j) {
struct ishtp_cl_tx_ring *tx_buf;
tx_buf = kzalloc_obj(struct ishtp_cl_tx_ring);
if (!tx_buf)
goto out;
tx_buf->send_buf.data = kmalloc(len, GFP_KERNEL);
if (!tx_buf->send_buf.data) {
kfree(tx_buf);
goto out;
}
spin_lock_irqsave(&cl->tx_free_list_spinlock, flags);
list_add_tail(&tx_buf->list, &cl->tx_free_list.list);
++cl->tx_ring_free_size;
spin_unlock_irqrestore(&cl->tx_free_list_spinlock, flags);
}
return 0;
out:
dev_err(&cl->device->dev, "error in allocating Tx pool\n");
ishtp_cl_free_tx_ring(cl);
return -ENOMEM;
}
/**
* ishtp_cl_free_rx_ring() - Free RX ring buffers
* @cl: client device instance
*
* Free RX ring buffers
*/
void ishtp_cl_free_rx_ring(struct ishtp_cl *cl)
{
struct ishtp_cl_rb *rb;
unsigned long flags;
/* release allocated memory - pass over free_rb_list */
spin_lock_irqsave(&cl->free_list_spinlock, flags);
while (!list_empty(&cl->free_rb_list.list)) {
rb = list_entry(cl->free_rb_list.list.next, struct ishtp_cl_rb,
list);
list_del(&rb->list);
kfree(rb->buffer.data);
kfree(rb);
}
spin_unlock_irqrestore(&cl->free_list_spinlock, flags);
/* release allocated memory - pass over in_process_list */
spin_lock_irqsave(&cl->in_process_spinlock, flags);
while (!list_empty(&cl->in_process_list.list)) {
rb = list_entry(cl->in_process_list.list.next,
struct ishtp_cl_rb, list);
list_del(&rb->list);
kfree(rb->buffer.data);
Annotation
- Immediate include surface: `linux/slab.h`, `client.h`.
- Detected declarations: `function Copyright`, `function ishtp_cl_alloc_tx_ring`, `function ishtp_cl_free_rx_ring`, `function ishtp_cl_free_tx_ring`, `function ishtp_io_rb_free`, `function ishtp_io_rb_init`, `function ishtp_io_rb_alloc_buf`, `function ishtp_cl_io_rb_recycle`, `function ishtp_cl_rx_get_rb`, `export ishtp_cl_io_rb_recycle`.
- Atlas domain: Driver Families / drivers/hid.
- Implementation status: integration 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.