aboutsummaryrefslogtreecommitdiff
path: root/hw/sd/sd.c
diff options
context:
space:
mode:
authorPhilippe Mathieu-Daudé <f4bug@amsat.org>2018-06-05 22:28:51 -0300
committerPhilippe Mathieu-Daudé <f4bug@amsat.org>2020-07-14 15:46:07 +0200
commit6dd3a164f5b31c703c7d8372841ad3bd6a57de6d (patch)
tree4ba3744abfbc60e6a22609b84582b92948a10bb5 /hw/sd/sd.c
parent9157dd597d293ab7f599f4d96c3fe8a6e07c633d (diff)
hw/sd/sdcard: Simplify realize() a bit
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>
Diffstat (limited to 'hw/sd/sd.c')
-rw-r--r--hw/sd/sd.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/hw/sd/sd.c b/hw/sd/sd.c
index 1cc16bfd31..edd60a09c0 100644
--- a/hw/sd/sd.c
+++ b/hw/sd/sd.c
@@ -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) {