drivers/watchdog/bcm47xx_wdt.c
Source file repositories/reference/linux-study-clean/drivers/watchdog/bcm47xx_wdt.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/watchdog/bcm47xx_wdt.c- Extension
.c- Size
- 5714 bytes
- Lines
- 234
- 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.
- 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/bcm47xx_wdt.hlinux/bitops.hlinux/errno.hlinux/kernel.hlinux/module.hlinux/moduleparam.hlinux/platform_device.hlinux/types.hlinux/watchdog.hlinux/timer.hlinux/jiffies.h
Detected Declarations
function bcm47xx_wdt_hard_keepalivefunction bcm47xx_wdt_hard_startfunction bcm47xx_wdt_hard_stopfunction bcm47xx_wdt_hard_set_timeoutfunction bcm47xx_wdt_restartfunction bcm47xx_wdt_soft_timer_tickfunction bcm47xx_wdt_soft_keepalivefunction bcm47xx_wdt_soft_startfunction bcm47xx_wdt_soft_stopfunction bcm47xx_wdt_soft_set_timeoutfunction bcm47xx_wdt_probe
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0+
/*
* Watchdog driver for Broadcom BCM47XX
*
* Copyright (C) 2008 Aleksandar Radovanovic <biblbroks@sezampro.rs>
* Copyright (C) 2009 Matthieu CASTET <castet.matthieu@free.fr>
* Copyright (C) 2012-2013 Hauke Mehrtens <hauke@hauke-m.de>
*
*/
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/bcm47xx_wdt.h>
#include <linux/bitops.h>
#include <linux/errno.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/platform_device.h>
#include <linux/types.h>
#include <linux/watchdog.h>
#include <linux/timer.h>
#include <linux/jiffies.h>
#define DRV_NAME "bcm47xx_wdt"
#define WDT_DEFAULT_TIME 30 /* seconds */
#define WDT_SOFTTIMER_MAX 255 /* seconds */
#define WDT_SOFTTIMER_THRESHOLD 60 /* seconds */
static int timeout = WDT_DEFAULT_TIME;
static bool nowayout = WATCHDOG_NOWAYOUT;
module_param(timeout, int, 0);
MODULE_PARM_DESC(timeout, "Watchdog time in seconds. (default="
__MODULE_STRING(WDT_DEFAULT_TIME) ")");
module_param(nowayout, bool, 0);
MODULE_PARM_DESC(nowayout,
"Watchdog cannot be stopped once started (default="
__MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
static inline struct bcm47xx_wdt *bcm47xx_wdt_get(struct watchdog_device *wdd)
{
return container_of(wdd, struct bcm47xx_wdt, wdd);
}
static int bcm47xx_wdt_hard_keepalive(struct watchdog_device *wdd)
{
struct bcm47xx_wdt *wdt = bcm47xx_wdt_get(wdd);
wdt->timer_set_ms(wdt, wdd->timeout * 1000);
return 0;
}
static int bcm47xx_wdt_hard_start(struct watchdog_device *wdd)
{
return 0;
}
static int bcm47xx_wdt_hard_stop(struct watchdog_device *wdd)
{
struct bcm47xx_wdt *wdt = bcm47xx_wdt_get(wdd);
wdt->timer_set(wdt, 0);
return 0;
}
static int bcm47xx_wdt_hard_set_timeout(struct watchdog_device *wdd,
unsigned int new_time)
{
struct bcm47xx_wdt *wdt = bcm47xx_wdt_get(wdd);
u32 max_timer = wdt->max_timer_ms;
if (new_time < 1 || new_time > max_timer / 1000) {
pr_warn("timeout value must be 1<=x<=%d, using %d\n",
max_timer / 1000, new_time);
return -EINVAL;
}
wdd->timeout = new_time;
return 0;
}
static int bcm47xx_wdt_restart(struct watchdog_device *wdd,
unsigned long action, void *data)
{
struct bcm47xx_wdt *wdt = bcm47xx_wdt_get(wdd);
Annotation
- Immediate include surface: `linux/bcm47xx_wdt.h`, `linux/bitops.h`, `linux/errno.h`, `linux/kernel.h`, `linux/module.h`, `linux/moduleparam.h`, `linux/platform_device.h`, `linux/types.h`.
- Detected declarations: `function bcm47xx_wdt_hard_keepalive`, `function bcm47xx_wdt_hard_start`, `function bcm47xx_wdt_hard_stop`, `function bcm47xx_wdt_hard_set_timeout`, `function bcm47xx_wdt_restart`, `function bcm47xx_wdt_soft_timer_tick`, `function bcm47xx_wdt_soft_keepalive`, `function bcm47xx_wdt_soft_start`, `function bcm47xx_wdt_soft_stop`, `function bcm47xx_wdt_soft_set_timeout`.
- Atlas domain: Driver Families / drivers/watchdog.
- 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.