From patchwork Sun May 3 20:04:04 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 47916 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f71.google.com (mail-la0-f71.google.com [209.85.215.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id C7E9C20553 for ; Sun, 3 May 2015 20:04:08 +0000 (UTC) Received: by labgx2 with SMTP id gx2sf41680340lab.1 for ; Sun, 03 May 2015 13:04:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=TLLTFn4/9GeXULjYiOu8bTElT/JsVkMsfvKQBOZ8oNk=; b=HY2WJwQ5HXMTXrQ8nsudtqligk3kkx5A+0CMZXXD42wkaSaoHktyzGAD7cRJkoqs+f qzmM6S4L6qabVWmTfWM2jZKdCqXTiDCqx/OqkUrcDnHhhrCZtYFpM1Jd541651NOXLIt xftGHvBtIEtqgQYBncJEvlTuTY7Y4fJEnYfHwp/j9ZavQkDdoNdtwyzUQFxsKa+jOZT/ yTOIfT4MwUuC0Zz43zI4aW3wAdgly/7kkFDJvYMer7AmtqX9KjKE2/lcEk0IeBJdCgRB ozzIWYDs+4HdGcT4icQsZPgtaBh7bCwo2BGAepxPqaxlM5MNoJw5+YQBo1S3ud+gU7YV rF2g== X-Gm-Message-State: ALoCoQkmUWViB6XsndC/Y+NbPrbutHZmQzYrNUJo1luiTQVXB4JiLb9MxdSIz8x9ZNARAkDQFBW4 X-Received: by 10.152.8.17 with SMTP id n17mr16300202laa.0.1430683447682; Sun, 03 May 2015 13:04:07 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.179.232 with SMTP id dj8ls683477lac.74.gmail; Sun, 03 May 2015 13:04:07 -0700 (PDT) X-Received: by 10.152.8.231 with SMTP id u7mr16420075laa.37.1430683447541; Sun, 03 May 2015 13:04:07 -0700 (PDT) Received: from mail-lb0-f170.google.com (mail-lb0-f170.google.com. [209.85.217.170]) by mx.google.com with ESMTPS id lm6si8669098lac.29.2015.05.03.13.04.07 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 03 May 2015 13:04:07 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.170 as permitted sender) client-ip=209.85.217.170; Received: by lbcga7 with SMTP id ga7so93094550lbc.1 for ; Sun, 03 May 2015 13:04:07 -0700 (PDT) X-Received: by 10.112.150.100 with SMTP id uh4mr16499234lbb.112.1430683447039; Sun, 03 May 2015 13:04:07 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.112.67.65 with SMTP id l1csp1325345lbt; Sun, 3 May 2015 13:04:06 -0700 (PDT) X-Received: by 10.194.249.201 with SMTP id yw9mr36412098wjc.5.1430683446387; Sun, 03 May 2015 13:04:06 -0700 (PDT) Received: from mnementh.archaic.org.uk (mnementh.archaic.org.uk. [2001:8b0:1d0::1]) by mx.google.com with ESMTPS id ei5si8206381wib.54.2015.05.03.13.04.06 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sun, 03 May 2015 13:04:06 -0700 (PDT) Received-SPF: none (google.com: pm215@archaic.org.uk does not designate permitted sender hosts) client-ip=2001:8b0:1d0::1; Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.80) (envelope-from ) id 1Yp07Q-0002YU-K9; Sun, 03 May 2015 21:04:04 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org Subject: [PATCH] hw/sd: Don't pass BlockBackend to sd_reset() Date: Sun, 3 May 2015 21:04:04 +0100 Message-Id: <1430683444-9797-1-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: peter.maydell@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.170 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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 --- 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(-) 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, §); + if (sd->blk) { + blk_get_geometry(sd->blk, §); } 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;