From: Jani Nikula <jani.nikula@intel.com>
To: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
Cc: igt-dev@lists.freedesktop.org
Subject: Re: [igt-dev] [PATCH i-g-t 3/3] tools/intel_vbt_decode: add --describe option
Date: Tue, 23 Jan 2018 16:58:08 +0200 [thread overview]
Message-ID: <87607s62rj.fsf@intel.com> (raw)
In-Reply-To: <20180123134720.GK5453@intel.com>
On Tue, 23 Jan 2018, Ville Syrjälä <ville.syrjala@linux.intel.com> wrote:
> On Tue, Jan 23, 2018 at 12:54:32PM +0200, Jani Nikula wrote:
>> Print description of the form <bdb-version>-<vbt-signature> that could
>> be used for e.g. filenames.
>>
>> Signed-off-by: Jani Nikula <jani.nikula@intel.com>
>> ---
>> tools/intel_vbt_decode.c | 40 ++++++++++++++++++++++++++++++++++++++--
>> 1 file changed, 38 insertions(+), 2 deletions(-)
>>
>> diff --git a/tools/intel_vbt_decode.c b/tools/intel_vbt_decode.c
>> index 00faca426145..d7cbc436c078 100644
>> --- a/tools/intel_vbt_decode.c
>> +++ b/tools/intel_vbt_decode.c
>> @@ -25,6 +25,7 @@
>> *
>> */
>>
>> +#include <ctype.h>
>> #include <errno.h>
>> #include <fcntl.h>
>> #include <getopt.h>
>> @@ -1662,6 +1663,33 @@ static bool dump_section(struct context *context, int section_id)
>> return true;
>> }
>>
>> +/* print a description of the VBT of the form <bdb-version>-<vbt-signature> */
>> +static void print_description(struct context *context)
>> +{
>> + const struct vbt_header *vbt = context->vbt;
>> + const struct bdb_header *bdb = context->bdb;
>> + char *desc = strndup((char *)vbt->signature, sizeof(vbt->signature));
>> + char *p;
>> +
>> + for (p = desc + strlen(desc) - 1; p >= desc && isspace(*p); p--)
>> + *p = '\0';
>> +
>> + for (p = desc; *p; p++) {
>> + if (!isalnum(*p))
>> + *p = '-';
>> + else
>> + *p = tolower(*p);
>> + }
>> +
>> + p = desc;
>> + if (strncmp(p, "-vbt-", 5) == 0)
>> + p += 5;
>
> Hmm. So this is getting rid of the "$VBT ". Maybe do that at the very
> beginning to make it a bit less obfuscated?
I've written this a while back actually, so didn't touch it now, and
pushed as-is. Can be improved later if it starts bugging us. ;)
Thanks for the review.
BR,
Jani.
>
> Either way series looks reasonable
> Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
>> +
>> + printf("%d-%s\n", bdb->version, p);
>> +
>> + free (desc);
>> +}
>> +
>> static void dump_headers(struct context *context)
>> {
>> const struct vbt_header *vbt = context->vbt;
>> @@ -1725,6 +1753,7 @@ enum opt {
>> OPT_BLOCK,
>> OPT_USAGE,
>> OPT_HEADER,
>> + OPT_DESCRIBE,
>> };
>>
>> static void usage(const char *toolname)
>> @@ -1737,6 +1766,7 @@ static void usage(const char *toolname)
>> " [--hexdump]"
>> " [--block=<block_no>]"
>> " [--header]"
>> + " [--describe]"
>> " [--help]\n");
>> }
>>
>> @@ -1757,7 +1787,7 @@ int main(int argc, char **argv)
>> };
>> char *endp;
>> int block_number = -1;
>> - bool header_only = false;
>> + bool header_only = false, describe = false;
>>
>> static struct option options[] = {
>> { "file", required_argument, NULL, OPT_FILE },
>> @@ -1767,6 +1797,7 @@ int main(int argc, char **argv)
>> { "hexdump", no_argument, NULL, OPT_HEXDUMP },
>> { "block", required_argument, NULL, OPT_BLOCK },
>> { "header", no_argument, NULL, OPT_HEADER },
>> + { "describe", no_argument, NULL, OPT_DESCRIBE },
>> { "help", no_argument, NULL, OPT_USAGE },
>> { 0 }
>> };
>> @@ -1810,6 +1841,9 @@ int main(int argc, char **argv)
>> case OPT_HEADER:
>> header_only = true;
>> break;
>> + case OPT_DESCRIBE:
>> + describe = true;
>> + break;
>> case OPT_END:
>> break;
>> case OPT_USAGE: /* fall-through */
>> @@ -1913,7 +1947,9 @@ int main(int argc, char **argv)
>> context.panel_type = 0;
>> }
>>
>> - if (header_only) {
>> + if (describe) {
>> + print_description(&context);
>> + } else if (header_only) {
>> dump_headers(&context);
>> } else if (block_number != -1) {
>> /* dump specific section only */
>> --
>> 2.11.0
>>
>> _______________________________________________
>> igt-dev mailing list
>> igt-dev@lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/igt-dev
--
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
next prev parent reply other threads:[~2018-01-23 14:52 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-23 10:54 [igt-dev] [PATCH i-g-t 1/3] tools/intel_vbt_decode: print child device count Jani Nikula
2018-01-23 10:54 ` [igt-dev] [PATCH i-g-t 2/3] tools/intel_vbt_decode: add --header option to only print header Jani Nikula
2018-01-23 10:54 ` [igt-dev] [PATCH i-g-t 3/3] tools/intel_vbt_decode: add --describe option Jani Nikula
2018-01-23 13:47 ` Ville Syrjälä
2018-01-23 14:58 ` Jani Nikula [this message]
2018-01-23 13:51 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [i-g-t,1/3] tools/intel_vbt_decode: print child device count Patchwork
2018-01-23 18:18 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87607s62rj.fsf@intel.com \
--to=jani.nikula@intel.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=ville.syrjala@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox