From patchwork Fri Feb 19 18:07:25 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Russell King - ARM Linux X-Patchwork-Id: 8363331 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 0357BC0553 for ; Fri, 19 Feb 2016 18:09:45 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C3BEB20547 for ; Fri, 19 Feb 2016 18:09:43 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C19882053D for ; Fri, 19 Feb 2016 18:09:42 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aWpTT-0003h3-27; Fri, 19 Feb 2016 18:08:15 +0000 Received: from pandora.arm.linux.org.uk ([2001:4d48:ad52:3201:214:fdff:fe10:1be6]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aWpTC-0003OX-Gp for linux-arm-kernel@lists.infradead.org; Fri, 19 Feb 2016 18:08:01 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=arm.linux.org.uk; s=pandora-2014; h=Sender:In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date; bh=nbZckdL7ELJjlrcrqaCirgQYyIh+0QWOWjEJghIW+9Y=; b=Wrpnhwbqf4Z3E9vN+WuCG5cWSvq9jtxse1IcekYtah8PRLnYRYDvktO6EkA/JU78Xxez6a16KSwB79SzRE9fJNQO3w7RAi2cEla0UAClm/JJkolip5luB4JHabR0zpnfHmPZojCgWLWOqeeohMnIjMLaw8rBl+Z5RXBlRsWnNH4=; Received: from n2100.arm.linux.org.uk ([2002:4e20:1eda:1:214:fdff:fe10:4f86]:46771) by pandora.arm.linux.org.uk with esmtpsa (TLSv1:DHE-RSA-AES256-SHA:256) (Exim 4.82_1-5b7a7c0-XX) (envelope-from ) id 1aWpSj-0001A2-BA; Fri, 19 Feb 2016 18:07:29 +0000 Received: from linux by n2100.arm.linux.org.uk with local (Exim 4.76) (envelope-from ) id 1aWpSg-0006Ad-1v; Fri, 19 Feb 2016 18:07:26 +0000 Date: Fri, 19 Feb 2016 18:07:25 +0000 From: Russell King - ARM Linux To: Nicolas Pitre Subject: Re: [PATCH 4/9] ARM: add CONFIG_PHYS_OFFSET default values Message-ID: <20160219180725.GB19428@n2100.arm.linux.org.uk> References: <1455804123-2526139-1-git-send-email-arnd@arndb.de> <3974581.yknKb3tq7o@wuerfel> <38246773.SnToSslHuj@wuerfel> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160219_100759_236885_D797C636 X-CRM114-Status: GOOD ( 22.16 ) X-Spam-Score: -4.3 (----) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jon Medhurst , Arnd Bergmann , Ard Biesheuvel , Marc Zyngier , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,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 On Fri, Feb 19, 2016 at 12:31:02PM -0500, Nicolas Pitre wrote: > Yet, the only reason for a default here is to accommodate automatic > build tests like randconfig, right? > > If so then this should be "fixed" by having the config system provide > built-in symbols that can be tested from kconfig files. This way you > could terminate the above list with: > > default 0x00000000 if RANDCONFIG || ALLYESCONFIG > > or the like. I've suggested in the past that we have kconf read a seed file for these configurations. kconf already has most of the required support for this, we just need to teach it where to read it from. Maybe something like this. arch/arm/allrandom.config | 1 + scripts/kconfig/conf.c | 61 ++++++++++++++++++++++++++++++++++++++--------- 2 files changed, 51 insertions(+), 11 deletions(-) diff --git a/arch/arm/allrandom.config b/arch/arm/allrandom.config index e69de29bb2d1..5a70ef5926f5 100644 --- a/arch/arm/allrandom.config +++ b/arch/arm/allrandom.config @@ -0,0 +1 @@ +CONFIG_PHYS_OFFSET=0 diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c index 866369f10ff8..5a4b2d8bbf9a 100644 --- a/scripts/kconfig/conf.c +++ b/scripts/kconfig/conf.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -489,10 +490,53 @@ static void conf_usage(const char *progname) printf(" --randconfig New config with random answer to all options\n"); } +static int try_allconfig(int try_arch, int input_mode) +{ + const char *name = NULL; + int fd = -1, ret; + + if (try_arch) { + const char *srctree = getenv("srctree"); + const char *arch = getenv("ARCH"); + + fd = open(".", O_DIRECTORY); + if (fd == -1) { + perror("opening ."); + return -1; + } + if (chdir(srctree) == -1 || + chdir("arch") == -1 || + chdir(arch) == -1) { + perror("chdir"); + return -1; + } + } + + switch (input_mode) { + case allnoconfig: name = "allno.config"; break; + case allyesconfig: name = "allyes.config"; break; + case allmodconfig: name = "allmod.config"; break; + case alldefconfig: name = "alldef.config"; break; + case randconfig: name = "allrandom.config"; break; + default: break; + } + + ret = name ? conf_read_simple(name, S_DEF_USER) : 1; + if (ret) + ret = conf_read_simple("all.config", S_DEF_USER); + + if (fd >= 0) { + fchdir(fd); + close(fd); + } + + return ret; +} + int main(int ac, char **av) { const char *progname = av[0]; - int opt; + int opt, ret; const char *name, *defconfig_file = NULL /* gcc uninit */; struct stat tmpstat; @@ -601,6 +645,9 @@ int main(int ac, char **av) case allmodconfig: case alldefconfig: case randconfig: + ret = try_allconfig(1, input_mode); + if (ret < 0) + exit(1); name = getenv("KCONFIG_ALLCONFIG"); if (!name) break; @@ -613,16 +660,8 @@ int main(int ac, char **av) } break; } - switch (input_mode) { - case allnoconfig: name = "allno.config"; break; - case allyesconfig: name = "allyes.config"; break; - case allmodconfig: name = "allmod.config"; break; - case alldefconfig: name = "alldef.config"; break; - case randconfig: name = "allrandom.config"; break; - default: break; - } - if (conf_read_simple(name, S_DEF_USER) && - conf_read_simple("all.config", S_DEF_USER)) { + ret = try_allconfig(0, input_mode); + if (ret) { fprintf(stderr, _("*** KCONFIG_ALLCONFIG set, but no \"%s\" or \"all.config\" file found\n"), name);