mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-19 03:15:00 +00:00
cmd: mvebu/bubt: a38x: Do not hardcode SATA block size to 512
Find SATA block device by blk_get_devnum_by_uclass_id() function and read from it the real block size of the SATA disk. In case of error, fallback back to 512 bytes. Signed-off-by: Pali Rohár <pali@kernel.org>
This commit is contained in:
parent
fa06a6df65
commit
4548b37a29
1 changed files with 5 additions and 2 deletions
|
@ -924,8 +924,11 @@ static int check_image_header(void)
|
||||||
offset = le32_to_cpu(hdr->srcaddr);
|
offset = le32_to_cpu(hdr->srcaddr);
|
||||||
size = le32_to_cpu(hdr->blocksize);
|
size = le32_to_cpu(hdr->blocksize);
|
||||||
|
|
||||||
if (hdr->blockid == 0x78) /* SATA id */
|
if (hdr->blockid == 0x78) { /* SATA id */
|
||||||
offset *= 512;
|
struct blk_desc *blk_dev = IS_ENABLED(BLK) ? blk_get_devnum_by_uclass_id(UCLASS_SCSI, 0) : NULL;
|
||||||
|
unsigned long blksz = blk_dev ? blk_dev->blksz : 512;
|
||||||
|
offset *= blksz;
|
||||||
|
}
|
||||||
|
|
||||||
if (offset % 4 != 0 || size < 4 || size % 4 != 0) {
|
if (offset % 4 != 0 || size < 4 || size % 4 != 0) {
|
||||||
printf("Error: Bad A38x image blocksize.\n");
|
printf("Error: Bad A38x image blocksize.\n");
|
||||||
|
|
Loading…
Add table
Reference in a new issue