]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
hw/sd/sdcard: Simplify realize() a bit
authorPhilippe Mathieu-Daudé <f4bug@amsat.org>
Wed, 6 Jun 2018 01:28:51 +0000 (22:28 -0300)
committerPhilippe Mathieu-Daudé <f4bug@amsat.org>
Tue, 14 Jul 2020 13:46:07 +0000 (15:46 +0200)
We don't need to check if sd->blk is set twice.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Message-Id: <20200630133912.9428-18-f4bug@amsat.org>

hw/sd/sd.c

index 1cc16bfd31259005ed4848464a1bd08df44a0575..edd60a09c01dd58cd9c8963e1b45cd85b9c4c7f1 100644 (file)
@@ -2105,12 +2105,12 @@ static void sd_realize(DeviceState *dev, Error **errp)
         return;
     }
 
-    if (sd->blk && blk_is_read_only(sd->blk)) {
-        error_setg(errp, "Cannot use read-only drive as SD card");
-        return;
-    }
-
     if (sd->blk) {
+        if (blk_is_read_only(sd->blk)) {
+            error_setg(errp, "Cannot use read-only drive as SD card");
+            return;
+        }
+
         ret = blk_set_perm(sd->blk, BLK_PERM_CONSISTENT_READ | BLK_PERM_WRITE,
                            BLK_PERM_ALL, errp);
         if (ret < 0) {