[PATCH] of/flattree: Add of_flat_dt_match() helper function

2010-12-31 Thread Grant Likely
This patch adds of_flat_dt_match() which tests a node for
compatibility with a list of values and converts the relevant powerpc
platform code to use it.  This approach simplifies the board support
code a bit.

Signed-off-by: Grant Likely 
---
 arch/powerpc/platforms/40x/ppc40x_simple.c|   13 +++---
 arch/powerpc/platforms/512x/mpc5121_generic.c |   13 +-
 arch/powerpc/platforms/52xx/lite5200.c|   16 +---
 arch/powerpc/platforms/52xx/media5200.c   |   13 +-
 arch/powerpc/platforms/52xx/mpc5200_simple.c  |   13 +-
 arch/powerpc/platforms/83xx/mpc830x_rdb.c |   13 ++
 arch/powerpc/platforms/83xx/mpc831x_rdb.c |   11 +---
 arch/powerpc/platforms/83xx/mpc837x_rdb.c |   15 +++
 arch/powerpc/platforms/85xx/tqm85xx.c |   20 +++
 drivers/of/fdt.c  |   34 -
 include/linux/of_fdt.h|1 +
 11 files changed, 84 insertions(+), 78 deletions(-)

diff --git a/arch/powerpc/platforms/40x/ppc40x_simple.c 
b/arch/powerpc/platforms/40x/ppc40x_simple.c
index 546bbc2..2521d93 100644
--- a/arch/powerpc/platforms/40x/ppc40x_simple.c
+++ b/arch/powerpc/platforms/40x/ppc40x_simple.c
@@ -50,7 +50,7 @@ machine_device_initcall(ppc40x_simple, ppc40x_device_probe);
  * Again, if your board needs to do things differently then create a
  * board.c file for it rather than adding it to this list.
  */
-static char *board[] __initdata = {
+static const char *board[] __initdata = {
"amcc,acadia",
"amcc,haleakala",
"amcc,kilauea",
@@ -60,14 +60,9 @@ static char *board[] __initdata = {
 
 static int __init ppc40x_probe(void)
 {
-   unsigned long root = of_get_flat_dt_root();
-   int i = 0;
-
-   for (i = 0; i < ARRAY_SIZE(board); i++) {
-   if (of_flat_dt_is_compatible(root, board[i])) {
-   ppc_pci_set_flags(PPC_PCI_REASSIGN_ALL_RSRC);
-   return 1;
-   }
+   if (of_flat_dt_match(of_get_flat_dt_root(), board)) {
+   ppc_pci_set_flags(PPC_PCI_REASSIGN_ALL_RSRC);
+   return 1;
}
 
return 0;
diff --git a/arch/powerpc/platforms/512x/mpc5121_generic.c 
b/arch/powerpc/platforms/512x/mpc5121_generic.c
index e487eb0..926731f 100644
--- a/arch/powerpc/platforms/512x/mpc5121_generic.c
+++ b/arch/powerpc/platforms/512x/mpc5121_generic.c
@@ -26,7 +26,7 @@
 /*
  * list of supported boards
  */
-static char *board[] __initdata = {
+static const char *board[] __initdata = {
"prt,prtlvt",
NULL
 };
@@ -36,16 +36,7 @@ static char *board[] __initdata = {
  */
 static int __init mpc5121_generic_probe(void)
 {
-   unsigned long node = of_get_flat_dt_root();
-   int i = 0;
-
-   while (board[i]) {
-   if (of_flat_dt_is_compatible(node, board[i]))
-   break;
-   i++;
-   }
-
-   return board[i] != NULL;
+   return of_flat_dt_match(of_get_flat_dt_root(), board);
 }
 
 define_machine(mpc5121_generic) {
diff --git a/arch/powerpc/platforms/52xx/lite5200.c 
b/arch/powerpc/platforms/52xx/lite5200.c
index de55bc0..01ffa64 100644
--- a/arch/powerpc/platforms/52xx/lite5200.c
+++ b/arch/powerpc/platforms/52xx/lite5200.c
@@ -172,20 +172,18 @@ static void __init lite5200_setup_arch(void)
mpc52xx_setup_pci();
 }
 
+static const char *board[] __initdata = {
+   "fsl,lite5200",
+   "fsl,lite5200b",
+   NULL,
+};
+
 /*
  * Called very early, MMU is off, device-tree isn't unflattened
  */
 static int __init lite5200_probe(void)
 {
-   unsigned long node = of_get_flat_dt_root();
-   const char *model = of_get_flat_dt_prop(node, "model", NULL);
-
-   if (!of_flat_dt_is_compatible(node, "fsl,lite5200") &&
-   !of_flat_dt_is_compatible(node, "fsl,lite5200b"))
-   return 0;
-   pr_debug("%s board found\n", model ? model : "unknown");
-
-   return 1;
+   return of_flat_dt_match(of_get_flat_dt_root(), board);
 }
 
 define_machine(lite5200) {
diff --git a/arch/powerpc/platforms/52xx/media5200.c 
b/arch/powerpc/platforms/52xx/media5200.c
index 0bac3a3..2c7780c 100644
--- a/arch/powerpc/platforms/52xx/media5200.c
+++ b/arch/powerpc/platforms/52xx/media5200.c
@@ -239,7 +239,7 @@ static void __init media5200_setup_arch(void)
 }
 
 /* list of the supported boards */
-static char *board[] __initdata = {
+static const char *board[] __initdata = {
"fsl,media5200",
NULL
 };
@@ -249,16 +249,7 @@ static char *board[] __initdata = {
  */
 static int __init media5200_probe(void)
 {
-   unsigned long node = of_get_flat_dt_root();
-   int i = 0;
-
-   while (board[i]) {
-   if (of_flat_dt_is_compatible(node, board[i]))
-   break;
-   i++;
-   }
-
-   return (board[i] != NULL);
+   return of_flat_dt_match(of_get_flat_dt_root(), board);
 }
 
 define_machine(medi

[PATCH] macintosh: wrong test in fan_{read,write}_reg()

2010-12-31 Thread roel kluin
Fix error test in fan_{read,write}_reg()

Signed-off-by: Roel Kluin 
---
 drivers/macintosh/therm_pm72.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

ENODEV and EIO are positive (22 and 8), so the tests did not work.

diff --git a/drivers/macintosh/therm_pm72.c b/drivers/macintosh/therm_pm72.c
index 4454927..6256a08 100644
--- a/drivers/macintosh/therm_pm72.c
+++ b/drivers/macintosh/therm_pm72.c
@@ -443,7 +443,7 @@ static int fan_read_reg(int reg, unsigned char *buf, int nb)
tries = 0;
for (;;) {
nr = i2c_master_recv(fcu, buf, nb);
-   if (nr > 0 || (nr < 0 && nr != ENODEV) || tries >= 100)
+   if (nr > 0 || (nr < 0 && nr != -ENODEV) || tries >= 100)
break;
msleep(10);
++tries;
@@ -464,7 +464,7 @@ static int fan_write_reg(int reg, const unsigned char *ptr, 
int nb)
tries = 0;
for (;;) {
nw = i2c_master_send(fcu, buf, nb);
-   if (nw > 0 || (nw < 0 && nw != EIO) || tries >= 100)
+   if (nw > 0 || (nw < 0 && nw != -EIO) || tries >= 100)
break;
msleep(10);
++tries;
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH] of/flattree: Add of_flat_dt_match() helper function

2010-12-31 Thread Stephen Neuendorffer
On Fri, Dec 31, 2010 at 1:15 AM, Grant Likely wrote:

> This patch adds of_flat_dt_match() which tests a node for
> compatibility with a list of values and converts the relevant powerpc
> platform code to use it.  This approach simplifies the board support
> code a bit.
>
> Signed-off-by: Grant Likely 
>

reviewed-by: Stephen Neuendorffer 

minor nits below.


> ---
>  arch/powerpc/platforms/40x/ppc40x_simple.c|   13 +++---
>  arch/powerpc/platforms/512x/mpc5121_generic.c |   13 +-
>  arch/powerpc/platforms/52xx/lite5200.c|   16 +---
>  arch/powerpc/platforms/52xx/media5200.c   |   13 +-
>  arch/powerpc/platforms/52xx/mpc5200_simple.c  |   13 +-
>  arch/powerpc/platforms/83xx/mpc830x_rdb.c |   13 ++
>  arch/powerpc/platforms/83xx/mpc831x_rdb.c |   11 +---
>  arch/powerpc/platforms/83xx/mpc837x_rdb.c |   15 +++
>  arch/powerpc/platforms/85xx/tqm85xx.c |   20 +++
>  drivers/of/fdt.c  |   34
> -
>  include/linux/of_fdt.h|1 +
>  11 files changed, 84 insertions(+), 78 deletions(-)
>
> diff --git a/arch/powerpc/platforms/40x/ppc40x_simple.c
> b/arch/powerpc/platforms/40x/ppc40x_simple.c
> index 546bbc2..2521d93 100644
> --- a/arch/powerpc/platforms/40x/ppc40x_simple.c
> +++ b/arch/powerpc/platforms/40x/ppc40x_simple.c
> @@ -50,7 +50,7 @@ machine_device_initcall(ppc40x_simple,
> ppc40x_device_probe);
>  * Again, if your board needs to do things differently then create a
>  * board.c file for it rather than adding it to this list.
>  */
> -static char *board[] __initdata = {
> +static const char *board[] __initdata = {
>"amcc,acadia",
>"amcc,haleakala",
>"amcc,kilauea",
> @@ -60,14 +60,9 @@ static char *board[] __initdata = {
>
>  static int __init ppc40x_probe(void)
>  {
> -   unsigned long root = of_get_flat_dt_root();
> -   int i = 0;
> -
> -   for (i = 0; i < ARRAY_SIZE(board); i++) {
> -   if (of_flat_dt_is_compatible(root, board[i])) {
> -   ppc_pci_set_flags(PPC_PCI_REASSIGN_ALL_RSRC);
> -   return 1;
> -   }
> +   if (of_flat_dt_match(of_get_flat_dt_root(), board)) {
> +   ppc_pci_set_flags(PPC_PCI_REASSIGN_ALL_RSRC);
> +   return 1;
>}
>
>return 0;
> diff --git a/arch/powerpc/platforms/512x/mpc5121_generic.c
> b/arch/powerpc/platforms/512x/mpc5121_generic.c
> index e487eb0..926731f 100644
> --- a/arch/powerpc/platforms/512x/mpc5121_generic.c
> +++ b/arch/powerpc/platforms/512x/mpc5121_generic.c
> @@ -26,7 +26,7 @@
>  /*
>  * list of supported boards
>  */
> -static char *board[] __initdata = {
> +static const char *board[] __initdata = {
>"prt,prtlvt",
>NULL
>  };
> @@ -36,16 +36,7 @@ static char *board[] __initdata = {
>  */
>  static int __init mpc5121_generic_probe(void)
>  {
> -   unsigned long node = of_get_flat_dt_root();
> -   int i = 0;
> -
> -   while (board[i]) {
> -   if (of_flat_dt_is_compatible(node, board[i]))
> -   break;
> -   i++;
> -   }
> -
> -   return board[i] != NULL;
> +   return of_flat_dt_match(of_get_flat_dt_root(), board);
>  }
>
>  define_machine(mpc5121_generic) {
> diff --git a/arch/powerpc/platforms/52xx/lite5200.c
> b/arch/powerpc/platforms/52xx/lite5200.c
> index de55bc0..01ffa64 100644
> --- a/arch/powerpc/platforms/52xx/lite5200.c
> +++ b/arch/powerpc/platforms/52xx/lite5200.c
> @@ -172,20 +172,18 @@ static void __init lite5200_setup_arch(void)
>mpc52xx_setup_pci();
>  }
>
> +static const char *board[] __initdata = {
> +   "fsl,lite5200",
> +   "fsl,lite5200b",
> +   NULL,
> +};
> +
>  /*
>  * Called very early, MMU is off, device-tree isn't unflattened
>  */
>  static int __init lite5200_probe(void)
>  {
> -   unsigned long node = of_get_flat_dt_root();
> -   const char *model = of_get_flat_dt_prop(node, "model", NULL);
> -
> -   if (!of_flat_dt_is_compatible(node, "fsl,lite5200") &&
> -   !of_flat_dt_is_compatible(node, "fsl,lite5200b"))
> -   return 0;
> -   pr_debug("%s board found\n", model ? model : "unknown");
> -
> -   return 1;
> +   return of_flat_dt_match(of_get_flat_dt_root(), board);
>  }
>
>  define_machine(lite5200) {
> diff --git a/arch/powerpc/platforms/52xx/media5200.c
> b/arch/powerpc/platforms/52xx/media5200.c
> index 0bac3a3..2c7780c 100644
> --- a/arch/powerpc/platforms/52xx/media5200.c
> +++ b/arch/powerpc/platforms/52xx/media5200.c
> @@ -239,7 +239,7 @@ static void __init media5200_setup_arch(void)
>  }
>
>  /* list of the supported boards */
> -static char *board[] __initdata = {
> +static const char *board[] __initdata = {
>"fsl,media5200",
>NULL
>  };
> @@ -249,16 +249,7 @@ static char *board[] __initdata = {
>  */
>  static int __init media5200_probe(void)
>  {

Re: PMU_IOC_SLEEP failed

2010-12-31 Thread Benjamin Herrenschmidt
On Wed, 2010-12-29 at 00:35 +0100, jjDaNiMoTh wrote:
> >> (dmesg..)
> >> [...]
> >> radeonfb_pci_register BEGIN
> >> radeonfb :00:10.0: BAR 0: can't reserve [mem
> 0xb800-0xbfff pref]
> >> radeonfb (:00:10.0): cannot request region 0.
> >> radeonfb: probe of :00:10.0 failed with error -16
> >
> > That looks bad indeed. Send me the complete dmesg, a snapshot of the
> > device-tree (tar -c /proc/device-tree >foo.tar) and the output
> > of /proc/iomem please.
> 
> [1] http://nat.vacau.com/linux/iomem.txt.gz
> [2] http://nat.vacau.com/linux/dmesg_37-rc.txt.gz
> [3] http://nat.vacau.com/linux/device_tree.tar 

Are you trying to use radeonfb as a module ? The dmesg seems to indicate
that you have offb taking control of the framebuffer, preventing
radeonfb from loading.

There's no offb->radeonfb handover (the handover mechanism is new and
only used by KMS for now). On those machines, radeonfb should be
built-in.

Cheers,
Ben.


___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH] of/flattree: Add of_flat_dt_match() helper function

2010-12-31 Thread Grant Likely
On Fri, Dec 31, 2010 at 07:59:02AM -0800, Stephen Neuendorffer wrote:
> On Fri, Dec 31, 2010 at 1:15 AM, Grant Likely 
> wrote:
> 
> > This patch adds of_flat_dt_match() which tests a node for
> > compatibility with a list of values and converts the relevant powerpc
> > platform code to use it.  This approach simplifies the board support
> > code a bit.
> >
> > Signed-off-by: Grant Likely 
> >
> 
> reviewed-by: Stephen Neuendorffer 
> 
> minor nits below.

Fixed, thanks.

g.

> 
> 
> > ---
> >  arch/powerpc/platforms/40x/ppc40x_simple.c|   13 +++---
> >  arch/powerpc/platforms/512x/mpc5121_generic.c |   13 +-
> >  arch/powerpc/platforms/52xx/lite5200.c|   16 +---
> >  arch/powerpc/platforms/52xx/media5200.c   |   13 +-
> >  arch/powerpc/platforms/52xx/mpc5200_simple.c  |   13 +-
> >  arch/powerpc/platforms/83xx/mpc830x_rdb.c |   13 ++
> >  arch/powerpc/platforms/83xx/mpc831x_rdb.c |   11 +---
> >  arch/powerpc/platforms/83xx/mpc837x_rdb.c |   15 +++
> >  arch/powerpc/platforms/85xx/tqm85xx.c |   20 +++
> >  drivers/of/fdt.c  |   34
> > -
> >  include/linux/of_fdt.h|1 +
> >  11 files changed, 84 insertions(+), 78 deletions(-)
> >
> > diff --git a/arch/powerpc/platforms/40x/ppc40x_simple.c
> > b/arch/powerpc/platforms/40x/ppc40x_simple.c
> > index 546bbc2..2521d93 100644
> > --- a/arch/powerpc/platforms/40x/ppc40x_simple.c
> > +++ b/arch/powerpc/platforms/40x/ppc40x_simple.c
> > @@ -50,7 +50,7 @@ machine_device_initcall(ppc40x_simple,
> > ppc40x_device_probe);
> >  * Again, if your board needs to do things differently then create a
> >  * board.c file for it rather than adding it to this list.
> >  */
> > -static char *board[] __initdata = {
> > +static const char *board[] __initdata = {
> >"amcc,acadia",
> >"amcc,haleakala",
> >"amcc,kilauea",
> > @@ -60,14 +60,9 @@ static char *board[] __initdata = {
> >
> >  static int __init ppc40x_probe(void)
> >  {
> > -   unsigned long root = of_get_flat_dt_root();
> > -   int i = 0;
> > -
> > -   for (i = 0; i < ARRAY_SIZE(board); i++) {
> > -   if (of_flat_dt_is_compatible(root, board[i])) {
> > -   ppc_pci_set_flags(PPC_PCI_REASSIGN_ALL_RSRC);
> > -   return 1;
> > -   }
> > +   if (of_flat_dt_match(of_get_flat_dt_root(), board)) {
> > +   ppc_pci_set_flags(PPC_PCI_REASSIGN_ALL_RSRC);
> > +   return 1;
> >}
> >
> >return 0;
> > diff --git a/arch/powerpc/platforms/512x/mpc5121_generic.c
> > b/arch/powerpc/platforms/512x/mpc5121_generic.c
> > index e487eb0..926731f 100644
> > --- a/arch/powerpc/platforms/512x/mpc5121_generic.c
> > +++ b/arch/powerpc/platforms/512x/mpc5121_generic.c
> > @@ -26,7 +26,7 @@
> >  /*
> >  * list of supported boards
> >  */
> > -static char *board[] __initdata = {
> > +static const char *board[] __initdata = {
> >"prt,prtlvt",
> >NULL
> >  };
> > @@ -36,16 +36,7 @@ static char *board[] __initdata = {
> >  */
> >  static int __init mpc5121_generic_probe(void)
> >  {
> > -   unsigned long node = of_get_flat_dt_root();
> > -   int i = 0;
> > -
> > -   while (board[i]) {
> > -   if (of_flat_dt_is_compatible(node, board[i]))
> > -   break;
> > -   i++;
> > -   }
> > -
> > -   return board[i] != NULL;
> > +   return of_flat_dt_match(of_get_flat_dt_root(), board);
> >  }
> >
> >  define_machine(mpc5121_generic) {
> > diff --git a/arch/powerpc/platforms/52xx/lite5200.c
> > b/arch/powerpc/platforms/52xx/lite5200.c
> > index de55bc0..01ffa64 100644
> > --- a/arch/powerpc/platforms/52xx/lite5200.c
> > +++ b/arch/powerpc/platforms/52xx/lite5200.c
> > @@ -172,20 +172,18 @@ static void __init lite5200_setup_arch(void)
> >mpc52xx_setup_pci();
> >  }
> >
> > +static const char *board[] __initdata = {
> > +   "fsl,lite5200",
> > +   "fsl,lite5200b",
> > +   NULL,
> > +};
> > +
> >  /*
> >  * Called very early, MMU is off, device-tree isn't unflattened
> >  */
> >  static int __init lite5200_probe(void)
> >  {
> > -   unsigned long node = of_get_flat_dt_root();
> > -   const char *model = of_get_flat_dt_prop(node, "model", NULL);
> > -
> > -   if (!of_flat_dt_is_compatible(node, "fsl,lite5200") &&
> > -   !of_flat_dt_is_compatible(node, "fsl,lite5200b"))
> > -   return 0;
> > -   pr_debug("%s board found\n", model ? model : "unknown");
> > -
> > -   return 1;
> > +   return of_flat_dt_match(of_get_flat_dt_root(), board);
> >  }
> >
> >  define_machine(lite5200) {
> > diff --git a/arch/powerpc/platforms/52xx/media5200.c
> > b/arch/powerpc/platforms/52xx/media5200.c
> > index 0bac3a3..2c7780c 100644
> > --- a/arch/powerpc/platforms/52xx/media5200.c
> > +++ b/arch/powerpc/platforms/52xx/media52