From patchwork Fri Sep 30 12:10:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fam Zheng X-Patchwork-Id: 677036 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 ozlabs.org (Postfix) with ESMTPS id 3slrtz1gDdz9s4x for ; Fri, 30 Sep 2016 22:52:27 +1000 (AEST) Received: from localhost ([::1]:44278 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bpxIf-0002FC-9o for incoming@patchwork.ozlabs.org; Fri, 30 Sep 2016 08:52:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44598) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bpwhJ-0001T1-Be for qemu-devel@nongnu.org; Fri, 30 Sep 2016 08:13:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bpwhC-0007XZ-NF for qemu-devel@nongnu.org; Fri, 30 Sep 2016 08:13:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58342) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bpwhA-0007WQ-Eq; Fri, 30 Sep 2016 08:13:40 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0D39243A44; Fri, 30 Sep 2016 12:13:40 +0000 (UTC) Received: from lemon.redhat.com (vpn1-7-9.pek2.redhat.com [10.72.7.9]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u8UCA6Y6017272; Fri, 30 Sep 2016 08:13:34 -0400 From: Fam Zheng To: qemu-devel@nongnu.org Date: Fri, 30 Sep 2016 20:10:04 +0800 Message-Id: <1475237406-26917-35-git-send-email-famz@redhat.com> In-Reply-To: <1475237406-26917-1-git-send-email-famz@redhat.com> References: <1475237406-26917-1-git-send-email-famz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Fri, 30 Sep 2016 12:13:40 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v8 34/36] onenand: Add 'lock-mode' property X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , qemu-block@nongnu.org, Markus Armbruster , Jeff Cody , rjones@redhat.com, Max Reitz , stefanha@redhat.com, pbonzini@redhat.com, den@openvz.org, John Snow Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Fam Zheng --- hw/block/onenand.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/hw/block/onenand.c b/hw/block/onenand.c index 8d84227..9b058e8 100644 --- a/hw/block/onenand.c +++ b/hw/block/onenand.c @@ -778,6 +778,7 @@ static int onenand_initfn(SysBusDevice *sbd) OneNANDState *s = ONE_NAND(dev); uint32_t size = 1 << (24 + ((s->id.dev >> 4) & 7)); void *ram; + Error *local_err = NULL; s->base = (hwaddr)-1; s->rdy = NULL; @@ -796,6 +797,11 @@ static int onenand_initfn(SysBusDevice *sbd) error_report("Can't use a read-only drive"); return -1; } + blk_lock_image(s->blk, s->lock_mode, &local_err); + if (local_err) { + error_report_err(local_err); + return -1; + } s->blk_cur = s->blk; } s->otp = memset(g_malloc((64 + 2) << PAGE_SHIFT), @@ -828,6 +834,7 @@ static Property onenand_properties[] = { DEFINE_PROP_UINT16("version_id", OneNANDState, id.ver, 0), DEFINE_PROP_INT32("shift", OneNANDState, shift, 0), DEFINE_PROP_DRIVE("drive", OneNANDState, blk), + DEFINE_PROP_LOCK_MODE("lock-mode", OneNANDState, lock_mode), DEFINE_PROP_END_OF_LIST(), };