drivers/net/dsa/mxl862xx/mxl862xx-host.c
Source file repositories/reference/linux-study-clean/drivers/net/dsa/mxl862xx/mxl862xx-host.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/dsa/mxl862xx/mxl862xx-host.c- Extension
.c- Size
- 14133 bytes
- Lines
- 505
- Domain
- Driver Families
- Bucket
- drivers/net
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bitops.hlinux/bits.hlinux/crc16.hlinux/iopoll.hlinux/limits.hnet/dsa.hmxl862xx.hmxl862xx-host.h
Detected Declarations
function Copyrightfunction mxl862xx_crc6function mxl862xx_crc6_encodefunction mxl862xx_crc6_verifyfunction mxl862xx_reg_readfunction mxl862xx_reg_writefunction mxl862xx_ctrl_readfunction mxl862xx_busy_waitfunction mxl862xx_issue_cmdfunction mxl862xx_set_datafunction mxl862xx_get_datafunction mxl862xx_rst_datafunction mxl862xx_send_cmdfunction mxl862xx_api_wrapfunction mxl862xx_resetfunction mxl862xx_host_initfunction mxl862xx_host_shutdown
Annotated Snippet
if (i && off == 0) {
/* Send command to set data when every
* MXL862XX_MMD_REG_DATA_MAX_SIZE of WORDs are written.
*/
ret = mxl862xx_set_data(priv, i);
if (ret < 0)
goto out;
}
if (i == max) {
/* Even size: full CRC word.
* Odd size: only CRC high byte remains (low byte
* was packed into the previous word).
*/
val = (size & 1) ? crc >> 8 : crc;
} else if ((i * 2 + 1) == size) {
/* Special handling for last BYTE if it's not WORD
* aligned to avoid reading beyond the allocated data
* structure. Pack the CRC low byte into the high
* byte of this word so it sits at byte offset 'size'
* in the firmware's contiguous buffer.
*/
val = *(u8 *)&data[i] | ((crc & 0xff) << 8);
} else {
val = le16_to_cpu(data[i]);
}
/* After RST_DATA, skip zero data words as the registers
* already contain zeros, but never skip the CRC word at the
* final word.
*/
if (use_rst && i < max && val == 0)
continue;
ret = mxl862xx_reg_write(priv,
MXL862XX_MMD_REG_DATA_FIRST + off,
val);
if (ret < 0)
goto out;
}
ret = mxl862xx_send_cmd(priv, cmd, size, quiet);
if (ret < 0 || !read)
goto out;
/* store result of mxl862xx_send_cmd() */
cmd_ret = ret;
for (i = 0; i < max + 1; i++) {
u16 off = i % MXL862XX_MMD_REG_DATA_MAX_SIZE;
if (i && off == 0) {
/* Send command to fetch next batch of data when every
* MXL862XX_MMD_REG_DATA_MAX_SIZE of WORDs are read.
*/
ret = mxl862xx_get_data(priv, i);
if (ret < 0)
goto out;
}
ret = mxl862xx_reg_read(priv, MXL862XX_MMD_REG_DATA_FIRST + off);
if (ret < 0)
goto out;
if (i == max) {
/* Even size: full CRC word.
* Odd size: only CRC high byte remains (low byte
* was in the previous word).
*/
if (size & 1)
crc = (crc & 0x00ff) |
(((u16)ret & 0xff) << 8);
else
crc = (u16)ret;
} else if ((i * 2 + 1) == size) {
/* Special handling for last BYTE if it's not WORD
* aligned to avoid writing beyond the allocated data
* structure. The high byte carries the CRC low byte.
*/
*(uint8_t *)&data[i] = ret & 0xff;
crc = (ret >> 8) & 0xff;
} else {
data[i] = cpu_to_le16((u16)ret);
}
}
if (crc16(0xffff, (const u8 *)data, size) != crc) {
if (!test_and_set_bit(MXL862XX_FLAG_CRC_ERR, &priv->flags))
schedule_work(&priv->crc_err_work);
ret = -EIO;
Annotation
- Immediate include surface: `linux/bitops.h`, `linux/bits.h`, `linux/crc16.h`, `linux/iopoll.h`, `linux/limits.h`, `net/dsa.h`, `mxl862xx.h`, `mxl862xx-host.h`.
- Detected declarations: `function Copyright`, `function mxl862xx_crc6`, `function mxl862xx_crc6_encode`, `function mxl862xx_crc6_verify`, `function mxl862xx_reg_read`, `function mxl862xx_reg_write`, `function mxl862xx_ctrl_read`, `function mxl862xx_busy_wait`, `function mxl862xx_issue_cmd`, `function mxl862xx_set_data`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source 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.