mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/2] device: fix dev_name
@ 2010-08-30  4:05 Jean-Christophe PLAGNIOL-VILLARD
  2010-08-30  4:05 ` [PATCH 2/2] stm8815: fix the uart device clock match Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 1 reply; 5+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2010-08-30  4:05 UTC (permalink / raw)
  To: barebox

dev_name is supposed to return the name of the device plus the id

currently we use %s%d format where in the kernel the use %s.%d
we may think to switch to this format for the device name and keeping the %s%d
for the devfs

this will be usefull to not modify the clock device name as example

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 include/driver.h |   12 +++++++-----
 lib/driver.c     |   16 +++++++---------
 2 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/include/driver.h b/include/driver.h
index ee0749d..ab1f850 100644
--- a/include/driver.h
+++ b/include/driver.h
@@ -25,7 +25,8 @@
 
 #include <linux/list.h>
 
-#define MAX_DRIVER_NAME 32
+#define MAX_DRIVER_NAME		32
+#define FORMAT_DRIVER_MANE_ID	"%s%d"
 
 #include <param.h>
 
@@ -176,9 +177,11 @@ int get_free_deviceid(const char *name_template);
 
 char *deviceid_from_spec_str(const char *str, char **endp);
 
+extern const char *dev_id(const struct device_d *dev);
+
 static inline const char *dev_name(const struct device_d *dev)
 {
-	return dev->name;
+	return dev_id(dev);
 }
 
 /* linear list over all available devices
@@ -239,11 +242,10 @@ static inline int dev_close_default(struct device_d *dev, struct filep *f)
 }
 
 /* debugging and troubleshooting/diagnostic helpers. */
-extern const char *dev_id(const struct device_d *dev);
 
 #define dev_printf(dev, format, arg...)	\
-	printf("%s@%s: " format , dev_name(dev) , \
-	       dev_id(dev) , ## arg)
+	printf("%s@%s: " format , dev->name , \
+	       dev_name(dev) , ## arg)
 
 #define dev_emerg(dev, format, arg...)		\
 	dev_printf((dev) , format , ## arg)
diff --git a/lib/driver.c b/lib/driver.c
index b600745..03a2817 100644
--- a/lib/driver.c
+++ b/lib/driver.c
@@ -45,11 +45,9 @@ static LIST_HEAD(active);
 struct device_d *get_device_by_name(const char *name)
 {
 	struct device_d *dev;
-	char devname[MAX_DRIVER_NAME + 3];
 
 	for_each_device(dev) {
-		sprintf(devname, "%s%d", dev->name, dev->id);
-		if(!strcmp(name, devname))
+		if(!strcmp(dev_name(dev), name))
 			return dev;
 	}
 
@@ -62,7 +60,7 @@ int get_free_deviceid(const char *name_template)
 	char name[MAX_DRIVER_NAME + 3];
 
 	while (1) {
-		sprintf(name, "%s%d", name_template, i);
+		sprintf(name, FORMAT_DRIVER_MANE_ID, name_template, i);
 		if (!get_device_by_name(name))
 			return i;
 		i++;
@@ -97,7 +95,7 @@ int register_device(struct device_d *new_device)
 
 	new_device->id = get_free_deviceid(new_device->name);
 
-	debug ("register_device: %s\n",new_device->name);
+	debug ("register_device: %s\n", dev_name(new_device));
 
 	if (!new_device->bus) {
 //		dev_err(new_device, "no bus type associated. Needs fixup\n");
@@ -120,7 +118,7 @@ EXPORT_SYMBOL(register_device);
 
 int unregister_device(struct device_d *old_dev)
 {
-	debug("unregister_device: %s:%s\n",old_dev->name, old_dev->id);
+	debug("unregister_device: %s\n", dev_name(old_dev->name));
 
 	if (!list_empty(&old_dev->children)) {
 		errno = -EBUSY;
@@ -164,7 +162,7 @@ struct driver_d *get_driver_by_name(const char *name)
 
 static void noinfo(struct device_d *dev)
 {
-	printf("no info available for %s\n", dev->name);
+	printf("no info available for %s\n", dev_name(dev));
 }
 
 static void noshortinfo(struct device_d *dev)
@@ -237,7 +235,7 @@ static int do_devinfo_subtree(struct device_d *dev, int depth, char edge)
 	for (i = 0; i < depth; i++)
 		printf("|    ");
 
-	printf("%c----%s%d", edge, dev->name, dev->id);
+	printf("%c----%s", edge, dev_name(dev));
 	if (!list_empty(&dev->cdevs)) {
 		printf(" (");
 		list_for_each_entry(cdev, &dev->cdevs, devices_list) {
@@ -264,7 +262,7 @@ const char *dev_id(const struct device_d *dev)
 {
 	static char buf[sizeof(unsigned long) * 2];
 
-	sprintf(buf, "%s%d", dev->name, dev->id);
+	sprintf(buf, FORMAT_DRIVER_MANE_ID, dev->name, dev->id);
 
 	return buf;
 }
-- 
1.7.1


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

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

* [PATCH 2/2] stm8815: fix the uart device clock match
  2010-08-30  4:05 [PATCH 1/2] device: fix dev_name Jean-Christophe PLAGNIOL-VILLARD
@ 2010-08-30  4:05 ` Jean-Christophe PLAGNIOL-VILLARD
  2010-08-30  7:36   ` Marc Kleine-Budde
  2010-08-30  7:40   ` [PATCH 2/2 v2] " Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 2 replies; 5+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2010-08-30  4:05 UTC (permalink / raw)
  To: barebox

