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
|
@ -255,7 +255,12 @@ struct grub_arc_system_parameter_block
|
|||
#define GRUB_ARC_STDIN 0
|
||||
#define GRUB_ARC_STDOUT 1
|
||||
|
||||
int EXPORT_FUNC (grub_arc_iterate_devs) (int (*hook) (const char *name, const struct grub_arc_component *comp), int alt_names);
|
||||
typedef int (*grub_arc_iterate_devs_hook_t)
|
||||
(const char *name, const struct grub_arc_component *comp, void *data);
|
||||
|
||||
int EXPORT_FUNC (grub_arc_iterate_devs) (grub_arc_iterate_devs_hook_t hook,
|
||||
void *hook_data,
|
||||
int alt_names);
|
||||
|
||||
#define FOR_ARC_CHILDREN(comp, parent) for (comp = GRUB_ARC_FIRMWARE_VECTOR->getchild (parent); comp; comp = GRUB_ARC_FIRMWARE_VECTOR->getpeer (comp))
|
||||
|
||||
|
|
|
@ -193,10 +193,12 @@ struct grub_ata
|
|||
|
||||
typedef struct grub_ata *grub_ata_t;
|
||||
|
||||
typedef int (*grub_ata_dev_iterate_hook_t) (int id, int bus, void *data);
|
||||
|
||||
struct grub_ata_dev
|
||||
{
|
||||
/* Call HOOK with each device name, until HOOK returns non-zero. */
|
||||
int (*iterate) (int (*hook) (int id, int bus),
|
||||
int (*iterate) (grub_ata_dev_iterate_hook_t hook, void *hook_data,
|
||||
grub_disk_pull_t pull);
|
||||
|
||||
/* Open the device named NAME, and set up SCSI. */
|
||||
|
|
|
@ -33,8 +33,11 @@ struct grub_device
|
|||
};
|
||||
typedef struct grub_device *grub_device_t;
|
||||
|
||||
typedef int (*grub_device_iterate_hook_t) (const char *name, void *data);
|
||||
|
||||
grub_device_t EXPORT_FUNC(grub_device_open) (const char *name);
|
||||
grub_err_t EXPORT_FUNC(grub_device_close) (grub_device_t device);
|
||||
int EXPORT_FUNC(grub_device_iterate) (int (*hook) (const char *name));
|
||||
int EXPORT_FUNC(grub_device_iterate) (grub_device_iterate_hook_t hook,
|
||||
void *hook_data);
|
||||
|
||||
#endif /* ! GRUB_DEVICE_HEADER */
|
||||
|
|
|
@ -56,6 +56,8 @@ typedef enum
|
|||
GRUB_DISK_PULL_MAX
|
||||
} grub_disk_pull_t;
|
||||
|
||||
typedef int (*grub_disk_dev_iterate_hook_t) (const char *name, void *data);
|
||||
|
||||
/* Disk device. */
|
||||
struct grub_disk_dev
|
||||
{
|
||||
|
@ -66,7 +68,7 @@ struct grub_disk_dev
|
|||
enum grub_disk_dev_id id;
|
||||
|
||||
/* Call HOOK with each device name, until HOOK returns non-zero. */
|
||||
int (*iterate) (int (*hook) (const char *name),
|
||||
int (*iterate) (grub_disk_dev_iterate_hook_t hook, void *hook_data,
|
||||
grub_disk_pull_t pull);
|
||||
|
||||
/* Open the device named NAME, and set up DISK. */
|
||||
|
@ -158,14 +160,14 @@ void grub_disk_cache_invalidate_all (void);
|
|||
void EXPORT_FUNC(grub_disk_dev_register) (grub_disk_dev_t dev);
|
||||
void EXPORT_FUNC(grub_disk_dev_unregister) (grub_disk_dev_t dev);
|
||||
static inline int
|
||||
grub_disk_dev_iterate (int (*hook) (const char *name))
|
||||
grub_disk_dev_iterate (grub_disk_dev_iterate_hook_t hook, void *hook_data)
|
||||
{
|
||||
grub_disk_dev_t p;
|
||||
grub_disk_pull_t pull;
|
||||
|
||||
for (pull = 0; pull < GRUB_DISK_PULL_MAX; pull++)
|
||||
for (p = grub_disk_dev_list; p; p = p->next)
|
||||
if (p->iterate && (p->iterate) (hook, pull))
|
||||
if (p->iterate && (p->iterate) (hook, hook_data, pull))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -80,8 +80,8 @@ struct grub_gpt_partentry
|
|||
|
||||
grub_err_t
|
||||
grub_gpt_partition_map_iterate (grub_disk_t disk,
|
||||
int (*hook) (grub_disk_t disk,
|
||||
const grub_partition_t partition));
|
||||
grub_partition_iterate_hook_t hook,
|
||||
void *hook_data);
|
||||
|
||||
|
||||
#endif /* ! GRUB_GPT_PARTITION_HEADER */
|
||||
|
|
|
@ -120,7 +120,7 @@ grub_msdos_partition_is_extended (int type)
|
|||
|
||||
grub_err_t
|
||||
grub_partition_msdos_iterate (grub_disk_t disk,
|
||||
int (*hook) (grub_disk_t disk,
|
||||
const grub_partition_t partition));
|
||||
grub_partition_iterate_hook_t hook,
|
||||
void *hook_data);
|
||||
|
||||
#endif /* ! GRUB_PC_PARTITION_HEADER */
|
||||
|
|
|
@ -33,6 +33,10 @@ typedef enum
|
|||
} grub_embed_type_t;
|
||||
#endif
|
||||
|
||||
typedef int (*grub_partition_iterate_hook_t) (struct grub_disk *disk,
|
||||
const grub_partition_t partition,
|
||||
void *data);
|
||||
|
||||
/* Partition map type. */
|
||||
struct grub_partition_map
|
||||
{
|
||||
|
@ -45,8 +49,7 @@ struct grub_partition_map
|
|||
|
||||
/* Call HOOK with each partition, until HOOK returns non-zero. */
|
||||
grub_err_t (*iterate) (struct grub_disk *disk,
|
||||
int (*hook) (struct grub_disk *disk,
|
||||
const grub_partition_t partition));
|
||||
grub_partition_iterate_hook_t hook, void *hook_data);
|
||||
#ifdef GRUB_UTIL
|
||||
/* Determine sectors available for embedding. */
|
||||
grub_err_t (*embed) (struct grub_disk *disk, unsigned int *nsectors,
|
||||
|
@ -89,8 +92,8 @@ struct grub_partition
|
|||
grub_partition_t EXPORT_FUNC(grub_partition_probe) (struct grub_disk *disk,
|
||||
const char *str);
|
||||
int EXPORT_FUNC(grub_partition_iterate) (struct grub_disk *disk,
|
||||
int (*hook) (struct grub_disk *disk,
|
||||
const grub_partition_t partition));
|
||||
grub_partition_iterate_hook_t hook,
|
||||
void *hook_data);
|
||||
char *EXPORT_FUNC(grub_partition_get_name) (const grub_partition_t partition);
|
||||
|
||||
|
||||
|
|
|
@ -49,10 +49,13 @@ grub_make_scsi_id (int subsystem, int bus, int lun)
|
|||
| (bus << GRUB_SCSI_ID_BUS_SHIFT) | (lun << GRUB_SCSI_ID_LUN_SHIFT);
|
||||
}
|
||||
|
||||
typedef int (*grub_scsi_dev_iterate_hook_t) (int id, int bus, int luns,
|
||||
void *data);
|
||||
|
||||
struct grub_scsi_dev
|
||||
{
|
||||
/* Call HOOK with each device name, until HOOK returns non-zero. */
|
||||
int (*iterate) (int NESTED_FUNC_ATTR (*hook) (int id, int bus, int luns),
|
||||
int (*iterate) (grub_scsi_dev_iterate_hook_t hook, void *hook_data,
|
||||
grub_disk_pull_t pull);
|
||||
|
||||
/* Open the device named NAME, and set up SCSI. */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue