diff mbox series

nfit: Hide unused functions behind CONFIG_X86

Message ID 20190108045853.5471-1-natechancellor@gmail.com (mailing list archive)
State Not Applicable, archived
Headers show
Series nfit: Hide unused functions behind CONFIG_X86 | expand

Commit Message

Nathan Chancellor Jan. 8, 2019, 4:58 a.m. UTC
On arm64 little endian allyesconfig:

drivers/acpi/nfit/intel.c:149:12: warning: unused function 'intel_security_unlock' [-Wunused-function]
static int intel_security_unlock(struct nvdimm *nvdimm,
           ^
drivers/acpi/nfit/intel.c:230:12: warning: unused function 'intel_security_erase' [-Wunused-function]
static int intel_security_erase(struct nvdimm *nvdimm,
           ^
drivers/acpi/nfit/intel.c:279:12: warning: unused function 'intel_security_query_overwrite' [-Wunused-function]
static int intel_security_query_overwrite(struct nvdimm *nvdimm)
           ^
drivers/acpi/nfit/intel.c:316:12: warning: unused function 'intel_security_overwrite' [-Wunused-function]
static int intel_security_overwrite(struct nvdimm *nvdimm,
           ^
4 warnings generated.

These functions are only used in __intel_security_ops when CONFIG_X86 is
set so only define these functions under that same condition.

Fixes: 4c6926a23b76 ("acpi/nfit, libnvdimm: Add unlock of nvdimm support for Intel DIMMs")
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
---
 drivers/acpi/nfit/intel.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

Comments

Dan Williams Jan. 8, 2019, 5:14 a.m. UTC | #1
On Mon, Jan 7, 2019 at 8:59 PM Nathan Chancellor
<natechancellor@gmail.com> wrote:
>
> On arm64 little endian allyesconfig:
>
> drivers/acpi/nfit/intel.c:149:12: warning: unused function 'intel_security_unlock' [-Wunused-function]
> static int intel_security_unlock(struct nvdimm *nvdimm,
>            ^
> drivers/acpi/nfit/intel.c:230:12: warning: unused function 'intel_security_erase' [-Wunused-function]
> static int intel_security_erase(struct nvdimm *nvdimm,
>            ^
> drivers/acpi/nfit/intel.c:279:12: warning: unused function 'intel_security_query_overwrite' [-Wunused-function]
> static int intel_security_query_overwrite(struct nvdimm *nvdimm)
>            ^
> drivers/acpi/nfit/intel.c:316:12: warning: unused function 'intel_security_overwrite' [-Wunused-function]
> static int intel_security_overwrite(struct nvdimm *nvdimm,
>            ^
> 4 warnings generated.
>
> These functions are only used in __intel_security_ops when CONFIG_X86 is
> set so only define these functions under that same condition.

Thanks for the report, not sure how the kbuild robot missed this. I'd
prefer marking the functions __maybe_unused rather than expanding the
ifdef guards.
Nathan Chancellor Jan. 8, 2019, 5:18 a.m. UTC | #2
On Mon, Jan 07, 2019 at 09:14:05PM -0800, Dan Williams wrote:
> On Mon, Jan 7, 2019 at 8:59 PM Nathan Chancellor
> <natechancellor@gmail.com> wrote:
> >
> > On arm64 little endian allyesconfig:
> >
> > drivers/acpi/nfit/intel.c:149:12: warning: unused function 'intel_security_unlock' [-Wunused-function]
> > static int intel_security_unlock(struct nvdimm *nvdimm,
> >            ^
> > drivers/acpi/nfit/intel.c:230:12: warning: unused function 'intel_security_erase' [-Wunused-function]
> > static int intel_security_erase(struct nvdimm *nvdimm,
> >            ^
> > drivers/acpi/nfit/intel.c:279:12: warning: unused function 'intel_security_query_overwrite' [-Wunused-function]
> > static int intel_security_query_overwrite(struct nvdimm *nvdimm)
> >            ^
> > drivers/acpi/nfit/intel.c:316:12: warning: unused function 'intel_security_overwrite' [-Wunused-function]
> > static int intel_security_overwrite(struct nvdimm *nvdimm,
> >            ^
> > 4 warnings generated.
> >
> > These functions are only used in __intel_security_ops when CONFIG_X86 is
> > set so only define these functions under that same condition.
> 
> Thanks for the report, not sure how the kbuild robot missed this. I'd
> prefer marking the functions __maybe_unused rather than expanding the
> ifdef guards.

allyesconfig defaults to big endian, which doesn't built the nfit folder
(haven't looked into the dependency chain to see why). I have been
working with Clang and have a local patch to avoid turning on big endian
mode with it for now (avoids a few other warnings for now).

I can send a v2 with that change if you would like.

Thanks for the quick reply,
Nathan
diff mbox series

Patch

diff --git a/drivers/acpi/nfit/intel.c b/drivers/acpi/nfit/intel.c
index 850b2927b4e7..2ba0f1543940 100644
--- a/drivers/acpi/nfit/intel.c
+++ b/drivers/acpi/nfit/intel.c
@@ -144,6 +144,7 @@  static int intel_security_change_key(struct nvdimm *nvdimm,
 	}
 }
 
+#ifdef CONFIG_X86
 static void nvdimm_invalidate_cache(void);
 
 static int intel_security_unlock(struct nvdimm *nvdimm,
@@ -186,6 +187,7 @@  static int intel_security_unlock(struct nvdimm *nvdimm,
 
 	return 0;
 }
+#endif
 
 static int intel_security_disable(struct nvdimm *nvdimm,
 		const struct nvdimm_key_data *key_data)
@@ -227,6 +229,7 @@  static int intel_security_disable(struct nvdimm *nvdimm,
 	return 0;
 }
 
+#ifdef CONFIG_X86
 static int intel_security_erase(struct nvdimm *nvdimm,
 		const struct nvdimm_key_data *key,
 		enum nvdimm_passphrase_type ptype)
@@ -360,16 +363,10 @@  static int intel_security_overwrite(struct nvdimm *nvdimm,
  * TODO: define a cross arch wbinvd equivalent when/if
  * NVDIMM_FAMILY_INTEL command support arrives on another arch.
  */
-#ifdef CONFIG_X86
 static void nvdimm_invalidate_cache(void)
 {
 	wbinvd_on_all_cpus();
 }
-#else
-static void nvdimm_invalidate_cache(void)
-{
-	WARN_ON_ONCE("cache invalidation required after unlock\n");
-}
 #endif
 
 static const struct nvdimm_security_ops __intel_security_ops = {