linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Michael Ellerman <mpe@ellerman.id.au>
To: <linuxppc-dev@lists.ozlabs.org>
Subject: [PATCH 3/3] macintosh/ams: Fix unused variable warning
Date: Wed,  6 Mar 2024 23:58:53 +1100	[thread overview]
Message-ID: <20240306125853.3714578-3-mpe@ellerman.id.au> (raw)
In-Reply-To: <20240306125853.3714578-1-mpe@ellerman.id.au>

If both CONFIG_SENSORS_AMS_PMU and CONFIG_SENSORS_AMS_I2C are unset,
there is an unused variable warning in the ams driver:

  drivers/macintosh/ams/ams-core.c: In function 'ams_init':
  drivers/macintosh/ams/ams-core.c:181:29: warning: unused variable 'np'
    181 |         struct device_node *np;

Fix it by using IS_ENABLED() to create a block for each case, and move
the variable declartion in there.

Probably the dependencies should be changed so that the driver can't be
built with both variants disabled, but that would be a larger change.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
 drivers/macintosh/ams/ams-core.c | 29 ++++++++++++++---------------
 1 file changed, 14 insertions(+), 15 deletions(-)

diff --git a/drivers/macintosh/ams/ams-core.c b/drivers/macintosh/ams/ams-core.c
index c978b4272daa..22d3e6605287 100644
--- a/drivers/macintosh/ams/ams-core.c
+++ b/drivers/macintosh/ams/ams-core.c
@@ -178,25 +178,24 @@ int ams_sensor_attach(void)
 
 static int __init ams_init(void)
 {
-	struct device_node *np;
-
 	spin_lock_init(&ams_info.irq_lock);
 	mutex_init(&ams_info.lock);
 	INIT_WORK(&ams_info.worker, ams_worker);
 
-#ifdef CONFIG_SENSORS_AMS_I2C
-	np = of_find_node_by_name(NULL, "accelerometer");
-	if (np && of_device_is_compatible(np, "AAPL,accelerometer_1"))
-		/* Found I2C motion sensor */
-		return ams_i2c_init(np);
-#endif
-
-#ifdef CONFIG_SENSORS_AMS_PMU
-	np = of_find_node_by_name(NULL, "sms");
-	if (np && of_device_is_compatible(np, "sms"))
-		/* Found PMU motion sensor */
-		return ams_pmu_init(np);
-#endif
+	if (IS_ENABLED(CONFIG_SENSORS_AMS_I2C)) {
+		struct device_node *np = of_find_node_by_name(NULL, "accelerometer");
+		if (np && of_device_is_compatible(np, "AAPL,accelerometer_1"))
+			/* Found I2C motion sensor */
+			return ams_i2c_init(np);
+	}
+
+	if (IS_ENABLED(CONFIG_SENSORS_AMS_PMU)) {
+		struct device_node *np = of_find_node_by_name(NULL, "sms");
+		if (np && of_device_is_compatible(np, "sms"))
+			/* Found PMU motion sensor */
+			return ams_pmu_init(np);
+	}
+
 	return -ENODEV;
 }
 
-- 
2.43.2


  parent reply	other threads:[~2024-03-06 13:01 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-06 12:58 [PATCH 1/3] powerpc/64s: Fix get_hugepd_cache_index() build failure Michael Ellerman
2024-03-06 12:58 ` [PATCH 2/3] powerpc/83xx: Fix build failure with FPU=n Michael Ellerman
2024-03-06 12:58 ` Michael Ellerman [this message]
2024-03-06 13:17   ` [PATCH 3/3] macintosh/ams: Fix unused variable warning Christophe Leroy
2024-03-07  5:32     ` Michael Ellerman
2024-03-07  6:29       ` Christophe Leroy
2024-03-13 13:19 ` (subset) [PATCH 1/3] powerpc/64s: Fix get_hugepd_cache_index() build failure Michael Ellerman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240306125853.3714578-3-mpe@ellerman.id.au \
    --to=mpe@ellerman.id.au \
    --cc=linuxppc-dev@lists.ozlabs.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).