disk: part: scan the disk if the part_type is unknow
We can get the new part table when we write a new partition table to a blank disk with this patch, or else we have to reset the board to get new partition table. Change-Id: If6688149a4a3ae9d6f5731757a1b5831494a9152 Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
This commit is contained in:
parent
1a3726ad91
commit
067b22ddca
24
disk/part.c
24
disk/part.c
|
|
@ -24,16 +24,28 @@
|
||||||
DECLARE_GLOBAL_DATA_PTR;
|
DECLARE_GLOBAL_DATA_PTR;
|
||||||
|
|
||||||
#ifdef HAVE_BLOCK_DEVICE
|
#ifdef HAVE_BLOCK_DEVICE
|
||||||
static struct part_driver *part_driver_lookup_type(int part_type)
|
static struct part_driver *part_driver_lookup_type(struct blk_desc *dev_desc)
|
||||||
{
|
{
|
||||||
struct part_driver *drv =
|
struct part_driver *drv =
|
||||||
ll_entry_start(struct part_driver, part_driver);
|
ll_entry_start(struct part_driver, part_driver);
|
||||||
const int n_ents = ll_entry_count(struct part_driver, part_driver);
|
const int n_ents = ll_entry_count(struct part_driver, part_driver);
|
||||||
struct part_driver *entry;
|
struct part_driver *entry;
|
||||||
|
|
||||||
for (entry = drv; entry != drv + n_ents; entry++) {
|
if (dev_desc->part_type == PART_TYPE_UNKNOWN) {
|
||||||
if (part_type == entry->part_type)
|
for (entry = drv; entry != drv + n_ents; entry++) {
|
||||||
return entry;
|
int ret;
|
||||||
|
|
||||||
|
ret = entry->test(dev_desc);
|
||||||
|
if (!ret) {
|
||||||
|
dev_desc->part_type = entry->part_type;
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (entry = drv; entry != drv + n_ents; entry++) {
|
||||||
|
if (dev_desc->part_type == entry->part_type)
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Not found */
|
/* Not found */
|
||||||
|
|
@ -286,7 +298,7 @@ void part_print(struct blk_desc *dev_desc)
|
||||||
{
|
{
|
||||||
struct part_driver *drv;
|
struct part_driver *drv;
|
||||||
|
|
||||||
drv = part_driver_lookup_type(dev_desc->part_type);
|
drv = part_driver_lookup_type(dev_desc);
|
||||||
if (!drv) {
|
if (!drv) {
|
||||||
printf("## Unknown partition table type %x\n",
|
printf("## Unknown partition table type %x\n",
|
||||||
dev_desc->part_type);
|
dev_desc->part_type);
|
||||||
|
|
@ -315,7 +327,7 @@ int part_get_info(struct blk_desc *dev_desc, int part,
|
||||||
info->type_guid[0] = 0;
|
info->type_guid[0] = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
drv = part_driver_lookup_type(dev_desc->part_type);
|
drv = part_driver_lookup_type(dev_desc);
|
||||||
if (!drv) {
|
if (!drv) {
|
||||||
debug("## Unknown partition table type %x\n",
|
debug("## Unknown partition table type %x\n",
|
||||||
dev_desc->part_type);
|
dev_desc->part_type);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue