xiaoxiang781216 commented on code in PR #15387: URL: https://github.com/apache/nuttx/pull/15387#discussion_r1900149644
########## include/nuttx/timers/watchdog.h: ########## @@ -31,6 +31,8 @@ #include <nuttx/compiler.h> #include <nuttx/irq.h> #include <nuttx/fs/ioctl.h> +#include <nuttx/notifier.h> +#include <nuttx/sched.h> Review Comment: why need include sched.h ########## drivers/timers/watchdog_notifier.c: ########## @@ -0,0 +1,89 @@ +/**************************************************************************** + * drivers/timers/watchdog_notifier.c + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/arch.h> +#include <nuttx/notifier.h> + +#include <sys/types.h> Review Comment: remove ########## drivers/timers/watchdog_notifier.c: ########## @@ -0,0 +1,89 @@ +/**************************************************************************** + * drivers/timers/watchdog_notifier.c + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/arch.h> +#include <nuttx/notifier.h> Review Comment: just need include <nuttx/timer/watchdog.h> ########## include/nuttx/timers/watchdog.h: ########## @@ -197,6 +228,61 @@ extern "C" #define EXTERN extern #endif +#ifdef CONFIG_WATCHDOG_TIMEOUT_NOTIFIER +/**************************************************************************** + * Name: watchdog_notifier_chain_register + * + * Description: + * Add notifier to the watchdog notifier chain + * + * Input Parameters: + * nb - New entry in notifier chain + * + ****************************************************************************/ + +void watchdog_notifier_chain_register(FAR struct notifier_block *nb); + +/**************************************************************************** + * Name: watchdog_notifier_chain_unregister + * + * Description: + * Remove notifier from the watchdog notifier chain + * + * Input Parameters: + * nb - Entry to remove from notifier chain + * + ****************************************************************************/ + +void watchdog_notifier_chain_unregister(FAR struct notifier_block *nb); + +/**************************************************************************** + * Name: watchdog_notifier_call_chain + * + * Description: + * Call functions in the watchdog notifier chain. + * + * Input Parameters: + * action - Value passed unmodified to notifier function + * data - Pointer passed unmodified to notifier function + * + ****************************************************************************/ + +void watchdog_notifier_call_chain(unsigned long action, FAR void *data); Review Comment: should we merge watchdog_notifier.c into watchdog.c and remove this function ########## drivers/timers/watchdog.c: ########## @@ -71,6 +71,19 @@ # endif #endif +#if defined(CONFIG_WATCHDOG_AUTOMONITOR_BY_ONESHOT) +#define WATCHDOG_NOTIFIER_ACTION WATCHDOG_KEEPALIVE_BY_ONESHOT Review Comment: ```suggestion # define WATCHDOG_NOTIFIER_ACTION WATCHDOG_KEEPALIVE_BY_ONESHOT ``` and other similar line ########## drivers/timers/watchdog.c: ########## @@ -71,6 +71,19 @@ # endif #endif +#if defined(CONFIG_WATCHDOG_AUTOMONITOR_BY_ONESHOT) +#define WATCHDOG_NOTIFIER_ACTION WATCHDOG_KEEPALIVE_BY_ONESHOT +#elif defined(CONFIG_WATCHDOG_AUTOMONITOR_BY_TIMER) +#define WATCHDOG_NOTIFIER_ACTION WATCHDOG_KEEPALIVE_BY_TIMER +#elif defined(CONFIG_WATCHDOG_AUTOMONITOR_BY_WDOG) +#define WATCHDOG_NOTIFIER_ACTION WATCHDOG_KEEPALIVE_BY_WDOG +#elif defined(CONFIG_WATCHDOG_AUTOMONITOR_BY_WORKER) +#define WATCHDOG_NOTIFIER_ACTION WATCHDOG_KEEPALIVE_BY_WORKER +#elif defined(CONFIG_WATCHDOG_AUTOMONITOR_BY_CAPTURE) +#define WATCHDOG_NOTIFIER_ACTION WATCHDOG_KEEPALIVE_BY_CAPTURE +#elif defined(CONFIG_WATCHDOG_AUTOMONITOR_BY_IDLE) +#define WATCHDOG_NOTIFIER_ACTION WATCHDOG_KEEPALIVE_BY_IDLE +#endif Review Comment: add blank line -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org