From ff8528ea9a69ca2ef6cfbed0b7a1283e165aabe6 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Tue, 16 Jan 2007 08:10:54 +0000 Subject: Create and use async_block() macro; it cuts down on the visual overhead of blocking on asynchronous operations, when that isn't an important aspect of the code. --- src/drivers/ata/aoedev.c | 9 +++------ src/drivers/scsi/iscsidev.c | 20 ++++++++++---------- 2 files changed, 13 insertions(+), 16 deletions(-) (limited to 'src/drivers') diff --git a/src/drivers/ata/aoedev.c b/src/drivers/ata/aoedev.c index 6658827cf..ff047f103 100644 --- a/src/drivers/ata/aoedev.c +++ b/src/drivers/ata/aoedev.c @@ -17,6 +17,7 @@ */ #include +#include #include /** @file @@ -37,13 +38,9 @@ static int aoe_command ( struct ata_device *ata, struct aoe_device *aoedev = container_of ( ata, struct aoe_device, ata ); struct async async; - int rc; - async_init_orphan ( &async ); - if ( ( rc = aoe_issue ( &aoedev->aoe, command, &async ) ) != 0 ) - return rc; - async_wait ( &async, &rc, 1 ); - return rc; + return async_block ( &async, aoe_issue ( &aoedev->aoe, command, + &async ) ); } /** diff --git a/src/drivers/scsi/iscsidev.c b/src/drivers/scsi/iscsidev.c index 75b857e71..aab99032d 100644 --- a/src/drivers/scsi/iscsidev.c +++ b/src/drivers/scsi/iscsidev.c @@ -17,6 +17,7 @@ */ #include +#include #include /** @file @@ -37,13 +38,9 @@ static int iscsi_command ( struct scsi_device *scsi, struct iscsi_device *iscsidev = container_of ( scsi, struct iscsi_device, scsi ); struct async async; - int rc; - async_init_orphan ( &async ); - if ( ( rc = iscsi_issue ( &iscsidev->iscsi, command, &async ) ) != 0 ) - return rc; - async_wait ( &async, &rc, 1 ); - return rc; + return async_block ( &async, iscsi_issue ( &iscsidev->iscsi, command, + &async ) ); } /** @@ -56,10 +53,13 @@ int init_iscsidev ( struct iscsi_device *iscsidev ) { iscsidev->scsi.command = iscsi_command; iscsidev->scsi.lun = iscsidev->iscsi.lun; - rc = init_scsidev ( &iscsidev->scsi ); - if ( rc != 0 ) { - fini_iscsidev ( iscsidev ); - } + if ( ( rc = init_scsidev ( &iscsidev->scsi ) ) != 0 ) + goto err; + + return 0; + + err: + fini_iscsidev ( iscsidev ); return rc; } -- cgit v1.2.3-55-g7522