drivers/dpll/zl3073x/flash.c
Source file repositories/reference/linux-study-clean/drivers/dpll/zl3073x/flash.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/dpll/zl3073x/flash.c- Extension
.c- Size
- 17991 bytes
- Lines
- 666
- Domain
- Driver Families
- Bucket
- drivers/dpll
- 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
linux/array_size.hlinux/bitfield.hlinux/bits.hlinux/delay.hlinux/dev_printk.hlinux/errno.hlinux/jiffies.hlinux/minmax.hlinux/netlink.hlinux/sched/signal.hlinux/sizes.hlinux/sprintf.hlinux/string.hlinux/types.hlinux/unaligned.hnet/devlink.hcore.hdevlink.hflash.h
Detected Declarations
function zl3073x_flash_downloadfunction zl3073x_flash_error_checkfunction zl3073x_flash_wait_readyfunction zl3073x_flash_cmd_waitfunction zl3073x_flash_get_sector_sizefunction zl3073x_flash_blockfunction zl3073x_flash_sectorsfunction zl3073x_flash_pagefunction zl3073x_flash_page_copyfunction zl3073x_flash_mode_verifyfunction zl3073x_flash_host_ctrl_enablefunction zl3073x_flash_mode_enterfunction zl3073x_flash_mode_leave
Annotated Snippet
if (rc) {
ZL_FLASH_ERR_MSG(extack,
"failed to write to memory at 0x%0x",
addr);
return rc;
}
if (time_is_before_jiffies(check_time)) {
if (signal_pending(current)) {
ZL_FLASH_ERR_MSG(extack,
"Flashing interrupted");
return -EINTR;
}
check_time = jiffies + msecs_to_jiffies(ZL_CHECK_DELAY);
}
/* Report status each 1 kB block */
if ((ptr - data) % 1024 == 0)
zl3073x_devlink_flash_notify(zldev, "Downloading image",
component, ptr - data,
size);
}
zl3073x_devlink_flash_notify(zldev, "Downloading image", component,
ptr - data, size);
dev_dbg(zldev->dev, "%zu bytes downloaded to device memory\n", size);
return rc;
}
/**
* zl3073x_flash_error_check - Check for flash utility errors
* @zldev: zl3073x device structure
* @extack: netlink extack pointer to report errors
*
* The function checks for errors detected by the flash utility and
* reports them if any were found.
*
* Return: 0 on success, -EIO when errors are detected
*/
static int
zl3073x_flash_error_check(struct zl3073x_dev *zldev,
struct netlink_ext_ack *extack)
{
u32 count, cause;
int rc;
rc = zl3073x_read_u32(zldev, ZL_REG_ERROR_COUNT, &count);
if (rc)
return rc;
else if (!count)
return 0; /* No error */
rc = zl3073x_read_u32(zldev, ZL_REG_ERROR_CAUSE, &cause);
if (rc)
return rc;
/* Report errors */
ZL_FLASH_ERR_MSG(extack,
"utility error occurred: count=%u cause=0x%x", count,
cause);
return -EIO;
}
/**
* zl3073x_flash_wait_ready - Check or wait for utility to be ready to flash
* @zldev: zl3073x device structure
* @timeout_ms: timeout for the waiting
*
* Return: 0 on success, <0 on error
*/
static int
zl3073x_flash_wait_ready(struct zl3073x_dev *zldev, unsigned int timeout_ms)
{
#define ZL_FLASH_POLL_DELAY_MS 100
unsigned long timeout;
int rc, i;
dev_dbg(zldev->dev, "Waiting for flashing to be ready\n");
timeout = jiffies + msecs_to_jiffies(timeout_ms);
for (i = 0; time_is_after_jiffies(timeout); i++) {
u8 value;
/* Check for interrupt each 1s */
if (i > 9) {
Annotation
- Immediate include surface: `linux/array_size.h`, `linux/bitfield.h`, `linux/bits.h`, `linux/delay.h`, `linux/dev_printk.h`, `linux/errno.h`, `linux/jiffies.h`, `linux/minmax.h`.
- Detected declarations: `function zl3073x_flash_download`, `function zl3073x_flash_error_check`, `function zl3073x_flash_wait_ready`, `function zl3073x_flash_cmd_wait`, `function zl3073x_flash_get_sector_size`, `function zl3073x_flash_block`, `function zl3073x_flash_sectors`, `function zl3073x_flash_page`, `function zl3073x_flash_page_copy`, `function zl3073x_flash_mode_verify`.
- Atlas domain: Driver Families / drivers/dpll.
- 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.