diff mbox series

[U-Boot,v2,09/41] spl: bootcount: Move code out of header file

Message ID 20191108195348.110648-2-sjg@chromium.org
State Changes Requested
Delegated to: Tom Rini
Headers show
Series common: Further reduce common.h | expand

Commit Message

Simon Glass Nov. 8, 2019, 7:53 p.m. UTC
It is not good practice to write code in a header file. If it is included
multiple times then the code can cause duplicate functions.

Move the bootcount_store() and bootcount_load() functions into SPL.

Note: bootcount is a bit strange in that it uses driver model but does not
define proper drivers. This should be fixed.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

Changes in v2: None

 common/spl/spl.c    | 11 +++++++++++
 include/bootcount.h |  4 ----
 2 files changed, 11 insertions(+), 4 deletions(-)

Comments

Tom Rini Nov. 11, 2019, 2:15 p.m. UTC | #1
On Fri, Nov 08, 2019 at 12:53:16PM -0700, Simon Glass wrote:

> It is not good practice to write code in a header file. If it is included
> multiple times then the code can cause duplicate functions.
> 
> Move the bootcount_store() and bootcount_load() functions into SPL.
> 
> Note: bootcount is a bit strange in that it uses driver model but does not
> define proper drivers. This should be fixed.
> 
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
> 
> Changes in v2: None
> 
>  common/spl/spl.c    | 11 +++++++++++
>  include/bootcount.h |  4 ----
>  2 files changed, 11 insertions(+), 4 deletions(-)
> 
> diff --git a/common/spl/spl.c b/common/spl/spl.c
> index cc5507f757..a2ef13a41c 100644
> --- a/common/spl/spl.c
> +++ b/common/spl/spl.c
> @@ -830,3 +830,14 @@ ulong spl_relocate_stack_gd(void)
>  	return 0;
>  #endif
>  }
> +
> +#if defined(CONFIG_BOOTCOUNT_LIMIT) && !defined(CONFIG_SPL_BOOTCOUNT_LIMIT)
> +void bootcount_store(ulong a)
> +{
> +}
> +
> +ulong bootcount_load(void)
> +{
> +	return 0;
> +}
> +#endif
> diff --git a/include/bootcount.h b/include/bootcount.h
> index 8fa8cf8218..a26a385233 100644
> --- a/include/bootcount.h
> +++ b/include/bootcount.h
> @@ -127,10 +127,6 @@ static inline void bootcount_inc(void)
>  #endif /* !CONFIG_SPL_BUILD */
>  }
>  
> -#if defined(CONFIG_SPL_BUILD) && !defined(CONFIG_SPL_BOOTCOUNT_LIMIT)
> -void bootcount_store(ulong a) {};
> -ulong bootcount_load(void) { return 0; }
> -#endif /* CONFIG_SPL_BUILD && !CONFIG_SPL_BOOTCOUNT_LIMIT */
>  #else
>  static inline int bootcount_error(void) { return 0; }
>  static inline void bootcount_inc(void) {}

Adding a few folks that have touched bootcount of late to chime in here,
thanks.
diff mbox series

Patch

diff --git a/common/spl/spl.c b/common/spl/spl.c
index cc5507f757..a2ef13a41c 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -830,3 +830,14 @@  ulong spl_relocate_stack_gd(void)
 	return 0;
 #endif
 }
+
+#if defined(CONFIG_BOOTCOUNT_LIMIT) && !defined(CONFIG_SPL_BOOTCOUNT_LIMIT)
+void bootcount_store(ulong a)
+{
+}
+
+ulong bootcount_load(void)
+{
+	return 0;
+}
+#endif
diff --git a/include/bootcount.h b/include/bootcount.h
index 8fa8cf8218..a26a385233 100644
--- a/include/bootcount.h
+++ b/include/bootcount.h
@@ -127,10 +127,6 @@  static inline void bootcount_inc(void)
 #endif /* !CONFIG_SPL_BUILD */
 }
 
-#if defined(CONFIG_SPL_BUILD) && !defined(CONFIG_SPL_BOOTCOUNT_LIMIT)
-void bootcount_store(ulong a) {};
-ulong bootcount_load(void) { return 0; }
-#endif /* CONFIG_SPL_BUILD && !CONFIG_SPL_BOOTCOUNT_LIMIT */
 #else
 static inline int bootcount_error(void) { return 0; }
 static inline void bootcount_inc(void) {}