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.

Dependency Surface

Detected Declarations

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

Implementation Notes