diff options
author | Laurent Vivier | 2008-11-19 17:31:07 +0100 |
---|---|---|
committer | Michael Brown | 2008-11-19 21:04:43 +0100 |
commit | a2686a55c4799f34dcaa60e14097ed0e8f5c9254 (patch) | |
tree | cc9d38a621fd9ebeb6ef9f63bfcc083fec1824b5 /src/drivers/block | |
parent | [virtio] Split virtio-net.c into several files. (diff) | |
download | ipxe-a2686a55c4799f34dcaa60e14097ed0e8f5c9254.tar.gz ipxe-a2686a55c4799f34dcaa60e14097ed0e8f5c9254.tar.xz ipxe-a2686a55c4799f34dcaa60e14097ed0e8f5c9254.zip |
[blockdev] Move block device operations to structure block_device_operations
Signed-off-by: Laurent Vivier <Laurent.Vivier@bull.net>
Diffstat (limited to 'src/drivers/block')
-rw-r--r-- | src/drivers/block/ata.c | 8 | ||||
-rw-r--r-- | src/drivers/block/ramdisk.c | 8 | ||||
-rw-r--r-- | src/drivers/block/scsi.c | 16 |
3 files changed, 24 insertions, 8 deletions
diff --git a/src/drivers/block/ata.c b/src/drivers/block/ata.c index 555a5f6e..c21d2f65 100644 --- a/src/drivers/block/ata.c +++ b/src/drivers/block/ata.c @@ -139,6 +139,11 @@ static int ata_identify ( struct block_device *blockdev ) { return 0; } +static struct block_device_operations ata_operations = { + .read = ata_read, + .write = ata_write +}; + /** * Initialise ATA device * @@ -153,7 +158,6 @@ static int ata_identify ( struct block_device *blockdev ) { */ int init_atadev ( struct ata_device *ata ) { /** Fill in read and write methods, and get device capacity */ - ata->blockdev.read = ata_read; - ata->blockdev.write = ata_write; + ata->blockdev.op = &ata_operations; return ata_identify ( &ata->blockdev ); } diff --git a/src/drivers/block/ramdisk.c b/src/drivers/block/ramdisk.c index b5324bf1..50911994 100644 --- a/src/drivers/block/ramdisk.c +++ b/src/drivers/block/ramdisk.c @@ -75,6 +75,11 @@ static int ramdisk_write ( struct block_device *blockdev, uint64_t block, return 0; } +static struct block_device_operations ramdisk_operations = { + .read = ramdisk_read, + .write = ramdisk_write +}; + int init_ramdisk ( struct ramdisk *ramdisk, userptr_t data, size_t len, unsigned int blksize ) { @@ -82,8 +87,7 @@ int init_ramdisk ( struct ramdisk *ramdisk, userptr_t data, size_t len, blksize = 512; ramdisk->data = data; - ramdisk->blockdev.read = ramdisk_read; - ramdisk->blockdev.write = ramdisk_write; + ramdisk->blockdev.op = &ramdisk_operations; ramdisk->blockdev.blksize = blksize; ramdisk->blockdev.blocks = ( len / blksize ); diff --git a/src/drivers/block/scsi.c b/src/drivers/block/scsi.c index 9651583a..9ff47f89 100644 --- a/src/drivers/block/scsi.c +++ b/src/drivers/block/scsi.c @@ -228,6 +228,16 @@ static int scsi_read_capacity_16 ( struct block_device *blockdev ) { return 0; } +static struct block_device_operations scsi_operations_16 = { + .read = scsi_read_16, + .write = scsi_write_16, +}; + +static struct block_device_operations scsi_operations_10 = { + .read = scsi_read_10, + .write = scsi_write_10, +}; + /** * Initialise SCSI device * @@ -250,8 +260,7 @@ int init_scsidev ( struct scsi_device *scsi ) { scsi_read_capacity_10 ( &scsi->blockdev ); /* Try READ CAPACITY (10), which is a mandatory command, first. */ - scsi->blockdev.read = scsi_read_10; - scsi->blockdev.write = scsi_write_10; + scsi->blockdev.op = &scsi_operations_10; if ( ( rc = scsi_read_capacity_10 ( &scsi->blockdev ) ) != 0 ) return rc; @@ -261,8 +270,7 @@ int init_scsidev ( struct scsi_device *scsi ) { * mandatory, so we can't just use it straight off. */ if ( scsi->blockdev.blocks == 0 ) { - scsi->blockdev.read = scsi_read_16; - scsi->blockdev.write = scsi_write_16; + scsi->blockdev.op = &scsi_operations_16; if ( ( rc = scsi_read_capacity_16 ( &scsi->blockdev ) ) != 0 ) return rc; } |