From patchwork Tue Nov 10 17:06:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 1397742 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=pass (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=CoYVfKyR; 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 4CVvYf5vQzz9sRK for ; Wed, 11 Nov 2020 04:12:22 +1100 (AEDT) Received: from localhost ([::1]:60828 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kcXBs-0002Gq-Ot for incoming@patchwork.ozlabs.org; Tue, 10 Nov 2020 12:12:20 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47674) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kcX6A-0006Ey-HR for qemu-devel@nongnu.org; Tue, 10 Nov 2020 12:06:26 -0500 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]:50295) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kcX5z-0008Im-Ti for qemu-devel@nongnu.org; Tue, 10 Nov 2020 12:06:26 -0500 Received: by mail-wm1-x344.google.com with SMTP id h2so3847592wmm.0 for ; Tue, 10 Nov 2020 09:06:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=kSQkE4mQsz+5YrFfsY3dUOcYsreKD46sMKkau53xx+o=; b=CoYVfKyR9xho72qKse3GoaQx9V4iQCL2Ifj3Xg6dLyX4SnE5bUd7tqoZjISskD72r+ I0TWV+Y8TQkfhyr9oiyAYuBK7hIKGome61lyvN1KerTsDQhXixaC7BCJpSzZNCT7kHvB ZbP/FpwDCzdzh/r/3SlnymfBi9f+7w9+LfV3TpDiHJo5ziJDyyI+uEdCDoXxr8Uj3diS Grc2y3JZZPR67cHah2yzWewSqaJSfnL0AF4CMu82/r8EQ83Z+buAPLv8Q2M975WNj5dt PIKFJnYebr8piu89neezzRSBzc3NK6Q7Eq5kIRFTASP4v6DWHbxR0Zx28zgqMaai9dz/ 7nsQ== 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=kSQkE4mQsz+5YrFfsY3dUOcYsreKD46sMKkau53xx+o=; b=AruyaGLIW3lb9Iga73IJuBWWDRDakrIF1AmaLO2Y841ERHIdO9AuG1zVuF9Ur90A4y e6/HhiIkar3U2NMwx5NfVKxjiRObBgXMFKUDpmLb/rRIz0COJ6U8ZXCMBb254Q+suphR zhJOraOBl6bpTH5fv4sUcYYgTteHi7pt2pDS94UkxM9I44Y57dDSgB5N90J6g3hsJULW vcl6BN6Y9BdJvkWc6SjXHJpyviwEqRoeDPl4pKL4tVvKhtkZ91THeVNEjFQSK25M6PyQ F57mxNturXGcs1fnJNZ/bs4mQ4ArE0hE4asS2K/8dOpa+foRWKuVIfeF3JhdWL2zZOV+ JZdg== X-Gm-Message-State: AOAM533WlSJ36NEJaSzpCiI7CLjllAvp+Sf3fMlCvxIlKhznruiFxAHE C2aMgUQUu1Rc34uPvgVT+lO/mtrzRlmjsQ== X-Google-Smtp-Source: ABdhPJwDRSFSdfkJBioSiU3QmeEe6yOeFq7/s3NVZYTXycowfhFDhPwqt9NdTcdOlh/nwFM4AD16rg== X-Received: by 2002:a1c:6856:: with SMTP id d83mr47665wmc.13.1605027970551; Tue, 10 Nov 2020 09:06:10 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id h4sm17334893wrq.3.2020.11.10.09.06.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Nov 2020 09:06:10 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PATCH for-5.2 v2 3/4] hw/net/can/ctucan_core: Handle big-endian hosts Date: Tue, 10 Nov 2020 17:06:03 +0000 Message-Id: <20201110170604.5897-4-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201110170604.5897-1-peter.maydell@linaro.org> References: <20201110170604.5897-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::344; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x344.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-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: Jason Wang , Vikram Garhwal , Pavel Pisa Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 --- hw/net/can/ctucan_core.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/hw/net/can/ctucan_core.h b/hw/net/can/ctucan_core.h index f21cb1c5ec3..bbc09ae0678 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