mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] devfs-core: introduce devfs_append_partition
@ 2013-06-18 12:50 Jan Luebbe
  2013-06-19  5:38 ` Sascha Hauer
  0 siblings, 1 reply; 4+ messages in thread
From: Jan Luebbe @ 2013-06-18 12:50 UTC (permalink / raw)
  To: barebox

This simplifies board code for partition setup by keeping track of the
offset.

Signed-off-by: Jan Luebbe <jlu@pengutronix.de>
---
 fs/devfs-core.c  | 9 +++++++++
 include/driver.h | 2 ++
 2 files changed, 11 insertions(+)

diff --git a/fs/devfs-core.c b/fs/devfs-core.c
index 262e0a2..f7d79ff 100644
--- a/fs/devfs-core.c
+++ b/fs/devfs-core.c
@@ -267,6 +267,15 @@ int devfs_add_partition(const char *devname, loff_t offset, loff_t size,
 	return 0;
 }
 
+int devfs_append_partition(const char *devname, loff_t *offset, loff_t size,
+		int flags, const char *name)
+{
+	int 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 716f792..3f4f7b9 100644
--- a/include/driver.h
+++ b/include/driver.h
@@ -463,6 +463,8 @@ int cdev_erase(struct cdev *cdev, size_t count, loff_t offset);
 
 int devfs_add_partition(const char *devname, loff_t offset, loff_t size,
 		int flags, const char *name);
+int 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.3.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH] devfs-core: introduce devfs_append_partition
  2013-06-18 12:50 [PATCH] devfs-core: introduce devfs_append_partition Jan Luebbe
@ 2013-06-19  5:38 ` Sascha Hauer
  2013-06-19  6:03   ` Re[2]: " Alexander Shiyan
  0 siblings, 1 reply; 4+ messages in thread
From: Sascha Hauer @ 2013-06-19  5:38 UTC (permalink / raw)
  To: Jan Luebbe; +Cc: barebox

On Tue, Jun 18, 2013 at 02:50:50PM +0200, Jan Luebbe wrote:
> This simplifies board code for partition setup by keeping track of the
> offset.
> 
> Signed-off-by: Jan Luebbe <jlu@pengutronix.de>

Good idea. There seem to be some bugs in this area. I'm fine with the
patch when some users are converted to this.

Sascha

> ---
>  fs/devfs-core.c  | 9 +++++++++
>  include/driver.h | 2 ++
>  2 files changed, 11 insertions(+)
> 
> diff --git a/fs/devfs-core.c b/fs/devfs-core.c
> index 262e0a2..f7d79ff 100644
> --- a/fs/devfs-core.c
> +++ b/fs/devfs-core.c
> @@ -267,6 +267,15 @@ int devfs_add_partition(const char *devname, loff_t offset, loff_t size,
>  	return 0;
>  }
>  
> +int devfs_append_partition(const char *devname, loff_t *offset, loff_t size,
> +		int flags, const char *name)
> +{
> +	int 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 716f792..3f4f7b9 100644
> --- a/include/driver.h
> +++ b/include/driver.h
> @@ -463,6 +463,8 @@ int cdev_erase(struct cdev *cdev, size_t count, loff_t offset);
>  
>  int devfs_add_partition(const char *devname, loff_t offset, loff_t size,
>  		int flags, const char *name);
> +int 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.3.1
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re[2]: [PATCH] devfs-core: introduce devfs_append_partition
  2013-06-19  5:38 ` Sascha Hauer
@ 2013-06-19  6:03   ` Alexander Shiyan
  2013-06-19  6:32     ` Jan Lübbe
  0 siblings, 1 reply; 4+ messages in thread
From: Alexander Shiyan @ 2013-06-19  6:03 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

> On Tue, Jun 18, 2013 at 02:50:50PM +0200, Jan Luebbe wrote:
> > This simplifies board code for partition setup by keeping track of the
> > offset.
> > 
> > Signed-off-by: Jan Luebbe <jlu@pengutronix.de>
> 
> Good idea. There seem to be some bugs in this area. I'm fine with the
> patch when some users are converted to this.

But lets make static variable "offset", setup it in devfs_add_partition and
just add "size" in the devfs_append_partition.
Otherwise I do not see any difference between "add" and "append".

> > ---
> >  fs/devfs-core.c  | 9 +++++++++
> >  include/driver.h | 2 ++
> >  2 files changed, 11 insertions(+)
> > 
> > diff --git a/fs/devfs-core.c b/fs/devfs-core.c
> > index 262e0a2..f7d79ff 100644
> > --- a/fs/devfs-core.c
> > +++ b/fs/devfs-core.c
> > @@ -267,6 +267,15 @@ int devfs_add_partition(const char *devname, loff_t offset, loff_t size,
> >  	return 0;
> >  }
> >  
> > +int devfs_append_partition(const char *devname, loff_t *offset, loff_t size,
> > +		int flags, const char *name)
> > +{
> > +	int 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 716f792..3f4f7b9 100644
> > --- a/include/driver.h
> > +++ b/include/driver.h
> > @@ -463,6 +463,8 @@ int cdev_erase(struct cdev *cdev, size_t count, loff_t offset);
> >  
> >  int devfs_add_partition(const char *devname, loff_t offset, loff_t size,
> >  		int flags, const char *name);
> > +int 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) \

---
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: Re[2]: [PATCH] devfs-core: introduce devfs_append_partition
  2013-06-19  6:03   ` Re[2]: " Alexander Shiyan
@ 2013-06-19  6:32     ` Jan Lübbe
  0 siblings, 0 replies; 4+ messages in thread
From: Jan Lübbe @ 2013-06-19  6:32 UTC (permalink / raw)
  To: Alexander Shiyan; +Cc: barebox

On Wed, 2013-06-19 at 10:03 +0400, Alexander Shiyan wrote:
> > On Tue, Jun 18, 2013 at 02:50:50PM +0200, Jan Luebbe wrote:
> > > This simplifies board code for partition setup by keeping track of the
> > > offset.
> > > 
> > > Signed-off-by: Jan Luebbe <jlu@pengutronix.de>
> > 
> > Good idea. There seem to be some bugs in this area. I'm fine with the
> > patch when some users are converted to this.
> 
> But lets make static variable "offset", setup it in devfs_add_partition and
> just add "size" in the devfs_append_partition.
> Otherwise I do not see any difference between "add" and "append".

I'd prefer to have the state where it's obvious to the caller and not in
a static variable somewhere else. :)

Regards,
Jan
-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

end of thread, other threads:[~2013-06-19  6:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-18 12:50 [PATCH] devfs-core: introduce devfs_append_partition Jan Luebbe
2013-06-19  5:38 ` Sascha Hauer
2013-06-19  6:03   ` Re[2]: " Alexander Shiyan
2013-06-19  6:32     ` Jan Lübbe

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