* [PATCH 0/5] Introduce devfs_append_partition and a few users
@ 2014-02-18 10:36 Uwe Kleine-König
2014-02-18 10:36 ` [PATCH 1/5] devfs-core: introduce devfs_append_partition Uwe Kleine-König
` (4 more replies)
0 siblings, 5 replies; 7+ messages in thread
From: Uwe Kleine-König @ 2014-02-18 10:36 UTC (permalink / raw)
To: barebox
Hello,
the fist patch was already sent some time ago by Jan Lübbe (with
Message-Id: <1371559852-21867-1-git-send-email-jlu@pengutronix.de>).
Back then Sascha said:
I'm fine with the patch when some users are converted to this.
and Alexander Shiyan suggested to make offset a static variable which
Jan didn't consider this a good idea, me does neither.
I thought about making devfs_append_partition an inline function, but
this function doesn't compile as efficient as it looks like at least on
ARM. That is because comparing the parameter lists of
devfs_append_partition and devfs_add_partition the former takes a
pointer as 2nd parameter while the latter a loff_t which is a 64 bit
type. So register allocation for parameters is as follows:
devfs_append_partition:
r0: const char *devname
r1: loff_t *offset
r2/r3: loff_t size
stack: const char *name
int flags
devfs_add_partition:
r0: const char *devname
/* r1: unused */
r2/r3: loff_t offset
stack: const char *name
int flags
loff_t size
/
So some juggling has to be done to setup the parameters for
devfs_add_partition. This could be fixed by changing the parameters to:
struct cdev *devfs_add_partition(loff_t offset, loff_t size,
const char *devname, int flags, const char *name);
struct cdev *devfs_append_partition(loff_t *offset, loff_t size,
const char *devname, int flags, const char *name);
but not sure it's worth the hassle.
So I just picked four random boards and converted them and fixed up
patch 1 for commit 121c3d6e9c2f (devfs: let devfs_add_partition return
the new partition).
The diffstat is bad. The new function account for a net addition of 11
lines. sama5d3xek adds (net) 10 lines, that's: two for the newly
required offset variable, 4 lines because I broke overlong lines and
four additional lines to preserve the hole in the partitioning layout.
Still I think it's a nice cleanup because holes in the partitioning
(which should be the exception) are more explicit now.
Best regards
Uwe
Jan Luebbe (1):
devfs-core: introduce devfs_append_partition
Uwe Kleine-König (4):
ARM: sama5d3xek: convert to devfs_append_partition
ARM: a9m2410: convert to devfs_append_partition
ARM: freescale-mx35-3-stack: convert to devfs_append_partition
ARM: pca100: convert to devfs_append_partition
arch/arm/boards/a9m2410/a9m2410.c | 24 +++++++++++++++++-------
arch/arm/boards/freescale-mx35-3-stack/3stack.c | 13 +++++++++----
arch/arm/boards/phycard-i.MX27/pca100.c | 5 +++--
arch/arm/boards/sama5d3xek/init.c | 18 ++++++++++++++----
fs/devfs-core.c | 9 +++++++++
include/driver.h | 6 ++++--
6 files changed, 56 insertions(+), 19 deletions(-)
--
1.8.5.3
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/5] devfs-core: introduce devfs_append_partition
2014-02-18 10:36 [PATCH 0/5] Introduce devfs_append_partition and a few users Uwe Kleine-König
@ 2014-02-18 10:36 ` Uwe Kleine-König
2014-02-18 10:36 ` [PATCH 2/5] ARM: sama5d3xek: convert to devfs_append_partition Uwe Kleine-König
` (3 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Uwe Kleine-König @ 2014-02-18 10:36 UTC (permalink / raw)
To: barebox
From: Jan Luebbe <jlu@pengutronix.de>
This simplifies board code for partition setup by keeping track of the
offset.
Signed-off-by: Jan Luebbe <jlu@pengutronix.de>
[ukl: change return type analogous to how devfs_add_partition was
changed in 121c3d6e9c2f (devfs: let devfs_add_partition return the new
partition).]
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
fs/devfs-core.c | 9 +++++++++
include/driver.h | 6 ++++--
2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/fs/devfs-core.c b/fs/devfs-core.c
index 44f0169e6324..c10345b3bfed 100644
--- a/fs/devfs-core.c
+++ b/fs/devfs-core.c
@@ -303,6 +303,15 @@ struct cdev *devfs_add_partition(const char *devname, loff_t offset, loff_t size
return new;
}
+struct cdev *devfs_append_partition(const char *devname, loff_t *offset,
+ loff_t size, int flags, const char *name)
+{
+ struct cdev *ret;
+ ret = devfs_add_partition(devname, *offset, size, flags, name);
+ *offset += size;
+ return ret;
+}
+
int devfs_del_partition(const char *name)
{
struct cdev *cdev;
diff --git a/include/driver.h b/include/driver.h
index bbe789b51ead..9fa94ae78ab2 100644
--- a/include/driver.h
+++ b/include/driver.h
@@ -487,8 +487,10 @@ int cdev_erase(struct cdev *cdev, size_t count, loff_t offset);
#define DEVFS_IS_PARTITION (1 << 2)
#define DEVFS_IS_CHARACTER_DEV (1 << 3)
-struct cdev *devfs_add_partition(const char *devname, loff_t offset, loff_t size,
- int flags, const char *name);
+struct cdev *devfs_add_partition(const char *devname, loff_t offset,
+ loff_t size, int flags, const char *name);
+struct cdev *devfs_append_partition(const char *devname, loff_t *offset,
+ loff_t size, int flags, const char *name);
int devfs_del_partition(const char *name);
#define DRV_OF_COMPAT(compat) \
--
1.8.5.3
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 2/5] ARM: sama5d3xek: convert to devfs_append_partition
2014-02-18 10:36 [PATCH 0/5] Introduce devfs_append_partition and a few users Uwe Kleine-König
2014-02-18 10:36 ` [PATCH 1/5] devfs-core: introduce devfs_append_partition Uwe Kleine-König
@ 2014-02-18 10:36 ` Uwe Kleine-König
2014-02-18 10:43 ` Jean-Christophe PLAGNIOL-VILLARD
2014-02-18 10:36 ` [PATCH 3/5] ARM: a9m2410: " Uwe Kleine-König
` (2 subsequent siblings)
4 siblings, 1 reply; 7+ messages in thread
From: Uwe Kleine-König @ 2014-02-18 10:36 UTC (permalink / raw)
To: barebox
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
arch/arm/boards/sama5d3xek/init.c | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
diff --git a/arch/arm/boards/sama5d3xek/init.c b/arch/arm/boards/sama5d3xek/init.c
index 4f866aa6f85d..ba5f90c7063c 100644
--- a/arch/arm/boards/sama5d3xek/init.c
+++ b/arch/arm/boards/sama5d3xek/init.c
@@ -402,6 +402,8 @@ static void ek_add_device_hdmi(void)
static int at91sama5d3xek_devices_init(void)
{
+ loff_t offset = 0x0;
+
ek_add_device_w1();
ek_add_device_hdmi();
ek_add_device_nand();
@@ -411,13 +413,21 @@ static int at91sama5d3xek_devices_init(void)
ek_add_device_mci();
ek_add_device_lcdc();
- devfs_add_partition("nand0", 0x00000, SZ_256K, DEVFS_PARTITION_FIXED, "at91bootstrap_raw");
+ devfs_append_partition("nand0", &offset, SZ_256K,
+ DEVFS_PARTITION_FIXED, "at91bootstrap_raw");
dev_add_bb_dev("at91bootstrap_raw", "at91bootstrap");
- devfs_add_partition("nand0", SZ_256K, SZ_256K + SZ_128K, DEVFS_PARTITION_FIXED, "self_raw");
+ devfs_append_partition("nand0", &offset, SZ_256K + SZ_128K,
+ DEVFS_PARTITION_FIXED, "self_raw");
dev_add_bb_dev("self_raw", "self0");
- devfs_add_partition("nand0", SZ_512K + SZ_256K, SZ_256K, DEVFS_PARTITION_FIXED, "env_raw");
+
+ /* there is a hole in the partition layout of 128K */
+ offset = SZ_512K + SZ_256K;
+
+ devfs_append_partition("nand0", &offset, SZ_256K,
+ DEVFS_PARTITION_FIXED, "env_raw");
dev_add_bb_dev("env_raw", "env0");
- devfs_add_partition("nand0", SZ_1M, SZ_256K, DEVFS_PARTITION_FIXED, "env_raw1");
+ devfs_append_partition("nand0", &offset, SZ_256K,
+ DEVFS_PARTITION_FIXED, "env_raw1");
dev_add_bb_dev("env_raw1", "env1");
return 0;
--
1.8.5.3
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 3/5] ARM: a9m2410: convert to devfs_append_partition
2014-02-18 10:36 [PATCH 0/5] Introduce devfs_append_partition and a few users Uwe Kleine-König
2014-02-18 10:36 ` [PATCH 1/5] devfs-core: introduce devfs_append_partition Uwe Kleine-König
2014-02-18 10:36 ` [PATCH 2/5] ARM: sama5d3xek: convert to devfs_append_partition Uwe Kleine-König
@ 2014-02-18 10:36 ` Uwe Kleine-König
2014-02-18 10:36 ` [PATCH 4/5] ARM: freescale-mx35-3-stack: " Uwe Kleine-König
2014-02-18 10:36 ` [PATCH 5/5] ARM: pca100: " Uwe Kleine-König
4 siblings, 0 replies; 7+ messages in thread
From: Uwe Kleine-König @ 2014-02-18 10:36 UTC (permalink / raw)
To: barebox
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
arch/arm/boards/a9m2410/a9m2410.c | 24 +++++++++++++++++-------
1 file changed, 17 insertions(+), 7 deletions(-)
diff --git a/arch/arm/boards/a9m2410/a9m2410.c b/arch/arm/boards/a9m2410/a9m2410.c
index b2b6c87117a3..868a27a5e5bf 100644
--- a/arch/arm/boards/a9m2410/a9m2410.c
+++ b/arch/arm/boards/a9m2410/a9m2410.c
@@ -82,6 +82,22 @@ static int a9m2410_mem_init(void)
}
mem_initcall(a9m2410_mem_init);
+static void a9m2410_nand_partitions(void)
+{
+#ifdef CONFIG_NAND
+ loff_t offset = 0;
+
+ /* ----------- add some vital partitions -------- */
+ devfs_append_partition("nand0", &offset, 0x40000,
+ DEVFS_PARTITION_FIXED, "self_raw");
+ dev_add_bb_dev("self_raw", "self0");
+
+ devfs_append_partition("nand0", &offset, 0x20000,
+ DEVFS_PARTITION_FIXED, "env_raw");
+ dev_add_bb_dev("env_raw", "env0");
+#endif
+}
+
static int a9m2410_devices_init(void)
{
uint32_t reg;
@@ -116,14 +132,8 @@ static int a9m2410_devices_init(void)
add_generic_device("smc91c111", DEVICE_ID_DYNAMIC, NULL, S3C_CS1_BASE + 0x300,
16, IORESOURCE_MEM, NULL);
-#ifdef CONFIG_NAND
- /* ----------- add some vital partitions -------- */
- devfs_add_partition("nand0", 0x00000, 0x40000, DEVFS_PARTITION_FIXED, "self_raw");
- dev_add_bb_dev("self_raw", "self0");
+ a9m2410_nand_partitions();
- devfs_add_partition("nand0", 0x40000, 0x20000, DEVFS_PARTITION_FIXED, "env_raw");
- dev_add_bb_dev("env_raw", "env0");
-#endif
armlinux_set_architecture(MACH_TYPE_A9M2410);
return 0;
--
1.8.5.3
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 4/5] ARM: freescale-mx35-3-stack: convert to devfs_append_partition
2014-02-18 10:36 [PATCH 0/5] Introduce devfs_append_partition and a few users Uwe Kleine-König
` (2 preceding siblings ...)
2014-02-18 10:36 ` [PATCH 3/5] ARM: a9m2410: " Uwe Kleine-König
@ 2014-02-18 10:36 ` Uwe Kleine-König
2014-02-18 10:36 ` [PATCH 5/5] ARM: pca100: " Uwe Kleine-König
4 siblings, 0 replies; 7+ messages in thread
From: Uwe Kleine-König @ 2014-02-18 10:36 UTC (permalink / raw)
To: barebox
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
arch/arm/boards/freescale-mx35-3-stack/3stack.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/arch/arm/boards/freescale-mx35-3-stack/3stack.c b/arch/arm/boards/freescale-mx35-3-stack/3stack.c
index dbd1c7adcb10..ec4a95a08e50 100644
--- a/arch/arm/boards/freescale-mx35-3-stack/3stack.c
+++ b/arch/arm/boards/freescale-mx35-3-stack/3stack.c
@@ -132,6 +132,7 @@ static void set_board_rev(int rev)
static int f3s_devices_init(void)
{
uint32_t reg;
+ loff_t offset = 0;
/* CS0: Nor Flash */
imx35_setup_weimcs(0, 0x0000cf03, 0x10000d03, 0x00720900);
@@ -151,15 +152,19 @@ static int f3s_devices_init(void)
switch ((reg >> 25) & 0x3) {
case 0x01: /* NAND is the source */
- devfs_add_partition("nand0", 0x00000, 0x40000, DEVFS_PARTITION_FIXED, "self_raw");
+ devfs_append_partition("nand0", &offset, 0x40000,
+ DEVFS_PARTITION_FIXED, "self_raw");
dev_add_bb_dev("self_raw", "self0");
- devfs_add_partition("nand0", 0x40000, 0x80000, DEVFS_PARTITION_FIXED, "env_raw");
+ devfs_append_partition("nand0", &offset, 0x80000,
+ DEVFS_PARTITION_FIXED, "env_raw");
dev_add_bb_dev("env_raw", "env0");
break;
case 0x00: /* NOR is the source */
- devfs_add_partition("nor0", 0x00000, 0x40000, DEVFS_PARTITION_FIXED, "self0");
- devfs_add_partition("nor0", 0x40000, 0x80000, DEVFS_PARTITION_FIXED, "env0");
+ devfs_append_partition("nor0", &offset, 0x40000,
+ DEVFS_PARTITION_FIXED, "self0");
+ devfs_append_partition("nor0", &offset, 0x80000,
+ DEVFS_PARTITION_FIXED, "env0");
protect_file("/dev/env0", 1);
break;
}
--
1.8.5.3
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 5/5] ARM: pca100: convert to devfs_append_partition
2014-02-18 10:36 [PATCH 0/5] Introduce devfs_append_partition and a few users Uwe Kleine-König
` (3 preceding siblings ...)
2014-02-18 10:36 ` [PATCH 4/5] ARM: freescale-mx35-3-stack: " Uwe Kleine-König
@ 2014-02-18 10:36 ` Uwe Kleine-König
4 siblings, 0 replies; 7+ messages in thread
From: Uwe Kleine-König @ 2014-02-18 10:36 UTC (permalink / raw)
To: barebox
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
arch/arm/boards/phycard-i.MX27/pca100.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/arch/arm/boards/phycard-i.MX27/pca100.c b/arch/arm/boards/phycard-i.MX27/pca100.c
index 2ff1b793291c..b211ef563532 100644
--- a/arch/arm/boards/phycard-i.MX27/pca100.c
+++ b/arch/arm/boards/phycard-i.MX27/pca100.c
@@ -179,6 +179,7 @@ static int pca100_devices_init(void)
{
int i;
struct device_d *nand;
+ loff_t offset = 0;
unsigned int mode[] = {
PD0_AIN_FEC_TXD0,
@@ -287,10 +288,10 @@ static int pca100_devices_init(void)
#endif
nand = get_device_by_name("nand0");
- devfs_add_partition("nand0", 0x00000, 0x40000, DEVFS_PARTITION_FIXED, "self_raw");
+ devfs_append_partition("nand0", &offset, 0x40000, DEVFS_PARTITION_FIXED, "self_raw");
dev_add_bb_dev("self_raw", "self0");
- devfs_add_partition("nand0", 0x40000, 0x20000, DEVFS_PARTITION_FIXED, "env_raw");
+ devfs_append_partition("nand0", &offset, 0x20000, DEVFS_PARTITION_FIXED, "env_raw");
dev_add_bb_dev("env_raw", "env0");
armlinux_set_architecture(2149);
--
1.8.5.3
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/5] ARM: sama5d3xek: convert to devfs_append_partition
2014-02-18 10:36 ` [PATCH 2/5] ARM: sama5d3xek: convert to devfs_append_partition Uwe Kleine-König
@ 2014-02-18 10:43 ` Jean-Christophe PLAGNIOL-VILLARD
0 siblings, 0 replies; 7+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2014-02-18 10:43 UTC (permalink / raw)
To: Uwe Kleine-K??nig; +Cc: barebox
On 11:36 Tue 18 Feb , Uwe Kleine-K??nig wrote:
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
I like it and not
can we simply use an struct now
like in linux
> ---
> arch/arm/boards/sama5d3xek/init.c | 18 ++++++++++++++----
> 1 file changed, 14 insertions(+), 4 deletions(-)
>
> diff --git a/arch/arm/boards/sama5d3xek/init.c b/arch/arm/boards/sama5d3xek/init.c
> index 4f866aa6f85d..ba5f90c7063c 100644
> --- a/arch/arm/boards/sama5d3xek/init.c
> +++ b/arch/arm/boards/sama5d3xek/init.c
> @@ -402,6 +402,8 @@ static void ek_add_device_hdmi(void)
>
> static int at91sama5d3xek_devices_init(void)
> {
> + loff_t offset = 0x0;
> +
> ek_add_device_w1();
> ek_add_device_hdmi();
> ek_add_device_nand();
> @@ -411,13 +413,21 @@ static int at91sama5d3xek_devices_init(void)
> ek_add_device_mci();
> ek_add_device_lcdc();
>
> - devfs_add_partition("nand0", 0x00000, SZ_256K, DEVFS_PARTITION_FIXED, "at91bootstrap_raw");
> + devfs_append_partition("nand0", &offset, SZ_256K,
> + DEVFS_PARTITION_FIXED, "at91bootstrap_raw");
> dev_add_bb_dev("at91bootstrap_raw", "at91bootstrap");
> - devfs_add_partition("nand0", SZ_256K, SZ_256K + SZ_128K, DEVFS_PARTITION_FIXED, "self_raw");
> + devfs_append_partition("nand0", &offset, SZ_256K + SZ_128K,
> + DEVFS_PARTITION_FIXED, "self_raw");
> dev_add_bb_dev("self_raw", "self0");
> - devfs_add_partition("nand0", SZ_512K + SZ_256K, SZ_256K, DEVFS_PARTITION_FIXED, "env_raw");
> +
> + /* there is a hole in the partition layout of 128K */
> + offset = SZ_512K + SZ_256K;
> +
> + devfs_append_partition("nand0", &offset, SZ_256K,
> + DEVFS_PARTITION_FIXED, "env_raw");
> dev_add_bb_dev("env_raw", "env0");
> - devfs_add_partition("nand0", SZ_1M, SZ_256K, DEVFS_PARTITION_FIXED, "env_raw1");
> + devfs_append_partition("nand0", &offset, SZ_256K,
> + DEVFS_PARTITION_FIXED, "env_raw1");
> dev_add_bb_dev("env_raw1", "env1");
>
> return 0;
> --
> 1.8.5.3
>
>
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2014-02-18 10:53 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-18 10:36 [PATCH 0/5] Introduce devfs_append_partition and a few users Uwe Kleine-König
2014-02-18 10:36 ` [PATCH 1/5] devfs-core: introduce devfs_append_partition Uwe Kleine-König
2014-02-18 10:36 ` [PATCH 2/5] ARM: sama5d3xek: convert to devfs_append_partition Uwe Kleine-König
2014-02-18 10:43 ` Jean-Christophe PLAGNIOL-VILLARD
2014-02-18 10:36 ` [PATCH 3/5] ARM: a9m2410: " Uwe Kleine-König
2014-02-18 10:36 ` [PATCH 4/5] ARM: freescale-mx35-3-stack: " Uwe Kleine-König
2014-02-18 10:36 ` [PATCH 5/5] ARM: pca100: " Uwe Kleine-König
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox