* [PATCH 1/2] driver core: platform: Introduce platform_get_irq_optional()
@ 2019-08-28 8:34 Thierry Reding
2019-08-28 8:34 ` [PATCH 2/2] hwmon: pwm-fan: Use platform_get_irq_optional() Thierry Reding
` (4 more replies)
0 siblings, 5 replies; 14+ messages in thread
From: Thierry Reding @ 2019-08-28 8:34 UTC (permalink / raw)
To: Greg Kroah-Hartman, Rafael J . Wysocki, Kamil Debski,
Bartlomiej Zolnierkiewicz, Jean Delvare, Guenter Roeck
Cc: Stephen Boyd, linux-hwmon, linux-kernel
From: Thierry Reding <treding@nvidia.com>
In some cases the interrupt line of a device is optional. Introduce a
new platform_get_irq_optional() that works much like platform_get_irq()
but does not output an error on failure to find the interrupt.
Signed-off-by: Thierry Reding <treding@nvidia.com>
---
drivers/base/platform.c | 22 ++++++++++++++++++++++
include/linux/platform_device.h | 1 +
2 files changed, 23 insertions(+)
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 8ad701068c11..0dda6ade50fd 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -192,6 +192,28 @@ int platform_get_irq(struct platform_device *dev, unsigned int num)
}
EXPORT_SYMBOL_GPL(platform_get_irq);
+/**
+ * platform_get_irq_optional - get an optional IRQ for a device
+ * @dev: platform device
+ * @num: IRQ number index
+ *
+ * Gets an IRQ for a platform device. Device drivers should check the return
+ * value for errors so as to not pass a negative integer value to the
+ * request_irq() APIs. This is the same as platform_get_irq(), except that it
+ * does not print an error message if an IRQ can not be obtained.
+ *
+ * Example:
+ * int irq = platform_get_irq_optional(pdev, 0);
+ * if (irq < 0)
+ * return irq;
+ *
+ * Return: IRQ number on success, negative error number on failure.
+ */
+int platform_get_irq_optional(struct platform_device *dev, unsigned int num)
+{
+ return __platform_get_irq(dev, num);
+}
+
/**
* platform_irq_count - Count the number of IRQs a platform device uses
* @dev: platform device
diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h
index 37e15a935a42..35bc4355a9df 100644
--- a/include/linux/platform_device.h
+++ b/include/linux/platform_device.h
@@ -58,6 +58,7 @@ extern void __iomem *
devm_platform_ioremap_resource(struct platform_device *pdev,
unsigned int index);
extern int platform_get_irq(struct platform_device *, unsigned int);
+extern int platform_get_irq_optional(struct platform_device *, unsigned int);
extern int platform_irq_count(struct platform_device *);
extern struct resource *platform_get_resource_byname(struct platform_device *,
unsigned int,
--
2.22.0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 2/2] hwmon: pwm-fan: Use platform_get_irq_optional()
2019-08-28 8:34 [PATCH 1/2] driver core: platform: Introduce platform_get_irq_optional() Thierry Reding
@ 2019-08-28 8:34 ` Thierry Reding
2019-08-28 9:10 ` Bartlomiej Zolnierkiewicz
` (2 more replies)
2019-08-28 8:57 ` [PATCH 1/2] driver core: platform: Introduce platform_get_irq_optional() Greg Kroah-Hartman
` (3 subsequent siblings)
4 siblings, 3 replies; 14+ messages in thread
From: Thierry Reding @ 2019-08-28 8:34 UTC (permalink / raw)
To: Greg Kroah-Hartman, Rafael J . Wysocki, Kamil Debski,
Bartlomiej Zolnierkiewicz, Jean Delvare, Guenter Roeck
Cc: Stephen Boyd, linux-hwmon, linux-kernel
From: Thierry Reding <treding@nvidia.com>
The PWM fan interrupt is optional, so we don't want an error message in
the kernel log if it wasn't specified.
Signed-off-by: Thierry Reding <treding@nvidia.com>
---
drivers/hwmon/pwm-fan.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
index 54c0ff00d67f..42ffd2e5182d 100644
--- a/drivers/hwmon/pwm-fan.c
+++ b/drivers/hwmon/pwm-fan.c
@@ -304,7 +304,7 @@ static int pwm_fan_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, ctx);
- ctx->irq = platform_get_irq(pdev, 0);
+ ctx->irq = platform_get_irq_optional(pdev, 0);
if (ctx->irq == -EPROBE_DEFER)
return ctx->irq;
--
2.22.0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH 1/2] driver core: platform: Introduce platform_get_irq_optional()
2019-08-28 8:34 [PATCH 1/2] driver core: platform: Introduce platform_get_irq_optional() Thierry Reding
2019-08-28 8:34 ` [PATCH 2/2] hwmon: pwm-fan: Use platform_get_irq_optional() Thierry Reding
@ 2019-08-28 8:57 ` Greg Kroah-Hartman
2019-08-28 9:32 ` Thierry Reding
2019-08-28 15:06 ` Guenter Roeck
2019-08-28 15:46 ` Stephen Boyd
` (2 subsequent siblings)
4 siblings, 2 replies; 14+ messages in thread
From: Greg Kroah-Hartman @ 2019-08-28 8:57 UTC (permalink / raw)
To: Thierry Reding
Cc: Rafael J . Wysocki, Kamil Debski, Bartlomiej Zolnierkiewicz,
Jean Delvare, Guenter Roeck, Stephen Boyd, linux-hwmon,
linux-kernel
On Wed, Aug 28, 2019 at 10:34:10AM +0200, Thierry Reding wrote:
> From: Thierry Reding <treding@nvidia.com>
>
> In some cases the interrupt line of a device is optional. Introduce a
> new platform_get_irq_optional() that works much like platform_get_irq()
> but does not output an error on failure to find the interrupt.
>
> Signed-off-by: Thierry Reding <treding@nvidia.com>
> ---
> drivers/base/platform.c | 22 ++++++++++++++++++++++
> include/linux/platform_device.h | 1 +
> 2 files changed, 23 insertions(+)
>
> diff --git a/drivers/base/platform.c b/drivers/base/platform.c
> index 8ad701068c11..0dda6ade50fd 100644
> --- a/drivers/base/platform.c
> +++ b/drivers/base/platform.c
> @@ -192,6 +192,28 @@ int platform_get_irq(struct platform_device *dev, unsigned int num)
> }
> EXPORT_SYMBOL_GPL(platform_get_irq);
>
> +/**
> + * platform_get_irq_optional - get an optional IRQ for a device
> + * @dev: platform device
> + * @num: IRQ number index
> + *
> + * Gets an IRQ for a platform device. Device drivers should check the return
> + * value for errors so as to not pass a negative integer value to the
> + * request_irq() APIs. This is the same as platform_get_irq(), except that it
> + * does not print an error message if an IRQ can not be obtained.
Kind of funny that the work people did to put error messages in a
central place needs to be worked around at times :)
Anyway, I have no objection to this, but it looks like it has to go in
through my tree. I can take the hwmon patch as well through my tree if
the hwmon maintainer(s) say it is ok to do so.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 2/2] hwmon: pwm-fan: Use platform_get_irq_optional()
2019-08-28 8:34 ` [PATCH 2/2] hwmon: pwm-fan: Use platform_get_irq_optional() Thierry Reding
@ 2019-08-28 9:10 ` Bartlomiej Zolnierkiewicz
2019-08-28 15:05 ` Guenter Roeck
2019-08-28 15:47 ` Stephen Boyd
2 siblings, 0 replies; 14+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2019-08-28 9:10 UTC (permalink / raw)
To: Thierry Reding
Cc: Greg Kroah-Hartman, Rafael J . Wysocki, Kamil Debski,
Jean Delvare, Guenter Roeck, Stephen Boyd, linux-hwmon,
linux-kernel
On 8/28/19 10:34 AM, Thierry Reding wrote:
> From: Thierry Reding <treding@nvidia.com>
>
> The PWM fan interrupt is optional, so we don't want an error message in
> the kernel log if it wasn't specified.
>
> Signed-off-by: Thierry Reding <treding@nvidia.com>
Acked-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics
> ---
> drivers/hwmon/pwm-fan.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
> index 54c0ff00d67f..42ffd2e5182d 100644
> --- a/drivers/hwmon/pwm-fan.c
> +++ b/drivers/hwmon/pwm-fan.c
> @@ -304,7 +304,7 @@ static int pwm_fan_probe(struct platform_device *pdev)
>
> platform_set_drvdata(pdev, ctx);
>
> - ctx->irq = platform_get_irq(pdev, 0);
> + ctx->irq = platform_get_irq_optional(pdev, 0);
> if (ctx->irq == -EPROBE_DEFER)
> return ctx->irq;
>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 1/2] driver core: platform: Introduce platform_get_irq_optional()
2019-08-28 8:57 ` [PATCH 1/2] driver core: platform: Introduce platform_get_irq_optional() Greg Kroah-Hartman
@ 2019-08-28 9:32 ` Thierry Reding
2019-08-28 15:06 ` Guenter Roeck
1 sibling, 0 replies; 14+ messages in thread
From: Thierry Reding @ 2019-08-28 9:32 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Rafael J . Wysocki, Kamil Debski, Bartlomiej Zolnierkiewicz,
Jean Delvare, Guenter Roeck, Stephen Boyd, linux-hwmon,
linux-kernel
[-- Attachment #1: Type: text/plain, Size: 2316 bytes --]
On Wed, Aug 28, 2019 at 10:57:24AM +0200, Greg Kroah-Hartman wrote:
> On Wed, Aug 28, 2019 at 10:34:10AM +0200, Thierry Reding wrote:
> > From: Thierry Reding <treding@nvidia.com>
> >
> > In some cases the interrupt line of a device is optional. Introduce a
> > new platform_get_irq_optional() that works much like platform_get_irq()
> > but does not output an error on failure to find the interrupt.
> >
> > Signed-off-by: Thierry Reding <treding@nvidia.com>
> > ---
> > drivers/base/platform.c | 22 ++++++++++++++++++++++
> > include/linux/platform_device.h | 1 +
> > 2 files changed, 23 insertions(+)
> >
> > diff --git a/drivers/base/platform.c b/drivers/base/platform.c
> > index 8ad701068c11..0dda6ade50fd 100644
> > --- a/drivers/base/platform.c
> > +++ b/drivers/base/platform.c
> > @@ -192,6 +192,28 @@ int platform_get_irq(struct platform_device *dev, unsigned int num)
> > }
> > EXPORT_SYMBOL_GPL(platform_get_irq);
> >
> > +/**
> > + * platform_get_irq_optional - get an optional IRQ for a device
> > + * @dev: platform device
> > + * @num: IRQ number index
> > + *
> > + * Gets an IRQ for a platform device. Device drivers should check the return
> > + * value for errors so as to not pass a negative integer value to the
> > + * request_irq() APIs. This is the same as platform_get_irq(), except that it
> > + * does not print an error message if an IRQ can not be obtained.
>
> Kind of funny that the work people did to put error messages in a
> central place needs to be worked around at times :)
Indeed. I think it does make sense in this case to have the error
message in a central place, because it really does seem like the vast
majority of users really do want that IRQ. Having the _optional variant
makes it really explicit in the cases where it's fine to continue
without the IRQ.
> Anyway, I have no objection to this, but it looks like it has to go in
> through my tree. I can take the hwmon patch as well through my tree if
> the hwmon maintainer(s) say it is ok to do so.
I suppose we could technically make this go through the driver core and
hwmon trees separately with a bit of timing, but the hwmon patch is so
trivial that it would indeed be simplest to take it through the driver
core tree as well.
Thierry
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 2/2] hwmon: pwm-fan: Use platform_get_irq_optional()
2019-08-28 8:34 ` [PATCH 2/2] hwmon: pwm-fan: Use platform_get_irq_optional() Thierry Reding
2019-08-28 9:10 ` Bartlomiej Zolnierkiewicz
@ 2019-08-28 15:05 ` Guenter Roeck
2019-08-28 15:38 ` Greg Kroah-Hartman
2019-08-28 15:47 ` Stephen Boyd
2 siblings, 1 reply; 14+ messages in thread
From: Guenter Roeck @ 2019-08-28 15:05 UTC (permalink / raw)
To: Thierry Reding
Cc: Greg Kroah-Hartman, Rafael J . Wysocki, Kamil Debski,
Bartlomiej Zolnierkiewicz, Jean Delvare, Stephen Boyd,
linux-hwmon, linux-kernel
On Wed, Aug 28, 2019 at 10:34:11AM +0200, Thierry Reding wrote:
> From: Thierry Reding <treding@nvidia.com>
>
> The PWM fan interrupt is optional, so we don't want an error message in
> the kernel log if it wasn't specified.
>
> Signed-off-by: Thierry Reding <treding@nvidia.com>
Acked-by: Guenter Roeck <linux@roeck-us.net>
I assume that Greg will pick up this patch.
Guenter
> ---
> drivers/hwmon/pwm-fan.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
> index 54c0ff00d67f..42ffd2e5182d 100644
> --- a/drivers/hwmon/pwm-fan.c
> +++ b/drivers/hwmon/pwm-fan.c
> @@ -304,7 +304,7 @@ static int pwm_fan_probe(struct platform_device *pdev)
>
> platform_set_drvdata(pdev, ctx);
>
> - ctx->irq = platform_get_irq(pdev, 0);
> + ctx->irq = platform_get_irq_optional(pdev, 0);
> if (ctx->irq == -EPROBE_DEFER)
> return ctx->irq;
>
> --
> 2.22.0
>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 1/2] driver core: platform: Introduce platform_get_irq_optional()
2019-08-28 8:57 ` [PATCH 1/2] driver core: platform: Introduce platform_get_irq_optional() Greg Kroah-Hartman
2019-08-28 9:32 ` Thierry Reding
@ 2019-08-28 15:06 ` Guenter Roeck
1 sibling, 0 replies; 14+ messages in thread
From: Guenter Roeck @ 2019-08-28 15:06 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Thierry Reding, Rafael J . Wysocki, Kamil Debski,
Bartlomiej Zolnierkiewicz, Jean Delvare, Stephen Boyd,
linux-hwmon, linux-kernel
On Wed, Aug 28, 2019 at 10:57:24AM +0200, Greg Kroah-Hartman wrote:
> On Wed, Aug 28, 2019 at 10:34:10AM +0200, Thierry Reding wrote:
> > From: Thierry Reding <treding@nvidia.com>
> >
> > In some cases the interrupt line of a device is optional. Introduce a
> > new platform_get_irq_optional() that works much like platform_get_irq()
> > but does not output an error on failure to find the interrupt.
> >
> > Signed-off-by: Thierry Reding <treding@nvidia.com>
> > ---
> > drivers/base/platform.c | 22 ++++++++++++++++++++++
> > include/linux/platform_device.h | 1 +
> > 2 files changed, 23 insertions(+)
> >
> > diff --git a/drivers/base/platform.c b/drivers/base/platform.c
> > index 8ad701068c11..0dda6ade50fd 100644
> > --- a/drivers/base/platform.c
> > +++ b/drivers/base/platform.c
> > @@ -192,6 +192,28 @@ int platform_get_irq(struct platform_device *dev, unsigned int num)
> > }
> > EXPORT_SYMBOL_GPL(platform_get_irq);
> >
> > +/**
> > + * platform_get_irq_optional - get an optional IRQ for a device
> > + * @dev: platform device
> > + * @num: IRQ number index
> > + *
> > + * Gets an IRQ for a platform device. Device drivers should check the return
> > + * value for errors so as to not pass a negative integer value to the
> > + * request_irq() APIs. This is the same as platform_get_irq(), except that it
> > + * does not print an error message if an IRQ can not be obtained.
>
> Kind of funny that the work people did to put error messages in a
> central place needs to be worked around at times :)
>
> Anyway, I have no objection to this, but it looks like it has to go in
> through my tree. I can take the hwmon patch as well through my tree if
> the hwmon maintainer(s) say it is ok to do so.
>
Ok with me.
Guenter
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 2/2] hwmon: pwm-fan: Use platform_get_irq_optional()
2019-08-28 15:05 ` Guenter Roeck
@ 2019-08-28 15:38 ` Greg Kroah-Hartman
0 siblings, 0 replies; 14+ messages in thread
From: Greg Kroah-Hartman @ 2019-08-28 15:38 UTC (permalink / raw)
To: Guenter Roeck
Cc: Thierry Reding, Rafael J . Wysocki, Kamil Debski,
Bartlomiej Zolnierkiewicz, Jean Delvare, Stephen Boyd,
linux-hwmon, linux-kernel
On Wed, Aug 28, 2019 at 08:05:22AM -0700, Guenter Roeck wrote:
> On Wed, Aug 28, 2019 at 10:34:11AM +0200, Thierry Reding wrote:
> > From: Thierry Reding <treding@nvidia.com>
> >
> > The PWM fan interrupt is optional, so we don't want an error message in
> > the kernel log if it wasn't specified.
> >
> > Signed-off-by: Thierry Reding <treding@nvidia.com>
>
> Acked-by: Guenter Roeck <linux@roeck-us.net>
>
> I assume that Greg will pick up this patch.
Will do, thanks.
greg k-h
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 1/2] driver core: platform: Introduce platform_get_irq_optional()
2019-08-28 8:34 [PATCH 1/2] driver core: platform: Introduce platform_get_irq_optional() Thierry Reding
2019-08-28 8:34 ` [PATCH 2/2] hwmon: pwm-fan: Use platform_get_irq_optional() Thierry Reding
2019-08-28 8:57 ` [PATCH 1/2] driver core: platform: Introduce platform_get_irq_optional() Greg Kroah-Hartman
@ 2019-08-28 15:46 ` Stephen Boyd
2019-08-29 7:44 ` Thierry Reding
2019-10-09 9:37 ` [PATCH] driver core: simplify definitions of platform_get_irq* Uwe Kleine-König
4 siblings, 0 replies; 14+ messages in thread
From: Stephen Boyd @ 2019-08-28 15:46 UTC (permalink / raw)
To: Rafael J . Wysocki, Bartlomiej Zolnierkiewicz,
Greg Kroah-Hartman, Guenter Roeck, Jean Delvare, Kamil Debski,
Thierry Reding
Cc: linux-hwmon, linux-kernel
Quoting Thierry Reding (2019-08-28 01:34:10)
> From: Thierry Reding <treding@nvidia.com>
>
> In some cases the interrupt line of a device is optional. Introduce a
> new platform_get_irq_optional() that works much like platform_get_irq()
> but does not output an error on failure to find the interrupt.
>
> Signed-off-by: Thierry Reding <treding@nvidia.com>
> ---
Thanks!
Reviewed-by: Stephen Boyd <swboyd@chromium.org>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 2/2] hwmon: pwm-fan: Use platform_get_irq_optional()
2019-08-28 8:34 ` [PATCH 2/2] hwmon: pwm-fan: Use platform_get_irq_optional() Thierry Reding
2019-08-28 9:10 ` Bartlomiej Zolnierkiewicz
2019-08-28 15:05 ` Guenter Roeck
@ 2019-08-28 15:47 ` Stephen Boyd
2 siblings, 0 replies; 14+ messages in thread
From: Stephen Boyd @ 2019-08-28 15:47 UTC (permalink / raw)
To: Rafael J . Wysocki, Bartlomiej Zolnierkiewicz,
Greg Kroah-Hartman, Guenter Roeck, Jean Delvare, Kamil Debski,
Thierry Reding
Cc: linux-hwmon, linux-kernel
Quoting Thierry Reding (2019-08-28 01:34:11)
> From: Thierry Reding <treding@nvidia.com>
>
> The PWM fan interrupt is optional, so we don't want an error message in
> the kernel log if it wasn't specified.
>
> Signed-off-by: Thierry Reding <treding@nvidia.com>
> ---
Reviewed-by: Stephen Boyd <swboyd@chromium.org>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 1/2] driver core: platform: Introduce platform_get_irq_optional()
2019-08-28 8:34 [PATCH 1/2] driver core: platform: Introduce platform_get_irq_optional() Thierry Reding
` (2 preceding siblings ...)
2019-08-28 15:46 ` Stephen Boyd
@ 2019-08-29 7:44 ` Thierry Reding
2019-08-29 10:10 ` Greg Kroah-Hartman
2019-10-09 9:37 ` [PATCH] driver core: simplify definitions of platform_get_irq* Uwe Kleine-König
4 siblings, 1 reply; 14+ messages in thread
From: Thierry Reding @ 2019-08-29 7:44 UTC (permalink / raw)
To: Greg Kroah-Hartman, Rafael J . Wysocki, Kamil Debski,
Bartlomiej Zolnierkiewicz, Jean Delvare, Guenter Roeck
Cc: Stephen Boyd, linux-hwmon, linux-kernel
[-- Attachment #1.1: Type: text/plain, Size: 2671 bytes --]
On Wed, Aug 28, 2019 at 10:34:10AM +0200, Thierry Reding wrote:
> From: Thierry Reding <treding@nvidia.com>
>
> In some cases the interrupt line of a device is optional. Introduce a
> new platform_get_irq_optional() that works much like platform_get_irq()
> but does not output an error on failure to find the interrupt.
>
> Signed-off-by: Thierry Reding <treding@nvidia.com>
> ---
> drivers/base/platform.c | 22 ++++++++++++++++++++++
> include/linux/platform_device.h | 1 +
> 2 files changed, 23 insertions(+)
>
> diff --git a/drivers/base/platform.c b/drivers/base/platform.c
> index 8ad701068c11..0dda6ade50fd 100644
> --- a/drivers/base/platform.c
> +++ b/drivers/base/platform.c
> @@ -192,6 +192,28 @@ int platform_get_irq(struct platform_device *dev, unsigned int num)
> }
> EXPORT_SYMBOL_GPL(platform_get_irq);
>
> +/**
> + * platform_get_irq_optional - get an optional IRQ for a device
> + * @dev: platform device
> + * @num: IRQ number index
> + *
> + * Gets an IRQ for a platform device. Device drivers should check the return
> + * value for errors so as to not pass a negative integer value to the
> + * request_irq() APIs. This is the same as platform_get_irq(), except that it
> + * does not print an error message if an IRQ can not be obtained.
> + *
> + * Example:
> + * int irq = platform_get_irq_optional(pdev, 0);
> + * if (irq < 0)
> + * return irq;
> + *
> + * Return: IRQ number on success, negative error number on failure.
> + */
> +int platform_get_irq_optional(struct platform_device *dev, unsigned int num)
> +{
> + return __platform_get_irq(dev, num);
> +}
Oh my... this is embarrassing, but the kbuild test robot reported that
the second patch here fails to build because I forgot to export this
symbol. I've attached a patch that fixes it.
Thierry
> +
> /**
> * platform_irq_count - Count the number of IRQs a platform device uses
> * @dev: platform device
> diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h
> index 37e15a935a42..35bc4355a9df 100644
> --- a/include/linux/platform_device.h
> +++ b/include/linux/platform_device.h
> @@ -58,6 +58,7 @@ extern void __iomem *
> devm_platform_ioremap_resource(struct platform_device *pdev,
> unsigned int index);
> extern int platform_get_irq(struct platform_device *, unsigned int);
> +extern int platform_get_irq_optional(struct platform_device *, unsigned int);
> extern int platform_irq_count(struct platform_device *);
> extern struct resource *platform_get_resource_byname(struct platform_device *,
> unsigned int,
> --
> 2.22.0
>
[-- Attachment #1.2: 0001-driver-core-platform-Export-platform_get_irq_optiona.patch --]
[-- Type: text/plain, Size: 932 bytes --]
From 0f7695c4d3f30b2946c97160b717de03c3deb73f Mon Sep 17 00:00:00 2001
From: Thierry Reding <treding@nvidia.com>
Date: Thu, 29 Aug 2019 09:29:32 +0200
Subject: [PATCH] driver core: platform: Export platform_get_irq_optional()
This function can be used by modules, so it needs to be exported.
Reported-by: kbuild test robot <lkp@intel.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
---
drivers/base/platform.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 014dc07b0056..b6c6c7d97d5b 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -194,6 +194,7 @@ int platform_get_irq_optional(struct platform_device *dev, unsigned int num)
{
return __platform_get_irq(dev, num);
}
+EXPORT_SYMBOL_GPL(platform_get_irq_optional);
/**
* platform_irq_count - Count the number of IRQs a platform device uses
--
2.22.0
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH 1/2] driver core: platform: Introduce platform_get_irq_optional()
2019-08-29 7:44 ` Thierry Reding
@ 2019-08-29 10:10 ` Greg Kroah-Hartman
0 siblings, 0 replies; 14+ messages in thread
From: Greg Kroah-Hartman @ 2019-08-29 10:10 UTC (permalink / raw)
To: Thierry Reding
Cc: Rafael J . Wysocki, Kamil Debski, Bartlomiej Zolnierkiewicz,
Jean Delvare, Guenter Roeck, Stephen Boyd, linux-hwmon,
linux-kernel
On Thu, Aug 29, 2019 at 09:44:08AM +0200, Thierry Reding wrote:
> On Wed, Aug 28, 2019 at 10:34:10AM +0200, Thierry Reding wrote:
> > From: Thierry Reding <treding@nvidia.com>
> >
> > In some cases the interrupt line of a device is optional. Introduce a
> > new platform_get_irq_optional() that works much like platform_get_irq()
> > but does not output an error on failure to find the interrupt.
> >
> > Signed-off-by: Thierry Reding <treding@nvidia.com>
> > ---
> > drivers/base/platform.c | 22 ++++++++++++++++++++++
> > include/linux/platform_device.h | 1 +
> > 2 files changed, 23 insertions(+)
> >
> > diff --git a/drivers/base/platform.c b/drivers/base/platform.c
> > index 8ad701068c11..0dda6ade50fd 100644
> > --- a/drivers/base/platform.c
> > +++ b/drivers/base/platform.c
> > @@ -192,6 +192,28 @@ int platform_get_irq(struct platform_device *dev, unsigned int num)
> > }
> > EXPORT_SYMBOL_GPL(platform_get_irq);
> >
> > +/**
> > + * platform_get_irq_optional - get an optional IRQ for a device
> > + * @dev: platform device
> > + * @num: IRQ number index
> > + *
> > + * Gets an IRQ for a platform device. Device drivers should check the return
> > + * value for errors so as to not pass a negative integer value to the
> > + * request_irq() APIs. This is the same as platform_get_irq(), except that it
> > + * does not print an error message if an IRQ can not be obtained.
> > + *
> > + * Example:
> > + * int irq = platform_get_irq_optional(pdev, 0);
> > + * if (irq < 0)
> > + * return irq;
> > + *
> > + * Return: IRQ number on success, negative error number on failure.
> > + */
> > +int platform_get_irq_optional(struct platform_device *dev, unsigned int num)
> > +{
> > + return __platform_get_irq(dev, num);
> > +}
>
> Oh my... this is embarrassing, but the kbuild test robot reported that
> the second patch here fails to build because I forgot to export this
> symbol. I've attached a patch that fixes it.
>
> Thierry
>
> > +
> > /**
> > * platform_irq_count - Count the number of IRQs a platform device uses
> > * @dev: platform device
> > diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h
> > index 37e15a935a42..35bc4355a9df 100644
> > --- a/include/linux/platform_device.h
> > +++ b/include/linux/platform_device.h
> > @@ -58,6 +58,7 @@ extern void __iomem *
> > devm_platform_ioremap_resource(struct platform_device *pdev,
> > unsigned int index);
> > extern int platform_get_irq(struct platform_device *, unsigned int);
> > +extern int platform_get_irq_optional(struct platform_device *, unsigned int);
> > extern int platform_irq_count(struct platform_device *);
> > extern struct resource *platform_get_resource_byname(struct platform_device *,
> > unsigned int,
> > --
> > 2.22.0
> >
> From 0f7695c4d3f30b2946c97160b717de03c3deb73f Mon Sep 17 00:00:00 2001
> From: Thierry Reding <treding@nvidia.com>
> Date: Thu, 29 Aug 2019 09:29:32 +0200
> Subject: [PATCH] driver core: platform: Export platform_get_irq_optional()
>
> This function can be used by modules, so it needs to be exported.
>
> Reported-by: kbuild test robot <lkp@intel.com>
> Signed-off-by: Thierry Reding <treding@nvidia.com>
> ---
> drivers/base/platform.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/base/platform.c b/drivers/base/platform.c
> index 014dc07b0056..b6c6c7d97d5b 100644
> --- a/drivers/base/platform.c
> +++ b/drivers/base/platform.c
> @@ -194,6 +194,7 @@ int platform_get_irq_optional(struct platform_device *dev, unsigned int num)
> {
> return __platform_get_irq(dev, num);
> }
> +EXPORT_SYMBOL_GPL(platform_get_irq_optional);
>
> /**
> * platform_irq_count - Count the number of IRQs a platform device uses
> --
> 2.22.0
>
Now merged, thanks.
greg k-h
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH] driver core: simplify definitions of platform_get_irq*
2019-08-28 8:34 [PATCH 1/2] driver core: platform: Introduce platform_get_irq_optional() Thierry Reding
` (3 preceding siblings ...)
2019-08-29 7:44 ` Thierry Reding
@ 2019-10-09 9:37 ` Uwe Kleine-König
2019-10-09 12:23 ` Rafael J. Wysocki
4 siblings, 1 reply; 14+ messages in thread
From: Uwe Kleine-König @ 2019-10-09 9:37 UTC (permalink / raw)
To: Thierry Reding, Greg Kroah-Hartman, Rafael J. Wysocki; +Cc: linux-kernel
platform_get_irq_optional is just a wrapper for __platform_get_irq. So
rename __platform_get_irq to platform_get_irq_optional and drop
platform_get_irq_optional's previous implementation. This way there is
one function and one indirection less without loss of functionality.
Signed-off-by: Uwe Kleine-König <uwe@kleine-koenig.org>
---
drivers/base/platform.c | 47 ++++++++++++++++++-----------------------
1 file changed, 21 insertions(+), 26 deletions(-)
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index b6c6c7d97d5b..60ff536b46f1 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -80,7 +80,24 @@ void __iomem *devm_platform_ioremap_resource(struct platform_device *pdev,
EXPORT_SYMBOL_GPL(devm_platform_ioremap_resource);
#endif /* CONFIG_HAS_IOMEM */
-static int __platform_get_irq(struct platform_device *dev, unsigned int num)
+/**
+ * platform_get_irq_optional - get an optional IRQ for a device
+ * @dev: platform device
+ * @num: IRQ number index
+ *
+ * Gets an IRQ for a platform device. Device drivers should check the return
+ * value for errors so as to not pass a negative integer value to the
+ * request_irq() APIs. This is the same as platform_get_irq(), except that it
+ * does not print an error message if an IRQ can not be obtained.
+ *
+ * Example:
+ * int irq = platform_get_irq_optional(pdev, 0);
+ * if (irq < 0)
+ * return irq;
+ *
+ * Return: IRQ number on success, negative error number on failure.
+ */
+int platform_get_irq_optional(struct platform_device *dev, unsigned int num)
{
#ifdef CONFIG_SPARC
/* sparc does not have irqs represented as IORESOURCE_IRQ resources */
@@ -144,6 +161,7 @@ static int __platform_get_irq(struct platform_device *dev, unsigned int num)
return -ENXIO;
#endif
}
+EXPORT_SYMBOL_GPL(platform_get_irq_optional);
/**
* platform_get_irq - get an IRQ for a device
@@ -165,7 +183,7 @@ int platform_get_irq(struct platform_device *dev, unsigned int num)
{
int ret;
- ret = __platform_get_irq(dev, num);
+ ret = platform_get_irq_optional(dev, num);
if (ret < 0 && ret != -EPROBE_DEFER)
dev_err(&dev->dev, "IRQ index %u not found\n", num);
@@ -173,29 +191,6 @@ int platform_get_irq(struct platform_device *dev, unsigned int num)
}
EXPORT_SYMBOL_GPL(platform_get_irq);
-/**
- * platform_get_irq_optional - get an optional IRQ for a device
- * @dev: platform device
- * @num: IRQ number index
- *
- * Gets an IRQ for a platform device. Device drivers should check the return
- * value for errors so as to not pass a negative integer value to the
- * request_irq() APIs. This is the same as platform_get_irq(), except that it
- * does not print an error message if an IRQ can not be obtained.
- *
- * Example:
- * int irq = platform_get_irq_optional(pdev, 0);
- * if (irq < 0)
- * return irq;
- *
- * Return: IRQ number on success, negative error number on failure.
- */
-int platform_get_irq_optional(struct platform_device *dev, unsigned int num)
-{
- return __platform_get_irq(dev, num);
-}
-EXPORT_SYMBOL_GPL(platform_get_irq_optional);
-
/**
* platform_irq_count - Count the number of IRQs a platform device uses
* @dev: platform device
@@ -206,7 +201,7 @@ int platform_irq_count(struct platform_device *dev)
{
int ret, nr = 0;
- while ((ret = __platform_get_irq(dev, nr)) >= 0)
+ while ((ret = platform_get_irq_optional(dev, nr)) >= 0)
nr++;
if (ret == -EPROBE_DEFER)
--
2.23.0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH] driver core: simplify definitions of platform_get_irq*
2019-10-09 9:37 ` [PATCH] driver core: simplify definitions of platform_get_irq* Uwe Kleine-König
@ 2019-10-09 12:23 ` Rafael J. Wysocki
0 siblings, 0 replies; 14+ messages in thread
From: Rafael J. Wysocki @ 2019-10-09 12:23 UTC (permalink / raw)
To: Uwe Kleine-König
Cc: Thierry Reding, Greg Kroah-Hartman, Rafael J. Wysocki,
Linux Kernel Mailing List
On Wed, Oct 9, 2019 at 11:39 AM Uwe Kleine-König <uwe@kleine-koenig.org> wrote:
>
> platform_get_irq_optional is just a wrapper for __platform_get_irq. So
> rename __platform_get_irq to platform_get_irq_optional and drop
> platform_get_irq_optional's previous implementation. This way there is
> one function and one indirection less without loss of functionality.
>
> Signed-off-by: Uwe Kleine-König <uwe@kleine-koenig.org>
Makes sense to me:
Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> ---
> drivers/base/platform.c | 47 ++++++++++++++++++-----------------------
> 1 file changed, 21 insertions(+), 26 deletions(-)
>
> diff --git a/drivers/base/platform.c b/drivers/base/platform.c
> index b6c6c7d97d5b..60ff536b46f1 100644
> --- a/drivers/base/platform.c
> +++ b/drivers/base/platform.c
> @@ -80,7 +80,24 @@ void __iomem *devm_platform_ioremap_resource(struct platform_device *pdev,
> EXPORT_SYMBOL_GPL(devm_platform_ioremap_resource);
> #endif /* CONFIG_HAS_IOMEM */
>
> -static int __platform_get_irq(struct platform_device *dev, unsigned int num)
> +/**
> + * platform_get_irq_optional - get an optional IRQ for a device
> + * @dev: platform device
> + * @num: IRQ number index
> + *
> + * Gets an IRQ for a platform device. Device drivers should check the return
> + * value for errors so as to not pass a negative integer value to the
> + * request_irq() APIs. This is the same as platform_get_irq(), except that it
> + * does not print an error message if an IRQ can not be obtained.
> + *
> + * Example:
> + * int irq = platform_get_irq_optional(pdev, 0);
> + * if (irq < 0)
> + * return irq;
> + *
> + * Return: IRQ number on success, negative error number on failure.
> + */
> +int platform_get_irq_optional(struct platform_device *dev, unsigned int num)
> {
> #ifdef CONFIG_SPARC
> /* sparc does not have irqs represented as IORESOURCE_IRQ resources */
> @@ -144,6 +161,7 @@ static int __platform_get_irq(struct platform_device *dev, unsigned int num)
> return -ENXIO;
> #endif
> }
> +EXPORT_SYMBOL_GPL(platform_get_irq_optional);
>
> /**
> * platform_get_irq - get an IRQ for a device
> @@ -165,7 +183,7 @@ int platform_get_irq(struct platform_device *dev, unsigned int num)
> {
> int ret;
>
> - ret = __platform_get_irq(dev, num);
> + ret = platform_get_irq_optional(dev, num);
> if (ret < 0 && ret != -EPROBE_DEFER)
> dev_err(&dev->dev, "IRQ index %u not found\n", num);
>
> @@ -173,29 +191,6 @@ int platform_get_irq(struct platform_device *dev, unsigned int num)
> }
> EXPORT_SYMBOL_GPL(platform_get_irq);
>
> -/**
> - * platform_get_irq_optional - get an optional IRQ for a device
> - * @dev: platform device
> - * @num: IRQ number index
> - *
> - * Gets an IRQ for a platform device. Device drivers should check the return
> - * value for errors so as to not pass a negative integer value to the
> - * request_irq() APIs. This is the same as platform_get_irq(), except that it
> - * does not print an error message if an IRQ can not be obtained.
> - *
> - * Example:
> - * int irq = platform_get_irq_optional(pdev, 0);
> - * if (irq < 0)
> - * return irq;
> - *
> - * Return: IRQ number on success, negative error number on failure.
> - */
> -int platform_get_irq_optional(struct platform_device *dev, unsigned int num)
> -{
> - return __platform_get_irq(dev, num);
> -}
> -EXPORT_SYMBOL_GPL(platform_get_irq_optional);
> -
> /**
> * platform_irq_count - Count the number of IRQs a platform device uses
> * @dev: platform device
> @@ -206,7 +201,7 @@ int platform_irq_count(struct platform_device *dev)
> {
> int ret, nr = 0;
>
> - while ((ret = __platform_get_irq(dev, nr)) >= 0)
> + while ((ret = platform_get_irq_optional(dev, nr)) >= 0)
> nr++;
>
> if (ret == -EPROBE_DEFER)
> --
> 2.23.0
>
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2019-10-09 12:23 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-28 8:34 [PATCH 1/2] driver core: platform: Introduce platform_get_irq_optional() Thierry Reding
2019-08-28 8:34 ` [PATCH 2/2] hwmon: pwm-fan: Use platform_get_irq_optional() Thierry Reding
2019-08-28 9:10 ` Bartlomiej Zolnierkiewicz
2019-08-28 15:05 ` Guenter Roeck
2019-08-28 15:38 ` Greg Kroah-Hartman
2019-08-28 15:47 ` Stephen Boyd
2019-08-28 8:57 ` [PATCH 1/2] driver core: platform: Introduce platform_get_irq_optional() Greg Kroah-Hartman
2019-08-28 9:32 ` Thierry Reding
2019-08-28 15:06 ` Guenter Roeck
2019-08-28 15:46 ` Stephen Boyd
2019-08-29 7:44 ` Thierry Reding
2019-08-29 10:10 ` Greg Kroah-Hartman
2019-10-09 9:37 ` [PATCH] driver core: simplify definitions of platform_get_irq* Uwe Kleine-König
2019-10-09 12:23 ` Rafael J. Wysocki
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).