[SeaBIOS] [PATCH 2/2] Remove unnecesary updates of the disk op->count field.

Kevin O'Connor kevin at koconnor.net
Fri Dec 27 17:37:18 CET 2013


Now that the op->count field is cleared in a global location on simple
errors, remove various local clears done in individual drivers.

Signed-off-by: Kevin O'Connor <kevin at koconnor.net>
---
 src/block.c         |  1 -
 src/cdrom.c         |  1 -
 src/hw/ahci.c       |  1 -
 src/hw/ata.c        |  2 --
 src/hw/blockcmd.c   |  1 -
 src/hw/floppy.c     | 44 ++++++++++++++------------------------------
 src/hw/ramdisk.c    |  1 -
 src/hw/usb-msc.c    |  1 -
 src/hw/virtio-blk.c |  1 -
 9 files changed, 14 insertions(+), 39 deletions(-)

diff --git a/src/block.c b/src/block.c
index 4fbf058..ac2a830 100644
--- a/src/block.c
+++ b/src/block.c
@@ -328,7 +328,6 @@ process_scsi_op(struct disk_op_s *op)
     case CMD_SEEK:
         return DISK_RET_SUCCESS;
     default:
-        op->count = 0;
         return DISK_RET_EPARAM;
     }
 }
diff --git a/src/cdrom.c b/src/cdrom.c
index 811bef5..ff419c0 100644
--- a/src/cdrom.c
+++ b/src/cdrom.c
@@ -104,7 +104,6 @@ process_cdemu_op(struct disk_op_s *op)
     case CMD_ISREADY:
         return DISK_RET_SUCCESS;
     default:
-        op->count = 0;
         return DISK_RET_EPARAM;
     }
 }
diff --git a/src/hw/ahci.c b/src/hw/ahci.c
index 687cc7d..ff5d5f9 100644
--- a/src/hw/ahci.c
+++ b/src/hw/ahci.c
@@ -314,7 +314,6 @@ process_ahci_op(struct disk_op_s *op)
         return DISK_RET_SUCCESS;
     default:
         dprintf(1, "AHCI: unknown disk command %d\n", op->command);
-        op->count = 0;
         return DISK_RET_EPARAM;
     }
 }
diff --git a/src/hw/ata.c b/src/hw/ata.c
index de2a919..d805706 100644
--- a/src/hw/ata.c
+++ b/src/hw/ata.c
@@ -452,7 +452,6 @@ ata_dma_transfer(struct disk_op_s *op)
 
     dprintf(6, "IDE DMA error (dma=%x ide=%x/%x/%x)\n", status, idestatus
             , inb(iobase2 + ATA_CB_ASTAT), inb(iobase1 + ATA_CB_ERR));
-    op->count = 0;
     return -1;
 }
 
@@ -575,7 +574,6 @@ process_ata_op(struct disk_op_s *op)
     case CMD_SEEK:
         return DISK_RET_SUCCESS;
     default:
-        op->count = 0;
         return DISK_RET_EPARAM;
     }
 }
diff --git a/src/hw/blockcmd.c b/src/hw/blockcmd.c
index 96950f2..97c6675 100644
--- a/src/hw/blockcmd.c
+++ b/src/hw/blockcmd.c
@@ -49,7 +49,6 @@ cdb_cmd_data(struct disk_op_s *op, void *cdbcmd, u16 blocksize)
         if (!MODESEGMENT)
             return ahci_cmd_data(op, cdbcmd, blocksize);
     default:
-        op->count = 0;
         return DISK_RET_EPARAM;
     }
 }
diff --git a/src/hw/floppy.c b/src/hw/floppy.c
index b848203..f4d7c01 100644
--- a/src/hw/floppy.c
+++ b/src/hw/floppy.c
@@ -538,9 +538,9 @@ static int
 floppy_read(struct disk_op_s *op)
 {
     struct chs_s chs = lba2chs(op);
-    int res = floppy_prep(op->drive_gf, chs.cylinder);
-    if (res)
-        goto fail;
+    int ret = floppy_prep(op->drive_gf, chs.cylinder);
+    if (ret)
+        return ret;
 
     // send read-normal-data command to controller
     u8 floppyid = GET_GLOBALFLAT(op->drive_gf->cntl_id);
@@ -553,13 +553,7 @@ floppy_read(struct disk_op_s *op)
     param[5] = chs.sector + op->count - 1; // last sector to read on track
     param[6] = FLOPPY_GAPLEN;
     param[7] = FLOPPY_DATALEN;
-    res = floppy_dma_cmd(op, op->count * DISK_SECTOR_SIZE, FC_READ, param);
-    if (res)
-        goto fail;
-    return DISK_RET_SUCCESS;
-fail:
-    op->count = 0; // no sectors read
-    return res;
+    return floppy_dma_cmd(op, op->count * DISK_SECTOR_SIZE, FC_READ, param);
 }
 
 // Write Diskette Sectors
@@ -567,9 +561,9 @@ static int
 floppy_write(struct disk_op_s *op)
 {
     struct chs_s chs = lba2chs(op);
-    int res = floppy_prep(op->drive_gf, chs.cylinder);
-    if (res)
-        goto fail;
+    int ret = floppy_prep(op->drive_gf, chs.cylinder);
+    if (ret)
+        return ret;
 
     // send write-normal-data command to controller
     u8 floppyid = GET_GLOBALFLAT(op->drive_gf->cntl_id);
@@ -582,13 +576,7 @@ floppy_write(struct disk_op_s *op)
     param[5] = chs.sector + op->count - 1; // last sector to write on track
     param[6] = FLOPPY_GAPLEN;
     param[7] = FLOPPY_DATALEN;
-    res = floppy_dma_cmd(op, op->count * DISK_SECTOR_SIZE, FC_WRITE, param);
-    if (res)
-        goto fail;
-    return DISK_RET_SUCCESS;
-fail:
-    op->count = 0; // no sectors read
-    return res;
+    return floppy_dma_cmd(op, op->count * DISK_SECTOR_SIZE, FC_WRITE, param);
 }
 
 // Verify Diskette Sectors
@@ -596,15 +584,12 @@ static int
 floppy_verify(struct disk_op_s *op)
 {
     struct chs_s chs = lba2chs(op);
-    int res = floppy_prep(op->drive_gf, chs.cylinder);
-    if (res)
-        goto fail;
+    int ret = floppy_prep(op->drive_gf, chs.cylinder);
+    if (ret)
+        return ret;
 
     // This command isn't implemented - just return success.
     return DISK_RET_SUCCESS;
-fail:
-    op->count = 0; // no sectors read
-    return res;
 }
 
 // format diskette track
@@ -612,9 +597,9 @@ static int
 floppy_format(struct disk_op_s *op)
 {
     struct chs_s chs = lba2chs(op);
-    int res = floppy_prep(op->drive_gf, chs.cylinder);
-    if (res)
-        return res;
+    int ret = floppy_prep(op->drive_gf, chs.cylinder);
+    if (ret)
+        return ret;
 
     // send format-track command to controller
     u8 floppyid = GET_GLOBALFLAT(op->drive_gf->cntl_id);
@@ -645,7 +630,6 @@ process_floppy_op(struct disk_op_s *op)
     case CMD_FORMAT:
         return floppy_format(op);
     default:
-        op->count = 0;
         return DISK_RET_EPARAM;
     }
 }
diff --git a/src/hw/ramdisk.c b/src/hw/ramdisk.c
index 81aed50..1177bc0 100644
--- a/src/hw/ramdisk.c
+++ b/src/hw/ramdisk.c
@@ -106,7 +106,6 @@ process_ramdisk_op(struct disk_op_s *op)
     case CMD_RESET:
         return DISK_RET_SUCCESS;
     default:
-        op->count = 0;
         return DISK_RET_EPARAM;
     }
 }
diff --git a/src/hw/usb-msc.c b/src/hw/usb-msc.c
index 7e2e440..2cf9725 100644
--- a/src/hw/usb-msc.c
+++ b/src/hw/usb-msc.c
@@ -117,7 +117,6 @@ usb_cmd_data(struct disk_op_s *op, void *cdbcmd, u16 blocksize)
 fail:
     // XXX - reset connection
     dprintf(1, "USB transmission failed\n");
-    op->count = 0;
     return DISK_RET_EBADTRACK;
 }
 
diff --git a/src/hw/virtio-blk.c b/src/hw/virtio-blk.c
index 0290d67..7b22bf5 100644
--- a/src/hw/virtio-blk.c
+++ b/src/hw/virtio-blk.c
@@ -94,7 +94,6 @@ process_virtio_blk_op(struct disk_op_s *op)
     case CMD_SEEK:
         return DISK_RET_SUCCESS;
     default:
-        op->count = 0;
         return DISK_RET_EPARAM;
     }
 }
-- 
1.8.3.1




More information about the SeaBIOS mailing list