diff options
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; } |