From patchwork Thu Sep 27 02:22:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 10617157 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 8470F16B1 for ; Thu, 27 Sep 2018 02:34:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 73B5D296CE for ; Thu, 27 Sep 2018 02:34:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 681542A2A0; Thu, 27 Sep 2018 02:34:34 +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 1B2BB296CE for ; Thu, 27 Sep 2018 02:34:34 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 137EF21159903; Wed, 26 Sep 2018 19:34:34 -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=dan.j.williams@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 EC67A21157FF0 for ; Wed, 26 Sep 2018 19:34:32 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Sep 2018 19:34:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,308,1534834800"; d="scan'208";a="77606709" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.16]) by orsmga006.jf.intel.com with ESMTP; 26 Sep 2018 19:34:21 -0700 Subject: [PATCH] acpi, nfit: Move acpi_nfit_get_security_ops() to generic location From: Dan Williams To: dave.jiang@intel.com Date: Wed, 26 Sep 2018 19:22:33 -0700 Message-ID: <153801495364.825550.11754266200142595221.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: StGit/0.18-2-gc94f 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: linux-nvdimm@lists.01.org Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP 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. Signed-off-by: Dan Williams Reviewed-by: Dave Jiang --- 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