public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 1/1] env_mmc: support env partition setup in runtime
@ 2014-07-29  9:46 Dmitry Lifshitz
  2014-07-29 17:44 ` Jeroen Hofstee
  2014-07-30 10:19 ` [U-Boot] [PATCH 1/2] env_mmc: add mmc_get_env_addr() prototype Dmitry Lifshitz
  0 siblings, 2 replies; 7+ messages in thread
From: Dmitry Lifshitz @ 2014-07-29  9:46 UTC (permalink / raw)
  To: u-boot

Add callback with __weak annotation to allow setup of environment
partition number in runtime from a board file.

Propagate mmc_switch_part() return value into init_mmc_for_env() instead
of -1 in case of failure.

Signed-off-by: Dmitry Lifshitz <lifshitz@compulab.co.il>
Signed-off-by: Igor Grinberg <grinberg@compulab.co.il>
---
 common/env_mmc.c |   35 +++++++++++++++++++++++------------
 1 files changed, 23 insertions(+), 12 deletions(-)

diff --git a/common/env_mmc.c b/common/env_mmc.c
index 7da10e6..a7621a8 100644
--- a/common/env_mmc.c
+++ b/common/env_mmc.c
@@ -62,16 +62,36 @@ int env_init(void)
 	return 0;
 }
 
-static int init_mmc_for_env(struct mmc *mmc)
-{
 #ifdef CONFIG_SYS_MMC_ENV_PART
+__weak uint mmc_get_env_part(struct mmc *mmc)
+{
+	return CONFIG_SYS_MMC_ENV_PART;
+}
+
+static int mmc_set_env_part(struct mmc *mmc)
+{
+	uint part = mmc_get_env_part(mmc);
 	int dev = CONFIG_SYS_MMC_ENV_DEV;
+	int ret = 0;
 
 #ifdef CONFIG_SPL_BUILD
 	dev = 0;
 #endif
+
+	if (part != mmc->part_num) {
+		ret = mmc_switch_part(dev, part);
+		if (ret)
+			puts("MMC partition switch failed\n");
+	}
+
+	return ret;
+}
+#else
+static inline int mmc_set_env_part(struct mmc *mmc) {return 0; };
 #endif
 
+static int init_mmc_for_env(struct mmc *mmc)
+{
 	if (!mmc) {
 		puts("No MMC card found\n");
 		return -1;
@@ -82,16 +102,7 @@ static int init_mmc_for_env(struct mmc *mmc)
 		return -1;
 	}
 
-#ifdef CONFIG_SYS_MMC_ENV_PART
-	if (CONFIG_SYS_MMC_ENV_PART != mmc->part_num) {
-		if (mmc_switch_part(dev, CONFIG_SYS_MMC_ENV_PART)) {
-			puts("MMC partition switch failed\n");
-			return -1;
-		}
-	}
-#endif
-
-	return 0;
+	return mmc_set_env_part(mmc);
 }
 
 static void fini_mmc_for_env(struct mmc *mmc)
-- 
1.7.5.4

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [U-Boot] [PATCH 1/1] env_mmc: support env partition setup in runtime
  2014-07-29  9:46 [U-Boot] [PATCH 1/1] env_mmc: support env partition setup in runtime Dmitry Lifshitz
@ 2014-07-29 17:44 ` Jeroen Hofstee
  2014-07-30  6:15   ` Igor Grinberg
  2014-07-30 10:19 ` [U-Boot] [PATCH 1/2] env_mmc: add mmc_get_env_addr() prototype Dmitry Lifshitz
  1 sibling, 1 reply; 7+ messages in thread
From: Jeroen Hofstee @ 2014-07-29 17:44 UTC (permalink / raw)
  To: u-boot

Hello Dmitry,

On 29-07-14 11:46, Dmitry Lifshitz wrote:
> Add callback with __weak annotation to allow setup of environment
> partition number in runtime from a board file.
>
> Propagate mmc_switch_part() return value into init_mmc_for_env() instead
> of -1 in case of failure.
>
> Signed-off-by: Dmitry Lifshitz <lifshitz@compulab.co.il>
> Signed-off-by: Igor Grinberg <grinberg@compulab.co.il>
> ---
>   common/env_mmc.c |   35 +++++++++++++++++++++++------------
>   1 files changed, 23 insertions(+), 12 deletions(-)
>
> diff --git a/common/env_mmc.c b/common/env_mmc.c
> index 7da10e6..a7621a8 100644
> --- a/common/env_mmc.c
> +++ b/common/env_mmc.c
> @@ -62,16 +62,36 @@ int env_init(void)
>   	return 0;
>   }
>   
> -static int init_mmc_for_env(struct mmc *mmc)
> -{
>   #ifdef CONFIG_SYS_MMC_ENV_PART
> +__weak uint mmc_get_env_part(struct mmc *mmc)
> +{
> +	return CONFIG_SYS_MMC_ENV_PART;
> +}
> +

mmc_get_env_part lacks a prototype and there seems to be no
"strong version" / user of this code.

Regards,
Jeroen

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [U-Boot] [PATCH 1/1] env_mmc: support env partition setup in runtime
  2014-07-29 17:44 ` Jeroen Hofstee
@ 2014-07-30  6:15   ` Igor Grinberg
  0 siblings, 0 replies; 7+ messages in thread
From: Igor Grinberg @ 2014-07-30  6:15 UTC (permalink / raw)
  To: u-boot

Hi Jeroen,

On 07/29/14 20:44, Jeroen Hofstee wrote:
> Hello Dmitry,
> 
> On 29-07-14 11:46, Dmitry Lifshitz wrote:
>> Add callback with __weak annotation to allow setup of environment
>> partition number in runtime from a board file.
>>
>> Propagate mmc_switch_part() return value into init_mmc_for_env() instead
>> of -1 in case of failure.
>>
>> Signed-off-by: Dmitry Lifshitz <lifshitz@compulab.co.il>
>> Signed-off-by: Igor Grinberg <grinberg@compulab.co.il>
>> ---
>>   common/env_mmc.c |   35 +++++++++++++++++++++++------------
>>   1 files changed, 23 insertions(+), 12 deletions(-)
>>
>> diff --git a/common/env_mmc.c b/common/env_mmc.c
>> index 7da10e6..a7621a8 100644
>> --- a/common/env_mmc.c
>> +++ b/common/env_mmc.c
>> @@ -62,16 +62,36 @@ int env_init(void)
>>       return 0;
>>   }
>>   -static int init_mmc_for_env(struct mmc *mmc)
>> -{
>>   #ifdef CONFIG_SYS_MMC_ENV_PART
>> +__weak uint mmc_get_env_part(struct mmc *mmc)
>> +{
>> +    return CONFIG_SYS_MMC_ENV_PART;
>> +}
>> +
> 
> mmc_get_env_part lacks a prototype and there seems to be no
> "strong version" / user of this code.

Thanks for finding this one.
Indeed we forgot to add a prototype - will fix that shortly.

As to the strong version - it is already upstream:
1c8c36f (cm-t54: add environment partition runtime detection)


-- 
Regards,
Igor.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [U-Boot] [PATCH 1/2] env_mmc: add mmc_get_env_addr() prototype
  2014-07-29  9:46 [U-Boot] [PATCH 1/1] env_mmc: support env partition setup in runtime Dmitry Lifshitz
  2014-07-29 17:44 ` Jeroen Hofstee
@ 2014-07-30 10:19 ` Dmitry Lifshitz
  2014-07-30 10:19   ` [U-Boot] [PATCH v2 2/2] env_mmc: support env partition setup in runtime Dmitry Lifshitz
  2014-08-01 17:14   ` [U-Boot] [PATCH 1/2] env_mmc: add mmc_get_env_addr() prototype Pantelis Antoniou
  1 sibling, 2 replies; 7+ messages in thread
From: Dmitry Lifshitz @ 2014-07-30 10:19 UTC (permalink / raw)
  To: u-boot

Add missing mmc_get_env_addr() prototype in environment.h

Signed-off-by: Dmitry Lifshitz <lifshitz@compulab.co.il>
---
 include/environment.h |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/include/environment.h b/include/environment.h
index 08679ae..d7a1adf 100644
--- a/include/environment.h
+++ b/include/environment.h
@@ -180,6 +180,12 @@ extern unsigned char env_get_char_spec(int);
 extern void env_reloc(void);
 #endif
 
+#ifdef CONFIG_ENV_IS_IN_MMC
+#include <mmc.h>
+
+extern int mmc_get_env_addr(struct mmc *mmc, int copy, u32 *env_addr);
+#endif
+
 #ifndef DO_DEPS_ONLY
 
 #include <env_attr.h>
-- 
1.7.5.4

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [U-Boot] [PATCH v2 2/2] env_mmc: support env partition setup in runtime
  2014-07-30 10:19 ` [U-Boot] [PATCH 1/2] env_mmc: add mmc_get_env_addr() prototype Dmitry Lifshitz
@ 2014-07-30 10:19   ` Dmitry Lifshitz
  2014-08-01 17:14     ` Pantelis Antoniou
  2014-08-01 17:14   ` [U-Boot] [PATCH 1/2] env_mmc: add mmc_get_env_addr() prototype Pantelis Antoniou
  1 sibling, 1 reply; 7+ messages in thread
From: Dmitry Lifshitz @ 2014-07-30 10:19 UTC (permalink / raw)
  To: u-boot

Add callback with __weak annotation to allow setup of environment
partition number in runtime from a board file.

Propagate mmc_switch_part() return value into init_mmc_for_env() instead
of -1 in case of failure.

Signed-off-by: Dmitry Lifshitz <lifshitz@compulab.co.il>
Signed-off-by: Igor Grinberg <grinberg@compulab.co.il>
---

 Changes in v2:

    * Added mmc_get_env_part() proto in environment.h.

 common/env_mmc.c      |   35 +++++++++++++++++++++++------------
 include/environment.h |    3 +++
 2 files changed, 26 insertions(+), 12 deletions(-)

diff --git a/common/env_mmc.c b/common/env_mmc.c
index 7da10e6..a7621a8 100644
--- a/common/env_mmc.c
+++ b/common/env_mmc.c
@@ -62,16 +62,36 @@ int env_init(void)
 	return 0;
 }
 
-static int init_mmc_for_env(struct mmc *mmc)
-{
 #ifdef CONFIG_SYS_MMC_ENV_PART
+__weak uint mmc_get_env_part(struct mmc *mmc)
+{
+	return CONFIG_SYS_MMC_ENV_PART;
+}
+
+static int mmc_set_env_part(struct mmc *mmc)
+{
+	uint part = mmc_get_env_part(mmc);
 	int dev = CONFIG_SYS_MMC_ENV_DEV;
+	int ret = 0;
 
 #ifdef CONFIG_SPL_BUILD
 	dev = 0;
 #endif
+
+	if (part != mmc->part_num) {
+		ret = mmc_switch_part(dev, part);
+		if (ret)
+			puts("MMC partition switch failed\n");
+	}
+
+	return ret;
+}
+#else
+static inline int mmc_set_env_part(struct mmc *mmc) {return 0; };
 #endif
 
+static int init_mmc_for_env(struct mmc *mmc)
+{
 	if (!mmc) {
 		puts("No MMC card found\n");
 		return -1;
@@ -82,16 +102,7 @@ static int init_mmc_for_env(struct mmc *mmc)
 		return -1;
 	}
 
-#ifdef CONFIG_SYS_MMC_ENV_PART
-	if (CONFIG_SYS_MMC_ENV_PART != mmc->part_num) {
-		if (mmc_switch_part(dev, CONFIG_SYS_MMC_ENV_PART)) {
-			puts("MMC partition switch failed\n");
-			return -1;
-		}
-	}
-#endif
-
-	return 0;
+	return mmc_set_env_part(mmc);
 }
 
 static void fini_mmc_for_env(struct mmc *mmc)
diff --git a/include/environment.h b/include/environment.h
index d7a1adf..1fdbdad 100644
--- a/include/environment.h
+++ b/include/environment.h
@@ -184,6 +184,9 @@ extern void env_reloc(void);
 #include <mmc.h>
 
 extern int mmc_get_env_addr(struct mmc *mmc, int copy, u32 *env_addr);
+# ifdef CONFIG_SYS_MMC_ENV_PART
+extern uint mmc_get_env_part(struct mmc *mmc);
+# endif
 #endif
 
 #ifndef DO_DEPS_ONLY
-- 
1.7.5.4

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [U-Boot] [PATCH 1/2] env_mmc: add mmc_get_env_addr() prototype
  2014-07-30 10:19 ` [U-Boot] [PATCH 1/2] env_mmc: add mmc_get_env_addr() prototype Dmitry Lifshitz
  2014-07-30 10:19   ` [U-Boot] [PATCH v2 2/2] env_mmc: support env partition setup in runtime Dmitry Lifshitz
@ 2014-08-01 17:14   ` Pantelis Antoniou
  1 sibling, 0 replies; 7+ messages in thread
From: Pantelis Antoniou @ 2014-08-01 17:14 UTC (permalink / raw)
  To: u-boot

Hi Dmitry,

On Jul 30, 2014, at 1:19 PM, Dmitry Lifshitz wrote:

> Add missing mmc_get_env_addr() prototype in environment.h
> 
> Signed-off-by: Dmitry Lifshitz <lifshitz@compulab.co.il>
> ---
> include/environment.h |    6 ++++++
> 1 files changed, 6 insertions(+), 0 deletions(-)
> 
> diff --git a/include/environment.h b/include/environment.h
> index 08679ae..d7a1adf 100644
> --- a/include/environment.h
> +++ b/include/environment.h
> @@ -180,6 +180,12 @@ extern unsigned char env_get_char_spec(int);
> extern void env_reloc(void);
> #endif
> 
> +#ifdef CONFIG_ENV_IS_IN_MMC
> +#include <mmc.h>
> +
> +extern int mmc_get_env_addr(struct mmc *mmc, int copy, u32 *env_addr);
> +#endif
> +
> #ifndef DO_DEPS_ONLY
> 
> #include <env_attr.h>
> -- 
> 1.7.5.4

Applied, thanks.

-- Pantelis

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [U-Boot] [PATCH v2 2/2] env_mmc: support env partition setup in runtime
  2014-07-30 10:19   ` [U-Boot] [PATCH v2 2/2] env_mmc: support env partition setup in runtime Dmitry Lifshitz
@ 2014-08-01 17:14     ` Pantelis Antoniou
  0 siblings, 0 replies; 7+ messages in thread
From: Pantelis Antoniou @ 2014-08-01 17:14 UTC (permalink / raw)
  To: u-boot

Hi Dmitry,

On Jul 30, 2014, at 1:19 PM, Dmitry Lifshitz wrote:

> Add callback with __weak annotation to allow setup of environment
> partition number in runtime from a board file.
> 
> Propagate mmc_switch_part() return value into init_mmc_for_env() instead
> of -1 in case of failure.
> 
> Signed-off-by: Dmitry Lifshitz <lifshitz@compulab.co.il>
> Signed-off-by: Igor Grinberg <grinberg@compulab.co.il>
> ---
> 
> Changes in v2:
> 
>    * Added mmc_get_env_part() proto in environment.h.
> 
> common/env_mmc.c      |   35 +++++++++++++++++++++++------------
> include/environment.h |    3 +++
> 2 files changed, 26 insertions(+), 12 deletions(-)
> 
> diff --git a/common/env_mmc.c b/common/env_mmc.c
> index 7da10e6..a7621a8 100644
> --- a/common/env_mmc.c
> +++ b/common/env_mmc.c
> @@ -62,16 +62,36 @@ int env_init(void)
> 	return 0;
> }
> 
> -static int init_mmc_for_env(struct mmc *mmc)
> -{
> #ifdef CONFIG_SYS_MMC_ENV_PART
> +__weak uint mmc_get_env_part(struct mmc *mmc)
> +{
> +	return CONFIG_SYS_MMC_ENV_PART;
> +}
> +
> +static int mmc_set_env_part(struct mmc *mmc)
> +{
> +	uint part = mmc_get_env_part(mmc);
> 	int dev = CONFIG_SYS_MMC_ENV_DEV;
> +	int ret = 0;
> 
> #ifdef CONFIG_SPL_BUILD
> 	dev = 0;
> #endif
> +
> +	if (part != mmc->part_num) {
> +		ret = mmc_switch_part(dev, part);
> +		if (ret)
> +			puts("MMC partition switch failed\n");
> +	}
> +
> +	return ret;
> +}
> +#else
> +static inline int mmc_set_env_part(struct mmc *mmc) {return 0; };
> #endif
> 
> +static int init_mmc_for_env(struct mmc *mmc)
> +{
> 	if (!mmc) {
> 		puts("No MMC card found\n");
> 		return -1;
> @@ -82,16 +102,7 @@ static int init_mmc_for_env(struct mmc *mmc)
> 		return -1;
> 	}
> 
> -#ifdef CONFIG_SYS_MMC_ENV_PART
> -	if (CONFIG_SYS_MMC_ENV_PART != mmc->part_num) {
> -		if (mmc_switch_part(dev, CONFIG_SYS_MMC_ENV_PART)) {
> -			puts("MMC partition switch failed\n");
> -			return -1;
> -		}
> -	}
> -#endif
> -
> -	return 0;
> +	return mmc_set_env_part(mmc);
> }
> 
> static void fini_mmc_for_env(struct mmc *mmc)
> diff --git a/include/environment.h b/include/environment.h
> index d7a1adf..1fdbdad 100644
> --- a/include/environment.h
> +++ b/include/environment.h
> @@ -184,6 +184,9 @@ extern void env_reloc(void);
> #include <mmc.h>
> 
> extern int mmc_get_env_addr(struct mmc *mmc, int copy, u32 *env_addr);
> +# ifdef CONFIG_SYS_MMC_ENV_PART
> +extern uint mmc_get_env_part(struct mmc *mmc);
> +# endif
> #endif
> 
> #ifndef DO_DEPS_ONLY
> -- 
> 1.7.5.4

Applied, thanks.

-- Pantelis

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-08-01 17:14 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-29  9:46 [U-Boot] [PATCH 1/1] env_mmc: support env partition setup in runtime Dmitry Lifshitz
2014-07-29 17:44 ` Jeroen Hofstee
2014-07-30  6:15   ` Igor Grinberg
2014-07-30 10:19 ` [U-Boot] [PATCH 1/2] env_mmc: add mmc_get_env_addr() prototype Dmitry Lifshitz
2014-07-30 10:19   ` [U-Boot] [PATCH v2 2/2] env_mmc: support env partition setup in runtime Dmitry Lifshitz
2014-08-01 17:14     ` Pantelis Antoniou
2014-08-01 17:14   ` [U-Boot] [PATCH 1/2] env_mmc: add mmc_get_env_addr() prototype Pantelis Antoniou

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox