public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* request_irq() return value
@ 2006-07-27 17:50 Mariusz Kozlowski
  2006-07-27 18:13 ` Stephen Hemminger
  2006-07-27 18:16 ` Lukas Jelinek
  0 siblings, 2 replies; 3+ messages in thread
From: Mariusz Kozlowski @ 2006-07-27 17:50 UTC (permalink / raw)
  To: linux-kernel

Hello,

	I'm looking at the source code of different drivers and wondering about 
request_irq() return value. It is used mostly in 'open' routine of struct 
net_device. If request_irq() fails some drivers return -EAGAIN, some -EBUSY 
and some the return value of request_irq(). Is this intentional? Sample 
drivers code:

8139cp.c:
static int cp_open (struct net_device *dev) {
        ...
        rc = request_irq(dev->irq, cp_interrupt, SA_SHIRQ, dev->name, dev);
        if (rc)
                goto err_out_hw;
        ...
err_out_hw:
        ...
        return rc;
}

3c359.c:
static int xl_open(struct net_device *dev){
        ...
        if(request_irq(dev->irq, &xl_interrupt, SA_SHIRQ , "3c359", dev)) {
                return -EAGAIN;
        }
        ...
}

Besides request_irq() is arch dependent so depending on arch it has different 
set of possible return values. So ... does the return value matter or I 
misunderstood something here?

Regards,

	Mariusz

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: request_irq() return value
  2006-07-27 17:50 request_irq() return value Mariusz Kozlowski
@ 2006-07-27 18:13 ` Stephen Hemminger
  2006-07-27 18:16 ` Lukas Jelinek
  1 sibling, 0 replies; 3+ messages in thread
From: Stephen Hemminger @ 2006-07-27 18:13 UTC (permalink / raw)
  To: linux-kernel

On Thu, 27 Jul 2006 19:50:03 +0200
Mariusz Kozlowski <m.kozlowski@tuxland.pl> wrote:

> Hello,
> 
> 	I'm looking at the source code of different drivers and wondering about 
> request_irq() return value. It is used mostly in 'open' routine of struct 
> net_device. If request_irq() fails some drivers return -EAGAIN, some -EBUSY 
> and some the return value of request_irq(). Is this intentional? Sample 
> drivers code:

Correct practice is to propagate the error code of request_irq out to be
the return value of the open routine. This allows the request_irq to return
different values for overlapping irqs, or out of memory, etc.

> Besides request_irq() is arch dependent so depending on arch it has different 
> set of possible return values. So ... does the return value matter or I 
> misunderstood something here?

Each architecture should return something sane. If it doesn't then it a problem
that should be addressed there.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: request_irq() return value
  2006-07-27 17:50 request_irq() return value Mariusz Kozlowski
  2006-07-27 18:13 ` Stephen Hemminger
@ 2006-07-27 18:16 ` Lukas Jelinek
  1 sibling, 0 replies; 3+ messages in thread
From: Lukas Jelinek @ 2006-07-27 18:16 UTC (permalink / raw)
  To: Mariusz Kozlowski; +Cc: linux-kernel

Hello,

> Hello,
> 
> 	I'm looking at the source code of different drivers and wondering about 
> request_irq() return value. It is used mostly in 'open' routine of struct 
> net_device. If request_irq() fails some drivers return -EAGAIN, some -EBUSY 
> and some the return value of request_irq(). Is this intentional? Sample 
> drivers code:
> 

I think the most suitable value for this case is -EBUSY. The reason is
that this type of failure is usually permanent and unrecoverable. But
other people may have a different opinion and thus they prefer -EAGAIN
(which is intended for temporary failures) or something else.

Lukas


> 8139cp.c:
> static int cp_open (struct net_device *dev) {
>         ...
>         rc = request_irq(dev->irq, cp_interrupt, SA_SHIRQ, dev->name, dev);
>         if (rc)
>                 goto err_out_hw;
>         ...
> err_out_hw:
>         ...
>         return rc;
> }
> 
> 3c359.c:
> static int xl_open(struct net_device *dev){
>         ...
>         if(request_irq(dev->irq, &xl_interrupt, SA_SHIRQ , "3c359", dev)) {
>                 return -EAGAIN;
>         }
>         ...
> }
> 
> Besides request_irq() is arch dependent so depending on arch it has different 
> set of possible return values. So ... does the return value matter or I 
> misunderstood something here?
> 
> Regards,
> 
> 	Mariusz
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-07-27 18:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-07-27 17:50 request_irq() return value Mariusz Kozlowski
2006-07-27 18:13 ` Stephen Hemminger
2006-07-27 18:16 ` Lukas Jelinek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox