Remove nested functions from device iterators.
* include/grub/arc/arc.h (grub_arc_iterate_devs_hook_t): New type. (grub_arc_iterate_devs): Add hook_data argument. * include/grub/ata.h (grub_ata_dev_iterate_hook_t): New type. (struct grub_ata_dev.iterate): Add hook_data argument. * include/grub/device.h (grub_device_iterate_hook_t): New type. (grub_device_iterate): Add hook_data argument. * include/grub/disk.h (grub_disk_dev_iterate_hook_t): New type. (struct grub_disk_dev.iterate): Add hook_data argument. (grub_disk_dev_iterate): Likewise. * include/grub/gpt_partition.h (grub_gpt_partition_map_iterate): Likewise. * include/grub/msdos_partition.h (grub_partition_msdos_iterate): Likewise. * include/grub/partition.h (grub_partition_iterate_hook_t): New type. (struct grub_partition_map.iterate): Add hook_data argument. (grub_partition_iterate): Likewise. * include/grub/scsi.h (grub_scsi_dev_iterate_hook_t): New type. (struct grub_scsi_dev.iterate): Add hook_data argument. Update all callers.
This commit is contained in:
parent
6c0314d638
commit
25239370fd
50 changed files with 1455 additions and 1165 deletions
|
@ -272,20 +272,21 @@ grub_biosdisk_get_drive (const char *name)
|
|||
}
|
||||
|
||||
static int
|
||||
grub_biosdisk_call_hook (int (*hook) (const char *name), int drive)
|
||||
grub_biosdisk_call_hook (grub_disk_dev_iterate_hook_t hook, void *hook_data,
|
||||
int drive)
|
||||
{
|
||||
char name[10];
|
||||
|
||||
if (cd_drive && drive == cd_drive)
|
||||
return hook ("cd");
|
||||
return hook ("cd", hook_data);
|
||||
|
||||
grub_snprintf (name, sizeof (name),
|
||||
(drive & 0x80) ? "hd%d" : "fd%d", drive & (~0x80));
|
||||
return hook (name);
|
||||
return hook (name, hook_data);
|
||||
}
|
||||
|
||||
static int
|
||||
grub_biosdisk_iterate (int (*hook) (const char *name),
|
||||
grub_biosdisk_iterate (grub_disk_dev_iterate_hook_t hook, void *hook_data,
|
||||
grub_disk_pull_t pull __attribute__ ((unused)))
|
||||
{
|
||||
int num_floppies;
|
||||
|
@ -304,7 +305,7 @@ grub_biosdisk_iterate (int (*hook) (const char *name),
|
|||
break;
|
||||
}
|
||||
|
||||
if (grub_biosdisk_call_hook (hook, drive))
|
||||
if (grub_biosdisk_call_hook (hook, hook_data, drive))
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -312,14 +313,14 @@ grub_biosdisk_iterate (int (*hook) (const char *name),
|
|||
case GRUB_DISK_PULL_REMOVABLE:
|
||||
if (cd_drive)
|
||||
{
|
||||
if (grub_biosdisk_call_hook (hook, cd_drive))
|
||||
if (grub_biosdisk_call_hook (hook, hook_data, cd_drive))
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* For floppy disks, we can get the number safely. */
|
||||
num_floppies = grub_biosdisk_get_num_floppies ();
|
||||
for (drive = 0; drive < num_floppies; drive++)
|
||||
if (grub_biosdisk_call_hook (hook, drive))
|
||||
if (grub_biosdisk_call_hook (hook, hook_data, drive))
|
||||
return 1;
|
||||
return 0;
|
||||
default:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue