From patchwork Tue Feb 16 18:09:45 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 8330421 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 E4D4B9F399 for ; Tue, 16 Feb 2016 18:12:05 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 555A7202BE for ; Tue, 16 Feb 2016 18:12:05 +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 42CE4202A1 for ; Tue, 16 Feb 2016 18:12:03 +0000 (UTC) Received: from localhost ([::1]:49159 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aVk6U-00054N-HS for patchwork-qemu-devel@patchwork.kernel.org; Tue, 16 Feb 2016 13:12:02 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45717) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aVk4Y-00025S-FP for qemu-devel@nongnu.org; Tue, 16 Feb 2016 13:10:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aVk4X-0005ts-GQ for qemu-devel@nongnu.org; Tue, 16 Feb 2016 13:10:02 -0500 Received: from mnementh.archaic.org.uk ([2001:8b0:1d0::1]:57405) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aVk4X-0005sC-Ad; Tue, 16 Feb 2016 13:10:01 -0500 Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.84) (envelope-from ) id 1aVk4P-0003SF-6u; Tue, 16 Feb 2016 18:09:53 +0000 From: Peter Maydell To: qemu-devel@nongnu.org Date: Tue, 16 Feb 2016 18:09:45 +0000 Message-Id: <1455646193-13238-4-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1455646193-13238-1-git-send-email-peter.maydell@linaro.org> References: <1455646193-13238-1-git-send-email-peter.maydell@linaro.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:8b0:1d0::1 Cc: "Edgar E. Iglesias" , Alistair Francis , qemu-arm@nongnu.org, Peter Crosthwaite Subject: [Qemu-devel] [PATCH v3 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 1681728..edd4c82 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -394,8 +394,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; @@ -436,7 +437,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); } } @@ -680,7 +681,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; @@ -1787,8 +1788,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[] = { @@ -1808,6 +1807,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 = {