* [PATCH 1/2] [media] ad5820: use __maybe_unused for PM functions
@ 2016-09-12 15:32 Arnd Bergmann
2016-09-12 15:32 ` [PATCH 2/2] [media] atmel-isc: mark PM functions as __maybe_unused Arnd Bergmann
2016-09-12 17:52 ` [PATCH 1/2] [media] ad5820: use __maybe_unused for PM functions Pavel Machek
0 siblings, 2 replies; 5+ messages in thread
From: Arnd Bergmann @ 2016-09-12 15:32 UTC (permalink / raw)
To: Mauro Carvalho Chehab
Cc: Arnd Bergmann, Sakari Ailus, Pali Rohár, Pavel Machek,
linux-media, linux-kernel
The new ad5820 driver uses #ifdef to hide the suspend/resume functions,
but gets it wrong when CONFIG_PM_SLEEP is disabled:
drivers/media/i2c/ad5820.c:286:12: error: 'ad5820_resume' defined but not used [-Werror=unused-function]
drivers/media/i2c/ad5820.c:274:12: error: 'ad5820_suspend' defined but not used [-Werror=unused-function]
This replaces the #ifdef with a __maybe_unused annotation that is
simpler and harder to get wrong, avoiding the warning.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Fixes: bee3d5115611 ("[media] ad5820: Add driver for auto-focus coil")
---
drivers/media/i2c/ad5820.c | 13 ++-----------
1 file changed, 2 insertions(+), 11 deletions(-)
diff --git a/drivers/media/i2c/ad5820.c b/drivers/media/i2c/ad5820.c
index fd4c5f67163d..beab2f381b81 100644
--- a/drivers/media/i2c/ad5820.c
+++ b/drivers/media/i2c/ad5820.c
@@ -269,9 +269,7 @@ static const struct v4l2_subdev_internal_ops ad5820_internal_ops = {
/*
* I2C driver
*/
-#ifdef CONFIG_PM
-
-static int ad5820_suspend(struct device *dev)
+static int __maybe_unused ad5820_suspend(struct device *dev)
{
struct i2c_client *client = container_of(dev, struct i2c_client, dev);
struct v4l2_subdev *subdev = i2c_get_clientdata(client);
@@ -283,7 +281,7 @@ static int ad5820_suspend(struct device *dev)
return ad5820_power_off(coil, false);
}
-static int ad5820_resume(struct device *dev)
+static int __maybe_unused ad5820_resume(struct device *dev)
{
struct i2c_client *client = container_of(dev, struct i2c_client, dev);
struct v4l2_subdev *subdev = i2c_get_clientdata(client);
@@ -295,13 +293,6 @@ static int ad5820_resume(struct device *dev)
return ad5820_power_on(coil, true);
}
-#else
-
-#define ad5820_suspend NULL
-#define ad5820_resume NULL
-
-#endif /* CONFIG_PM */
-
static int ad5820_probe(struct i2c_client *client,
const struct i2c_device_id *devid)
{
--
2.9.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] [media] atmel-isc: mark PM functions as __maybe_unused
2016-09-12 15:32 [PATCH 1/2] [media] ad5820: use __maybe_unused for PM functions Arnd Bergmann
@ 2016-09-12 15:32 ` Arnd Bergmann
2016-09-13 2:11 ` Wu, Songjun
2016-09-12 17:52 ` [PATCH 1/2] [media] ad5820: use __maybe_unused for PM functions Pavel Machek
1 sibling, 1 reply; 5+ messages in thread
From: Arnd Bergmann @ 2016-09-12 15:32 UTC (permalink / raw)
To: Mauro Carvalho Chehab
Cc: Arnd Bergmann, Songjun Wu, Hans Verkuil, linux-media,
linux-kernel
The newly added atmel-isc driver uses SET_RUNTIME_PM_OPS() to
refer to its suspend/resume functions, causing a warning when
CONFIG_PM is not set:
media/platform/atmel/atmel-isc.c:1477:12: error: 'isc_runtime_resume' defined but not used [-Werror=unused-function]
media/platform/atmel/atmel-isc.c:1467:12: error: 'isc_runtime_suspend' defined but not used [-Werror=unused-function]
This adds __maybe_unused annotations to avoid the warning without
adding an error-prone #ifdef around it.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/media/platform/atmel/atmel-isc.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/media/platform/atmel/atmel-isc.c b/drivers/media/platform/atmel/atmel-isc.c
index db6773de92f0..a9ab7ae89f04 100644
--- a/drivers/media/platform/atmel/atmel-isc.c
+++ b/drivers/media/platform/atmel/atmel-isc.c
@@ -1464,7 +1464,7 @@ static int atmel_isc_remove(struct platform_device *pdev)
return 0;
}
-static int isc_runtime_suspend(struct device *dev)
+static int __maybe_unused isc_runtime_suspend(struct device *dev)
{
struct isc_device *isc = dev_get_drvdata(dev);
@@ -1474,7 +1474,7 @@ static int isc_runtime_suspend(struct device *dev)
return 0;
}
-static int isc_runtime_resume(struct device *dev)
+static int __maybe_unused isc_runtime_resume(struct device *dev)
{
struct isc_device *isc = dev_get_drvdata(dev);
int ret;
--
2.9.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] [media] ad5820: use __maybe_unused for PM functions
2016-09-12 15:32 [PATCH 1/2] [media] ad5820: use __maybe_unused for PM functions Arnd Bergmann
2016-09-12 15:32 ` [PATCH 2/2] [media] atmel-isc: mark PM functions as __maybe_unused Arnd Bergmann
@ 2016-09-12 17:52 ` Pavel Machek
2016-09-13 8:31 ` Sakari Ailus
1 sibling, 1 reply; 5+ messages in thread
From: Pavel Machek @ 2016-09-12 17:52 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Mauro Carvalho Chehab, Sakari Ailus, Pali Rohár, linux-media,
linux-kernel
On Mon 2016-09-12 17:32:57, Arnd Bergmann wrote:
> The new ad5820 driver uses #ifdef to hide the suspend/resume functions,
> but gets it wrong when CONFIG_PM_SLEEP is disabled:
>
> drivers/media/i2c/ad5820.c:286:12: error: 'ad5820_resume' defined but not used [-Werror=unused-function]
> drivers/media/i2c/ad5820.c:274:12: error: 'ad5820_suspend' defined but not used [-Werror=unused-function]
>
> This replaces the #ifdef with a __maybe_unused annotation that is
> simpler and harder to get wrong, avoiding the warning.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> Fixes: bee3d5115611 ("[media] ad5820: Add driver for auto-focus
coil")
Thanks!
Acked-by: Pavel Machek <pavel@ucw.cz>
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] [media] atmel-isc: mark PM functions as __maybe_unused
2016-09-12 15:32 ` [PATCH 2/2] [media] atmel-isc: mark PM functions as __maybe_unused Arnd Bergmann
@ 2016-09-13 2:11 ` Wu, Songjun
0 siblings, 0 replies; 5+ messages in thread
From: Wu, Songjun @ 2016-09-13 2:11 UTC (permalink / raw)
To: Arnd Bergmann, Mauro Carvalho Chehab
Cc: Hans Verkuil, linux-media, linux-kernel, Nicolas Ferre
Hi Arnd,
Thank you for your patch.
I think it's better to add switch CONFIG_PM, but the PM feature is a
must, or the ISC can not work, maybe the best choice is to add 'depends
on PM' in Kconfig.
#ifdef CONFIG_PM
isc_runtime_suspend
{
XXX
}
isc_runtime_resume
{
XXX
}
static const struct dev_pm_ops atmel_isc_dev_pm_ops = {
SET_RUNTIME_PM_OPS(isc_runtime_suspend, isc_runtime_resume, NULL)
};
#define ATMEL_ISC_PM_OPS (&atmel_isc_dev_pm_ops)
#else
#define ATMEL_ISC_PM_OPS NULL
#endif
static struct platform_driver atmel_isc_driver = {
.probe = atmel_isc_probe,
.remove = atmel_isc_remove,
.driver = {
.name = ATMEL_ISC_NAME,
.pm = ATMEL_ISC_PM_OPS,
.of_match_table = of_match_ptr(atmel_isc_of_match),
},
};
On 9/12/2016 23:32, Arnd Bergmann wrote:
> The newly added atmel-isc driver uses SET_RUNTIME_PM_OPS() to
> refer to its suspend/resume functions, causing a warning when
> CONFIG_PM is not set:
>
> media/platform/atmel/atmel-isc.c:1477:12: error: 'isc_runtime_resume' defined but not used [-Werror=unused-function]
> media/platform/atmel/atmel-isc.c:1467:12: error: 'isc_runtime_suspend' defined but not used [-Werror=unused-function]
>
> This adds __maybe_unused annotations to avoid the warning without
> adding an error-prone #ifdef around it.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> drivers/media/platform/atmel/atmel-isc.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/media/platform/atmel/atmel-isc.c b/drivers/media/platform/atmel/atmel-isc.c
> index db6773de92f0..a9ab7ae89f04 100644
> --- a/drivers/media/platform/atmel/atmel-isc.c
> +++ b/drivers/media/platform/atmel/atmel-isc.c
> @@ -1464,7 +1464,7 @@ static int atmel_isc_remove(struct platform_device *pdev)
> return 0;
> }
>
> -static int isc_runtime_suspend(struct device *dev)
> +static int __maybe_unused isc_runtime_suspend(struct device *dev)
> {
> struct isc_device *isc = dev_get_drvdata(dev);
>
> @@ -1474,7 +1474,7 @@ static int isc_runtime_suspend(struct device *dev)
> return 0;
> }
>
> -static int isc_runtime_resume(struct device *dev)
> +static int __maybe_unused isc_runtime_resume(struct device *dev)
> {
> struct isc_device *isc = dev_get_drvdata(dev);
> int ret;
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] [media] ad5820: use __maybe_unused for PM functions
2016-09-12 17:52 ` [PATCH 1/2] [media] ad5820: use __maybe_unused for PM functions Pavel Machek
@ 2016-09-13 8:31 ` Sakari Ailus
0 siblings, 0 replies; 5+ messages in thread
From: Sakari Ailus @ 2016-09-13 8:31 UTC (permalink / raw)
To: Pavel Machek
Cc: Arnd Bergmann, Mauro Carvalho Chehab, Sakari Ailus,
Pali Rohár, linux-media, linux-kernel
On Mon, Sep 12, 2016 at 07:52:08PM +0200, Pavel Machek wrote:
> On Mon 2016-09-12 17:32:57, Arnd Bergmann wrote:
> > The new ad5820 driver uses #ifdef to hide the suspend/resume functions,
> > but gets it wrong when CONFIG_PM_SLEEP is disabled:
> >
> > drivers/media/i2c/ad5820.c:286:12: error: 'ad5820_resume' defined but not used [-Werror=unused-function]
> > drivers/media/i2c/ad5820.c:274:12: error: 'ad5820_suspend' defined but not used [-Werror=unused-function]
> >
> > This replaces the #ifdef with a __maybe_unused annotation that is
> > simpler and harder to get wrong, avoiding the warning.
> >
> > Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> > Fixes: bee3d5115611 ("[media] ad5820: Add driver for auto-focus
> coil")
>
> Thanks!
>
> Acked-by: Pavel Machek <pavel@ucw.cz>
Thanks, Arnd and Pavel!
Added to my ad5820 branch.
--
Sakari Ailus
e-mail: sakari.ailus@iki.fi XMPP: sailus@retiisi.org.uk
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2016-09-13 8:31 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-12 15:32 [PATCH 1/2] [media] ad5820: use __maybe_unused for PM functions Arnd Bergmann
2016-09-12 15:32 ` [PATCH 2/2] [media] atmel-isc: mark PM functions as __maybe_unused Arnd Bergmann
2016-09-13 2:11 ` Wu, Songjun
2016-09-12 17:52 ` [PATCH 1/2] [media] ad5820: use __maybe_unused for PM functions Pavel Machek
2016-09-13 8:31 ` Sakari Ailus
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).