From: Simon Glass <sjg@chromium.org>
To: U-Boot Mailing List <u-boot@lists.denx.de>
Cc: Simon Glass <sjg@chromium.org>
Subject: [PATCH 03/24] part: dos: Use desc instead of dev_desc
Date: Sun, 13 Aug 2023 08:26:31 -0600 [thread overview]
Message-ID: <20230813142708.361456-4-sjg@chromium.org> (raw)
In-Reply-To: <20230813142708.361456-1-sjg@chromium.org>
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>
---
disk/part_dos.c | 61 ++++++++++++++++++++++++-------------------------
1 file changed, 30 insertions(+), 31 deletions(-)
diff --git a/disk/part_dos.c b/disk/part_dos.c
index 56e61884deff..f94d2172d772 100644
--- a/disk/part_dos.c
+++ b/disk/part_dos.c
@@ -98,27 +98,26 @@ static int test_block_type(unsigned char *buffer)
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
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;
if (test_block_type((unsigned char *)mbr) != DOS_MBR)
return -1;
- if (dev_desc->sig_type == SIG_TYPE_NONE &&
- mbr->unique_mbr_signature != 0) {
- dev_desc->sig_type = SIG_TYPE_MBR;
- dev_desc->mbr_sig = mbr->unique_mbr_signature;
+ if (desc->sig_type == SIG_TYPE_NONE && mbr->unique_mbr_signature) {
+ desc->sig_type = SIG_TYPE_MBR;
+ desc->mbr_sig = mbr->unique_mbr_signature;
}
#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;
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
*/
-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 relative,
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;
int i;
@@ -146,9 +145,9 @@ static void print_partition_extended(struct blk_desc *dev_desc,
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",
- dev_desc->devnum, ext_part_sector);
+ desc->devnum, ext_part_sector);
return;
}
i=test_block_type(buffer);
@@ -189,9 +188,9 @@ static void print_partition_extended(struct blk_desc *dev_desc,
lbaint_t lba_start
= get_unaligned_le32 (pt->start4) + relative;
- print_partition_extended(dev_desc, lba_start,
- ext_part_sector == 0 ? lba_start : relative,
- part_num, disksig);
+ print_partition_extended(desc, lba_start,
+ !ext_part_sector ? lba_start :
+ 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
*/
-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,
int part_num, int which_part,
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);
dos_partition_t *pt;
int i;
int dos_type;
@@ -218,9 +217,9 @@ static int part_get_info_extended(struct blk_desc *dev_desc,
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",
- dev_desc->devnum, ext_part_sector);
+ desc->devnum, ext_part_sector);
return -1;
}
if (buffer[DOS_PART_MAGIC_OFFSET] != 0x55 ||
@@ -251,7 +250,7 @@ static int part_get_info_extended(struct blk_desc *dev_desc,
info->start = (lbaint_t)(ext_part_sector +
get_unaligned_le32(pt->start4));
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);
/* sprintf(info->type, "%d, pt->sys_ind); */
strcpy((char *)info->type, "U-Boot");
@@ -277,7 +276,7 @@ static int part_get_info_extended(struct blk_desc *dev_desc,
lbaint_t lba_start
= 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,
part_num, which_part, info, disksig);
}
@@ -288,7 +287,7 @@ static int part_get_info_extended(struct blk_desc *dev_desc,
if (dos_type == DOS_PBR) {
info->start = 0;
- info->size = dev_desc->lba;
+ info->size = desc->lba;
info->blksz = DOS_PART_DEFAULT_SECTOR;
info->bootable = 0;
strcpy((char *)info->type, "U-Boot");
@@ -301,16 +300,16 @@ static int part_get_info_extended(struct blk_desc *dev_desc,
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");
- 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,
- struct disk_partition *info)
+static int __maybe_unused part_get_info_dos(struct blk_desc *desc, int part,
+ 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)
@@ -490,20 +489,20 @@ int layout_mbr_partitions(struct disk_partition *p, int count,
}
#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))
return -1;
/* 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",
__func__, "MBR");
return 1;
}
/* Update the partition table entries*/
- part_init(dev_desc);
+ part_init(desc);
return 0;
}
--
2.41.0.640.ga95def55d0-goog
next prev parent reply other threads:[~2023-08-13 14:27 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-13 14:26 [PATCH 00/24] bootstd: Support ChromiumOS better Simon Glass
2023-08-13 14:26 ` [PATCH 01/24] part: Use desc instead of dev_desc Simon Glass
2023-08-13 14:26 ` [PATCH 02/24] part: amiga: " Simon Glass
2023-08-13 14:26 ` Simon Glass [this message]
2023-08-13 14:26 ` [PATCH 04/24] part: efi: " Simon Glass
2023-08-13 14:26 ` [PATCH 05/24] part: iso: " Simon Glass
2023-08-13 14:26 ` [PATCH 06/24] part: nac: " Simon Glass
2023-08-13 14:26 ` [PATCH 07/24] part: Add comments for static functions Simon Glass
2023-08-13 14:26 ` [PATCH 08/24] part: Add accessors for struct disk_partition uuid Simon Glass
2023-08-13 14:26 ` [PATCH 09/24] part: Add accessors for struct disk_partition type_uuid Simon Glass
2023-08-13 14:26 ` [PATCH 10/24] part: Add an accessor for struct disk_partition sys_ind Simon Glass
2023-08-13 14:26 ` [PATCH 11/24] part: efi: Add debugging for the signature check Simon Glass
2023-08-13 14:26 ` [PATCH 12/24] fs/erofs: Quieten test for filesystem presence Simon Glass
2023-08-14 3:45 ` Gao Xiang
2023-08-13 14:26 ` [PATCH 13/24] dm: core: Correct error handling when event fails Simon Glass
2023-08-13 14:26 ` [PATCH 14/24] uuid: Move function comments to header file Simon Glass
2023-08-13 14:26 ` [PATCH 15/24] sandbox: Add a way to access persistent test files Simon Glass
2023-08-13 14:26 ` [PATCH 16/24] test: Move 1MB.fat32.img and 2MB.ext2.img Simon Glass
2023-08-13 14:26 ` [PATCH 17/24] bootflow: Show an empty filename when there is none Simon Glass
2023-08-13 14:26 ` [PATCH 18/24] bootstd: test: Allow binding and using any mmc device Simon Glass
2023-08-13 14:26 ` [PATCH 19/24] bootstd: Add a test for bootmeth_cros Simon Glass
2023-08-13 14:26 ` [PATCH 20/24] part: Add a fallback for part_get_bootable() Simon Glass
2023-08-13 14:26 ` [PATCH 21/24] bootstd: Support bootmeths which can scan any partition Simon Glass
2023-08-13 14:26 ` [PATCH 22/24] uuid: Add ChromiumOS partition types Simon Glass
2023-08-13 14:26 ` [PATCH 23/24] bootstd: cros: Allow detection of any kernel partition Simon Glass
2023-08-13 14:26 ` [PATCH 24/24] CI: Add ChromiumOS utilities Simon Glass
2023-08-24 17:43 ` [PATCH 00/24] bootstd: Support ChromiumOS better Tom Rini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230813142708.361456-4-sjg@chromium.org \
--to=sjg@chromium.org \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox