From 4101f6879256720b30df712089a3df18565f9203 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 29 Feb 2016 15:25:34 -0700 Subject: dm: Drop the block_dev_desc_t typedef Use 'struct' instead of a typdef. Also since 'struct block_dev_desc' is long and causes 80-column violations, rename it to struct blk_desc. Signed-off-by: Simon Glass Reviewed-by: Bin Meng Tested-by: Stephen Warren --- disk/part_amiga.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'disk/part_amiga.c') diff --git a/disk/part_amiga.c b/disk/part_amiga.c index 57c1b9d055..008941c532 100644 --- a/disk/part_amiga.c +++ b/disk/part_amiga.c @@ -126,7 +126,7 @@ static void print_part_info(struct partition_block *p) * the ID AMIGA_ID_RDISK ('RDSK') and needs to have a valid * sum-to-zero checksum */ -struct rigid_disk_block *get_rdisk(block_dev_desc_t *dev_desc) +struct rigid_disk_block *get_rdisk(struct blk_desc *dev_desc) { int i; int limit; @@ -166,7 +166,7 @@ struct rigid_disk_block *get_rdisk(block_dev_desc_t *dev_desc) * Ridgid disk block */ -struct bootcode_block *get_bootcode(block_dev_desc_t *dev_desc) +struct bootcode_block *get_bootcode(struct blk_desc *dev_desc) { int i; int limit; @@ -207,7 +207,7 @@ struct bootcode_block *get_bootcode(block_dev_desc_t *dev_desc) * Test if the given partition has an Amiga partition table/Rigid * Disk block */ -int test_part_amiga(block_dev_desc_t *dev_desc) +int test_part_amiga(struct blk_desc *dev_desc) { struct rigid_disk_block *rdb; struct bootcode_block *bootcode; @@ -236,7 +236,8 @@ int test_part_amiga(block_dev_desc_t *dev_desc) /* * Find partition number partnum on the given drive. */ -static struct partition_block *find_partition(block_dev_desc_t *dev_desc, int partnum) +static struct partition_block *find_partition(struct blk_desc *dev_desc, + int partnum) { struct rigid_disk_block *rdb; struct partition_block *p; @@ -290,7 +291,8 @@ static struct partition_block *find_partition(block_dev_desc_t *dev_desc, int pa /* * Get info about a partition */ -int get_partition_info_amiga (block_dev_desc_t *dev_desc, int part, disk_partition_t *info) +int get_partition_info_amiga(struct blk_desc *dev_desc, int part, + disk_partition_t *info) { struct partition_block *p = find_partition(dev_desc, part-1); struct amiga_part_geometry *g; @@ -317,7 +319,7 @@ int get_partition_info_amiga (block_dev_desc_t *dev_desc, int part, disk_partiti return 0; } -void print_part_amiga (block_dev_desc_t *dev_desc) +void print_part_amiga(struct blk_desc *dev_desc) { struct rigid_disk_block *rdb; struct bootcode_block *boot; -- cgit v1.2.1 From 95a6f9dfcbeb612564a014ccb135ae4e1e4fc942 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 29 Feb 2016 15:25:45 -0700 Subject: dm: part: Add a cast to avoid a compiler warning In part_amiga.c the name is unsigned but bcpl_strcpy() requires a signed pointer. Add a cast to fix the warning. Signed-off-by: Simon Glass Reviewed-by: Bin Meng Tested-by: Stephen Warren --- disk/part_amiga.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'disk/part_amiga.c') diff --git a/disk/part_amiga.c b/disk/part_amiga.c index 008941c532..5702c95782 100644 --- a/disk/part_amiga.c +++ b/disk/part_amiga.c @@ -304,7 +304,7 @@ int get_partition_info_amiga(struct blk_desc *dev_desc, int part, info->start = g->low_cyl * g->block_per_track * g->surfaces; info->size = (g->high_cyl - g->low_cyl + 1) * g->block_per_track * g->surfaces - 1; info->blksz = rdb.block_bytes; - bcpl_strcpy(info->name, p->drive_name); + bcpl_strcpy((char *)info->name, p->drive_name); disk_type = g->dos_type; -- cgit v1.2.1 From 96e5b03c8ab749b6547f6a3ceb4d4b9f274211aa Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 29 Feb 2016 15:25:47 -0700 Subject: dm: part: Convert partition API use to linker lists We can use linker lists instead of explicitly declaring each function. This makes the code shorter by avoiding switch() statements and lots of header file declarations. While this does clean up the code it introduces a few code issues with SPL. SPL never needs to print partition information since this all happens from commands. SPL mostly doesn't need to obtain information about a partition either, except in a few cases. Add these cases so that the code will be dropped from each partition driver when not needed. This avoids code bloat. I think this is still a win, since it is not a bad thing to be explicit about which features are used in SPL. But others may like to weigh in. Signed-off-by: Simon Glass Reviewed-by: Tom Rini Tested-by: Stephen Warren --- disk/part_amiga.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'disk/part_amiga.c') diff --git a/disk/part_amiga.c b/disk/part_amiga.c index 5702c95782..0f569f0c9b 100644 --- a/disk/part_amiga.c +++ b/disk/part_amiga.c @@ -207,7 +207,7 @@ struct bootcode_block *get_bootcode(struct blk_desc *dev_desc) * Test if the given partition has an Amiga partition table/Rigid * Disk block */ -int test_part_amiga(struct blk_desc *dev_desc) +static int test_part_amiga(struct blk_desc *dev_desc) { struct rigid_disk_block *rdb; struct bootcode_block *bootcode; @@ -291,8 +291,8 @@ static struct partition_block *find_partition(struct blk_desc *dev_desc, /* * Get info about a partition */ -int get_partition_info_amiga(struct blk_desc *dev_desc, int part, - disk_partition_t *info) +static int get_partition_info_amiga(struct blk_desc *dev_desc, int part, + disk_partition_t *info) { struct partition_block *p = find_partition(dev_desc, part-1); struct amiga_part_geometry *g; @@ -319,7 +319,7 @@ int get_partition_info_amiga(struct blk_desc *dev_desc, int part, return 0; } -void print_part_amiga(struct blk_desc *dev_desc) +static void print_part_amiga(struct blk_desc *dev_desc) { struct rigid_disk_block *rdb; struct bootcode_block *boot; @@ -379,4 +379,12 @@ void print_part_amiga(struct blk_desc *dev_desc) } } +U_BOOT_PART_TYPE(amiga) = { + .name = "AMIGA", + .part_type = PART_TYPE_AMIGA, + .get_info = get_partition_info_amiga, + .print = print_part_amiga, + .test = test_part_amiga, +}; + #endif -- cgit v1.2.1 From 3e8bd469504f5d5a8800a2ea46d664dde701105b Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 29 Feb 2016 15:25:48 -0700 Subject: dm: part: Rename some partition functions Rename three partition functions so that they start with part_. This makes it clear what they relate to. Signed-off-by: Simon Glass Tested-by: Stephen Warren --- disk/part_amiga.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'disk/part_amiga.c') diff --git a/disk/part_amiga.c b/disk/part_amiga.c index 0f569f0c9b..d323b4bc1e 100644 --- a/disk/part_amiga.c +++ b/disk/part_amiga.c @@ -291,7 +291,7 @@ static struct partition_block *find_partition(struct blk_desc *dev_desc, /* * Get info about a partition */ -static int get_partition_info_amiga(struct blk_desc *dev_desc, int part, +static int part_get_info_amiga(struct blk_desc *dev_desc, int part, disk_partition_t *info) { struct partition_block *p = find_partition(dev_desc, part-1); @@ -382,7 +382,7 @@ static void print_part_amiga(struct blk_desc *dev_desc) U_BOOT_PART_TYPE(amiga) = { .name = "AMIGA", .part_type = PART_TYPE_AMIGA, - .get_info = get_partition_info_amiga, + .get_info = part_get_info_amiga, .print = print_part_amiga, .test = test_part_amiga, }; -- cgit v1.2.1 From 2a981dc2c62c500110aad297fa70503aec36e689 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 29 Feb 2016 15:25:52 -0700 Subject: dm: block: Adjust device calls to go through helpers function To ease conversion to driver model, add helper functions which deal with calling each block device method. With driver model we can reimplement these functions with the same arguments. Use inline functions to avoid increasing code size on some boards. Signed-off-by: Simon Glass Reviewed-by: Bin Meng Tested-by: Stephen Warren --- disk/part_amiga.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'disk/part_amiga.c') diff --git a/disk/part_amiga.c b/disk/part_amiga.c index d323b4bc1e..4a67689c75 100644 --- a/disk/part_amiga.c +++ b/disk/part_amiga.c @@ -140,7 +140,7 @@ struct rigid_disk_block *get_rdisk(struct blk_desc *dev_desc) for (i=0; iblock_read(dev_desc, i, 1, (ulong *)block_buffer); + ulong res = blk_dread(dev_desc, i, 1, (ulong *)block_buffer); if (res == 1) { struct rigid_disk_block *trdb = (struct rigid_disk_block *)block_buffer; @@ -182,7 +182,7 @@ struct bootcode_block *get_bootcode(struct blk_desc *dev_desc) for (i = 0; i < limit; i++) { - ulong res = dev_desc->block_read(dev_desc, i, 1, (ulong *)block_buffer); + ulong res = blk_dread(dev_desc, i, 1, (ulong *)block_buffer); if (res == 1) { struct bootcode_block *boot = (struct bootcode_block *)block_buffer; @@ -258,8 +258,7 @@ static struct partition_block *find_partition(struct blk_desc *dev_desc, while (block != 0xFFFFFFFF) { - ulong res = dev_desc->block_read(dev_desc, block, 1, - (ulong *)block_buffer); + ulong res = blk_dread(dev_desc, block, 1, (ulong *)block_buffer); if (res == 1) { p = (struct partition_block *)block_buffer; @@ -355,7 +354,7 @@ static void print_part_amiga(struct blk_desc *dev_desc) PRINTF("Trying to load block #0x%X\n", block); - res = dev_desc->block_read(dev_desc, block, 1, (ulong *)block_buffer); + res = blk_dread(dev_desc, block, 1, (ulong *)block_buffer); if (res == 1) { p = (struct partition_block *)block_buffer; -- cgit v1.2.1 From 084bf4c244ce98ab1ee7b590d44471fa5cae25f6 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 29 Feb 2016 15:26:04 -0700 Subject: part: Rename test_part_xx() and print_part_xx() Rename these functions so that part_ is at the start. This more clearly identifies these functions as partition functions. Signed-off-by: Simon Glass --- disk/part_amiga.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'disk/part_amiga.c') diff --git a/disk/part_amiga.c b/disk/part_amiga.c index 4a67689c75..d4316b858c 100644 --- a/disk/part_amiga.c +++ b/disk/part_amiga.c @@ -207,27 +207,27 @@ struct bootcode_block *get_bootcode(struct blk_desc *dev_desc) * Test if the given partition has an Amiga partition table/Rigid * Disk block */ -static int test_part_amiga(struct blk_desc *dev_desc) +static int part_test_amiga(struct blk_desc *dev_desc) { struct rigid_disk_block *rdb; struct bootcode_block *bootcode; - PRINTF("test_part_amiga: Testing for an Amiga RDB partition\n"); + PRINTF("part_test_amiga: Testing for an Amiga RDB partition\n"); rdb = get_rdisk(dev_desc); if (rdb) { bootcode = get_bootcode(dev_desc); if (bootcode) - PRINTF("test_part_amiga: bootable Amiga disk\n"); + PRINTF("part_test_amiga: bootable Amiga disk\n"); else - PRINTF("test_part_amiga: non-bootable Amiga disk\n"); + PRINTF("part_test_amiga: non-bootable Amiga disk\n"); return 0; } else { - PRINTF("test_part_amiga: no RDB found\n"); + PRINTF("part_test_amiga: no RDB found\n"); return -1; } @@ -318,7 +318,7 @@ static int part_get_info_amiga(struct blk_desc *dev_desc, int part, return 0; } -static void print_part_amiga(struct blk_desc *dev_desc) +static void part_print_amiga(struct blk_desc *dev_desc) { struct rigid_disk_block *rdb; struct bootcode_block *boot; @@ -329,14 +329,14 @@ static void print_part_amiga(struct blk_desc *dev_desc) rdb = get_rdisk(dev_desc); if (!rdb) { - PRINTF("print_part_amiga: no rdb found\n"); + PRINTF("part_print_amiga: no rdb found\n"); return; } - PRINTF("print_part_amiga: Scanning partition list\n"); + PRINTF("part_print_amiga: Scanning partition list\n"); block = rdb->partition_list; - PRINTF("print_part_amiga: partition list at 0x%x\n", block); + PRINTF("part_print_amiga: partition list at 0x%x\n", block); printf("Summary: DiskBlockSize: %d\n" " Cylinders : %d\n" @@ -382,8 +382,8 @@ U_BOOT_PART_TYPE(amiga) = { .name = "AMIGA", .part_type = PART_TYPE_AMIGA, .get_info = part_get_info_amiga, - .print = print_part_amiga, - .test = test_part_amiga, + .print = part_print_amiga, + .test = part_test_amiga, }; #endif -- cgit v1.2.1