From patchwork Tue Nov 10 21:52:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Pavel Pisa X-Patchwork-Id: 322900 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:5ce:0:0:0:0 with SMTP id l14csp598808ils; Tue, 10 Nov 2020 14:05:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJzYaDMSn99qv2+hEPKaZJckrlVyp5pVtnCsAUwctAnYeidRoDFs0RWID0/1ddbGz/7uZnRu X-Received: by 2002:a25:d416:: with SMTP id m22mr1939253ybf.318.1605045930762; Tue, 10 Nov 2020 14:05:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605045930; cv=none; d=google.com; s=arc-20160816; b=QNPr2TaXl0E3WPcQqzPn9R29pXJsSxWWP/hn78+XwxTlI9qmn4HPTgkOXl72WzpkQN IB2Uu5O2GlkJi3PD3W1CFusfxNEytTKAmc3rJQsHuQG2Hz3kE6Usg18qHY9grNJgmzE5 Y3es78/+69Nshedgon/xjiRkPPgEMZsSXYWl8/qHr1INm2x/2E8nipl4XtqVnJmOi16+ nPf6LDgoiptVcwC94QlDOsTv1e3FamqEHciTPxqHAx4eIBmHkGAfrZRpT3mAxub0tw71 K8W5lR2fDUzOLeuiif/JAo2lKwpMu/JE+rBkkfQ2lHZ0M23Cy6dvRestRErFX8IKvYRP 7oRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from; bh=t7CFjQ2WNsxy4YsJ/b8Uun9h9CHZO0BrwTSz66Z+Jt4=; b=uSYY2x27WSXSkMDw71QX2DTJumI1xfRfh2oXTyCjpcJMKG7fVB8E9jKCd5b2u/I1gy SJLoeEa90Dg2rG0ysUi4oz0xrUooNnWhspjhTqTPo05RfILPC0iCqyrgehgfH9fXri1a K+GSTFG08ymJKCAsIyjCO5i/FM5L8NNU55EQmg/LQAg2URjKGaiG3oDi8U+GlHslzqbe V5C/lhvWwcpeJXbZH4JQ1fvqRXj1lthfYrEQ1AvAV12nqWLZyDleXWXDq4mqmrwpeRxg VjXGw/ALlgjkHQycX78D48O5Ga8DizygrInf0z9zqc2XxDUdsjCDWD5hcr14cioFGL9X on3Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id w14si60811ybl.233.2020.11.10.14.05.30 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 10 Nov 2020 14:05:30 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Received: from localhost ([::1]:37166 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kcbla-00032N-68 for patch@linaro.org; Tue, 10 Nov 2020 17:05:30 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:34554) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kcbbO-0007rs-5y for qemu-devel@nongnu.org; Tue, 10 Nov 2020 16:54:58 -0500 Received: from relay.felk.cvut.cz ([2001:718:2:1611:0:1:0:70]:13424) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kcbbM-0002ce-Fl for qemu-devel@nongnu.org; Tue, 10 Nov 2020 16:54:57 -0500 Received: from cmp.felk.cvut.cz (haar.felk.cvut.cz [147.32.84.19]) by relay.felk.cvut.cz (8.15.2/8.15.2) with ESMTP id 0AALrejj095303; Tue, 10 Nov 2020 22:53:40 +0100 (CET) (envelope-from pisa@cmp.felk.cvut.cz) Received: from haar.felk.cvut.cz (localhost [127.0.0.1]) by cmp.felk.cvut.cz (8.14.0/8.12.3/SuSE Linux 0.6) with ESMTP id 0AALreW1028082; Tue, 10 Nov 2020 22:53:40 +0100 Received: (from pisa@localhost) by haar.felk.cvut.cz (8.14.0/8.13.7/Submit) id 0AALret1028081; Tue, 10 Nov 2020 22:53:40 +0100 From: Pavel Pisa To: qemu-devel@nongnu.org, Peter Maydell Subject: [PATCH for-5.2 v3 3/4] hw/net/can/ctucan_core: Handle big-endian hosts Date: Tue, 10 Nov 2020 22:52:49 +0100 Message-Id: <61096a9130b50e74e03914fcbfbb7bc759f5b6b5.1605044619.git.pisa@cmp.felk.cvut.cz> X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 X-FELK-MailScanner-Information: X-MailScanner-ID: 0AALrejj095303 X-FELK-MailScanner: Found to be clean X-FELK-MailScanner-SpamCheck: not spam, SpamAssassin (not cached, score=-0.099, required 6, BAYES_00 -0.50, KHOP_HELO_FCRDNS 0.40, SPF_HELO_NONE 0.00, SPF_NONE 0.00) X-FELK-MailScanner-From: pisa@cmp.felk.cvut.cz X-FELK-MailScanner-Watermark: 1605650023.95102@awhc3FVjGoDauf5+3cGHtg Received-SPF: none client-ip=2001:718:2:1611:0:1:0:70; envelope-from=pisa@cmp.felk.cvut.cz; helo=relay.felk.cvut.cz X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/10 16:54:16 X-ACL-Warn: Detected OS = ??? X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no 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: Vikram Garhwal , Jason Wang , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Ondrej Ille , =?utf-8?q?Jan_Charv=C3=A1t?= , Pavel Pisa Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Peter Maydell The ctucan driver defines types for its registers which are a union of a uint32_t with a struct with bitfields for the individual fields within that register. This is a bad idea, because bitfields aren't portable. The ctu_can_fd_regs.h header works around the most glaring of the portability issues by defining the fields in two different orders depending on the setting of the __LITTLE_ENDIAN_BITFIELD define. However, in ctucan_core.h this is unconditionally set to 1, which is wrong for big-endian hosts. Set it only if HOST_WORDS_BIGENDIAN is not set. There is no need for a "have we defined it already" guard, because the only place that should set it is ctucan_core.h, which has the usual double-inclusion guard. Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé Acked-by: Pavel Pisa Tested-by: Pavel Pisa --- hw/net/can/ctucan_core.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) -- 2.20.1 diff --git a/hw/net/can/ctucan_core.h b/hw/net/can/ctucan_core.h index f21cb1c5ec..bbc09ae067 100644 --- a/hw/net/can/ctucan_core.h +++ b/hw/net/can/ctucan_core.h @@ -31,8 +31,7 @@ #include "exec/hwaddr.h" #include "net/can_emu.h" - -#ifndef __LITTLE_ENDIAN_BITFIELD +#ifndef HOST_WORDS_BIGENDIAN #define __LITTLE_ENDIAN_BITFIELD 1 #endif