From patchwork Fri Jun 5 10:22:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 1304050 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=IayJJ0n/; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49df3f22Ftz9sSF for ; Fri, 5 Jun 2020 20:27:42 +1000 (AEST) Received: from localhost ([::1]:46960 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jh9Zc-0003Pi-0J for incoming@patchwork.ozlabs.org; Fri, 05 Jun 2020 06:27:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45138) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jh9WX-0007HX-BI for qemu-devel@nongnu.org; Fri, 05 Jun 2020 06:24:29 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:37680 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jh9WW-0006ia-K2 for qemu-devel@nongnu.org; Fri, 05 Jun 2020 06:24:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591352667; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/743Z1QyCRowFD2sBc8yC4KQi0Lmbj/XYRlJsfWAxhE=; b=IayJJ0n/luS5Sq2w1vWMSBHF9FI3IeunXnyRkCWbZIcQXWDdgWTy8cwokhrwG4a8bsFhqy zv/nB+XlgAItPLolyDxfolNYbGcAtZyKpfLfdtNQRD0+d7jFgDdNGpCcgDM78a5fHm72eb H/ovLTsYtGlnHQbfpbPie2EVToqGQOE= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-212-3gbEtARkP0-fNPjxZYTYdA-1; Fri, 05 Jun 2020 06:24:26 -0400 X-MC-Unique: 3gbEtARkP0-fNPjxZYTYdA-1 Received: by mail-wm1-f70.google.com with SMTP id u11so2843583wmc.7 for ; Fri, 05 Jun 2020 03:24:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/743Z1QyCRowFD2sBc8yC4KQi0Lmbj/XYRlJsfWAxhE=; b=tYokkK6ZF8OinUdpN062vJi3Gi2LIU9o6YMJzbXwEe3f/XaLMYtHHGiQnfCdDF9nJ0 EvSeVH2/LBKbN8S/dCOF+oEjY7iCMXfnBwCTna+FjqMyNYDf/Scs6vLa67q13QkNtV+x Vs+nF4+iXb0JE/WMxmGL6tmSuG1IrL0zEKYMKzXuUoh+gU8aL01N2HPW8e5JjLLvIfSY WXuefyRqX6P8PUy/8846VHCRfpn6Ug8B3i8A58Kwv1BqS93cRo62Gusumo42EonhRbmX i2MCQtu6VCm9Pea8/ozKH8qpSrU+doWxeOiGvoPJN2eJ1QmL8XOn6Zy1+71TORjPerxR 1cng== X-Gm-Message-State: AOAM530TXt9z73AYoY/eg4VI5ulaIvEx1B1e9jUHKPQP2LBMkVRjwafu eQeE5m9Nz8Lz7IUEmpDQuYS1h+B64a2CNC1yM8gvVgK4RvQFYlyN1nX1cNEXMZmoLXza8QahK9z MtCbQVrC9E1VdpeI= X-Received: by 2002:a7b:c1ce:: with SMTP id a14mr372867wmj.144.1591352605071; Fri, 05 Jun 2020 03:23:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxAovcUB3nYBZFOQy3cP29FUa8Tar7jITLsTOdjGHAtir/ecZFqj56zF0bezkJyYqEZGsQ0GQ== X-Received: by 2002:a7b:c1ce:: with SMTP id a14mr372848wmj.144.1591352604869; Fri, 05 Jun 2020 03:23:24 -0700 (PDT) Received: from localhost.localdomain (181.red-88-10-103.dynamicip.rima-tde.net. [88.10.103.181]) by smtp.gmail.com with ESMTPSA id y17sm11833422wrn.12.2020.06.05.03.23.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jun 2020 03:23:24 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v3 11/11] hw/sd/sdcard: Simplify realize() a bit Date: Fri, 5 Jun 2020 12:22:30 +0200 Message-Id: <20200605102230.21493-12-philmd@redhat.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200605102230.21493-1-philmd@redhat.com> References: <20200605102230.21493-1-philmd@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=205.139.110.61; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/05 03:35:49 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?P?= =?utf-8?q?hilippe_Mathieu-Daud=C3=A9?= , qemu-block@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Philippe Mathieu-Daudé We don't need to check if sd->blk is set twice. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Peter Maydell --- 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 a1b25ed36f..060ca9d993 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -2123,12 +2123,12 @@ static void sd_realize(DeviceState *dev, Error **errp) return; } - if (sd->blk && blk_is_read_only(sd->blk)) { - error_setg(errp, "Cannot use read-only drive as SD card"); - return; - } - if (sd->blk) { + if (blk_is_read_only(sd->blk)) { + error_setg(errp, "Cannot use read-only drive as SD card"); + return; + } + ret = blk_set_perm(sd->blk, BLK_PERM_CONSISTENT_READ | BLK_PERM_WRITE, BLK_PERM_ALL, errp); if (ret < 0) {