diff mbox

[1/2] ppc/85xx: create a platform node for PCI EDAC device

Message ID 1307017502-3965-1-git-send-email-dbaryshkov@gmail.com (mailing list archive)
State Superseded
Headers show

Commit Message

Dmitry Baryshkov June 2, 2011, 12:25 p.m. UTC
As a device for pci node isn't created, create a special platform_device
for PCI EDAC device on MPC85xx.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
 arch/powerpc/sysdev/fsl_pci.c |   33 +++++++++++++++++++++++++++++++++
 1 files changed, 33 insertions(+), 0 deletions(-)

Comments

Anton Vorontsov June 2, 2011, 3:14 p.m. UTC | #1
On Thu, Jun 02, 2011 at 04:25:02PM +0400, Dmitry Eremin-Solenikov wrote:
> As a device for pci node isn't created, create a special platform_device
> for PCI EDAC device on MPC85xx.
> 
> Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
> ---
>  arch/powerpc/sysdev/fsl_pci.c |   33 +++++++++++++++++++++++++++++++++
>  1 files changed, 33 insertions(+), 0 deletions(-)
> 
> diff --git a/arch/powerpc/sysdev/fsl_pci.c b/arch/powerpc/sysdev/fsl_pci.c
> index 68ca929..0e37259 100644
> --- a/arch/powerpc/sysdev/fsl_pci.c
> +++ b/arch/powerpc/sysdev/fsl_pci.c
> @@ -381,6 +381,39 @@ int __init fsl_add_bridge(struct device_node *dev, int is_primary)
>  	return 0;
>  }
>  
> +int __init fsl_add_pci_err(void)

static :-)

> +{
> +	struct device_node *np;
> +
> +	for_each_node_by_type(np, "pci") {
> +		/* Only PCI, not PCI Express! */
> +		if (of_device_is_compatible(np, "fsl,mpc8540-pci")) {
> +			struct resource r[2];

How about '= {};' initializer instead of the '= NULL's down below?

> +
> +			r[0].parent = NULL;
> +			r[1].parent = NULL;

Thanks,
David Laight June 2, 2011, 3:15 p.m. UTC | #2
> > +int __init fsl_add_pci_err(void)
> 
> static :-)

and why __ ?
aren't such names reserved in the C language for some purpose.

	David
Scott Wood June 2, 2011, 5:48 p.m. UTC | #3
On Thu, 2 Jun 2011 16:25:02 +0400
Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> wrote:

> As a device for pci node isn't created, create a special platform_device
> for PCI EDAC device on MPC85xx.
> 
> Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
> ---
>  arch/powerpc/sysdev/fsl_pci.c |   33 +++++++++++++++++++++++++++++++++
>  1 files changed, 33 insertions(+), 0 deletions(-)
> 
> diff --git a/arch/powerpc/sysdev/fsl_pci.c b/arch/powerpc/sysdev/fsl_pci.c
> index 68ca929..0e37259 100644
> --- a/arch/powerpc/sysdev/fsl_pci.c
> +++ b/arch/powerpc/sysdev/fsl_pci.c
> @@ -381,6 +381,39 @@ int __init fsl_add_bridge(struct device_node *dev, int is_primary)
>  	return 0;
>  }
>  
> +int __init fsl_add_pci_err(void)
> +{
> +	struct device_node *np;
> +
> +	for_each_node_by_type(np, "pci") {
> +		/* Only PCI, not PCI Express! */
> +		if (of_device_is_compatible(np, "fsl,mpc8540-pci")) {
> +			struct resource r[2];
> +
> +			r[0].parent = NULL;
> +			r[1].parent = NULL;
> +
> +			if (of_address_to_resource(np, 0, &r[0])) {
> +				printk(KERN_WARNING
> +						"Can't get register base for PCI EDAC!\n");
> +				continue;
> +			}
> +			r[0].start += 0xe00;
> +
> +			if (of_irq_to_resource(np, 0, &r[1]) == NO_IRQ) {
> +				printk(KERN_WARNING
> +						"Can't get irq for PCI EDAC!\n");
> +				continue;
> +			}
> +			platform_device_register_simple("mpc85xx_pci_err", -1,
> +					r, ARRAY_SIZE(r));
> +		}
> +	}

This use of device_type is deprecated -- use for_each_compatible_node().

-Scott
diff mbox

Patch

diff --git a/arch/powerpc/sysdev/fsl_pci.c b/arch/powerpc/sysdev/fsl_pci.c
index 68ca929..0e37259 100644
--- a/arch/powerpc/sysdev/fsl_pci.c
+++ b/arch/powerpc/sysdev/fsl_pci.c
@@ -381,6 +381,39 @@  int __init fsl_add_bridge(struct device_node *dev, int is_primary)
 	return 0;
 }
 
+int __init fsl_add_pci_err(void)
+{
+	struct device_node *np;
+
+	for_each_node_by_type(np, "pci") {
+		/* Only PCI, not PCI Express! */
+		if (of_device_is_compatible(np, "fsl,mpc8540-pci")) {
+			struct resource r[2];
+
+			r[0].parent = NULL;
+			r[1].parent = NULL;
+
+			if (of_address_to_resource(np, 0, &r[0])) {
+				printk(KERN_WARNING
+						"Can't get register base for PCI EDAC!\n");
+				continue;
+			}
+			r[0].start += 0xe00;
+
+			if (of_irq_to_resource(np, 0, &r[1]) == NO_IRQ) {
+				printk(KERN_WARNING
+						"Can't get irq for PCI EDAC!\n");
+				continue;
+			}
+			platform_device_register_simple("mpc85xx_pci_err", -1,
+					r, ARRAY_SIZE(r));
+		}
+	}
+
+	return 0;
+}
+device_initcall(fsl_add_pci_err);
+
 DECLARE_PCI_FIXUP_HEADER(0x1957, PCI_DEVICE_ID_MPC8548E, quirk_fsl_pcie_header);
 DECLARE_PCI_FIXUP_HEADER(0x1957, PCI_DEVICE_ID_MPC8548, quirk_fsl_pcie_header);
 DECLARE_PCI_FIXUP_HEADER(0x1957, PCI_DEVICE_ID_MPC8543E, quirk_fsl_pcie_header);