From patchwork Mon Oct 1 12:21:19 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anisse Astier X-Patchwork-Id: 188285 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 0B22D2C0100 for ; Mon, 1 Oct 2012 22:28:14 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752517Ab2JAM1b (ORCPT ); Mon, 1 Oct 2012 08:27:31 -0400 Received: from mail-wi0-f172.google.com ([209.85.212.172]:64877 "EHLO mail-wi0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751828Ab2JAM1a (ORCPT ); Mon, 1 Oct 2012 08:27:30 -0400 Received: by mail-wi0-f172.google.com with SMTP id hq12so2664823wib.1 for ; Mon, 01 Oct 2012 05:27:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:x-gm-message-state; bh=g7dsBn9I77mq4lP2BuJGPva3Zg2UqWhMq8OLzTky+jk=; b=BEqqHqkpxpIBFl6KebWG1mHfqBerZLBWloRYqzWJrxbssxNjCYfWeutC6G8hRbsPqi dpBueq9X+qNekeyyf2wWlXfAvYGqtML9JFgTw/646Zuy77VOE+gJiknpEto0J1xvETHT o07ToG2TjCj09ApsJzfOqYmcriNqjFhF37LnzPJDUU3Inbf5xxUrn5xOC/8mLZzTCM9l 1wu6B76eIMSOMpljwjqlsN2V52pIcE3YtPJT35d4y19EZ5nPGZ4OeX8aq6qFvT0rAm5S AnWyydanP85LO8CTvJok0tmj5GauaCfdt1/DIWxrducaJK84LSxnWT6n0F88G8g3Hai8 qVfw== Received: by 10.180.93.33 with SMTP id cr1mr14365295wib.8.1349094449197; Mon, 01 Oct 2012 05:27:29 -0700 (PDT) Received: from compilator-1.substantiel.local ([78.228.214.160]) by mx.google.com with ESMTPS id q7sm18395644wiy.11.2012.10.01.05.27.27 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 01 Oct 2012 05:27:28 -0700 (PDT) From: Anisse Astier To: linux-kernel@vger.kernel.org, netdev@vger.kernel.org Cc: Paul Gortmaker , Michal Marek , Linus Torvalds , Michael Chan , Matt Carlson , Anisse Astier Subject: [PATCH 1/2] kconfig: Introduce IS_DEPENDENCY_SATISFIED() Date: Mon, 1 Oct 2012 14:21:19 +0200 Message-Id: <1349094080-769-1-git-send-email-anisse@astier.eu> X-Mailer: git-send-email 1.7.10.3 X-Gm-Message-State: ALoCoQlSM8gprh+oitcZ+qPeEEvg9hkTwg8MjGQJ7iBAMf/E+qp6hSey665zScOtXHIacJpH/yZj Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Most of the time, when we use IS_ENABLED() it's to specify a dependency on a config option that might be enabled. But if this option is enabled as a module, and we are built-in, then we'll have missing symbols. This new macro is therefore useful to specify a dependency on another config. But it also needs to know our own config option in order to check if the dependency is properly satisfied. IS_DEPENDENCY_SATISFIED(CONFIG_SELF, CONFIG_FOO) evaluates to 1 if CONFIG_FOO is set to 'y' or 'm', and set the same as CONFIG_SELF. It evaluates to 0 otherwise. Signed-off-by: Anisse Astier --- include/linux/kconfig.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/include/linux/kconfig.h b/include/linux/kconfig.h index be342b9..8b8ec1f 100644 --- a/include/linux/kconfig.h +++ b/include/linux/kconfig.h @@ -43,4 +43,14 @@ */ #define IS_MODULE(option) config_enabled(option##_MODULE) + +/* + * IS_DEPENDENCY_SATISFIED(CONFIG_SELF, CONFIG_FOO) evaluates to 1 if + * CONFIG_FOO is set to 'y' or 'm', and set the same as CONFIG_SELF. + * Useful for specifying build-time config dependencies. + */ +#define IS_DEPENDENCY_SATISFIED(self, dependency) \ + ((config_enabled(self) && config_enabled(dependency)) || \ + (config_enabled(self##_MODULE) && config_enabled(dependency##_MODULE))) + #endif /* __LINUX_KCONFIG_H */