From patchwork Fri Jan 22 16:16:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 8091311 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 67F219F1C0 for ; Fri, 22 Jan 2016 16:22:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CE3C92034F for ; Fri, 22 Jan 2016 16:22:12 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 208D320340 for ; Fri, 22 Jan 2016 16:22:12 +0000 (UTC) Received: from localhost ([::1]:54552 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aMeTT-0005ND-BW for patchwork-qemu-devel@patchwork.kernel.org; Fri, 22 Jan 2016 11:22:11 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55548) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aMePI-0006L3-Rk for qemu-devel@nongnu.org; Fri, 22 Jan 2016 11:17:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aMeP9-0004y2-7R for qemu-devel@nongnu.org; Fri, 22 Jan 2016 11:17:52 -0500 Received: from mnementh.archaic.org.uk ([2001:8b0:1d0::1]:59524) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aMeP9-0004xO-0g; Fri, 22 Jan 2016 11:17:43 -0500 Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.80) (envelope-from ) id 1aMeOB-0003sV-35; Fri, 22 Jan 2016 16:16:43 +0000 From: Peter Maydell To: qemu-devel@nongnu.org Date: Fri, 22 Jan 2016 16:16:35 +0000 Message-Id: <1453479402-14870-4-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1453479402-14870-1-git-send-email-peter.maydell@linaro.org> References: <1453479402-14870-1-git-send-email-peter.maydell@linaro.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 2001:8b0:1d0::1 Cc: Peter Crosthwaite , Sai Pavan Boddu , patches@linaro.org, Markus Armbruster , Alistair Francis , Kevin O'Connor , qemu-arm@nongnu.org, "Edgar E. Iglesias" , Paolo Bonzini Subject: [Qemu-devel] [PATCH v2 03/10] hw/sd/sd.c: Convert sd_reset() function into Device reset method X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Convert the sd_reset() function into a proper Device reset method. Signed-off-by: Peter Maydell Reviewed-by: Alistair Francis Reviewed-by: Peter Crosthwaite --- hw/sd/sd.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 745e9d6..b62f7f5 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -393,8 +393,9 @@ 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) +static void sd_reset(DeviceState *dev) { + SDState *sd = SD_CARD(dev); uint64_t size; uint64_t sect; @@ -435,7 +436,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_reset(DEVICE(sd)); qemu_set_irq(sd->readonly_cb, sd->wp_switch); } } @@ -677,7 +678,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, default: sd->state = sd_idle_state; - sd_reset(sd); + sd_reset(DEVICE(sd)); return sd->spi ? sd_r1 : sd_r0; } break; @@ -1783,8 +1784,6 @@ static void sd_realize(DeviceState *dev, Error **errp) if (sd->blk) { blk_set_dev_ops(sd->blk, &sd_block_ops, sd); } - - sd_reset(sd); } static Property sd_properties[] = { @@ -1804,6 +1803,7 @@ static void sd_class_init(ObjectClass *klass, void *data) dc->realize = sd_realize; dc->props = sd_properties; dc->vmsd = &sd_vmstate; + dc->reset = sd_reset; } static const TypeInfo sd_info = {