mirror of https://github.com/ipxe/ipxe.git
[block] Allow for iteration over SAN device list in drive number order
Maintain the SAN device list in order of drive number, and provide sandev_next() to locate the first SAN device at or above a given drive number. Signed-off-by: Michael Brown <mcb30@ipxe.org>pull/300/merge
parent
37edfea72b
commit
8da22a59ee
|
@ -107,6 +107,22 @@ struct san_device * sandev_find ( unsigned int drive ) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find next SAN device by drive number
|
||||||
|
*
|
||||||
|
* @v drive Minimum drive number
|
||||||
|
* @ret sandev SAN device, or NULL
|
||||||
|
*/
|
||||||
|
struct san_device * sandev_next ( unsigned int drive ) {
|
||||||
|
struct san_device *sandev;
|
||||||
|
|
||||||
|
list_for_each_entry ( sandev, &san_devices, list ) {
|
||||||
|
if ( sandev->drive >= drive )
|
||||||
|
return sandev;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Free SAN device
|
* Free SAN device
|
||||||
*
|
*
|
||||||
|
@ -870,6 +886,7 @@ struct san_device * alloc_sandev ( struct uri **uris, unsigned int count,
|
||||||
*/
|
*/
|
||||||
int register_sandev ( struct san_device *sandev, unsigned int drive,
|
int register_sandev ( struct san_device *sandev, unsigned int drive,
|
||||||
unsigned int flags ) {
|
unsigned int flags ) {
|
||||||
|
struct san_device *before;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
/* Check that drive number is not in use */
|
/* Check that drive number is not in use */
|
||||||
|
@ -903,8 +920,12 @@ int register_sandev ( struct san_device *sandev, unsigned int drive,
|
||||||
if ( ( rc = sandev_parse_iso9660 ( sandev ) ) != 0 )
|
if ( ( rc = sandev_parse_iso9660 ( sandev ) ) != 0 )
|
||||||
goto err_iso9660;
|
goto err_iso9660;
|
||||||
|
|
||||||
/* Add to list of SAN devices */
|
/* Add to list of SAN devices, in drive order */
|
||||||
list_add_tail ( &sandev->list, &san_devices );
|
for_each_sandev ( before ) {
|
||||||
|
if ( before->drive > sandev->drive )
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
list_add_tail ( &sandev->list, &before->list );
|
||||||
DBGC ( sandev->drive, "SAN %#02x registered\n", sandev->drive );
|
DBGC ( sandev->drive, "SAN %#02x registered\n", sandev->drive );
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -234,6 +234,7 @@ static inline int sandev_needs_reopen ( struct san_device *sandev ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
extern struct san_device * sandev_find ( unsigned int drive );
|
extern struct san_device * sandev_find ( unsigned int drive );
|
||||||
|
extern struct san_device * sandev_next ( unsigned int drive );
|
||||||
extern int sandev_reopen ( struct san_device *sandev );
|
extern int sandev_reopen ( struct san_device *sandev );
|
||||||
extern int sandev_reset ( struct san_device *sandev );
|
extern int sandev_reset ( struct san_device *sandev );
|
||||||
extern int sandev_read ( struct san_device *sandev, uint64_t lba,
|
extern int sandev_read ( struct san_device *sandev, uint64_t lba,
|
||||||
|
|
Loading…
Reference in New Issue