From patchwork Fri Sep 28 21:54:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Jiang X-Patchwork-Id: 10620371 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CBFE415A6 for ; Fri, 28 Sep 2018 21:54:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BA8CB2BFC5 for ; Fri, 28 Sep 2018 21:54:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AF16A2BFF4; Fri, 28 Sep 2018 21:54:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5558E2BFC5 for ; Fri, 28 Sep 2018 21:54:47 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 482752115C083; Fri, 28 Sep 2018 14:54:47 -0700 (PDT) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.24; helo=mga09.intel.com; envelope-from=dave.jiang@intel.com; receiver=linux-nvdimm@lists.01.org Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 818A021148DB4 for ; Fri, 28 Sep 2018 14:54:46 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Sep 2018 14:54:46 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,316,1534834800"; d="scan'208";a="266889783" Received: from djiang5-desk3.ch.intel.com ([143.182.136.93]) by fmsmga005.fm.intel.com with ESMTP; 28 Sep 2018 14:54:35 -0700 Subject: [PATCH v11 12/12] acpi, nfit: Move acpi_nfit_get_security_ops() to generic location From: Dave Jiang To: dan.j.williams@intel.com Date: Fri, 28 Sep 2018 14:54:34 -0700 Message-ID: <153817167456.17152.874519072328282288.stgit@djiang5-desk3.ch.intel.com> In-Reply-To: <153817140052.17152.8594371908103118425.stgit@djiang5-desk3.ch.intel.com> References: <153817140052.17152.8594371908103118425.stgit@djiang5-desk3.ch.intel.com> User-Agent: StGit/unknown-version MIME-Version: 1.0 X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alison.schofield@intel.com, keescook@chromium.org, linux-nvdimm@lists.01.org, ebiggers3@gmail.com, dhowells@redhat.com, keyrings@vger.kernel.org Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP From: Dan Williams In anticipation of other DIMMs adding security operations support, don't require them to edit intel.h. Instead have intel.h optionally arrange for intel_security_ops to be NULL or not based on build parameters. Reviewed-by: Dave Jiang Signed-off-by: Dan Williams --- drivers/acpi/nfit/core.c | 10 ++++++++++ drivers/acpi/nfit/intel.c | 3 ++- drivers/acpi/nfit/intel.h | 18 +++--------------- 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c index e5f7c664a7c8..b7773c70ee81 100644 --- a/drivers/acpi/nfit/core.c +++ b/drivers/acpi/nfit/core.c @@ -1835,6 +1835,16 @@ static void shutdown_dimm_notify(void *data) mutex_unlock(&acpi_desc->init_mutex); } +static const struct nvdimm_security_ops *acpi_nfit_get_security_ops(int family) +{ + switch (family) { + case NVDIMM_FAMILY_INTEL: + return intel_security_ops; + default: + return NULL; + } +} + static int acpi_nfit_register_dimms(struct acpi_nfit_desc *acpi_desc) { struct nfit_mem *nfit_mem; diff --git a/drivers/acpi/nfit/intel.c b/drivers/acpi/nfit/intel.c index 70bccb0c57e2..8d2413810a5f 100644 --- a/drivers/acpi/nfit/intel.c +++ b/drivers/acpi/nfit/intel.c @@ -358,7 +358,7 @@ static int intel_dimm_security_state(struct nvdimm *nvdimm, return rc; } -const struct nvdimm_security_ops intel_security_ops = { +static const struct nvdimm_security_ops __intel_security_ops = { .state = intel_dimm_security_state, .unlock = intel_dimm_security_unlock, .change_key = intel_dimm_security_update_passphrase, @@ -366,3 +366,4 @@ const struct nvdimm_security_ops intel_security_ops = { .freeze_lock = intel_dimm_security_freeze_lock, .erase = intel_dimm_security_erase, }; +const struct nvdimm_security_ops *intel_security_ops = &__intel_security_ops; diff --git a/drivers/acpi/nfit/intel.h b/drivers/acpi/nfit/intel.h index f9ac718776ca..f831084f95fa 100644 --- a/drivers/acpi/nfit/intel.h +++ b/drivers/acpi/nfit/intel.h @@ -8,7 +8,7 @@ #ifdef CONFIG_X86 -extern const struct nvdimm_security_ops intel_security_ops; +extern const struct nvdimm_security_ops *intel_security_ops; #define ND_INTEL_STATUS_SIZE 4 #define ND_INTEL_PASSPHRASE_SIZE 32 @@ -64,19 +64,7 @@ struct nd_intel_overwrite { struct nd_intel_query_overwrite { u32 status; } __packed; +#else /* CONFIG_X86 */ +#define intel_security_ops (NULL) #endif /* CONFIG_X86 */ - -static inline const struct nvdimm_security_ops * -acpi_nfit_get_security_ops(int family) -{ - switch (family) { -#ifdef CONFIG_X86 - case NVDIMM_FAMILY_INTEL: - return &intel_security_ops; -#endif - default: - return NULL; - } -} - #endif