Message ID | 1376687156-6737-2-git-send-email-julien.grall@linaro.org |
---|---|
State | Superseded, archived |
Headers | show |
On 08/16/2013 11:05 PM, Julien Grall wrote: > On some board, there is no alias to the UART. To avoid modification in > the device tree, dt-uart should also search device by path. Funny, it wrote almost the same patch two days ago (including the variable renaming, minus the "/" check). Thanks for saving me the cleanup and send-out ;-) It is really useful for Midway! > To distinguish an alias from a path, dt-uart will check the first character. > If it's a / then it's path, otherwise it's an alias. Is that really needed? In my patch I just try it as an alias first, if there is no match (dev == NULL), I try the full path. Are there any ambiguities expected between an alias and a full path? Regards, Andre. > Signed-off-by: Julien Grall <julien.grall@linaro.org> > --- > xen/drivers/char/dt-uart.c | 16 ++++++++++------ > 1 file changed, 10 insertions(+), 6 deletions(-) > > diff --git a/xen/drivers/char/dt-uart.c b/xen/drivers/char/dt-uart.c > index 93bb0f5..d7204fb 100644 > --- a/xen/drivers/char/dt-uart.c > +++ b/xen/drivers/char/dt-uart.c > @@ -26,9 +26,10 @@ > > /* > * Configure UART port with a string: > - * alias,options > + * path,options > * > - * @alias: alias used in the device tree for the UART > + * @path: full path used in the device tree for the UART. If the path > + * doesn't start with '/', we assuming that it's an alias. > * @options: UART speficic options (see in each UART driver) > */ > static char __initdata opt_dtuart[30] = ""; > @@ -38,7 +39,7 @@ void __init dt_uart_init(void) > { > struct dt_device_node *dev; > int ret; > - const char *devalias = opt_dtuart; > + const char *devpath = opt_dtuart; > char *options; > > if ( !console_has("dtuart") || !strcmp(opt_dtuart, "") ) > @@ -53,12 +54,15 @@ void __init dt_uart_init(void) > else > options = ""; > > - early_printk("Looking for UART console %s\n", devalias); > - dev = dt_find_node_by_alias(devalias); > + early_printk("Looking for UART console %s\n", devpath); > + if ( *devpath == '/' ) > + dev = dt_find_node_by_path(devpath); > + else > + dev = dt_find_node_by_alias(devpath); > > if ( !dev ) > { > - early_printk("Unable to find device \"%s\"\n", devalias); > + early_printk("Unable to find device \"%s\"\n", devpath); > return; > } > >
On 08/16/2013 10:25 PM, Andre Przywara wrote: > On 08/16/2013 11:05 PM, Julien Grall wrote: >> On some board, there is no alias to the UART. To avoid modification in >> the device tree, dt-uart should also search device by path. > > Funny, it wrote almost the same patch two days ago (including the > variable renaming, minus the "/" check). Thanks for saving me the > cleanup and send-out ;-) > It is really useful for Midway! > >> To distinguish an alias from a path, dt-uart will check the first >> character. >> If it's a / then it's path, otherwise it's an alias. > > Is that really needed? In my patch I just try it as an alias first, if > there is no match (dev == NULL), I try the full path. > Are there any ambiguities expected between an alias and a full path? Following the ePAPR documentation (section 2.2.4), the name property can't contain '/' in the name. I choose this solution, because I want to avoid to call the 2 functions if it's possible. It's a waste of time to call both if we know that the path always start with a '/' and alias not. Cheers,
On Mon, 2013-08-19 at 16:09 +0100, Julien Grall wrote: > On 08/16/2013 10:25 PM, Andre Przywara wrote: > > On 08/16/2013 11:05 PM, Julien Grall wrote: > >> On some board, there is no alias to the UART. To avoid modification in > >> the device tree, dt-uart should also search device by path. > > > > Funny, it wrote almost the same patch two days ago (including the > > variable renaming, minus the "/" check). Thanks for saving me the > > cleanup and send-out ;-) > > It is really useful for Midway! > > > >> To distinguish an alias from a path, dt-uart will check the first > >> character. > >> If it's a / then it's path, otherwise it's an alias. > > > > Is that really needed? In my patch I just try it as an alias first, if > > there is no match (dev == NULL), I try the full path. > > Are there any ambiguities expected between an alias and a full path? > > Following the ePAPR documentation (section 2.2.4), the name property > can't contain '/' in the name. > > I choose this solution, because I want to avoid to call the 2 functions > if it's possible. It's a waste of time to call both if we know that the > path always start with a '/' and alias not. This is hardly a hot path. But in any case: Acked-by: Ian Campbell <ian.campbell@citrix.com>
diff --git a/xen/drivers/char/dt-uart.c b/xen/drivers/char/dt-uart.c index 93bb0f5..d7204fb 100644 --- a/xen/drivers/char/dt-uart.c +++ b/xen/drivers/char/dt-uart.c @@ -26,9 +26,10 @@ /* * Configure UART port with a string: - * alias,options + * path,options * - * @alias: alias used in the device tree for the UART + * @path: full path used in the device tree for the UART. If the path + * doesn't start with '/', we assuming that it's an alias. * @options: UART speficic options (see in each UART driver) */ static char __initdata opt_dtuart[30] = ""; @@ -38,7 +39,7 @@ void __init dt_uart_init(void) { struct dt_device_node *dev; int ret; - const char *devalias = opt_dtuart; + const char *devpath = opt_dtuart; char *options; if ( !console_has("dtuart") || !strcmp(opt_dtuart, "") ) @@ -53,12 +54,15 @@ void __init dt_uart_init(void) else options = ""; - early_printk("Looking for UART console %s\n", devalias); - dev = dt_find_node_by_alias(devalias); + early_printk("Looking for UART console %s\n", devpath); + if ( *devpath == '/' ) + dev = dt_find_node_by_path(devpath); + else + dev = dt_find_node_by_alias(devpath); if ( !dev ) { - early_printk("Unable to find device \"%s\"\n", devalias); + early_printk("Unable to find device \"%s\"\n", devpath); return; }
On some board, there is no alias to the UART. To avoid modification in the device tree, dt-uart should also search device by path. To distinguish an alias from a path, dt-uart will check the first character. If it's a / then it's path, otherwise it's an alias. Signed-off-by: Julien Grall <julien.grall@linaro.org> --- xen/drivers/char/dt-uart.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)