From patchwork Thu Jun 30 16:52:17 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 642707 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 3rgQdc2ssTz9s9n for ; Fri, 1 Jul 2016 02:55:16 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b=UewlS8vc; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 9D51AA75F8; Thu, 30 Jun 2016 18:54:17 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 6bw3bjm5v06V; Thu, 30 Jun 2016 18:54:17 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id C7E66A75E5; Thu, 30 Jun 2016 18:53:53 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 7ED2AA75F9 for ; Thu, 30 Jun 2016 18:53:04 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 8YJ9gThNaBSj for ; Thu, 30 Jun 2016 18:53:04 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-io0-f178.google.com (mail-io0-f178.google.com [209.85.223.178]) by theia.denx.de (Postfix) with ESMTPS id B33B8A75D7 for ; Thu, 30 Jun 2016 18:52:55 +0200 (CEST) Received: by mail-io0-f178.google.com with SMTP id f30so77273658ioj.2 for ; Thu, 30 Jun 2016 09:52:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=Fm1Kp0Bv6XXZYucqol2ghZFYT1tirVRiCL0si/hlw9I=; b=UewlS8vc3B3W4sqhCjax1W4gnWlv+OSZV4TuRmFKUKVM1B1EGxkFiWGHMJM5OJFx5k GnYPU1aLQMORSdGrb/EBQkWY1crxe6DOBMKmzcMLnduu8TD51Ex2umJbM069VAzbmZie 2XcOy2l0Hy43dXDGqZO535Ov9WMgnxZFQBEkAYBCtIGNfhKLGzjBCnRIF4vzHU1/IvT1 k6NUTjdTkLcZExLxGuN0Gdn6UEp9l/5aSkRtY3HPHLLb4CjCKwSp+FLjlmcs7JdMEsiw ZRZRknIKBIc0WQC8dpQ0ZdDdVdwAs7N0IGL0QeIAw87Ol/O4CTWclkUXebOP//1Tasi4 AIHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=Fm1Kp0Bv6XXZYucqol2ghZFYT1tirVRiCL0si/hlw9I=; b=gxkYMSGIyH8kWw768FH9REZ7MluG4MJkC7EmHwRhc5hmhiKFaZo/aqmP3j44I+waNx GqHyyyW8HWZVrTZYGK7O9WTEWvP+xlvHkajiALFCFbapILYJEayImc1JMIW2QCsd9cfS TfrXb6ArTlNbddLnGVBJjbwTlKVW94t6eyHQz/0YkWAX+9DS/Mi7pTESVjFS+v55jitt j0mQk2gUpNHxifL2ThQVwRRPd7Ac7JTvEYWhVdRw3gvHtth9GSnl53den7TgEUSwNZOM thbwMNt/KwLZeSyABjy1cDOquoJI3i6jftym1wMZdYcy61tWgyBpn+V1iiBI7z1zYllJ wfQg== X-Gm-Message-State: ALyK8tIa5rkLcQ2pCt1s7IlLtyGsd1dkjmiinO2n4IQZ8sgXwzIVC0EJZ69Bxi1MbAArL8N4 X-Received: by 10.107.35.148 with SMTP id j142mr17080843ioj.52.1467305565163; Thu, 30 Jun 2016 09:52:45 -0700 (PDT) Received: from kaki.bld.corp.google.com ([100.100.202.57]) by smtp.gmail.com with ESMTPSA id v129sm7659378itg.10.2016.06.30.09.52.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Jun 2016 09:52:42 -0700 (PDT) Received: by kaki.bld.corp.google.com (Postfix, from userid 121222) id 81B322220A5; Thu, 30 Jun 2016 10:52:40 -0600 (MDT) From: Simon Glass To: U-Boot Mailing List Date: Thu, 30 Jun 2016 10:52:17 -0600 Message-Id: <1467305540-13607-12-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 2.8.0.rc3.226.g39d4020 In-Reply-To: <1467305540-13607-1-git-send-email-sjg@chromium.org> References: <1467305540-13607-1-git-send-email-sjg@chromium.org> Cc: Tom Rini , Vinoth Eswaran , Joe Hershberger Subject: [U-Boot] [PATCH 11/14] mkimage: Allow display of a list of any image header category X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Add a generic function which can display a list of items in any category. This will allow displaying of images for the -A, -C, -O and -T flags. At present only -T is supported. Signed-off-by: Simon Glass Reviewed-by: Tom Rini --- tools/mkimage.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/tools/mkimage.c b/tools/mkimage.c index 920d3be..d375c2a 100644 --- a/tools/mkimage.c +++ b/tools/mkimage.c @@ -25,6 +25,49 @@ static struct image_tool_params params = { .imagename2 = "", }; +static enum ih_category cur_category; + +static int h_compare_category_name(const void *vtype1, const void *vtype2) +{ + const int *type1 = vtype1; + const int *type2 = vtype2; + const char *name1 = genimg_get_cat_short_name(cur_category, *type1); + const char *name2 = genimg_get_cat_short_name(cur_category, *type2); + + return strcmp(name1, name2); +} + +int show_valid_options(enum ih_category category) +{ + int *order; + int count; + int item; + int i; + + count = genimg_get_cat_count(category); + order = calloc(count, sizeof(*order)); + if (!order) + return -ENOMEM; + + /* Sort the names in order of short name for easier reading */ + for (item = 0; item < count; item++) + order[item] = item; + cur_category = category; + qsort(order, count, sizeof(int), h_compare_category_name); + + fprintf(stderr, "\nInvalid %s, supported are:\n", + genimg_get_cat_desc(category)); + for (i = 0; i < count; i++) { + item = order[i]; + fprintf(stderr, "\t%-15s %s\n", + genimg_get_cat_short_name(category, item), + genimg_get_cat_name(category, item)); + } + fprintf(stderr, "\n"); + + return 0; +} + static int h_compare_image_name(const void *vtype1, const void *vtype2) { const int *type1 = vtype1;