From: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
To: Antony Pavlov <antonynpavlov@gmail.com>
Cc: barebox@lists.infradead.org
Subject: Re: [RFC] gen-dtb-s: make metadata binary fields always little-endian
Date: Mon, 4 Aug 2014 08:31:27 +0200 [thread overview]
Message-ID: <20140804063127.GI6146@pengutronix.de> (raw)
In-Reply-To: <20140803215338.3b436b58bf5d796c46dd23bd@gmail.com>
On Sun, Aug 03, 2014 at 09:53:38PM +0400, Antony Pavlov wrote:
> On Sun, 03 Aug 2014 18:17:45 +0200
> Jan Lübbe <jlu@pengutronix.de> wrote:
>
> > Hi,
> >
> > On Sat, 2014-08-02 at 09:45 +0400, Antony Pavlov wrote:
> > >
> > > compatlen=$($FDTGET -t s "$dtb" / compatible | wc -c)
> > > - echo ".int 0x640c8005"
> > > - echo ".int " $compatlen
> > > + echo ".byte 0x05, 0x80, 0x0c, 0x64"
> > > + python -c "print(\".byte 0x%02x, 0x%02x, 0x%02x, 0x%02x\\n\" % ($compatlen & 0xff, ($compatlen >> 8) & 0xff, ($compatlen >> 16) & 0xff, ($compatlen >> 24) & 0xff))"
> >
> > Rather than adding a build-time dependency on python, maybe we should
> > just handle this in C?
>
> We use sphinx for documentation generation so we already have dependency on python.
>
> Here is an another solution:
>
> - echo ".int " $compatlen
> + echo ".byte " $(printf "%08x" $compatlen | sed "s/\(..\)/0x\1\n/g" | tac | xargs | sed "s/ /, /g")
yet another alternative:
awk -v var=$compatlen 'BEGIN { for (i = 0; i < 4; ++i) ba[i] = and(rshift(var, 8 * i), 0xff); printf ".byte 0x%02x, 0x%02x, 0x%02x, 0x%02x\n", ba[0], ba[1], ba[2], ba[3]; }'
It's not shorter, but maybe a bit more obvious what it does.
Best regards
Uwe
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | http://www.pengutronix.de/ |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2014-08-04 6:31 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-02 5:45 Antony Pavlov
2014-08-03 16:17 ` Jan Lübbe
2014-08-03 17:53 ` Antony Pavlov
2014-08-04 6:31 ` Uwe Kleine-König [this message]
2014-08-04 17:34 ` Sascha Hauer
2014-08-04 19:19 ` Antony Pavlov
2014-08-06 4:00 ` Jean-Christophe PLAGNIOL-VILLARD
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=20140804063127.GI6146@pengutronix.de \
--to=u.kleine-koenig@pengutronix.de \
--cc=antonynpavlov@gmail.com \
--cc=barebox@lists.infradead.org \
/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