From patchwork Mon Mar 14 23:38:45 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 8584381 Return-Path: X-Original-To: patchwork-linux-nvdimm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id E1A449F294 for ; Mon, 14 Mar 2016 23:39:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E0E47202A1 for ; Mon, 14 Mar 2016 23:39:17 +0000 (UTC) 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.kernel.org (Postfix) with ESMTPS id C0A4120251 for ; Mon, 14 Mar 2016 23:39:16 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 80AD71A1E91; Mon, 14 Mar 2016 16:39:33 -0700 (PDT) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by ml01.01.org (Postfix) with ESMTP id 0D9011A1E91 for ; Mon, 14 Mar 2016 16:39:32 -0700 (PDT) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga101.jf.intel.com with ESMTP; 14 Mar 2016 16:39:11 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,337,1455004800"; d="scan'208";a="669553691" Received: from dwillia2-desk3.jf.intel.com ([10.54.39.14]) by FMSMGA003.fm.intel.com with ESMTP; 14 Mar 2016 16:39:11 -0700 Subject: [ndctl PATCH] ndctl: fix definition of conditional functionality From: Dan Williams To: linux-nvdimm@lists.01.org Date: Mon, 14 Mar 2016 16:38:45 -0700 Message-ID: <20160314233845.35672.69216.stgit@dwillia2-desk3.jf.intel.com> User-Agent: StGit/0.17.1-9-g687f MIME-Version: 1.0 X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Resolve HAVE_NDCTL_ARS and HAVE_NDCTL_CLEAR_ERROR in libndctl.h from the results of configure. Signed-off-by: Dan Williams --- configure.ac | 21 +++++++++++++++++++++ lib/ndctl/libndctl.h.in | 20 +++++++++++--------- 2 files changed, 32 insertions(+), 9 deletions(-) rename lib/ndctl/{libndctl.h => libndctl.h.in} (98%) diff --git a/configure.ac b/configure.ac index 7e006641b197..1ab376885215 100644 --- a/configure.ac +++ b/configure.ac @@ -144,6 +144,27 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ) AM_CONDITIONAL([ENABLE_CLEAR_ERROR], [test "x$enable_clear_err" = "xyes"]) +AC_CONFIG_COMMANDS([gen-libndctl.h], + [[ + if test "x$enable_ars" = "xyes"; then + enable_ars=1 + else + enable_ars=0 + fi + if test "x$enable_clear_err" = "xyes"; then + enable_clear_err=1 + else + enable_clear_err=0 + fi + sed -e s/HAVE_NDCTL_ARS/$enable_ars/ \ + -e s/HAVE_NDCTL_CLEAR_ERROR/$enable_clear_err/ \ + < lib/ndctl/libndctl.h.in > lib/ndctl/libndctl.h + ]], + [[ + enable_ars=$enable_ars + enable_clear_err=$enable_clear_err + ]]) + AC_CHECK_HEADERS_ONCE([linux/version.h]) AC_CHECK_FUNCS([ \ diff --git a/lib/ndctl/libndctl.h b/lib/ndctl/libndctl.h.in similarity index 98% rename from lib/ndctl/libndctl.h rename to lib/ndctl/libndctl.h.in index 456288f66aee..b16f26dae535 100644 --- a/lib/ndctl/libndctl.h +++ b/lib/ndctl/libndctl.h.in @@ -148,7 +148,8 @@ int ndctl_dimm_disable(struct ndctl_dimm *dimm); int ndctl_dimm_enable(struct ndctl_dimm *dimm); struct ndctl_cmd; -#ifdef HAVE_NDCTL_ARS +#define HAS_ARS HAVE_NDCTL_ARS +#if HAS_ARS == 1 struct ndctl_cmd *ndctl_bus_cmd_new_ars_cap(struct ndctl_bus *bus, unsigned long long address, unsigned long long len); struct ndctl_cmd *ndctl_bus_cmd_new_ars_start(struct ndctl_cmd *ars_cap, int type); @@ -167,18 +168,18 @@ unsigned long long ndctl_cmd_ars_get_record_addr(struct ndctl_cmd *ars_stat, unsigned long long ndctl_cmd_ars_get_record_len(struct ndctl_cmd *ars_stat, unsigned int rec_index); -#ifdef HAVE_NDCTL_CLEAR_ERROR +#define HAS_CLEAR_ERROR HAVE_NDCTL_CLEAR_ERROR +#if HAS_CLEAR_ERROR == 1 /* - * clear_error requires ars_cap, so we require HAVE_NDCTL_ARS to export the - * clear_error capability + * clear_error requires ars_cap, so we require HAS_CLEAR_ERROR to export + * the clear_error capability */ struct ndctl_cmd *ndctl_bus_cmd_new_clear_error(unsigned long long address, unsigned long long len, struct ndctl_cmd *ars_cap); unsigned long long ndctl_cmd_clear_error_get_cleared( struct ndctl_cmd *clear_err); -#define HAS_CLEAR_ERROR 1 #endif -#else /* HAVE_NDCTL_ARS */ +#else /* HAS_ARS == 0 */ static inline struct ndctl_cmd *ndctl_bus_cmd_new_ars_cap(struct ndctl_bus *bus, unsigned long long address, unsigned long long len) { @@ -202,7 +203,7 @@ static inline unsigned int ndctl_cmd_ars_cap_get_size(struct ndctl_cmd *ars_cap) return 0; } - +struct ndctl_range; static inline int ndctl_cmd_ars_cap_get_range(struct ndctl_cmd *ars_cap, struct ndctl_range *range) { @@ -230,9 +231,10 @@ static inline unsigned long long ndctl_cmd_ars_get_record_len( { return 0; } -#endif /* HAVE_NDCTL_ARS */ +#define HAS_CLEAR_ERROR 0 +#endif /* HAS_ARS */ -#ifndef HAS_CLEAR_ERROR +#if HAS_CLEAR_ERROR == 0 static inline struct ndctl_cmd *ndctl_bus_cmd_new_clear_error( unsigned long long address, unsigned long long len, struct ndctl_cmd *ars_cap)