All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefan Roese <sr@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 05/30] wdt: Move code out of the header
Date: Mon, 28 Oct 2019 06:07:37 +0100	[thread overview]
Message-ID: <207d2096-e19b-6809-9615-2fa4dda3c4fe@denx.de> (raw)
In-Reply-To: <20191027155410.187957-5-sjg@chromium.org>

On 27.10.19 16:53, Simon Glass wrote:
> We should not have C code in a header file. Move it into a shared C file
> so it can be used by U-Boot and SPL.
> 
> Signed-off-by: Simon Glass <sjg@chromium.org>

Reviewed-by: Stefan Roese <sr@denx.de>

Thanks,
Stefan

> ---
> 
>   common/init/Makefile |  1 +
>   common/init/wdt.c    | 46 ++++++++++++++++++++++++++++++++++++++++++++
>   include/init.h       |  7 +++++++
>   include/wdt.h        | 38 ------------------------------------
>   4 files changed, 54 insertions(+), 38 deletions(-)
>   create mode 100644 common/init/wdt.c
> 
> diff --git a/common/init/Makefile b/common/init/Makefile
> index 853b56d1e5..a76dedf350 100644
> --- a/common/init/Makefile
> +++ b/common/init/Makefile
> @@ -6,3 +6,4 @@
>   
>   obj-y += board_init.o
>   obj-$(CONFIG_$(SPL_TPL_)HANDOFF) += handoff.o
> +obj-$(CONFIG_$(SPL_TPL_)WDT) += wdt.o
> diff --git a/common/init/wdt.c b/common/init/wdt.c
> new file mode 100644
> index 0000000000..79146fb293
> --- /dev/null
> +++ b/common/init/wdt.c
> @@ -0,0 +1,46 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * Copyright 2017 Google, Inc
> + */
> +
> +#include <common.h>
> +#include <dm.h>
> +#include <wdt.h>
> +
> +DECLARE_GLOBAL_DATA_PTR;
> +
> +#ifndef CONFIG_WATCHDOG_TIMEOUT_MSECS
> +#define CONFIG_WATCHDOG_TIMEOUT_MSECS	(60 * 1000)
> +#endif
> +#define WATCHDOG_TIMEOUT_SECS	(CONFIG_WATCHDOG_TIMEOUT_MSECS / 1000)
> +
> +int initr_watchdog(void)
> +{
> +	u32 timeout = WATCHDOG_TIMEOUT_SECS;
> +
> +	/*
> +	 * Init watchdog: This will call the probe function of the
> +	 * watchdog driver, enabling the use of the device
> +	 */
> +	if (uclass_get_device_by_seq(UCLASS_WDT, 0,
> +				     (struct udevice **)&gd->watchdog_dev)) {
> +		debug("WDT:   Not found by seq!\n");
> +		if (uclass_get_device(UCLASS_WDT, 0,
> +				      (struct udevice **)&gd->watchdog_dev)) {
> +			printf("WDT:   Not found!\n");
> +			return 0;
> +		}
> +	}
> +
> +	if (CONFIG_IS_ENABLED(OF_CONTROL)) {
> +		timeout = dev_read_u32_default(gd->watchdog_dev, "timeout-sec",
> +					       WATCHDOG_TIMEOUT_SECS);
> +	}
> +
> +	wdt_start(gd->watchdog_dev, timeout * 1000, 0);
> +	gd->flags |= GD_FLG_WDT_READY;
> +	printf("WDT:   Started with%s servicing (%ds timeout)\n",
> +	       IS_ENABLED(CONFIG_WATCHDOG) ? "" : "out", timeout);
> +
> +	return 0;
> +}
> diff --git a/include/init.h b/include/init.h
> index afc953d51e..3e5857f07f 100644
> --- a/include/init.h
> +++ b/include/init.h
> @@ -181,6 +181,13 @@ int init_func_vid(void);
>   int checkboard(void);
>   int show_board_info(void);
>   
> +/**
> + * initr_watchdog() - Init the watchdog
> + *
> + * @return 0 if OK, -ve on error
> + */
> +int initr_watchdog(void);
> +
>   #endif	/* __ASSEMBLY__ */
>   /* Put only stuff here that the assembler can digest */
>   
> diff --git a/include/wdt.h b/include/wdt.h
> index 5bcff24ab3..5698605c02 100644
> --- a/include/wdt.h
> +++ b/include/wdt.h
> @@ -106,42 +106,4 @@ struct wdt_ops {
>   	int (*expire_now)(struct udevice *dev, ulong flags);
>   };
>   
> -#if CONFIG_IS_ENABLED(WDT)
> -#ifndef CONFIG_WATCHDOG_TIMEOUT_MSECS
> -#define CONFIG_WATCHDOG_TIMEOUT_MSECS	(60 * 1000)
> -#endif
> -#define WATCHDOG_TIMEOUT_SECS	(CONFIG_WATCHDOG_TIMEOUT_MSECS / 1000)
> -
> -static inline int initr_watchdog(void)
> -{
> -	u32 timeout = WATCHDOG_TIMEOUT_SECS;
> -
> -	/*
> -	 * Init watchdog: This will call the probe function of the
> -	 * watchdog driver, enabling the use of the device
> -	 */
> -	if (uclass_get_device_by_seq(UCLASS_WDT, 0,
> -				     (struct udevice **)&gd->watchdog_dev)) {
> -		debug("WDT:   Not found by seq!\n");
> -		if (uclass_get_device(UCLASS_WDT, 0,
> -				      (struct udevice **)&gd->watchdog_dev)) {
> -			printf("WDT:   Not found!\n");
> -			return 0;
> -		}
> -	}
> -
> -	if (CONFIG_IS_ENABLED(OF_CONTROL)) {
> -		timeout = dev_read_u32_default(gd->watchdog_dev, "timeout-sec",
> -					       WATCHDOG_TIMEOUT_SECS);
> -	}
> -
> -	wdt_start(gd->watchdog_dev, timeout * 1000, 0);
> -	gd->flags |= GD_FLG_WDT_READY;
> -	printf("WDT:   Started with%s servicing (%ds timeout)\n",
> -	       IS_ENABLED(CONFIG_WATCHDOG) ? "" : "out", timeout);
> -
> -	return 0;
> -}
> -#endif
> -
>   #endif  /* _WDT_H_ */
> 

