diff mbox

hw/sd: Don't pass BlockBackend to sd_reset()

Message ID 1430683444-9797-1-git-send-email-peter.maydell@linaro.org
State New
Headers show

Commit Message

Peter Maydell May 3, 2015, 8:04 p.m. UTC
The only valid BlockBackend to pass to sd_reset() is the one for
the SD card, which is sd->blk. Drop the second argument from this
function in favour of having it just use sd->blk.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
A minor cleanup that was lurking in the omap3 tree (where it's
used to allow SD card controllers to reset the card, which is
something I haven't yet figured out the legitimacy of...)

 hw/sd/sd.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

Comments

Markus Armbruster May 4, 2015, 7:53 a.m. UTC | #1
Peter Maydell <peter.maydell@linaro.org> writes:

> The only valid BlockBackend to pass to sd_reset() is the one for
> the SD card, which is sd->blk. Drop the second argument from this
> function in favour of having it just use sd->blk.
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> A minor cleanup that was lurking in the omap3 tree (where it's
> used to allow SD card controllers to reset the card, which is
> something I haven't yet figured out the legitimacy of...)

Reviewed-by: Markus Armbruster <armbru@redhat.com>
diff mbox

Patch

diff --git a/hw/sd/sd.c b/hw/sd/sd.c
index 8abf0c9..a1ff465 100644
--- a/hw/sd/sd.c
+++ b/hw/sd/sd.c
@@ -389,13 +389,13 @@  static inline uint64_t sd_addr_to_wpnum(uint64_t addr)
     return addr >> (HWBLOCK_SHIFT + SECTOR_SHIFT + WPGROUP_SHIFT);
 }
 
-static void sd_reset(SDState *sd, BlockBackend *blk)
+static void sd_reset(SDState *sd)
 {
     uint64_t size;
     uint64_t sect;
 
-    if (blk) {
-        blk_get_geometry(blk, &sect);
+    if (sd->blk) {
+        blk_get_geometry(sd->blk, &sect);
     } else {
         sect = 0;
     }
@@ -412,11 +412,9 @@  static void sd_reset(SDState *sd, BlockBackend *blk)
     sd_set_cardstatus(sd);
     sd_set_sdstatus(sd);
 
-    sd->blk = blk;
-
     if (sd->wp_groups)
         g_free(sd->wp_groups);
-    sd->wp_switch = blk ? blk_is_read_only(blk) : false;
+    sd->wp_switch = sd->blk ? blk_is_read_only(sd->blk) : false;
     sd->wpgrps_size = sect;
     sd->wp_groups = bitmap_new(sd->wpgrps_size);
     memset(sd->function_group, 0, sizeof(sd->function_group));
@@ -434,7 +432,7 @@  static void sd_cardchange(void *opaque, bool load)
 
     qemu_set_irq(sd->inserted_cb, blk_is_inserted(sd->blk));
     if (blk_is_inserted(sd->blk)) {
-        sd_reset(sd, sd->blk);
+        sd_reset(sd);
         qemu_set_irq(sd->readonly_cb, sd->wp_switch);
     }
 }
@@ -492,7 +490,8 @@  SDState *sd_init(BlockBackend *blk, bool is_spi)
     sd->buf = blk_blockalign(blk, 512);
     sd->spi = is_spi;
     sd->enable = true;
-    sd_reset(sd, blk);
+    sd->blk = blk;
+    sd_reset(sd);
     if (sd->blk) {
         blk_attach_dev_nofail(sd->blk, sd);
         blk_set_dev_ops(sd->blk, &sd_block_ops, sd);
@@ -680,7 +679,7 @@  static sd_rsp_type_t sd_normal_command(SDState *sd,
 
         default:
             sd->state = sd_idle_state;
-            sd_reset(sd, sd->blk);
+            sd_reset(sd);
             return sd->spi ? sd_r1 : sd_r0;
         }
         break;