From patchwork Mon Nov 18 18:38:14 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Cooper X-Patchwork-Id: 3197691 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id B26239F43F for ; Mon, 18 Nov 2013 18:40:23 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 82D7520547 for ; Mon, 18 Nov 2013 18:40:22 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2785920249 for ; Mon, 18 Nov 2013 18:40:21 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ViTjS-0003yY-6T; Mon, 18 Nov 2013 18:39:34 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ViTjG-0002sA-Sp; Mon, 18 Nov 2013 18:39:22 +0000 Received: from mho-03-ewr.mailhop.org ([204.13.248.66] helo=mho-01-ewr.mailhop.org) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ViTiw-0002p0-3q for linux-arm-kernel@lists.infradead.org; Mon, 18 Nov 2013 18:39:03 +0000 Received: from pool-108-39-110-144.nrflva.fios.verizon.net ([108.39.110.144] helo=titan) by mho-01-ewr.mailhop.org with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.72) (envelope-from ) id 1ViTiZ-0004Jt-03; Mon, 18 Nov 2013 18:38:39 +0000 Received: from triton.localdomain (omega.lakedaemon.net [10.16.5.5]) by titan (Postfix) with ESMTP id F1C384DA227; Mon, 18 Nov 2013 13:38:35 -0500 (EST) X-Mail-Handler: Dyn Standard SMTP by Dyn X-Originating-IP: 108.39.110.144 X-Report-Abuse-To: abuse@dyndns.com (see http://www.dyndns.com/services/sendlabs/outbound_abuse.html for abuse reporting information) X-MHO-User: U2FsdGVkX19meMzPRGoVBodI1W2NVHBPyAxYiJRFnbY= From: Jason Cooper To: Rob Herring , Pawel Moll , Mark Rutland , Stephen Warren , Ian Campbell , Olof Johansson Subject: [RFC PATCH V2 1/2] dtc: add 'compat' output option, prints board string Date: Mon, 18 Nov 2013 18:38:14 +0000 Message-Id: <728deb9bbeab491a728da077aa5e47c0e01bccf8.1384798508.git.jason@lakedaemon.net> X-Mailer: git-send-email 1.8.4.3 In-Reply-To: References: <1384201760-16785-1-git-send-email-jason@lakedaemon.net> In-Reply-To: References: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20131118_133902_203986_423E1E4B X-CRM114-Status: GOOD ( 12.58 ) X-Spam-Score: -1.9 (-) Cc: devicetree@vger.kernel.org, Jason Cooper , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 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.7 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, 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 Consumers of the Linux kernel's build products are beginning to hardcode the filenames of the dtbs generated. Since the dtb filenames are currently the dts filename s/dts/dtb/, this prevents the kernel community from renaming dts files as needed. Let's provide a consistent naming structure for consumers to script against. Or at least, as consistent as the dts properties themselves. With this patch, adding the '-O compat' option to the dtc commandline will cause dtc to parse the provided file, and print out the board compatible string to stdout. This will facilitate an 'installdtbs.sh' script in the kernel for naming dtb files by their compatible string, eg: $ dtc -I dtb -O compat arch/arm/boot/dts/armada-370-mirabox.dtb globalscale,mirabox This change will also simplify distribution install scripts that need to search through many dtbs to find the right one for a target board. Signed-off-by: Jason Cooper --- changes since v1: - made patch against in-tree dtc code to facilitate testing - dtc prints compatible string to stdout now, instead of creating symlink - should be more flexible for end-users scripts/dtc/dtc.c | 3 +++ scripts/dtc/dtc.h | 1 + scripts/dtc/flattree.c | 9 +++++++++ 3 files changed, 13 insertions(+) diff --git a/scripts/dtc/dtc.c b/scripts/dtc/dtc.c index a375683c1534..89264bb0a3dd 100644 --- a/scripts/dtc/dtc.c +++ b/scripts/dtc/dtc.c @@ -68,6 +68,7 @@ static void __attribute__ ((noreturn)) usage(void) fprintf(stderr, "\t\tOutput formats are:\n"); fprintf(stderr, "\t\t\tdts - device tree source text\n"); fprintf(stderr, "\t\t\tdtb - device tree blob\n"); + fprintf(stderr, "\t\t\tcompat - print board compatible string\n"); fprintf(stderr, "\t\t\tasm - assembler source\n"); fprintf(stderr, "\t-V \n"); fprintf(stderr, "\t\tBlob version to produce, defaults to %d (relevant for dtb\n\t\tand asm output only)\n", DEFAULT_FDT_VERSION); @@ -250,6 +251,8 @@ int main(int argc, char *argv[]) dt_to_blob(outf, bi, outversion); } else if (streq(outform, "asm")) { dt_to_asm(outf, bi, outversion); + } else if (streq(outform, "compat")) { + dt_to_compat(bi); } else if (streq(outform, "null")) { /* do nothing */ } else { diff --git a/scripts/dtc/dtc.h b/scripts/dtc/dtc.h index 3e42a071070e..d4e47c697c2f 100644 --- a/scripts/dtc/dtc.h +++ b/scripts/dtc/dtc.h @@ -255,6 +255,7 @@ void process_checks(int force, struct boot_info *bi); void dt_to_blob(FILE *f, struct boot_info *bi, int version); void dt_to_asm(FILE *f, struct boot_info *bi, int version); +void dt_to_compat(struct boot_info *bi); struct boot_info *dt_from_blob(const char *fname); diff --git a/scripts/dtc/flattree.c b/scripts/dtc/flattree.c index 665dad7bb465..bdbd3d7e8964 100644 --- a/scripts/dtc/flattree.c +++ b/scripts/dtc/flattree.c @@ -577,6 +577,15 @@ void dt_to_asm(FILE *f, struct boot_info *bi, int version) data_free(strbuf); } +void dt_to_compat(struct boot_info *bi) +{ + struct property *prop; + + prop = get_property(bi->dt, "compatible"); + + printf("%s\n", prop->val.val); +} + struct inbuf { char *base, *limit, *ptr; };