Viele Grüße,
Stefan

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr at denx.de

  reply	other threads:[~2019-10-28  5:07 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-27 15:53 [U-Boot] [PATCH 01/30] lib: Allow crc32 to be disabled Simon Glass
2019-10-27 15:53 ` [U-Boot] [PATCH 02/30] spi: Allow separate control of SPI_FLASH_TINY for SPL/TPL Simon Glass
2019-10-27 15:53 ` [U-Boot] [PATCH 03/30] mtd: spi-nor: Tidy up error handling / debug code Simon Glass
2019-10-27 15:53 ` [U-Boot] [PATCH 04/30] mtd: spi: Export spi_flash_std_probe() Simon Glass
2019-10-27 15:53 ` [U-Boot] [PATCH 05/30] wdt: Move code out of the header Simon Glass
2019-10-28  5:07   ` Stefan Roese [this message]
2019-10-27 15:53 ` [U-Boot] [PATCH 06/30] wdt: Drop dm.h header file Simon Glass
2019-10-28  5:44   ` Stefan Roese
2019-10-27 15:53 ` [U-Boot] [PATCH 07/30] mtd: spi-mem: " Simon Glass
2019-10-27 15:53 ` [U-Boot] [PATCH 08/30] mtd: spi: Drop SPI_XFER_MMAP* Simon Glass
2019-10-27 15:53 ` [U-Boot] [PATCH 09/30] dm: core: Drop dm.h header file from dm-demo.h Simon Glass
2019-10-27 15:53 ` [U-Boot] [PATCH 10/30] dm: core: Drop header files from dm/test.h Simon Glass
2019-10-27 15:53 ` [U-Boot] [PATCH 11/30] fs: fs-loader: Drop dm.h header file Simon Glass
2019-10-27 15:53 ` [U-Boot] [PATCH 12/30] net: Drop dm.h header file from phy.h Simon Glass
2019-10-27 15:53 ` [U-Boot] [PATCH 13/30] sf: Drop dm.h header file from spi_flash.h Simon Glass
2019-10-27 15:53 ` [U-Boot] [PATCH 14/30] thermal: Drop dm.h header file Simon Glass
2019-10-27 15:53 ` [U-Boot] [PATCH 15/30] w1: " Simon Glass
2019-10-27 15:53 ` [U-Boot] [PATCH 16/30] efi: Tidy up header includes Simon Glass
2019-10-27 17:42   ` Heinrich Schuchardt
2019-10-27 18:59     ` Simon Glass
2019-10-27 15:53 ` [U-Boot] [PATCH 17/30] power: Tidy up inclusion of regulator_common.h Simon Glass
2019-10-27 15:53 ` [U-Boot] [PATCH 18/30] mmc: Drop duplicate dm.h inclusion Simon Glass
2019-10-27 15:53 ` [U-Boot] [PATCH 19/30] spi: " Simon Glass
2019-10-27 15:54 ` [U-Boot] [PATCH 20/30] ti: am654: " Simon Glass
2019-10-29  5:43   ` Lokesh Vutla
2019-10-27 15:54 ` [U-Boot] [PATCH 21/30] liebherr: " Simon Glass
2019-11-01 22:45   ` Lukasz Majewski
2019-10-27 15:54 ` [U-Boot] [PATCH 22/30] pci: Drop dm.h inclusion from header file Simon Glass
2019-10-27 15:54 ` [PATCH 23/30] video: meson: Drop unnecessary header includes Simon Glass
2019-10-27 15:54   ` [U-Boot] " Simon Glass
2019-10-27 17:06   ` Anatolij Gustschin
2019-10-27 17:06     ` [U-Boot] " Anatolij Gustschin
2019-10-27 17:48   ` Neil Armstrong
2019-10-27 17:48     ` [U-Boot] " Neil Armstrong
2020-01-07 10:16     ` Neil Armstrong
2020-01-07 10:16       ` Neil Armstrong
2019-10-27 15:54 ` [U-Boot] [PATCH 24/30] mediatek: Drop dm.h header file Simon Glass
2019-10-27 15:54 ` [U-Boot] [PATCH 25/30] mscc: " Simon Glass
2019-10-27 15:54 ` [U-Boot] [PATCH 26/30] adc: " Simon Glass
2019-10-27 15:54 ` [U-Boot] [PATCH 27/30] nand: " Simon Glass
2019-10-27 15:54 ` [U-Boot] [PATCH 28/30] ufs: " Simon Glass
2019-10-27 15:54 ` [U-Boot] [PATCH 29/30] usb: " Simon Glass
2019-10-27 15:54 ` [U-Boot] [PATCH 30/30] dm: core: Guard against including dm.h in header files Simon Glass
2019-10-27 16:48 ` [U-Boot] [PATCH 01/30] lib: Allow crc32 to be disabled Heinrich Schuchardt
2019-11-08 14:59   ` Tom Rini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=207d2096-e19b-6809-9615-2fa4dda3c4fe@denx.de \
    --to=sr@denx.de \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.