Skip to contentSkip to conversation

hw/arm/aspeed: Do not create and attach empty SD cards by default

PATCH Applied Philippe Mathieu-Daudé 3 participants 3 messages Jul 5, 2020 – Jul 13, 2020 Arm/Aspeed machine support

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/arm/aspeed: Do not create and attach empty SD cards by default

Since added in commit 2bea128c3d, each SDHCI is wired with a SD card, using empty card when no block drive provided. This is not the desired behavior. The SDHCI exposes a SD bus to plug cards on, if no card available, it is fine to have an unplugged bus.

Avoid creating unnecessary SD card device when no block drive provided.

Fixes 2bea128c3d ("hw/sd/aspeed_sdhci: New device")

---
Cc: Eddie James <[email protected]>
Cc: Cédric Le Goater <[email protected]>
Cc: Joel Stanley <[email protected]>
Cc: Andrew Jeffery <[email protected]>

---
 hw/arm/aspeed.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
hw/arm/aspeed.c +5 -4
index 379f9672a5..11521c4be1 100644
@@ -246,11 +246,12 @@ static void sdhci_attach_drive(SDHCIState *sdhci, DriveInfo *dinfo)
 {
         DeviceState *card;
 
-        card = qdev_new(TYPE_SD_CARD);
-        if (dinfo) {
-            qdev_prop_set_drive_err(card, "drive", blk_by_legacy_dinfo(dinfo),
-                                    &error_fatal);
+        if (!dinfo) {
+            return;
         }
+        card = qdev_new(TYPE_SD_CARD);
+        qdev_prop_set_drive_err(card, "drive", blk_by_legacy_dinfo(dinfo),
+                                &error_fatal);
         qdev_realize_and_unref(card,
                                qdev_get_child_bus(DEVICE(sdhci), "sd-bus"),
                                &error_fatal);
Signature · 1 line
2.21.3
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Philippe Mathieu-Daudé

Since added in commit 2bea128c3d, each SDHCI is wired with a SD card, using empty card when no block drive provided. This is not the desired behavior. The SDHCI exposes a SD bus to plug cards on, if no card available, it is fine to have an unplugged bus.

Avoid creating unnecessary SD card device when no block drive provided.

Fixes 2bea128c3d ("hw/sd/aspeed_sdhci: New device")

Thanks,

C.

Quoted 31 lines

---
Cc: Eddie James <[email protected]>
Cc: Cédric Le Goater <[email protected]>
Cc: Joel Stanley <[email protected]>
Cc: Andrew Jeffery <[email protected]>

---
 hw/arm/aspeed.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
hw/arm/aspeed.c +5 -4
index 379f9672a5..11521c4be1 100644
@@ -246,11 +246,12 @@ static void sdhci_attach_drive(SDHCIState *sdhci, DriveInfo *dinfo)
 {
         DeviceState *card;
 
-        card = qdev_new(TYPE_SD_CARD);
-        if (dinfo) {
-            qdev_prop_set_drive_err(card, "drive", blk_by_legacy_dinfo(dinfo),
-                                    &error_fatal);
+        if (!dinfo) {
+            return;
         }
+        card = qdev_new(TYPE_SD_CARD);
+        qdev_prop_set_drive_err(card, "drive", blk_by_legacy_dinfo(dinfo),
+                                &error_fatal);
         qdev_realize_and_unref(card,
                                qdev_get_child_bus(DEVICE(sdhci), "sd-bus"),
                                &error_fatal);
#2 lore raw
Quoted 7 lines · Cédric Le Goater
Quoted 5 lines · Philippe Mathieu-Daudé

Since added in commit 2bea128c3d, each SDHCI is wired with a SD card, using empty card when no block drive provided. This is not the desired behavior. The SDHCI exposes a SD bus to plug cards on, if no card available, it is fine to have an unplugged bus.

Quoted 7 lines
Quoted 5 lines

Avoid creating unnecessary SD card device when no block drive provided.

Fixes 2bea128c3d ("hw/sd/aspeed_sdhci: New device")

Applied to target-arm.next for 5.1, thanks.

-- PMM