From patchwork Sun Dec 8 12:23:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 1205648 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (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 47W5Pr4vltz9sPK for ; Sun, 8 Dec 2019 23:35:12 +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="eXQ5WKip"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 47W5Pr2TqtzDqHr for ; Sun, 8 Dec 2019 23:35:12 +1100 (AEDT) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::442; helo=mail-pf1-x442.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="eXQ5WKip"; dkim-atps=neutral Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) (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 47W59c48lPzDqLd for ; Sun, 8 Dec 2019 23:24:36 +1100 (AEDT) Received: by mail-pf1-x442.google.com with SMTP id h14so5741059pfe.10 for ; Sun, 08 Dec 2019 04:24:36 -0800 (PST) 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=eXQ5WKipaCKUsrJebQ0uVt68R+/EDPGt8t+qa6dle06Na3FJ3Htxw00TKI5gQr7llS YHIFWscXdXsenwfz7+PH1GJ/L49wQYK9XeeCi9QfvJvADL/M0ejJM5nPT/bvL/H+Th1n xeuOl95VUFT/4/JinDa5pPMeL+riGQIHeMNQL0fMt79ymQLIKFGszRYllfcqEiIcxhN8 3JLzUDol42Q9vUoqdVutFHG2e+6l4Gi/WZdPBCKgMAPHTjQftVD1o/6dxWuNOE868Moh homwfwz1vE8OcABM/kGryR/ulCHUiJan8bRfKUkGJbCQqCzlB1P74wzjmSLMTAvQexRp p6rA== 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=n5jAFVfMniXUHIzdzgZuCu7MyJxwGv5bRx3ICvxyr9qY8buXDH9i27T8CLX57JLiqU 5CkW6NsCmEz1GVJ88N7CLzdfdZ9wyYu/O9bzLqRIFPD8CeGhdTqaYfLrXXpAUrk0jqgA JfvRoAftSSND+8pOXAnVWU0rtdjJrW+FqngxAiZl+6fhNR6hjmnsrCxpbbz9lyCZaecr 64HM/I9e3MMeCc1cUDJ6eW7PXlh8mhOuUa5xK2fkqqlIKqHOoOkcmFsauY3+mTLm1TlI ifDPvLcaZcQvUunK+t2f1TKpFMPnjaAVZ0WvFvURFIrImThzig6G2yqqfSdF1bUXucuB y+FA== X-Gm-Message-State: APjAAAWvQ/vJyGp7Cll8xUTVhz4YhG6cSBHtpV75L79MN9onum4YbQkT sBkdRERUZUCjJHRhMB9iTAD/L+Va X-Google-Smtp-Source: APXvYqxXykwAEH+Ph/9wuRwAWC4/uBvi7Yyngik8W6vLenkc1BYQafU9GdUaPxqcfIu7Oyzz4lXfMA== X-Received: by 2002:a63:e30a:: with SMTP id f10mr13332789pgh.331.1575807874564; Sun, 08 Dec 2019 04:24:34 -0800 (PST) Received: from bobo.local0.net ([202.21.15.182]) by smtp.gmail.com with ESMTPSA id i9sm23741866pfk.24.2019.12.08.04.24.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Dec 2019 04:24:34 -0800 (PST) From: Nicholas Piggin To: skiboot@lists.ozlabs.org Date: Sun, 8 Dec 2019 22:23:07 +1000 Message-Id: <20191208122312.12837-27-npiggin@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191208122312.12837-1-npiggin@gmail.com> References: <20191208122312.12837-1-npiggin@gmail.com> MIME-Version: 1.0 Subject: [Skiboot] [PATCH v10 26/31] 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)