drivers/staging/most/dim2/dim2.c
Source file repositories/reference/linux-study-clean/drivers/staging/most/dim2/dim2.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/staging/most/dim2/dim2.c- Extension
.c- Size
- 28685 bytes
- Lines
- 1114
- Domain
- Driver Families
- Bucket
- drivers/staging
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/printk.hlinux/init.hlinux/platform_device.hlinux/interrupt.hlinux/slab.hlinux/io.hlinux/clk.hlinux/dma-mapping.hlinux/kthread.hlinux/most.hlinux/of.hhal.herrors.hsysfs.h
Detected Declarations
struct hdm_channelstruct dim2_hdmstruct dim2_platform_dataenum dim2_platformsfunction packet_is_net_infofunction state_showfunction dimcb_on_errorfunction try_start_dim_transferfunction deliver_netinfo_threadfunction retrieve_netinfofunction service_done_flagfunction dim2_mlb_isrfunction dim2_task_irqfunction dim2_ahb_isrfunction complete_all_mbosfunction configure_channelfunction enqueuefunction request_netinfofunction poison_channelfunction dma_freefunction get_dim2_clk_speedfunction dim2_releasefunction dim2_probefunction dim2_removefunction fsl_mx6_enablefunction fsl_mx6_disablefunction rcar_gen2_enablefunction rcar_gen2_disablefunction rcar_gen3_enablefunction rcar_gen3_disable
Annotated Snippet
struct hdm_channel {
char name[sizeof "caNNN"];
bool is_initialized;
struct dim_channel ch;
u16 *reset_dbr_size;
struct list_head pending_list; /* before dim_enqueue_buffer() */
struct list_head started_list; /* after dim_enqueue_buffer() */
enum most_channel_direction direction;
enum most_channel_data_type data_type;
};
/*
* struct dim2_hdm - private structure to keep interface specific data
* @hch: an array of channel specific data
* @most_iface: most interface structure
* @capabilities: an array of channel capability data
* @io_base: I/O register base address
* @netinfo_task: thread to deliver network status
* @netinfo_waitq: waitq for the thread to sleep
* @deliver_netinfo: to identify whether network status received
* @mac_addrs: INIC mac address
* @link_state: network link state
* @atx_idx: index of async tx channel
*/
struct dim2_hdm {
struct device dev;
struct hdm_channel hch[DMA_CHANNELS];
struct most_channel_capability capabilities[DMA_CHANNELS];
struct most_interface most_iface;
char name[16 + sizeof "dim2-"];
void __iomem *io_base;
u8 clk_speed;
struct clk *clk;
struct clk *clk_pll;
struct task_struct *netinfo_task;
wait_queue_head_t netinfo_waitq;
int deliver_netinfo;
unsigned char mac_addrs[6];
unsigned char link_state;
int atx_idx;
struct medialb_bus bus;
void (*on_netinfo)(struct most_interface *most_iface,
unsigned char link_state, unsigned char *addrs);
void (*disable_platform)(struct platform_device *pdev);
};
struct dim2_platform_data {
int (*enable)(struct platform_device *pdev);
void (*disable)(struct platform_device *pdev);
u8 fcnt;
};
static inline struct dim2_hdm *iface_to_hdm(struct most_interface *iface)
{
return container_of(iface, struct dim2_hdm, most_iface);
}
/* Identify a network status message */
static bool packet_is_net_info(const u8 *p)
{
return p[1] == 0x18 && p[2] == 0x05 && p[3] == 0x0C &&
p[13] == 0x3C && p[14] == 0x00 && p[15] == 0x0A;
}
static ssize_t state_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
bool state;
unsigned long flags;
spin_lock_irqsave(&dim_lock, flags);
state = dim_get_lock_state();
spin_unlock_irqrestore(&dim_lock, flags);
return sysfs_emit(buf, "%s\n", state ? "locked" : "");
}
static DEVICE_ATTR_RO(state);
static struct attribute *dim2_attrs[] = {
&dev_attr_state.attr,
NULL,
};
ATTRIBUTE_GROUPS(dim2);
/**
* dimcb_on_error - callback from HAL to report miscommunication between
* HDM and HAL
* @error_id: Error ID
Annotation
- Immediate include surface: `linux/printk.h`, `linux/init.h`, `linux/platform_device.h`, `linux/interrupt.h`, `linux/slab.h`, `linux/io.h`, `linux/clk.h`, `linux/dma-mapping.h`.
- Detected declarations: `struct hdm_channel`, `struct dim2_hdm`, `struct dim2_platform_data`, `enum dim2_platforms`, `function packet_is_net_info`, `function state_show`, `function dimcb_on_error`, `function try_start_dim_transfer`, `function deliver_netinfo_thread`, `function retrieve_netinfo`.
- Atlas domain: Driver Families / drivers/staging.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.