From patchwork Mon Oct 8 23:56:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Jiang X-Patchwork-Id: 10631725 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 E3BFC13AA for ; Mon, 8 Oct 2018 23:56:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D4E7329971 for ; Mon, 8 Oct 2018 23:56:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C9096299A2; Mon, 8 Oct 2018 23:56:39 +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 7CEAC29971 for ; Mon, 8 Oct 2018 23:56:39 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 752F621163DE3; Mon, 8 Oct 2018 16:56:39 -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.65; helo=mga03.intel.com; envelope-from=dave.jiang@intel.com; receiver=linux-nvdimm@lists.01.org Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (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 B625F2114083E for ; Mon, 8 Oct 2018 16:56:37 -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 orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Oct 2018 16:56:37 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,358,1534834800"; d="scan'208";a="269600773" Received: from djiang5-desk3.ch.intel.com ([143.182.136.93]) by fmsmga005.fm.intel.com with ESMTP; 08 Oct 2018 16:56:36 -0700 Subject: [PATCH v12 12/12] acpi, nfit: Move acpi_nfit_get_security_ops() to generic location From: Dave Jiang To: dan.j.williams@intel.com Date: Mon, 08 Oct 2018 16:56:36 -0700 Message-ID: <153904299685.60070.3336606945357072947.stgit@djiang5-desk3.ch.intel.com> In-Reply-To: <153904272246.60070.6230977215877367778.stgit@djiang5-desk3.ch.intel.com> References: <153904272246.60070.6230977215877367778.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