[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20180109203248.139249-2-briannorris@chromium.org>
Date: Tue, 9 Jan 2018 12:32:48 -0800
From: Brian Norris <briannorris@...omium.org>
To: Archit Taneja <architt@...eaurora.org>,
Andrzej Hajda <a.hajda@...sung.com>,
Laurent Pinchart <Laurent.pinchart@...asonboard.com>
Cc: David Airlie <airlied@...ux.ie>,
Yannick Fertre <yannick.fertre@...com>,
Philippe Cornu <philippe.cornu@...com>,
Vincent Abriou <vincent.abriou@...com>,
dri-devel@...ts.freedesktop.org, linux-kernel@...r.kernel.org,
Sean Paul <seanpaul@...omium.org>,
Nickey Yang <nickey.yang@...k-chips.com>, hl@...k-chips.com,
<linux-rockchip@...ts.infradead.org>, mka@...omium.org,
hoegsberg@...il.com, zyw@...k-chips.com, xbl@...k-chips.com,
Brian Norris <briannorris@...omium.org>
Subject: [PATCH v2 2/2] drm/bridge/synopsys: dsi: handle endianness correctly in dw_mipi_dsi_write()
We're filling the "remainder" word with little-endian data, then writing
it out to IO registers with endian-correcting writel(). That probably
won't work on big-endian systems.
Let's mark the "remainder" variable as LE32 (since we fill it with
memcpy()) and do the swapping explicitly.
Some of this function could be done more easily without memcpy(), but
the unaligned "remainder" case is a little hard to do without
potentially overrunning 'tx_buf', so I just applied the same solution in
all cases (memcpy() + le32_to_cpu()).
Tested only on a little-endian system.
Signed-off-by: Brian Norris <briannorris@...omium.org>
---
drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
index ed91e32ee43a..90f13df6f106 100644
--- a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
+++ b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
@@ -360,18 +360,18 @@ static int dw_mipi_dsi_write(struct dw_mipi_dsi *dsi,
{
const u8 *tx_buf = packet->payload;
int len = packet->payload_length, pld_data_bytes = sizeof(u32), ret;
- u32 remainder;
+ __le32 word;
u32 val;
while (len) {
if (len < pld_data_bytes) {
- remainder = 0;
- memcpy(&remainder, tx_buf, len);
- dsi_write(dsi, DSI_GEN_PLD_DATA, remainder);
+ word = 0;
+ memcpy(&word, tx_buf, len);
+ dsi_write(dsi, DSI_GEN_PLD_DATA, le32_to_cpu(word));
len = 0;
} else {
- memcpy(&remainder, tx_buf, pld_data_bytes);
- dsi_write(dsi, DSI_GEN_PLD_DATA, remainder);
+ memcpy(&word, tx_buf, pld_data_bytes);
+ dsi_write(dsi, DSI_GEN_PLD_DATA, le32_to_cpu(word));
tx_buf += pld_data_bytes;
len -= pld_data_bytes;
}
@@ -386,9 +386,9 @@ static int dw_mipi_dsi_write(struct dw_mipi_dsi *dsi,
}
}
- remainder = 0;
- memcpy(&remainder, packet->header, sizeof(packet->header));
- return dw_mipi_dsi_gen_pkt_hdr_write(dsi, remainder);
+ word = 0;
+ memcpy(&word, packet->header, sizeof(packet->header));
+ return dw_mipi_dsi_gen_pkt_hdr_write(dsi, le32_to_cpu(word));
}
static ssize_t dw_mipi_dsi_host_transfer(struct mipi_dsi_host *host,
--
2.16.0.rc1.238.g530d649a79-goog
Powered by blists - more mailing lists