Re: [PATCH v2 04/10] irqdomain: Return errors from irq_create_of_mapping()

2013-10-15 Thread Grant Likely
On Mon, 23 Sep 2013 10:13:38 +0200, Thierry Reding thierry.red...@gmail.com 
wrote:
 On Sun, Sep 22, 2013 at 04:14:43PM -0500, Rob Herring wrote:
  On Wed, Sep 18, 2013 at 8:24 AM, Thierry Reding
  thierry.red...@gmail.com wrote:
   Instead of returning 0 for all errors, allow the precise error code to
   be propagated. This will be used in subsequent patches to allow further
   propagation of error codes.
  
   The interrupt number corresponding to the new mapping is returned in an
   output parameter so that the return value is reserved to signal success
   (== 0) or failure ( 0).
  
   Signed-off-by: Thierry Reding tred...@nvidia.com
  
  One comment below, otherwise:
  
  Acked-by: Rob Herring rob.herr...@calxeda.com
  
   diff --git a/arch/powerpc/kernel/pci-common.c 
   b/arch/powerpc/kernel/pci-common.c
   index 905a24b..ae71b14 100644
   --- a/arch/powerpc/kernel/pci-common.c
   +++ b/arch/powerpc/kernel/pci-common.c
   @@ -230,6 +230,7 @@ static int pci_read_irq_line(struct pci_dev *pci_dev)
{
   struct of_irq oirq;
   unsigned int virq;
   +   int ret;
  
   pr_debug(PCI: Try to map irq for %s...\n, pci_name(pci_dev));
  
   @@ -266,8 +267,10 @@ static int pci_read_irq_line(struct pci_dev *pci_dev)
oirq.size, oirq.specifier[0], oirq.specifier[1],
of_node_full_name(oirq.controller));
  
   -   virq = irq_create_of_mapping(oirq.controller, 
   oirq.specifier,
   -oirq.size);
   +   ret = irq_create_of_mapping(oirq.controller, 
   oirq.specifier,
   +   oirq.size, virq);
   +   if (ret)
   +   virq = NO_IRQ;
   }
   if(virq == NO_IRQ) {
   pr_debug( Failed to map !\n);
  
  Can you get rid of NO_IRQ usage here instead of adding to it.
 
 I was trying to stay consistent with the remainder of the code. PowerPC
 is a pretty heavy user of NO_IRQ. Of all 348 references, more than half
 (182) are in arch/powerpc, so I'd rather like to get a go-ahead from
 Benjamin on this.
 
 That said, perhaps we should just go all the way and get rid of NO_IRQ
 for good. Things could get somewhat messy, though. There are a couple of
 these spread through the code:
 
   #ifndef NO_IRQ
   #define NO_IRQ (-1)
   #endif

And all of them are wrong and need to be removed.  :-)  We're /slowly/
getting rid of the -1 and the usage of NO_IRQ. A global search and
replace of s/NO_IRQ/0/g can be very safely done on arch/powerpc since
powerpc has had NO_IRQ set correctly to '0' for a very long time now.

So, yes, if you're keen to do it I'd love to see a series getting rid of
more NO_IRQ users.

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


Re: [PATCH v2 04/10] irqdomain: Return errors from irq_create_of_mapping()

