Restructure SCSI .id handling.

Reported and tested by: Aleš Nesrsta.

	* disk/ata.c (grub_atapi_close): Removed. All users updated.
	(grub_atapi_dev): Changed .name to "ata". New field .id.
	* disk/usbms.c (grub_usbms_close): Removed. All users updated.
	(grub_usbms_dev): New field .id.
	* disk/scsi.c (grub_scsi_iterate): Generate name.
	(grub_scsi_open): Parse name.
	* include/grub/scsi.h (grub_make_scsi_id): New function.
	(grub_scsi_dev): Change iterate and open to number instead of naming
	busses. All users updated.
	(grub_scsi): Remove name. Add .bus.
This commit is contained in:
Vladimir 'phcoder' Serbinenko 2010-07-10 02:59:33 +02:00
parent 5bc24388fb
commit 4274c30fbc
5 changed files with 93 additions and 77 deletions

View file

@ -26,16 +26,35 @@ void grub_scsi_dev_unregister (grub_scsi_dev_t dev);
struct grub_scsi;
enum
{
GRUB_SCSI_SUBSYSTEM_USBMS,
GRUB_SCSI_SUBSYSTEM_ATAPI
};
#define GRUB_SCSI_ID_SUBSYSTEM_SHIFT 24
#define GRUB_SCSI_ID_BUS_SHIFT 8
#define GRUB_SCSI_ID_LUN_SHIFT 0
static inline grub_uint32_t
grub_make_scsi_id (int subsystem, int bus, int lun)
{
return (subsystem << GRUB_SCSI_ID_SUBSYSTEM_SHIFT)
| (bus << GRUB_SCSI_ID_BUS_SHIFT) | (lun << GRUB_SCSI_ID_BUS_SHIFT);
}
struct grub_scsi_dev
{
/* The device name. */
const char *name;
grub_uint8_t id;
/* Call HOOK with each device name, until HOOK returns non-zero. */
int (*iterate) (int (*hook) (const char *name, int luns));
int (*iterate) (int (*hook) (int bus, int luns));
/* Open the device named NAME, and set up SCSI. */
grub_err_t (*open) (const char *name, struct grub_scsi *scsi);
grub_err_t (*open) (int bus, struct grub_scsi *scsi);
/* Close the scsi device SCSI. */
void (*close) (struct grub_scsi *scsi);
@ -56,15 +75,14 @@ struct grub_scsi_dev
struct grub_scsi
{
/* The scsi device name. */
char *name;
/* The underlying scsi device. */
grub_scsi_dev_t dev;
/* Type of SCSI device. XXX: Make enum. */
grub_uint8_t devtype;
int bus;
/* Number of LUNs. */
int luns;