From patchwork Tue Oct 15 03:07:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 1176754 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46sgfQ6zpGz9sPF for ; Tue, 15 Oct 2019 14:20:14 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Z43xjezy"; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 46sgfQ5Wz2zDqJK for ; Tue, 15 Oct 2019 14:20:14 +1100 (AEDT) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::641; helo=mail-pl1-x641.google.com; envelope-from=npiggin@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Z43xjezy"; dkim-atps=neutral Received: from mail-pl1-x641.google.com (mail-pl1-x641.google.com [IPv6:2607:f8b0:4864:20::641]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 46sgV44wdMzDqRR for ; Tue, 15 Oct 2019 14:13:00 +1100 (AEDT) Received: by mail-pl1-x641.google.com with SMTP id u20so8882716plq.4 for ; Mon, 14 Oct 2019 20:13:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=nbK3P51iV91Lhm+V6LgZgLT1Nyd+Sf5dGmmno7i0JiI=; b=Z43xjezy0MBWPaq1dXScA2dN7Ze2XwW6XJumKWWZgxB//tnmmaRTH4AgMxmubYDGp0 yoPb296tfm6duzp+SSB37lP2i1iK+zvwD7DsIaFmz1k+RueRuB1woTzItQgL7+dyzZbk HAtSts1HwRoKI2MM8+kQu0BSMg4oj+MXzrrWGME+Pu4L2wsO/ZmjqTuY15vCo2VBYZrR flv6d+ITYo8pMRSpj0SVkM3MUjI6zp4sMG/v8hkmSjDZzouaY1bRvw79FtKWCxwi7c/L klQYsU/jtP2R/hpumsAzuQGRTiPJtemDA0dwLdmykD5oImYuN8HgljLHLSF3bpdHbyxg 5YWw== 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=nbK3P51iV91Lhm+V6LgZgLT1Nyd+Sf5dGmmno7i0JiI=; b=cx8bcliFFU4xZhZFYNloK92/FwYDyYVtdGLzj3B7RASqaVuS9rowVTSAsqlSOOG82V U57vxwQAyGXgqzlGGBeFWksbcljJ6Qzy1Q71hCX89k5GTYswv5TXjQIZNvFrfubcs+Au 9MNtLfNq09MYp1BHgjTLXYdOL0Nn81Sam8m6HTwnA8e5/m6aW0o4tGg1KC6zK376tNT+ sFOZTBdL1P6doXRO78Z7oiI42PByBvRRqZruAWAUOXFpd46ENNj+PYBHQwfFq0MaV14v GPqWWf4l/U9oe47E2ncjsRgNlv/sHaJaDub50FaKopmy3JLUnKNQRhURmhSR34R8nRTO hQqA== X-Gm-Message-State: APjAAAXvos8C8pjwZB7Y4r5C0MUXWgZAanQZBG9/GlDzL+2F0Ef4W5fH LHPpY7DA7cc/hSD7RM3s4+d9IxwC4P4= X-Google-Smtp-Source: APXvYqyXPcjTctAT/4nqFfqXKmNcYds2jC2hQSr0CqOaPYktLWyBsUjJAk3UCX74qXxPKlQAsK9pfQ== X-Received: by 2002:a17:902:a717:: with SMTP id w23mr32695045plq.177.1571109178057; Mon, 14 Oct 2019 20:12:58 -0700 (PDT) Received: from bobo.local0.net (60-240-111-58.tpgi.com.au. [60.240.111.58]) by smtp.gmail.com with ESMTPSA id w6sm23089828pfw.84.2019.10.14.20.12.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2019 20:12:57 -0700 (PDT) From: Nicholas Piggin To: skiboot@lists.ozlabs.org Date: Tue, 15 Oct 2019 13:07:13 +1000 Message-Id: <20191015030717.15637-24-npiggin@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191015030717.15637-1-npiggin@gmail.com> References: <20191015030717.15637-1-npiggin@gmail.com> MIME-Version: 1.0 Subject: [Skiboot] [PATCH v5 23/27] sfc-ctrl: endian conversions X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" Signed-off-by: Nicholas Piggin --- hw/sfc-ctrl.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/hw/sfc-ctrl.c b/hw/sfc-ctrl.c index f17b8de29..d66be09eb 100644 --- a/hw/sfc-ctrl.c +++ b/hw/sfc-ctrl.c @@ -110,33 +110,32 @@ struct sfc_ctrl { /* Command register support */ static inline int sfc_reg_read(uint8_t reg, uint32_t *val) { - uint32_t tmp; int rc; *val = 0xffffffff; - rc = lpc_fw_read32(&tmp, SFC_CMDREG_OFFSET + reg); + rc = lpc_fw_read32(val, SFC_CMDREG_OFFSET + reg); if (rc) return rc; - *val = be32_to_cpu(tmp); return 0; } static inline int sfc_reg_write(uint8_t reg, uint32_t val) { - return lpc_fw_write32(cpu_to_be32(val), SFC_CMDREG_OFFSET + reg); + return lpc_fw_write32(val, SFC_CMDREG_OFFSET + reg); } static int sfc_buf_write(uint32_t len, const void *data) { - uint32_t tmp, off = 0; + __be32 tmp; + uint32_t off = 0; int rc; if (len > SFC_CMDBUF_SIZE) return FLASH_ERR_PARM_ERROR; while (len >= 4) { - tmp = *(const uint32_t *)data; - rc = lpc_fw_write32(tmp, SFC_CMDBUF_OFFSET + off); + tmp = cpu_to_be32(*(const uint32_t *)data); + rc = lpc_fw_write32((u32)tmp, SFC_CMDBUF_OFFSET + off); if (rc) return rc; off += 4; @@ -150,9 +149,9 @@ static int sfc_buf_write(uint32_t len, const void *data) * in memory with memcpy. The swap in the register on LE doesn't * matter, the result in memory will be in the right order. */ - tmp = -1; - memcpy(&tmp, data, len); - return lpc_fw_write32(tmp, SFC_CMDBUF_OFFSET + off); + tmp = cpu_to_be32(-1); + memcpy(&tmp, data, len); /* XXX: is this right? */ + return lpc_fw_write32((u32)tmp, SFC_CMDBUF_OFFSET + off); } static int sfc_buf_read(uint32_t len, void *data)