2013-09-23 Thread Thierry Reding
On Sun, Sep 22, 2013 at 04:14:43PM -0500, Rob Herring wrote:
 On Wed, Sep 18, 2013 at 8:24 AM, Thierry Reding
 thierry.red...@gmail.com wrote:
  Instead of returning 0 for all errors, allow the precise error code to
  be propagated. This will be used in subsequent patches to allow further
  propagation of error codes.
 
  The interrupt number corresponding to the new mapping is returned in an
  output parameter so that the return value is reserved to signal success
  (== 0) or failure ( 0).
 
  Signed-off-by: Thierry Reding tred...@nvidia.com
 
 One comment below, otherwise:
 
 Acked-by: Rob Herring rob.herr...@calxeda.com
 
  diff --git a/arch/powerpc/kernel/pci-common.c 
  b/arch/powerpc/kernel/pci-common.c
  index 905a24b..ae71b14 100644
  --- a/arch/powerpc/kernel/pci-common.c
  +++ b/arch/powerpc/kernel/pci-common.c
  @@ -230,6 +230,7 @@ static int pci_read_irq_line(struct pci_dev *pci_dev)
   {
  struct of_irq oirq;
  unsigned int virq;
  +   int ret;
 
  pr_debug(PCI: Try to map irq for %s...\n, pci_name(pci_dev));
 
  @@ -266,8 +267,10 @@ static int pci_read_irq_line(struct pci_dev *pci_dev)
   oirq.size, oirq.specifier[0], oirq.specifier[1],
   of_node_full_name(oirq.controller));
 
  -   virq = irq_create_of_mapping(oirq.controller, 
  oirq.specifier,
  -oirq.size);
  +   ret = irq_create_of_mapping(oirq.controller, oirq.specifier,
  +   oirq.size, virq);
  +   if (ret)
  +   virq = NO_IRQ;
  }
  if(virq == NO_IRQ) {
  pr_debug( Failed to map !\n);
 
 Can you get rid of NO_IRQ usage here instead of adding to it.

I was trying to stay consistent with the remainder of the code. PowerPC
is a pretty heavy user of NO_IRQ. Of all 348 references, more than half
(182) are in arch/powerpc, so I'd rather like to get a go-ahead from
Benjamin on this.

That said, perhaps we should just go all the way and get rid of NO_IRQ
for good. Things could get somewhat messy, though. There are a couple of
these spread through the code:

#ifndef NO_IRQ
#define NO_IRQ (-1)
#endif

And this isn't very encouraging either:

$ git grep 'irq.*=.*-1' | wc -l
638

Thierry


pgpI7td10X2n7.pgp
Description: PGP signature
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH v2 04/10] irqdomain: Return errors from irq_create_of_mapping()

2013-09-22 Thread Rob Herring
On Wed, Sep 18, 2013 at 8:24 AM, Thierry Reding
thierry.red...@gmail.com wrote:
 Instead of returning 0 for all errors, allow the precise error code to
 be propagated. This will be used in subsequent patches to allow further
 propagation of error codes.

 The interrupt number corresponding to the new mapping is returned in an
 output parameter so that the return value is reserved to signal success
 (== 0) or failure ( 0).

 Signed-off-by: Thierry Reding tred...@nvidia.com

One comment below, otherwise:

Acked-by: Rob Herring rob.herr...@calxeda.com

 diff --git a/arch/powerpc/kernel/pci-common.c 
 b/arch/powerpc/kernel/pci-common.c
 index 905a24b..ae71b14 100644
 --- a/arch/powerpc/kernel/pci-common.c
 +++ b/arch/powerpc/kernel/pci-common.c
 @@ -230,6 +230,7 @@ static int pci_read_irq_line(struct pci_dev *pci_dev)
  {
 struct of_irq oirq;
 unsigned int virq;
 +   int ret;

 pr_debug(PCI: Try to map irq for %s...\n, pci_name(pci_dev));

 @@ -266,8 +267,10 @@ static int pci_read_irq_line(struct pci_dev *pci_dev)
  oirq.size, oirq.specifier[0], oirq.specifier[1],
  of_node_full_name(oirq.controller));

 -   virq = irq_create_of_mapping(oirq.controller, oirq.specifier,
 -oirq.size);
 +   ret = irq_create_of_mapping(oirq.controller, oirq.specifier,
 +   oirq.size, virq);
 +   if (ret)
 +   virq = NO_IRQ;
 }
 if(virq == NO_IRQ) {
 pr_debug( Failed to map !\n);

Can you get rid of NO_IRQ usage here instead of adding to it.

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


[PATCH v2 04/10] irqdomain: Return errors from irq_create_of_mapping()

2013-09-18 Thread Thierry Reding
Instead of returning 0 for all errors, allow the precise error code to
be propagated. This will be used in subsequent patches to allow further
propagation of error codes.

The interrupt number corresponding to the new mapping is returned in an
output parameter so that the return value is reserved to signal success
(== 0) or failure ( 0).

Signed-off-by: Thierry Reding tred...@nvidia.com
---
Changes in v2:
- convert existing callers instead of using compatible wrapper

 arch/arm/mach-integrator/pci_v3.c  |  8 ++--
 arch/microblaze/pci/pci-common.c   |  6 --
 arch/mips/pci/fixup-lantiq.c   | 12 +++
 arch/mips/pci/pci-rt3883.c |  9 +
 arch/powerpc/kernel/pci-common.c   |  7 +--
 arch/powerpc/platforms/cell/celleb_scc_sio.c   |  8 +---
 arch/powerpc/platforms/cell/spu_manage.c   |  6 +++---
 arch/powerpc/platforms/fsl_uli1575.c   |  7 +++
 arch/powerpc/platforms/pseries/event_sources.c | 12 ++-
 arch/x86/kernel/devicetree.c   | 11 +-
 drivers/pci/host/pci-mvebu.c   |  9 +++--
 include/linux/of_irq.h |  6 +++---
 kernel/irq/irqdomain.c | 28 --
 13 files changed, 78 insertions(+), 51 deletions(-)

diff --git a/arch/arm/mach-integrator/pci_v3.c 
b/arch/arm/mach-integrator/pci_v3.c
index bef1005..aa0f867 100644
--- a/arch/arm/mach-integrator/pci_v3.c
+++ b/arch/arm/mach-integrator/pci_v3.c
@@ -847,8 +847,12 @@ static int __init pci_v3_map_irq_dt(const struct pci_dev 
*dev, u8 slot, u8 pin)
return 0;
}
 
