coresight: etm4x: fix unused function warning

Message ID 20191210203339.2830960-1-arnd@arndb.de
State Accepted
Commit 500589d8bd73cc4c1fc8dc433b675cea5fe79e86
Headers show
Series
  • coresight: etm4x: fix unused function warning
Related show

Commit Message

Arnd Bergmann Dec. 10, 2019, 8:33 p.m.
Some of the newly added code in the etm4x driver is inside of an #ifdef,
and some other code is outside of it, leading to a harmless warning when
CONFIG_CPU_PM is disabled:

drivers/hwtracing/coresight/coresight-etm4x.c:68:13: error: 'etm4_os_lock' defined but not used [-Werror=unused-function]
 static void etm4_os_lock(struct etmv4_drvdata *drvdata)
             ^~~~~~~~~~~~

To avoid the warning and simplify the the #ifdef checks, use
IS_ENABLED() instead, so the compiler can drop the unused functions
without complaining.

Fixes: f188b5e76aae ("coresight: etm4x: Save/restore state across CPU low power states")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>

---
 drivers/hwtracing/coresight/coresight-etm4x.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

-- 
2.20.0

Comments

Mathieu Poirier Dec. 12, 2019, 5:19 p.m. | #1
On Tue, 10 Dec 2019 at 13:33, Arnd Bergmann <arnd@arndb.de> wrote:
>

> Some of the newly added code in the etm4x driver is inside of an #ifdef,

> and some other code is outside of it, leading to a harmless warning when

> CONFIG_CPU_PM is disabled:

>

> drivers/hwtracing/coresight/coresight-etm4x.c:68:13: error: 'etm4_os_lock' defined but not used [-Werror=unused-function]

>  static void etm4_os_lock(struct etmv4_drvdata *drvdata)

>              ^~~~~~~~~~~~

>

> To avoid the warning and simplify the the #ifdef checks, use

> IS_ENABLED() instead, so the compiler can drop the unused functions

> without complaining.

>

> Fixes: f188b5e76aae ("coresight: etm4x: Save/restore state across CPU low power states")

> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

> ---

>  drivers/hwtracing/coresight/coresight-etm4x.c | 13 ++++++-------

>  1 file changed, 6 insertions(+), 7 deletions(-)

>

> diff --git a/drivers/hwtracing/coresight/coresight-etm4x.c b/drivers/hwtracing/coresight/coresight-etm4x.c

> index dc3f507e7562..a90d757f7043 100644

> --- a/drivers/hwtracing/coresight/coresight-etm4x.c

> +++ b/drivers/hwtracing/coresight/coresight-etm4x.c

> @@ -1132,7 +1132,6 @@ static void etm4_init_trace_id(struct etmv4_drvdata *drvdata)

>         drvdata->trcid = coresight_get_trace_id(drvdata->cpu);

>  }

>

> -#ifdef CONFIG_CPU_PM

>  static int etm4_cpu_save(struct etmv4_drvdata *drvdata)

>  {

>         int i, ret = 0;

> @@ -1402,17 +1401,17 @@ static struct notifier_block etm4_cpu_pm_nb = {

>

>  static int etm4_cpu_pm_register(void)

>  {

> -       return cpu_pm_register_notifier(&etm4_cpu_pm_nb);

> +       if (IS_ENABLED(CONFIG_CPU_PM))

> +               return cpu_pm_register_notifier(&etm4_cpu_pm_nb);

> +

> +       return 0;

>  }

>

>  static void etm4_cpu_pm_unregister(void)

>  {

> -       cpu_pm_unregister_notifier(&etm4_cpu_pm_nb);

> +       if (IS_ENABLED(CONFIG_CPU_PM))

> +               cpu_pm_unregister_notifier(&etm4_cpu_pm_nb);

>  }

> -#else

> -static int etm4_cpu_pm_register(void) { return 0; }

> -static void etm4_cpu_pm_unregister(void) { }

> -#endif


I have applied this.

Thanks,
Mathieu

>

>  static int etm4_probe(struct amba_device *adev, const struct amba_id *id)

>  {

> --

> 2.20.0

>

Patch

diff --git a/drivers/hwtracing/coresight/coresight-etm4x.c b/drivers/hwtracing/coresight/coresight-etm4x.c
index dc3f507e7562..a90d757f7043 100644
--- a/drivers/hwtracing/coresight/coresight-etm4x.c
+++ b/drivers/hwtracing/coresight/coresight-etm4x.c
@@ -1132,7 +1132,6 @@  static void etm4_init_trace_id(struct etmv4_drvdata *drvdata)
 	drvdata->trcid = coresight_get_trace_id(drvdata->cpu);
 }
 
-#ifdef CONFIG_CPU_PM
 static int etm4_cpu_save(struct etmv4_drvdata *drvdata)
 {
 	int i, ret = 0;
@@ -1402,17 +1401,17 @@  static struct notifier_block etm4_cpu_pm_nb = {
 
 static int etm4_cpu_pm_register(void)
 {
-	return cpu_pm_register_notifier(&etm4_cpu_pm_nb);
+	if (IS_ENABLED(CONFIG_CPU_PM))
+		return cpu_pm_register_notifier(&etm4_cpu_pm_nb);
+
+	return 0;
 }
 
 static void etm4_cpu_pm_unregister(void)
 {
-	cpu_pm_unregister_notifier(&etm4_cpu_pm_nb);
+	if (IS_ENABLED(CONFIG_CPU_PM))
+		cpu_pm_unregister_notifier(&etm4_cpu_pm_nb);
 }
-#else
-static int etm4_cpu_pm_register(void) { return 0; }
-static void etm4_cpu_pm_unregister(void) { }
-#endif
 
 static int etm4_probe(struct amba_device *adev, const struct amba_id *id)
 {