Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2218818pxb; Tue, 23 Feb 2021 01:16:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJzCYlqo5o2SbU6MCcU72L/L7ILFrxPn8+2RVXijkrmiuC8EBntz3bThJvYEPMjcgvfyznx4 X-Received: by 2002:a17:906:ad83:: with SMTP id la3mr24379281ejb.257.1614071799160; Tue, 23 Feb 2021 01:16:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614071799; cv=none; d=google.com; s=arc-20160816; b=XKXeq8nihssNoR6p46XvWkeKJIYsN/6FL/AaCLcLZL+Tc7chrtGlqeLPZ8mfl8TCwb TIavfG2zQ7TsPhMzyh2UGMGxOk2W5JafOmWSme30a7YCFyXgG2MayP4E2C08ajL39KBm PF5FrBkLjzAR+FXzP6sM0wL3OUzVjhEychFWKun9Xg7bihb1FK/wc0p7gM1XrqkqlHdm pHb9xLexwC13MtOC05xK+Tm0Mux9sbPWm3aBrCqDcL2KHra/jYrfas6NgJbW1Rj7GXI9 JsRX7vZG0HbNpFDpQQ2nV3e+Lh27W0PkCRzIJN12lu82f+Rf7ozyWcvOoXZ2nKQb8WS5 QzEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=nNEw5+KN/m9CFj7d9waUxYOFKIXM7YhrKD+xb21xU64=; b=W2IjcmgEi5dx9yekkf4STO9skxRth89ImGTOIEk6n3GtV4CKyKhVPlLvjlXunc73si bJ4dKJ2VLnazZ5R32r9AajzxjMNtjThtbEHoWaDuIK9OqveuWElAz0XmqmG1dxDWjNSC YzHqInoTfkAqYSqoSeUt1wI0O1uauf/O75BlpkUiQ6HbpHjZPKZqqziUsGNt6Zlv8jZx yQQ5ahLZ9KmID1gG1uAMO5/6UpnX2F741GinaaTUkOE+oJCPRrUQtcj7SaLR9SkrfWXz k2kEc5cRx+0hgwhUHTRbN8W6qwqE75rwBQzd4+8qmUIXdIxF+m5hLzbz+TQYtdZ3qWqK 0n6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="psiBN/V+"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y16si13660777edi.542.2021.02.23.01.16.13; Tue, 23 Feb 2021 01:16:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="psiBN/V+"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232137AbhBWISc (ORCPT + 99 others); Tue, 23 Feb 2021 03:18:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232101AbhBWISS (ORCPT ); Tue, 23 Feb 2021 03:18:18 -0500 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B8B4C061786; Tue, 23 Feb 2021 00:17:38 -0800 (PST) Received: by mail-wr1-x42f.google.com with SMTP id c7so4866901wru.8; Tue, 23 Feb 2021 00:17:38 -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=nNEw5+KN/m9CFj7d9waUxYOFKIXM7YhrKD+xb21xU64=; b=psiBN/V+prGRoutioxbXUUfUKvFc27265OGNjYreAdo/hf0ULLM8HWcAABYSKGQ09J LkHN1Bha86AZT2mA8vu4iUaHWqGldOVmQpQ7nYN5Xxg1rhCXuTbijw5/iUMp8VyjHEV2 fK/pC9OaYn8fWVRWtBi1S89y5i+HHO/66Cxtf0JvnTB+ndmNfoW0Ro6OvW+CE8F0gAyJ dC91zs9voWHUTcusUafYEPRW2Zw+TB/2uQkQ2ZTgiNm4C9uvOlF8GHj+PYfT+PuIQA8k 7O5KY3nWWBB+G1tx/auQvOMNKeLQpJhEzkCkJ/SuRjykuW8pnyqX+/wTZxQZpIMtwpDC h3Dw== 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=nNEw5+KN/m9CFj7d9waUxYOFKIXM7YhrKD+xb21xU64=; b=mNngCPDJO3GnPtUYaPHUDPApFegPV8ffNEpm4q2RO26CMBE+u9nmK4CY+iTHbdUZKh YdMu8c0ovlgvI0RUD3+zWypEGVk1CH9mDgwEy4vhbaWgA+xWGyADNOEV+eH7T+AW6wL7 CYAglQdbPNtotVe8CpRzDa2cczefoFCIkkH/fqUeSRRYulTdw4OQ+dJqt2+jsmbpaXvV UjVpqF3g8SkdNuusQlkJ7klqBRDwyMNiy3o/+kG9oQgS/Cm6E0Ceg+BeoDgroejiLGFf F5lEWFqYIz0DtcD67JxPGXRkJSRHwmf211kxoPLfPwxeSQh3TCe7e3bgm3w07xhPbrWD 46dw== X-Gm-Message-State: AOAM532DeokHKvNZ23IkDwoLpLL5acdA6yfOpYInE8cYobemuMnM8N6u la3BIhN1fyHFU+I9U4w/7vk= X-Received: by 2002:adf:b611:: with SMTP id f17mr24561268wre.8.1614068257013; Tue, 23 Feb 2021 00:17:37 -0800 (PST) Received: from skynet.lan (170.red-88-1-105.dynamicip.rima-tde.net. [88.1.105.170]) by smtp.gmail.com with ESMTPSA id b83sm1903753wmd.4.2021.02.23.00.17.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Feb 2021 00:17:36 -0800 (PST) From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= To: f.fainelli@gmail.com, Pavel Machek , Dan Murphy , linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org Cc: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= Subject: [PATCH 2/2] leds: bcm6358: improve write and read functions Date: Tue, 23 Feb 2021 09:17:32 +0100 Message-Id: <20210223081732.9362-3-noltari@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210223081732.9362-1-noltari@gmail.com> References: <20210223081732.9362-1-noltari@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is proven to work in BMIPS BE/LE and ARM BE/LE, as used in bcm2835-rng and bcmgenet drivers. Both should also be inline functions. Signed-off-by: Álvaro Fernández Rojas --- drivers/leds/leds-bcm6358.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/drivers/leds/leds-bcm6358.c b/drivers/leds/leds-bcm6358.c index 9d2e487fa08a..775b8c8b562a 100644 --- a/drivers/leds/leds-bcm6358.c +++ b/drivers/leds/leds-bcm6358.c @@ -43,22 +43,23 @@ struct bcm6358_led { bool active_low; }; -static void bcm6358_led_write(void __iomem *reg, unsigned long data) +static inline void bcm6358_led_write(void __iomem *reg, unsigned long data) { -#ifdef CONFIG_CPU_BIG_ENDIAN - iowrite32be(data, reg); -#else - writel(data, reg); -#endif + /* MIPS chips strapped for BE will automagically configure the + * peripheral registers for CPU-native byte order. + */ + if (IS_ENABLED(CONFIG_MIPS) && IS_ENABLED(CONFIG_CPU_BIG_ENDIAN)) + __raw_writel(data, reg); + else + writel_relaxed(data, reg); } -static unsigned long bcm6358_led_read(void __iomem *reg) +static inline unsigned long bcm6358_led_read(void __iomem *reg) { -#ifdef CONFIG_CPU_BIG_ENDIAN - return ioread32be(reg); -#else - return readl(reg); -#endif + if (IS_ENABLED(CONFIG_MIPS) && IS_ENABLED(CONFIG_CPU_BIG_ENDIAN)) + return __raw_readl(reg); + else + return readl_relaxed(reg); } static unsigned long bcm6358_led_busy(void __iomem *mem) -- 2.20.1