-   return irq_create_of_mapping(oirq.controller, oirq.specifier,
-oirq.size);
+   ret = irq_create_of_mapping(oirq.controller, oirq.specifier,
+   oirq.size, virq);
+   if (ret)
+   return 0;
+
+   return virq;
 }
 
 static int __init pci_v3_dtprobe(struct platform_device *pdev,
diff --git a/arch/microblaze/pci/pci-common.c b/arch/microblaze/pci/pci-common.c
index 1b93bf0..80b6e0f 100644
--- a/arch/microblaze/pci/pci-common.c
+++ b/arch/microblaze/pci/pci-common.c
@@ -246,8 +246,10 @@ int pci_read_irq_line(struct pci_dev *pci_dev)
 oirq.size, oirq.specifier[0], oirq.specifier[1],
 of_node_full_name(oirq.controller));
 
-   virq = irq_create_of_mapping(oirq.controller, oirq.specifier,
-oirq.size);
+   ret = irq_create_of_mapping(oirq.controller, oirq.specifier,
+   oirq.size, virq);
+   if (ret)
+   virq = 0;
}
if (!virq) {
pr_debug( Failed to map !\n);
diff --git a/arch/mips/pci/fixup-lantiq.c b/arch/mips/pci/fixup-lantiq.c
index 6c829df..dfe7bf1 100644
--- a/arch/mips/pci/fixup-lantiq.c
+++ b/arch/mips/pci/fixup-lantiq.c
@@ -26,15 +26,19 @@ int pcibios_plat_dev_init(struct pci_dev *dev)
 int __init pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
 {
struct of_irq dev_irq;
-   int irq;
+   unsigned int irq;
+   int err;
 
if (of_irq_map_pci(dev, dev_irq)) {
dev_err(dev-dev, trying to map irq for unknown slot:%d 
pin:%d\n,
slot, pin);
return 0;
}
-   irq = irq_create_of_mapping(dev_irq.controller, dev_irq.specifier,
-   dev_irq.size);
-   dev_info(dev-dev, SLOT:%d PIN:%d IRQ:%d\n, slot, pin, irq);
+   err = irq_create_of_mapping(dev_irq.controller, dev_irq.specifier,
+   dev_irq.size, irq);
+   if (err)
+   return 0;
+
+   dev_info(dev-dev, SLOT:%d PIN:%d IRQ:%u\n, slot, pin, irq);
return irq;
 }
diff --git a/arch/mips/pci/pci-rt3883.c b/arch/mips/pci/pci-rt3883.c
index 95c9d41..79b49b5 100644
--- a/arch/mips/pci/pci-rt3883.c
+++ b/arch/mips/pci/pci-rt3883.c
@@ -584,8 +584,8 @@ err_put_intc_node:
 int __init pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
 {
struct of_irq dev_irq;
+   unsigned int irq = 0;
int err;
-   int irq;
 
err = of_irq_map_pci(dev, dev_irq);
if (err) {
@@ -594,11 +594,12 @@ int __init pcibios_map_irq(const struct pci_dev *dev, u8 
slot, u8 pin)
return 0;
}
 
-   irq = irq_create_of_mapping(dev_irq.controller,
+   err = irq_create_of_mapping(dev_irq.controller,
dev_irq.specifier,
-   dev_irq.size);
+   dev_irq.size,
+   irq);
 
-   if (irq == 0)
+   if (err)
pr_crit(pci %s: no irq found for pin %u\n,
pci_name((struct pci_dev *) dev), pin);
else

Re: [PATCH v2 04/10] irqdomain: Return errors from irq_create_of_mapping()

2013-09-18 Thread Ralf Baechle
On Wed, Sep 18, 2013 at 03:24:46PM +0200, Thierry Reding wrote:

For the MIPS bits:

Acked-by: Ralf Baechle r...@linux-mips.org

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