From nobody Tue Feb 10 03:38:57 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1518109034190154.26004101315243; Thu, 8 Feb 2018 08:57:14 -0800 (PST) Received: from localhost ([::1]:52898 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ejpVV-0006A1-77 for importer@patchew.org; Thu, 08 Feb 2018 11:57:09 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41890) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ejpNc-0007pj-6W for qemu-devel@nongnu.org; Thu, 08 Feb 2018 11:49:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ejpNb-0003h6-BW for qemu-devel@nongnu.org; Thu, 08 Feb 2018 11:49:00 -0500 Received: from mail-qk0-x244.google.com ([2607:f8b0:400d:c09::244]:42801) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ejpNb-0003gy-6m for qemu-devel@nongnu.org; Thu, 08 Feb 2018 11:48:59 -0500 Received: by mail-qk0-x244.google.com with SMTP id f68so6420432qke.9 for ; Thu, 08 Feb 2018 08:48:59 -0800 (PST) Received: from x1.local ([138.117.48.219]) by smtp.gmail.com with ESMTPSA id z66sm240905qkc.9.2018.02.08.08.48.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Feb 2018 08:48:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=CJcCd45F8+A4vABbq5ncEfOD1zDCAnlEhafaIXycSmQ=; b=oWBe9TFh5xiSfqqDuYWhs4Q1Wtk/xscim/7CHSflikbQbXGGgq+o/L1ViTbVsWPInq qOL0LLtS4uRIhDRhtMvpFeX/eMkwgxyvtf3Fv2Lgp4e4rGYeHxzpQdm72wXZYpUvD4Gn tf1wMsCowdK8D85YTEwIxiSpt/BHG3dQM7LR33VBZGuD/OtyEcTPgpOzOF4kLzcWND39 6RHoLPFve9ek1659YfRjEyYc3v569ORVij04I6xIqb8miOqCwGfIbF1LdbKvvGa/Hryg ZKFl+LqTTjqe5sTcxlAp6OJvDZFPln9uCzyojzSyjvvvw50IyMpVx46SU/ixH203ksfA c01A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=CJcCd45F8+A4vABbq5ncEfOD1zDCAnlEhafaIXycSmQ=; b=NfiK1xyKWJMwKPE/Z/fSDy7Jh3ejTiKG5HPoDUpUyD3dRVt38Kz/5hWNWJ0bi5O9nU 3NLzVHC8UM2314cBkJsvF5ZupPJ73SSbNxHGVGF/v84ufygLlg6C+bl11qB131YyGFEj Xj7WC5IMI3SB97Kd6Bd7/UFy8flj+gVpfr0MVvr/kDcXcs6J2Id2QL+Z7Pz6oAgS84R/ qbEvKQjCf4DPEDyihfVDNM+Ie0paSn4XVpOupphRzTJSEfW/494P4x7hl1w2bBvycxCM JPM7FeWAI1AFoeIPPbk53XXhtAmOWhrVszXZ96CZeyt6gPZDduLb+lpNCNgrRfWKn7XC UXmQ== X-Gm-Message-State: APf1xPBkZxqD5rcyNFTZr9ukscrBNKLF2kqblldW1fxmxqYf+rImHvbO ndk54kkfvGq1WBpvKCF79W0= X-Google-Smtp-Source: AH8x227/OsCW8oJlVfDuQCfmYezQdzzwzoJKgs3MoH6vCKoLDc1q+lXZCIb/gKpLaCeZNcVJKYu54A== X-Received: by 10.55.42.229 with SMTP id q98mr1824504qkq.150.1518108538608; Thu, 08 Feb 2018 08:48:58 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: Paolo Bonzini , Peter Maydell Date: Thu, 8 Feb 2018 13:47:57 -0300 Message-Id: <20180208164818.7961-10-f4bug@amsat.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180208164818.7961-1-f4bug@amsat.org> References: <20180208164818.7961-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c09::244 Subject: [Qemu-devel] [PATCH v11 09/30] sdhci: simplify sdhci_get_fifolen() 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: "Edgar E . Iglesias" , Alistair Francis , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Alistair Francis --- hw/sd/sdhci-internal.h | 4 +++- hw/sd/sdhci.c | 20 +++++--------------- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/hw/sd/sdhci-internal.h b/hw/sd/sdhci-internal.h index b7751c815f..577ca9da54 100644 --- a/hw/sd/sdhci-internal.h +++ b/hw/sd/sdhci-internal.h @@ -24,6 +24,8 @@ #ifndef SDHCI_INTERNAL_H #define SDHCI_INTERNAL_H =20 +#include "hw/registerfields.h" + /* R/W SDMA System Address register 0x0 */ #define SDHC_SYSAD 0x00 =20 @@ -179,7 +181,7 @@ #define SDHC_CAN_DO_ADMA2 0x00080000 #define SDHC_CAN_DO_ADMA1 0x00100000 #define SDHC_64_BIT_BUS_SUPPORT (1 << 28) -#define SDHC_CAPAB_BLOCKSIZE(x) (((x) >> 16) & 0x3) +FIELD(SDHC_CAPAB, MAXBLOCKLENGTH, 16, 2); =20 /* HWInit Maximum Current Capabilities Register 0x0 */ #define SDHC_MAXCURR 0x48 diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c index da30b58723..b1bcaa6153 100644 --- a/hw/sd/sdhci.c +++ b/hw/sd/sdhci.c @@ -59,6 +59,11 @@ */ #define SDHC_CAPAB_REG_DEFAULT 0x057834b4 =20 +static inline unsigned int sdhci_get_fifolen(SDHCIState *s) +{ + return 1 << (9 + FIELD_EX32(s->capareg, SDHC_CAPAB, MAXBLOCKLENGTH)); +} + static uint8_t sdhci_slotint(SDHCIState *s) { return (s->norintsts & s->norintsigen) || (s->errintsts & s->errintsig= en) || @@ -1118,21 +1123,6 @@ static const MemoryRegionOps sdhci_mmio_ops =3D { .endianness =3D DEVICE_LITTLE_ENDIAN, }; =20 -static inline unsigned int sdhci_get_fifolen(SDHCIState *s) -{ - switch (SDHC_CAPAB_BLOCKSIZE(s->capareg)) { - case 0: - return 512; - case 1: - return 1024; - case 2: - return 2048; - default: - hw_error("SDHC: unsupported value for maximum block size\n"); - return 0; - } -} - static void sdhci_init_readonly_registers(SDHCIState *s, Error **errp) { if (s->sd_spec_version !=3D 2) { --=20 2.16.1