part: dos: Use desc instead of dev_desc

The dev_ prefix is a hangover from the pre-driver model days. The device
is now a different thing, with driver model. Update the dos code to
just use 'desc'.

Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Simon Glass
2023-08-24 13:55:26 -06:00
committed by Tom Rini
parent 3557e8d223
commit cfdcd41e5a

View File

@@ -98,27 +98,26 @@ static int test_block_type(unsigned char *buffer)
return -1; return -1;
} }
static int part_test_dos(struct blk_desc *dev_desc) static int part_test_dos(struct blk_desc *desc)
{ {
#ifndef CONFIG_SPL_BUILD #ifndef CONFIG_SPL_BUILD
ALLOC_CACHE_ALIGN_BUFFER(legacy_mbr, mbr, ALLOC_CACHE_ALIGN_BUFFER(legacy_mbr, mbr,
DIV_ROUND_UP(dev_desc->blksz, sizeof(legacy_mbr))); DIV_ROUND_UP(desc->blksz, sizeof(legacy_mbr)));
if (blk_dread(dev_desc, 0, 1, (ulong *)mbr) != 1) if (blk_dread(desc, 0, 1, (ulong *)mbr) != 1)
return -1; return -1;
if (test_block_type((unsigned char *)mbr) != DOS_MBR) if (test_block_type((unsigned char *)mbr) != DOS_MBR)
return -1; return -1;
if (dev_desc->sig_type == SIG_TYPE_NONE && if (desc->sig_type == SIG_TYPE_NONE && mbr->unique_mbr_signature) {
mbr->unique_mbr_signature != 0) { desc->sig_type = SIG_TYPE_MBR;
dev_desc->sig_type = SIG_TYPE_MBR; desc->mbr_sig = mbr->unique_mbr_signature;
dev_desc->mbr_sig = mbr->unique_mbr_signature;
} }
#else #else
ALLOC_CACHE_ALIGN_BUFFER(unsigned char, buffer, dev_desc->blksz); ALLOC_CACHE_ALIGN_BUFFER(unsigned char, buffer, desc->blksz);
if (blk_dread(dev_desc, 0, 1, (ulong *)buffer) != 1) if (blk_dread(desc, 0, 1, (ulong *)buffer) != 1)
return -1; return -1;
if (test_block_type(buffer) != DOS_MBR) if (test_block_type(buffer) != DOS_MBR)
@@ -130,12 +129,12 @@ static int part_test_dos(struct blk_desc *dev_desc)
/* Print a partition that is relative to its Extended partition table /* Print a partition that is relative to its Extended partition table
*/ */
static void print_partition_extended(struct blk_desc *dev_desc, static void print_partition_extended(struct blk_desc *desc,
lbaint_t ext_part_sector, lbaint_t ext_part_sector,
lbaint_t relative, lbaint_t relative,
int part_num, unsigned int disksig) int part_num, unsigned int disksig)
{ {
ALLOC_CACHE_ALIGN_BUFFER(unsigned char, buffer, dev_desc->blksz); ALLOC_CACHE_ALIGN_BUFFER(unsigned char, buffer, desc->blksz);
dos_partition_t *pt; dos_partition_t *pt;
int i; int i;
@@ -146,9 +145,9 @@ static void print_partition_extended(struct blk_desc *dev_desc,
return; return;
} }
if (blk_dread(dev_desc, ext_part_sector, 1, (ulong *)buffer) != 1) { if (blk_dread(desc, ext_part_sector, 1, (ulong *)buffer) != 1) {
printf ("** Can't read partition table on %d:" LBAFU " **\n", printf ("** Can't read partition table on %d:" LBAFU " **\n",
dev_desc->devnum, ext_part_sector); desc->devnum, ext_part_sector);
return; return;
} }
i=test_block_type(buffer); i=test_block_type(buffer);
@@ -189,9 +188,9 @@ static void print_partition_extended(struct blk_desc *dev_desc,
lbaint_t lba_start lbaint_t lba_start
= get_unaligned_le32 (pt->start4) + relative; = get_unaligned_le32 (pt->start4) + relative;
print_partition_extended(dev_desc, lba_start, print_partition_extended(desc, lba_start,
ext_part_sector == 0 ? lba_start : relative, !ext_part_sector ? lba_start :
part_num, disksig); relative, part_num, disksig);
} }
} }
@@ -201,12 +200,12 @@ static void print_partition_extended(struct blk_desc *dev_desc,
/* Print a partition that is relative to its Extended partition table /* Print a partition that is relative to its Extended partition table
*/ */
static int part_get_info_extended(struct blk_desc *dev_desc, static int part_get_info_extended(struct blk_desc *desc,
lbaint_t ext_part_sector, lbaint_t relative, lbaint_t ext_part_sector, lbaint_t relative,
int part_num, int which_part, int part_num, int which_part,
struct disk_partition *info, uint disksig) struct disk_partition *info, uint disksig)
{ {
ALLOC_CACHE_ALIGN_BUFFER(unsigned char, buffer, dev_desc->blksz); ALLOC_CACHE_ALIGN_BUFFER(unsigned char, buffer, desc->blksz);
struct disk_partition wdinfo = { 0 }; struct disk_partition wdinfo = { 0 };
dos_partition_t *pt; dos_partition_t *pt;
int i, ret; int i, ret;
@@ -219,9 +218,9 @@ static int part_get_info_extended(struct blk_desc *dev_desc,
return -1; return -1;
} }
if (blk_dread(dev_desc, ext_part_sector, 1, (ulong *)buffer) != 1) { if (blk_dread(desc, ext_part_sector, 1, (ulong *)buffer) != 1) {
printf ("** Can't read partition table on %d:" LBAFU " **\n", printf ("** Can't read partition table on %d:" LBAFU " **\n",
dev_desc->devnum, ext_part_sector); desc->devnum, ext_part_sector);
return -1; return -1;
} }
if (buffer[DOS_PART_MAGIC_OFFSET] != 0x55 || if (buffer[DOS_PART_MAGIC_OFFSET] != 0x55 ||
@@ -237,7 +236,7 @@ static int part_get_info_extended(struct blk_desc *dev_desc,
disksig = get_unaligned_le32(&buffer[DOS_PART_DISKSIG_OFFSET]); disksig = get_unaligned_le32(&buffer[DOS_PART_DISKSIG_OFFSET]);
#endif #endif
ret = part_get_info_whole_disk(dev_desc, &wdinfo); ret = part_get_info_whole_disk(desc, &wdinfo);
if (ret) if (ret)
return ret; return ret;
@@ -259,7 +258,7 @@ static int part_get_info_extended(struct blk_desc *dev_desc,
info->start = (lbaint_t)(ext_part_sector + info->start = (lbaint_t)(ext_part_sector +
get_unaligned_le32(pt->start4)); get_unaligned_le32(pt->start4));
info->size = (lbaint_t)get_unaligned_le32(pt->size4); info->size = (lbaint_t)get_unaligned_le32(pt->size4);
part_set_generic_name(dev_desc, part_num, part_set_generic_name(desc, part_num,
(char *)info->name); (char *)info->name);
/* sprintf(info->type, "%d, pt->sys_ind); */ /* sprintf(info->type, "%d, pt->sys_ind); */
strcpy((char *)info->type, "U-Boot"); strcpy((char *)info->type, "U-Boot");
@@ -285,7 +284,7 @@ static int part_get_info_extended(struct blk_desc *dev_desc,
lbaint_t lba_start lbaint_t lba_start
= get_unaligned_le32 (pt->start4) + relative; = get_unaligned_le32 (pt->start4) + relative;
return part_get_info_extended(dev_desc, lba_start, return part_get_info_extended(desc, lba_start,
ext_part_sector == 0 ? lba_start : relative, ext_part_sector == 0 ? lba_start : relative,
part_num, which_part, info, disksig); part_num, which_part, info, disksig);
} }
@@ -296,7 +295,7 @@ static int part_get_info_extended(struct blk_desc *dev_desc,
if (dos_type == DOS_PBR) { if (dos_type == DOS_PBR) {
info->start = 0; info->start = 0;
info->size = dev_desc->lba; info->size = desc->lba;
if (wdinfo.blksz > DOS_PART_DEFAULT_SECTOR) if (wdinfo.blksz > DOS_PART_DEFAULT_SECTOR)
info->blksz = wdinfo.blksz; info->blksz = wdinfo.blksz;
else else
@@ -312,16 +311,16 @@ static int part_get_info_extended(struct blk_desc *dev_desc,
return -1; return -1;
} }
static void __maybe_unused part_print_dos(struct blk_desc *dev_desc) static void __maybe_unused part_print_dos(struct blk_desc *desc)
{ {
printf("Part\tStart Sector\tNum Sectors\tUUID\t\tType\n"); printf("Part\tStart Sector\tNum Sectors\tUUID\t\tType\n");
print_partition_extended(dev_desc, 0, 0, 1, 0); print_partition_extended(desc, 0, 0, 1, 0);
} }
static int __maybe_unused part_get_info_dos(struct blk_desc *dev_desc, int part, static int __maybe_unused part_get_info_dos(struct blk_desc *desc, int part,
struct disk_partition *info) struct disk_partition *info)
{ {
return part_get_info_extended(dev_desc, 0, 0, 1, part, info, 0); return part_get_info_extended(desc, 0, 0, 1, part, info, 0);
} }
int is_valid_dos_buf(void *buf) int is_valid_dos_buf(void *buf)
@@ -501,20 +500,20 @@ int layout_mbr_partitions(struct disk_partition *p, int count,
} }
#endif #endif
int write_mbr_sector(struct blk_desc *dev_desc, void *buf) int write_mbr_sector(struct blk_desc *desc, void *buf)
{ {
if (is_valid_dos_buf(buf)) if (is_valid_dos_buf(buf))
return -1; return -1;
/* write MBR */ /* write MBR */
if (blk_dwrite(dev_desc, 0, 1, buf) != 1) { if (blk_dwrite(desc, 0, 1, buf) != 1) {
printf("%s: failed writing '%s' (1 blks at 0x0)\n", printf("%s: failed writing '%s' (1 blks at 0x0)\n",
__func__, "MBR"); __func__, "MBR");
return 1; return 1;
} }
/* Update the partition table entries*/ /* Update the partition table entries*/
part_init(dev_desc); part_init(desc);
return 0; return 0;
} }