* [patch 1/2] resources: clean up pnp_irq() error return
@ 2013-11-07 8:17 Dan Carpenter
2013-11-07 8:52 ` Takashi Iwai
0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2013-11-07 8:17 UTC (permalink / raw)
To: Andrew Morton
Cc: Jaroslav Kysela, Takashi Iwai, Bill Pemberton, alsa-devel,
kernel-janitors, Toshi Kani, Ram Pai, linux-kernel
pnp_irq() returns -1 on error but cast to an unsigned. It is confusing
for callers who assume that it returns a negative value. I have
introduced a new define IORESOURCE_INVALID which is the same value but
hopefully it looks less like a negative value.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
diff --git a/include/linux/ioport.h b/include/linux/ioport.h
index 89b7c24..fdccfa5 100644
--- a/include/linux/ioport.h
+++ b/include/linux/ioport.h
@@ -55,6 +55,8 @@ struct resource {
#define IORESOURCE_AUTO 0x40000000
#define IORESOURCE_BUSY 0x80000000 /* Driver has marked this resource busy */
+#define IORESOURCE_INVALID ((resource_size_t)-1)
+
/* PnP IRQ specific bits (IORESOURCE_BITS) */
#define IORESOURCE_IRQ_HIGHEDGE (1<<0)
#define IORESOURCE_IRQ_LOWEDGE (1<<1)
diff --git a/include/linux/pnp.h b/include/linux/pnp.h
index 195aafc..818669c 100644
--- a/include/linux/pnp.h
+++ b/include/linux/pnp.h
@@ -151,7 +151,7 @@ static inline resource_size_t pnp_irq(struct pnp_dev *dev, unsigned int bar)
if (pnp_resource_valid(res))
return res->start;
- return -1;
+ return IORESOURCE_INVALID;
}
static inline unsigned long pnp_irq_flags(struct pnp_dev *dev, unsigned int bar)
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [patch 1/2] resources: clean up pnp_irq() error return
2013-11-07 8:17 [patch 1/2] resources: clean up pnp_irq() error return Dan Carpenter
@ 2013-11-07 8:52 ` Takashi Iwai
0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2013-11-07 8:52 UTC (permalink / raw)
To: Dan Carpenter
Cc: Andrew Morton, Jaroslav Kysela, Bill Pemberton, alsa-devel,
kernel-janitors, Toshi Kani, Ram Pai, linux-kernel
At Thu, 7 Nov 2013 11:17:49 +0300,
Dan Carpenter wrote:
>
> pnp_irq() returns -1 on error but cast to an unsigned. It is confusing
> for callers who assume that it returns a negative value. I have
> introduced a new define IORESOURCE_INVALID which is the same value but
> hopefully it looks less like a negative value.
How about just returning int instead of resource_size_t?
IRQ numbers are handled by int in almost all drivers.
thanks,
Takashi
>
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>
> diff --git a/include/linux/ioport.h b/include/linux/ioport.h
> index 89b7c24..fdccfa5 100644
> --- a/include/linux/ioport.h
> +++ b/include/linux/ioport.h
> @@ -55,6 +55,8 @@ struct resource {
> #define IORESOURCE_AUTO 0x40000000
> #define IORESOURCE_BUSY 0x80000000 /* Driver has marked this resource busy */
>
> +#define IORESOURCE_INVALID ((resource_size_t)-1)
> +
> /* PnP IRQ specific bits (IORESOURCE_BITS) */
> #define IORESOURCE_IRQ_HIGHEDGE (1<<0)
> #define IORESOURCE_IRQ_LOWEDGE (1<<1)
> diff --git a/include/linux/pnp.h b/include/linux/pnp.h
> index 195aafc..818669c 100644
> --- a/include/linux/pnp.h
> +++ b/include/linux/pnp.h
> @@ -151,7 +151,7 @@ static inline resource_size_t pnp_irq(struct pnp_dev *dev, unsigned int bar)
>
> if (pnp_resource_valid(res))
> return res->start;
> - return -1;
> + return IORESOURCE_INVALID;
> }
>
> static inline unsigned long pnp_irq_flags(struct pnp_dev *dev, unsigned int bar)
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-11-07 8:53 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-07 8:17 [patch 1/2] resources: clean up pnp_irq() error return Dan Carpenter
2013-11-07 8:52 ` Takashi Iwai
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).