Linux-Hwmon Archive on lore.kernel.org
 help / color / Atom feed
* [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
                   ` (3 more replies)
  0 siblings, 4 replies; 12+ 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	[flat|nested] 12+ 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
                   ` (2 subsequent siblings)
  3 siblings, 3 replies; 12+ 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	[flat|nested] 12+ 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
  2019-08-29  7:44 ` Thierry Reding
  3 siblings, 2 replies; 12+ 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] 12+ 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; 12+ 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] 12+ 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; 12+ 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] 12+ 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; 12+ 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] 12+ 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; 12+ 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] 12+ 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; 12+ 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] 12+ 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
  3 siblings, 0 replies; 12+ 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] 12+ 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; 12+ 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] 12+ 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
  3 siblings, 1 reply; 12+ 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	[flat|nested] 12+ 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; 12+ 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] 12+ messages in thread

end of thread, back to index

Thread overview: 12+ 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

Linux-Hwmon Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-hwmon/0 linux-hwmon/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-hwmon linux-hwmon/ https://lore.kernel.org/linux-hwmon \
		linux-hwmon@vger.kernel.org linux-hwmon@archiver.kernel.org
	public-inbox-index linux-hwmon


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-hwmon


AGPL code for this site: git clone https://public-inbox.org/ public-inbox