that use the device name + id to found it's clock
to use the right match as we fix the dev_name macro

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 arch/arm/mach-nomadik/8815.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-nomadik/8815.c b/arch/arm/mach-nomadik/8815.c
index 8598f14..f1d5e8c 100644
--- a/arch/arm/mach-nomadik/8815.c
+++ b/arch/arm/mach-nomadik/8815.c
@@ -50,12 +50,14 @@ void st8815_add_device_sdram(u32 size)
 }
 
 static struct device_d uart0_serial_device = {
+	id = 0,
 	.name = "uart-pl011",
 	.map_base = NOMADIK_UART0_BASE,
 	.size = 4096,
 };
 
 static struct device_d uart1_serial_device = {
+	id = 1,
 	.name = "uart-pl011",
 	.map_base = NOMADIK_UART1_BASE,
 	.size = 4096,
@@ -65,12 +67,12 @@ void st8815_register_uart(unsigned id)
 {
 	switch (id) {
 	case 0:
-		nmdk_clk_create(&st8815_clk_48, uart0_serial_device.name);
 		register_device(&uart0_serial_device);
+		nmdk_clk_create(&st8815_clk_48, dev_name(uart0_serial_device));
 		break;
 	case 1:
-		nmdk_clk_create(&st8815_clk_48, uart1_serial_device.name);
 		register_device(&uart1_serial_device);
+		nmdk_clk_create(&st8815_clk_48, dev_name(uart0_serial_device));
 		break;
 	}
 }
-- 
1.7.1


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

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

* Re: [PATCH 2/2] stm8815: fix the uart device clock match
  2010-08-30  4:05 ` [PATCH 2/2] stm8815: fix the uart device clock match Jean-Christophe PLAGNIOL-VILLARD
@ 2010-08-30  7:36   ` Marc Kleine-Budde
  2010-08-30  7:37     ` Jean-Christophe PLAGNIOL-VILLARD
  2010-08-30  7:40   ` [PATCH 2/2 v2] " Jean-Christophe PLAGNIOL-VILLARD
  1 sibling, 1 reply; 5+ messages in thread
From: Marc Kleine-Budde @ 2010-08-30  7:36 UTC (permalink / raw)
  To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox


[-- Attachment #1.1: Type: text/plain, Size: 1754 bytes --]

Jean-Christophe PLAGNIOL-VILLARD wrote:
> that use the device name + id to found it's clock
> to use the right match as we fix the dev_name macro
> 
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> ---
>  arch/arm/mach-nomadik/8815.c |    6 ++++--
>  1 files changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/arm/mach-nomadik/8815.c b/arch/arm/mach-nomadik/8815.c
> index 8598f14..f1d5e8c 100644
> --- a/arch/arm/mach-nomadik/8815.c
> +++ b/arch/arm/mach-nomadik/8815.c
> @@ -50,12 +50,14 @@ void st8815_add_device_sdram(u32 size)
>  }
>  
>  static struct device_d uart0_serial_device = {
> +	id = 0,
        ^

you missed a dot, here.
>  	.name = "uart-pl011",
>  	.map_base = NOMADIK_UART0_BASE,
>  	.size = 4096,
>  };
>  
>  static struct device_d uart1_serial_device = {
> +	id = 1,
dito
>  	.name = "uart-pl011",
>  	.map_base = NOMADIK_UART1_BASE,
>  	.size = 4096,
> @@ -65,12 +67,12 @@ void st8815_register_uart(unsigned id)
>  {
>  	switch (id) {
>  	case 0:
> -		nmdk_clk_create(&st8815_clk_48, uart0_serial_device.name);
>  		register_device(&uart0_serial_device);
> +		nmdk_clk_create(&st8815_clk_48, dev_name(uart0_serial_device));
>  		break;
>  	case 1:
> -		nmdk_clk_create(&st8815_clk_48, uart1_serial_device.name);
>  		register_device(&uart1_serial_device);
> +		nmdk_clk_create(&st8815_clk_48, dev_name(uart0_serial_device));
>  		break;
>  	}
>  }

cheers, Marc


-- 
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |


[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 260 bytes --]

[-- Attachment #2: Type: text/plain, Size: 149 bytes --]

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

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

* Re: [PATCH 2/2] stm8815: fix the uart device clock match
  2010-08-30  7:36   ` Marc Kleine-Budde
@ 2010-08-30  7:37     ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 0 replies; 5+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2010-08-30  7:37 UTC (permalink / raw)
  To: Marc Kleine-Budde; +Cc: barebox

On 09:36 Mon 30 Aug     , Marc Kleine-Budde wrote:
> Jean-Christophe PLAGNIOL-VILLARD wrote:
> > that use the device name + id to found it's clock
> > to use the right match as we fix the dev_name macro
> > 
> > Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> > ---
> >  arch/arm/mach-nomadik/8815.c |    6 ++++--
> >  1 files changed, 4 insertions(+), 2 deletions(-)
> > 
> > diff --git a/arch/arm/mach-nomadik/8815.c b/arch/arm/mach-nomadik/8815.c
> > index 8598f14..f1d5e8c 100644
> > --- a/arch/arm/mach-nomadik/8815.c
> > +++ b/arch/arm/mach-nomadik/8815.c
> > @@ -50,12 +50,14 @@ void st8815_add_device_sdram(u32 size)
> >  }
> >  
> >  static struct device_d uart0_serial_device = {
> > +	id = 0,
>         ^
> 
> you missed a dot, here.
bad paste

Best Regards,
J.

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

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

* [PATCH 2/2 v2] stm8815: fix the uart device clock match
  2010-08-30  4:05 ` [PATCH 2/2] stm8815: fix the uart device clock match Jean-Christophe PLAGNIOL-VILLARD
  2010-08-30  7:36   ` Marc Kleine-Budde
@ 2010-08-30  7:40   ` Jean-Christophe PLAGNIOL-VILLARD
  1 sibling, 0 replies; 5+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2010-08-30  7:40 UTC (permalink / raw)
  To: barebox

that use the device name + id to found it's clock
to use the right match as we fix the dev_name macro

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 arch/arm/mach-nomadik/8815.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-nomadik/8815.c b/arch/arm/mach-nomadik/8815.c
index 8598f14..e79c3a2 100644
--- a/arch/arm/mach-nomadik/8815.c
+++ b/arch/arm/mach-nomadik/8815.c
@@ -50,12 +50,14 @@ void st8815_add_device_sdram(u32 size)
 }
 
 static struct device_d uart0_serial_device = {
+	.id = 0,
 	.name = "uart-pl011",
 	.map_base = NOMADIK_UART0_BASE,
 	.size = 4096,
 };
 
 static struct device_d uart1_serial_device = {
+	.id = 1,
 	.name = "uart-pl011",
 	.map_base = NOMADIK_UART1_BASE,
 	.size = 4096,
@@ -65,12 +67,12 @@ void st8815_register_uart(unsigned id)
 {
 	switch (id) {
 	case 0:
-		nmdk_clk_create(&st8815_clk_48, uart0_serial_device.name);
 		register_device(&uart0_serial_device);
+		nmdk_clk_create(&st8815_clk_48, dev_name(uart0_serial_device));
 		break;
 	case 1:
-		nmdk_clk_create(&st8815_clk_48, uart1_serial_device.name);
 		register_device(&uart1_serial_device);
+		nmdk_clk_create(&st8815_clk_48, dev_name(uart0_serial_device));
 		break;
 	}
 }
-- 
1.7.1


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

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

end of thread, other threads:[~2010-08-30  7:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-30  4:05 [PATCH 1/2] device: fix dev_name Jean-Christophe PLAGNIOL-VILLARD
2010-08-30  4:05 ` [PATCH 2/2] stm8815: fix the uart device clock match Jean-Christophe PLAGNIOL-VILLARD
2010-08-30  7:36   ` Marc Kleine-Budde
2010-08-30  7:37     ` Jean-Christophe PLAGNIOL-VILLARD
2010-08-30  7:40   ` [PATCH 2/2 v2] " Jean-Christophe PLAGNIOL-VILLARD

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