[1/6] smsc911x: add support for platform-specific irq flags
diff mbox

Message ID 1232458114-10997-2-git-send-email-steve.glendinning@smsc.com
State Deferred, archived
Delegated to: David Miller
Headers show

Commit Message

Steve Glendinning Jan. 20, 2009, 1:28 p.m. UTC
this patch adds support for the platform_device's resources to indicate
additional flags to use when registering the irq, for example
IORESOURCE_IRQ_LOWLEVEL (which corresponds to IRQF_TRIGGER_LOW).  These
should be set in the irq resource flags field.

Signed-off-by: Steve Glendinning <steve.glendinning@smsc.com>
---
 drivers/net/smsc911x.c |   19 ++++++++++++++-----
 1 files changed, 14 insertions(+), 5 deletions(-)

Comments

Ben Dooks Jan. 20, 2009, 2:55 p.m. UTC | #1
On Tue, Jan 20, 2009 at 01:28:29PM +0000, Steve Glendinning wrote:
> this patch adds support for the platform_device's resources to indicate
> additional flags to use when registering the irq, for example
> IORESOURCE_IRQ_LOWLEVEL (which corresponds to IRQF_TRIGGER_LOW).  These
> should be set in the irq resource flags field.
> 
> Signed-off-by: Steve Glendinning <steve.glendinning@smsc.com>
> ---
>  drivers/net/smsc911x.c |   19 ++++++++++++++-----
>  1 files changed, 14 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/net/smsc911x.c b/drivers/net/smsc911x.c
> index f513bdf..3565df1 100644
> --- a/drivers/net/smsc911x.c
> +++ b/drivers/net/smsc911x.c
> @@ -1892,9 +1892,9 @@ static int __devinit smsc911x_drv_probe(struct platform_device *pdev)
>  	struct net_device *dev;
>  	struct smsc911x_data *pdata;
>  	struct smsc911x_platform_config *config = pdev->dev.platform_data;
> -	struct resource *res;
> +	struct resource *res, *irq_res;
>  	unsigned int intcfg = 0;
> -	int res_size;
> +	int res_size, irq_flags;
>  	int retval;
>  	DECLARE_MAC_BUF(mac);
>  
> @@ -1919,6 +1919,14 @@ static int __devinit smsc911x_drv_probe(struct platform_device *pdev)
>  	}
>  	res_size = res->end - res->start;
>  
> +	irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
> +	if (!irq_res) {
> +		pr_warning("%s: Could not allocate irq resource.\n",
> +			SMSC_CHIPNAME);
> +		retval = -ENODEV;
> +		goto out_0;

-ENODEV is certainly not the right code to be returning here, it is
likely to get lost in the driver porbe process.

> +	}
> +
>  	if (!request_mem_region(res->start, res_size, SMSC_CHIPNAME)) {
>  		retval = -EBUSY;
>  		goto out_0;
> @@ -1935,7 +1943,8 @@ static int __devinit smsc911x_drv_probe(struct platform_device *pdev)
>  
>  	pdata = netdev_priv(dev);
>  
> -	dev->irq = platform_get_irq(pdev, 0);
> +	dev->irq = irq_res->start;
> +	irq_flags = irq_res->flags & IRQF_TRIGGER_MASK;
>  	pdata->ioaddr = ioremap_nocache(res->start, res_size);
>  
>  	/* copy config parameters across to pdata */
> @@ -1968,8 +1977,8 @@ static int __devinit smsc911x_drv_probe(struct platform_device *pdev)
>  	smsc911x_reg_write(pdata, INT_EN, 0);
>  	smsc911x_reg_write(pdata, INT_STS, 0xFFFFFFFF);
>  
> -	retval = request_irq(dev->irq, smsc911x_irqhandler, IRQF_DISABLED,
> -			     dev->name, dev);
> +	retval = request_irq(dev->irq, smsc911x_irqhandler,
> +			     irq_flags | IRQF_DISABLED, dev->name, dev);
>  	if (retval) {
>  		SMSC_WARNING(PROBE,
>  			"Unable to claim requested irq: %d", dev->irq);
> -- 
> 1.6.0.6
> 
> 
> -------------------------------------------------------------------
> List admin: http://lists.arm.linux.org.uk/mailman/listinfo/linux-arm-kernel
> FAQ:        http://www.arm.linux.org.uk/mailinglists/faq.php
> Etiquette:  http://www.arm.linux.org.uk/mailinglists/etiquette.php
Steve Glendinning Jan. 21, 2009, 3:54 p.m. UTC | #2
Hi Ben,

Ben Dooks <ben-linux@fluff.org> wrote on 20/01/2009 14:55:39:
> On Tue, Jan 20, 2009 at 01:28:29PM +0000, Steve Glendinning wrote:
> > @@ -1919,6 +1919,14 @@ static int __devinit 
> smsc911x_drv_probe(struct platform_device *pdev)
> >     }
> >     res_size = res->end - res->start;
> > 
> > +   irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
> > +   if (!irq_res) {
> > +      pr_warning("%s: Could not allocate irq resource.\n",
> > +         SMSC_CHIPNAME);
> > +      retval = -ENODEV;
> > +      goto out_0;
> 
> -ENODEV is certainly not the right code to be returning here, it is
> likely to get lost in the driver porbe process.
> 

Thanks for spotting this.

This probe function also returns -ENODEV in two other places: if 
platform_data is null or if it fails to get it's IORESOURCE_MEM.  I guess 
these should all be fixed, which return code should the driver use to 
indicate "my platform_data is missing or incomplete"?

Steve
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Miller Jan. 26, 2009, 1:45 a.m. UTC | #3
These platform conversion patches still seem to be in a state
of flux.

Steve could you resubmit this stuff and when doing so please clearly
indicate exactly which ones you think I should stick into the net-2.6
tree and which are to be added to the ARM tree.

Thanks.


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Steve Glendinning Jan. 26, 2009, 8:45 a.m. UTC | #4
David Miller <davem@davemloft.net> wrote on 26/01/2009 01:45:48:
> 
> These platform conversion patches still seem to be in a state
> of flux.
> 
> Steve could you resubmit this stuff and when doing so please clearly
> indicate exactly which ones you think I should stick into the net-2.6
> tree and which are to be added to the ARM tree.
> 
> Thanks.
> 

Thanks David,  I've also added two more minor initialisation workarounds
for hardware problems on in-tree boards.  The platform maintainers are
testing now.

I'll re-post the set when we're all happy, hopefully later this week.

Steve
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch
diff mbox

diff --git a/drivers/net/smsc911x.c b/drivers/net/smsc911x.c
index f513bdf..3565df1 100644
--- a/drivers/net/smsc911x.c
+++ b/drivers/net/smsc911x.c
@@ -1892,9 +1892,9 @@  static int __devinit smsc911x_drv_probe(struct platform_device *pdev)
 	struct net_device *dev;
 	struct smsc911x_data *pdata;
 	struct smsc911x_platform_config *config = pdev->dev.platform_data;
-	struct resource *res;
+	struct resource *res, *irq_res;
 	unsigned int intcfg = 0;
-	int res_size;
+	int res_size, irq_flags;
 	int retval;
 	DECLARE_MAC_BUF(mac);
 
@@ -1919,6 +1919,14 @@  static int __devinit smsc911x_drv_probe(struct platform_device *pdev)
 	}
 	res_size = res->end - res->start;
 
+	irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
+	if (!irq_res) {
+		pr_warning("%s: Could not allocate irq resource.\n",
+			SMSC_CHIPNAME);
+		retval = -ENODEV;
+		goto out_0;
+	}
+
 	if (!request_mem_region(res->start, res_size, SMSC_CHIPNAME)) {
 		retval = -EBUSY;
 		goto out_0;
@@ -1935,7 +1943,8 @@  static int __devinit smsc911x_drv_probe(struct platform_device *pdev)
 
 	pdata = netdev_priv(dev);
 
-	dev->irq = platform_get_irq(pdev, 0);
+	dev->irq = irq_res->start;
+	irq_flags = irq_res->flags & IRQF_TRIGGER_MASK;
 	pdata->ioaddr = ioremap_nocache(res->start, res_size);
 
 	/* copy config parameters across to pdata */
@@ -1968,8 +1977,8 @@  static int __devinit smsc911x_drv_probe(struct platform_device *pdev)
 	smsc911x_reg_write(pdata, INT_EN, 0);
 	smsc911x_reg_write(pdata, INT_STS, 0xFFFFFFFF);
 
-	retval = request_irq(dev->irq, smsc911x_irqhandler, IRQF_DISABLED,
-			     dev->name, dev);
+	retval = request_irq(dev->irq, smsc911x_irqhandler,
+			     irq_flags | IRQF_DISABLED, dev->name, dev);
 	if (retval) {
 		SMSC_WARNING(PROBE,
 			"Unable to claim requested irq: %d", dev->irq);