drivers/watchdog/rave-sp-wdt.c

Source file repositories/reference/linux-study-clean/drivers/watchdog/rave-sp-wdt.c

File Facts

System
Linux kernel
Corpus path
drivers/watchdog/rave-sp-wdt.c
Extension
.c
Size
8281 bytes
Lines
337
Domain
Driver Families
Bucket
drivers/watchdog
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

struct rave_sp_wdt_variant {
	unsigned int max_timeout;
	unsigned int min_timeout;

	int (*configure)(struct watchdog_device *, bool);
	int (*restart)(struct watchdog_device *);
};

/**
 * struct rave_sp_wdt - RAVE SP watchdog
 *
 * @wdd:		Underlying watchdog device
 * @sp:			Pointer to parent RAVE SP device
 * @variant:		Device specific variant information
 * @reboot_notifier:	Reboot notifier implementing machine reset
 */
struct rave_sp_wdt {
	struct watchdog_device wdd;
	struct rave_sp *sp;
	const struct rave_sp_wdt_variant *variant;
	struct notifier_block reboot_notifier;
};

static struct rave_sp_wdt *to_rave_sp_wdt(struct watchdog_device *wdd)
{
	return container_of(wdd, struct rave_sp_wdt, wdd);
}

static int rave_sp_wdt_exec(struct watchdog_device *wdd, void *data,
			    size_t data_size)
{
	return rave_sp_exec(to_rave_sp_wdt(wdd)->sp,
			    data, data_size, NULL, 0);
}

static int rave_sp_wdt_legacy_configure(struct watchdog_device *wdd, bool on)
{
	u8 cmd[] = {
		[0] = RAVE_SP_CMD_SW_WDT,
		[1] = 0,
		[2] = 0,
		[3] = on,
		[4] = on ? wdd->timeout : 0,
	};

	return rave_sp_wdt_exec(wdd, cmd, sizeof(cmd));
}

static int rave_sp_wdt_rdu_configure(struct watchdog_device *wdd, bool on)
{
	u8 cmd[] = {
		[0] = RAVE_SP_CMD_SW_WDT,
		[1] = 0,
		[2] = on,
		[3] = (u8)wdd->timeout,
		[4] = (u8)(wdd->timeout >> 8),
	};

	return rave_sp_wdt_exec(wdd, cmd, sizeof(cmd));
}

/**
 * rave_sp_wdt_configure - Configure watchdog device
 *
 * @wdd:	Device to configure
 * @on:		Desired state of the watchdog timer (ON/OFF)
 *
 * This function configures two aspects of the watchdog timer:
 *
 *  - Wheither it is ON or OFF
 *  - Its timeout duration
 *
 * with first aspect specified via function argument and second via
 * the value of 'wdd->timeout'.
 */
static int rave_sp_wdt_configure(struct watchdog_device *wdd, bool on)
{
	return to_rave_sp_wdt(wdd)->variant->configure(wdd, on);
}

static int rave_sp_wdt_legacy_restart(struct watchdog_device *wdd)
{
	u8 cmd[] = {
		[0] = RAVE_SP_CMD_RESET,
		[1] = 0,
		[2] = RAVE_SP_RESET_BYTE
	};

	return rave_sp_wdt_exec(wdd, cmd, sizeof(cmd));
}

Annotation

Implementation Notes