Skip to content

Commit 439cf01

Browse files
teksturiWim Van Sebroeck
authored andcommitted
watchdog: Make API functions const correct
Many watchdog API functions do not modify the watchdog_device nor device. Mark their arguments as const to reflect this and improve const-correctness of the API. No functional change intended. Signed-off-by: Kari Argillander <kari.argillander@gmail.com> Reviewed-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Wim Van Sebroeck <wim@linux-watchdog.org>
1 parent d303d37 commit 439cf01

3 files changed

Lines changed: 10 additions & 7 deletions

File tree

Documentation/watchdog/watchdog-kernel-api.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ To initialize the timeout field, the following function can be used::
293293

294294
extern int watchdog_init_timeout(struct watchdog_device *wdd,
295295
unsigned int timeout_parm,
296-
struct device *dev);
296+
const struct device *dev);
297297

298298
The watchdog_init_timeout function allows you to initialize the timeout field
299299
using the module timeout parameter or by retrieving the timeout-sec property from

drivers/watchdog/watchdog_core.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@ static void watchdog_check_min_max_timeout(struct watchdog_device *wdd)
117117
* bounds.
118118
*/
119119
int watchdog_init_timeout(struct watchdog_device *wdd,
120-
unsigned int timeout_parm, struct device *dev)
120+
unsigned int timeout_parm,
121+
const struct device *dev)
121122
{
122123
const char *dev_str = wdd->parent ? dev_name(wdd->parent) :
123124
(const char *)wdd->info->identity;

include/linux/watchdog.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ struct watchdog_device {
129129
#define WATCHDOG_NOWAYOUT_INIT_STATUS (WATCHDOG_NOWAYOUT << WDOG_NO_WAY_OUT)
130130

131131
/* Use the following function to check whether or not the watchdog is active */
132-
static inline bool watchdog_active(struct watchdog_device *wdd)
132+
static inline bool watchdog_active(const struct watchdog_device *wdd)
133133
{
134134
return test_bit(WDOG_ACTIVE, &wdd->status);
135135
}
@@ -138,7 +138,7 @@ static inline bool watchdog_active(struct watchdog_device *wdd)
138138
* Use the following function to check whether or not the hardware watchdog
139139
* is running
140140
*/
141-
static inline bool watchdog_hw_running(struct watchdog_device *wdd)
141+
static inline bool watchdog_hw_running(const struct watchdog_device *wdd)
142142
{
143143
return test_bit(WDOG_HW_RUNNING, &wdd->status);
144144
}
@@ -169,7 +169,8 @@ static inline void watchdog_stop_ping_on_suspend(struct watchdog_device *wdd)
169169
}
170170

171171
/* Use the following function to check if a timeout value is invalid */
172-
static inline bool watchdog_timeout_invalid(struct watchdog_device *wdd, unsigned int t)
172+
static inline bool watchdog_timeout_invalid(const struct watchdog_device *wdd,
173+
unsigned int t)
173174
{
174175
/*
175176
* The timeout is invalid if
@@ -188,7 +189,7 @@ static inline bool watchdog_timeout_invalid(struct watchdog_device *wdd, unsigne
188189
}
189190

190191
/* Use the following function to check if a pretimeout value is invalid */
191-
static inline bool watchdog_pretimeout_invalid(struct watchdog_device *wdd,
192+
static inline bool watchdog_pretimeout_invalid(const struct watchdog_device *wdd,
192193
unsigned int t)
193194
{
194195
return t && wdd->timeout && t >= wdd->timeout;
@@ -218,7 +219,8 @@ static inline void watchdog_notify_pretimeout(struct watchdog_device *wdd)
218219
/* drivers/watchdog/watchdog_core.c */
219220
void watchdog_set_restart_priority(struct watchdog_device *wdd, int priority);
220221
extern int watchdog_init_timeout(struct watchdog_device *wdd,
221-
unsigned int timeout_parm, struct device *dev);
222+
unsigned int timeout_parm,
223+
const struct device *dev);
222224
extern int watchdog_register_device(struct watchdog_device *);
223225
extern void watchdog_unregister_device(struct watchdog_device *);
224226
int watchdog_dev_suspend(struct watchdog_device *wdd);

0 commit comments

Comments
 (0)