tools/firmware/ihex2fw: Simplify next record offset calculation
authorAndrey Smirnov <andrew.smirnov@gmail.com>
Fri, 21 Dec 2018 07:28:40 +0000 (23:28 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 22 Jan 2019 09:23:17 +0000 (10:23 +0100)
commit2ef8179bb7a6817de3fc9407ab55aa357f2d1e4d
treec332bc00c3006f2d0a347e1a1409c169d37d9d34
parent9fb4ab4d3dd665a62da9c176a89e7c7feaf5d9e4
tools/firmware/ihex2fw: Simplify next record offset calculation

We can convert original expression for 'writelen" to use ALIGN as
follows:

    (p->len + 9) & ~3 => (p->len + 6 + 3) & ~3 => ALIGN(p->len + 6, 4)

Now, subsituting "p->len + 6" with "p->len + sizeof(p->addr) +
sizeof(p->len)" we end up with the same expression as used by kernel
couterpart in linux/ihex.h:

    ALIGN(p->len + sizeof(p->addr) + sizeof(p->len), 4)

That is a full size of the record, aligned to 4 bytes. No functional
change intended.

Cc: Chris Healy <cphealy@gmail.com>
Cc: Kyle McMartin <kyle@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-kernel <linux-kernel@vger.kernel.org>
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
tools/firmware/ihex2fw.c