mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-05 18:39:59 +00:00
powerpc/nvram: Fix endian issue when using the partition length
When reading partitions, the length has to be translated from big endian to the endian order of the host. Similarly, when writing partitions, the length needs to be in big endian order. The userspace tool 'nvram' needs a similar fix as it is reading and writing partitions through /dev/nram : http://sourceforge.net/p/powerpc-utils/mailman/message/31571277/ Signed-off-by: Cedric Le Goater <clg@fr.ibm.com> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
This commit is contained in:
parent
563c5d8af5
commit
c81095a465
1 changed files with 8 additions and 2 deletions
|
@ -223,9 +223,13 @@ static int __init nvram_write_header(struct nvram_partition * part)
|
|||
{
|
||||
loff_t tmp_index;
|
||||
int rc;
|
||||
|
||||
struct nvram_header phead;
|
||||
|
||||
memcpy(&phead, &part->header, NVRAM_HEADER_LEN);
|
||||
phead.length = cpu_to_be16(phead.length);
|
||||
|
||||
tmp_index = part->index;
|
||||
rc = ppc_md.nvram_write((char *)&part->header, NVRAM_HEADER_LEN, &tmp_index);
|
||||
rc = ppc_md.nvram_write((char *)&phead, NVRAM_HEADER_LEN, &tmp_index);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
@ -505,6 +509,8 @@ int __init nvram_scan_partitions(void)
|
|||
|
||||
memcpy(&phead, header, NVRAM_HEADER_LEN);
|
||||
|
||||
phead.length = be16_to_cpu(phead.length);
|
||||
|
||||
err = 0;
|
||||
c_sum = nvram_checksum(&phead);
|
||||
if (c_sum != phead.checksum) {
|
||||
|
|
Loading…
Reference in a new issue