From patchwork Tue Aug 11 17:23:15 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liam Girdwood X-Patchwork-Id: 6994001 Return-Path: X-Original-To: patchwork-alsa-devel@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 B6C899F344 for ; Tue, 11 Aug 2015 17:27:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AA35020562 for ; Tue, 11 Aug 2015 17:27:51 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 7E9992060A for ; Tue, 11 Aug 2015 17:27:50 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 8E60B261546; Tue, 11 Aug 2015 19:27:49 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id CA3582605AA; Tue, 11 Aug 2015 19:27:22 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id C66B4260592; Tue, 11 Aug 2015 19:27:20 +0200 (CEST) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by alsa0.perex.cz (Postfix) with ESMTP id 4C78826057B for ; Tue, 11 Aug 2015 19:27:13 +0200 (CEST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP; 11 Aug 2015 10:23:24 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.15,654,1432623600"; d="scan'208";a="746537649" Received: from atwinomu-mobl1.ger.corp.intel.com (HELO loki.ger.corp.intel.com) ([10.252.21.203]) by orsmga001.jf.intel.com with ESMTP; 11 Aug 2015 10:23:21 -0700 From: Liam Girdwood To: Date: Tue, 11 Aug 2015 18:23:15 +0100 Message-Id: <1439313797-6169-2-git-send-email-liam.r.girdwood@linux.intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1439313797-6169-1-git-send-email-liam.r.girdwood@linux.intel.com> References: <1439313797-6169-1-git-send-email-liam.r.girdwood@linux.intel.com> Cc: Takashi Iwai , Liam Girdwood , Mark Brown Subject: [alsa-devel] [PATCH v3 1/3] core: add convenience macros to local.h X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP Move ARRAY_SIZE() from tplg_local.h to local.h and add container_of() macro to local.h. Both macros are generic but are initially used by topology. Signed-off-by: Liam Girdwood --- include/local.h | 7 +++++++ src/topology/tplg_local.h | 1 - 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/include/local.h b/include/local.h index 6600816..b429f5d 100644 --- a/include/local.h +++ b/include/local.h @@ -350,4 +350,11 @@ int snd_config_search_alias_hooks(snd_config_t *config, int _snd_conf_generic_id(const char *id); +/* convenience macros */ +#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0])) + +#define container_of(ptr, type, member) ({ \ + const typeof( ((type *)0)->member ) *__mptr = (ptr); \ + (type *)( (char *)__mptr - offsetof(type,member) );}) + #endif diff --git a/src/topology/tplg_local.h b/src/topology/tplg_local.h index febc177..3982cc7 100644 --- a/src/topology/tplg_local.h +++ b/src/topology/tplg_local.h @@ -32,7 +32,6 @@ #define MAX_FILE 256 #define TPLG_MAX_PRIV_SIZE (1024 * 128) #define ALSA_TPLG_DIR ALSA_CONFIG_DIR "/topology" -#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0])) /** The name of the environment variable containing the tplg directory */ #define ALSA_CONFIG_TPLG_VAR "ALSA_CONFIG_TPLG"