Fixed unaligned access
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
parent
597da1b76e
commit
97f3cc022c
|
@ -38,6 +38,7 @@
|
|||
#include <malloc.h>
|
||||
#include <common.h>
|
||||
#include <block.h>
|
||||
#include <asm/unaligned.h>
|
||||
|
||||
/**
|
||||
* Description of one partition table entry (D*S type)
|
||||
|
@ -97,25 +98,29 @@ static int disk_register_partitions(struct device_d *dev, struct partition_entry
|
|||
int part_order[4] = {0, 1, 2, 3};
|
||||
int i, rc;
|
||||
char drive_name[16], partition_name[19];
|
||||
u32 partition_start, partition_size;
|
||||
|
||||
/* TODO order the partitions */
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
partition_start = get_unaligned(&table[part_order[i]].partition_start);
|
||||
partition_size = get_unaligned(&table[part_order[i]].partition_size);
|
||||
|
||||
sprintf(drive_name, "%s%d", dev->name, dev->id);
|
||||
sprintf(partition_name, "%s%d.%d", dev->name, dev->id, i);
|
||||
if (table[part_order[i]].partition_start != 0) {
|
||||
if (partition_start != 0) {
|
||||
#if 1
|
||||
/* ignore partitions we can't handle due to 32 bit limits */
|
||||
if (table[part_order[i]].partition_start > 0x7fffff)
|
||||
if (partition_start > 0x7fffff)
|
||||
continue;
|
||||
if (table[part_order[i]].partition_size > 0x7fffff)
|
||||
if (partition_size > 0x7fffff)
|
||||
continue;
|
||||
#endif
|
||||
dev_dbg(dev, "Registering partition %s to drive %s\n",
|
||||
partition_name, drive_name);
|
||||
rc = devfs_add_partition(drive_name,
|
||||
table[part_order[i]].partition_start * SECTOR_SIZE,
|
||||
table[part_order[i]].partition_size * SECTOR_SIZE,
|
||||
partition_start * SECTOR_SIZE,
|
||||
partition_size * SECTOR_SIZE,
|
||||
DEVFS_PARTITION_FIXED, partition_name);
|
||||
if (rc != 0)
|
||||
dev_err(dev, "Failed to register partition %s (%d)\n", partition_name, rc);
|
||||
|
|
Loading…
Reference in New Issue