Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp107345ybg; Mon, 8 Jun 2020 17:47:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxK0aMm0JlJei8NfzVKI1t40cCBHHNRxmCXCuKSuA3Ar1l781P7iGArnpzRZnzo/rzhgajf X-Received: by 2002:a17:906:4944:: with SMTP id f4mr23232488ejt.3.1591663667891; Mon, 08 Jun 2020 17:47:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591663667; cv=none; d=google.com; s=arc-20160816; b=zc8yIDeWoU83z9OdipVxm8yshHqDOgHYfUWSnvtiEgPKSKbS9ny+nBMJ8xS7YykakI g3+8sBh/50pMrkL8IvlOEHaOFreO7MKFxkjKm+JEk2XCOt1cQyxJfWrgy4jmMul151qY nFm33LGxa4Mkw+1Tg0T1mg4rAzSUQeE/Qk1tVwz23Oi1EAmddWkVz+z8aw6Vrkuil1Ft 6vRM5c4QbzGZS2e5YcPCxhZcx9ss2K0M5b4WBhiH9rgxl5/kv5vSjSGz/Xw0y5YOdcEQ JPzkS7T7lVuLM8vG/df/A0YjxBhGPsy5wcQqRgx4iOY5W7mMGsHBJNgg9VLc2hPCVoD3 mOBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=s+eMORbSgXQ59wiCn9qpCqSkMNqxMFgY+tjIknFeMY4=; b=hUVdR/DrHcff5cp9P26p2mwC9Erx54iIVa/ckQqckXHRK2+b+nhcS9XOfuQqHGHXi7 Geo8S4IPcIdo4rUjNnSF6eg5imkiA5SukDnsNw3bNQfBFEbFrQPtuT1WgJEHnMCnKWUF RW4Fo+JzSN2Yazv7N8UJN1kN8ksjYRWEygDFLANtE11OFjJ4aZU946JLMV4QNe5JQIdJ 446FumoyTybIT3mNI4y4SlkkwKwrWx6Wvi4LlReAE5NwEDporPSZ9BcIpv/hf5osDIjx t6E5Wa+wbhSsX+eRvfgKu3k9HrI1D8QrxXZOG8yfL3F9tSJbixN4kskjrCK4zwcOWtq1 M/Jg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=wpauXWF0; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dp4si12087185ejc.258.2020.06.08.17.47.24; Mon, 08 Jun 2020 17:47:47 -0700 (PDT) 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=@kernel.org header.s=default header.b=wpauXWF0; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733282AbgFIApo (ORCPT + 99 others); Mon, 8 Jun 2020 20:45:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:58772 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728970AbgFHXLp (ORCPT ); Mon, 8 Jun 2020 19:11:45 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4458620C56; Mon, 8 Jun 2020 23:11:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591657905; bh=T+jPFC0lA+eBgkxLgd3PN4lxPcbqGMXjwaRExUrc1pA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wpauXWF0xUP/EW+swiGrLj8liDsHnL+S8AW+VkjDO6s4bdx0HuNWU5Hh1wE3UH3zT Wm1Jo/Z7KcgH2KrLcp2Fs23m/huH3apgLJuPORLQZ76sj8c7V7kWChy53jIbQ7h7MX dnM3cgwWSf+JmyDFlzXruaJFpbkLMUdgOyU0yaSw= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Angelo Dureghello , Vladimir Oltean , Mark Brown , Sasha Levin , linux-spi@vger.kernel.org Subject: [PATCH AUTOSEL 5.7 257/274] spi: spi-fsl-dspi: fix native data copy Date: Mon, 8 Jun 2020 19:05:50 -0400 Message-Id: <20200608230607.3361041-257-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200608230607.3361041-1-sashal@kernel.org> References: <20200608230607.3361041-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Angelo Dureghello [ Upstream commit 263b81dc6c932c8bc550d5e7bfc178d2b3fc491e ] ColdFire is a big-endian cpu with a big-endian dspi hw module, so, it uses native access, but memcpy breaks the endianness. So, if i understand properly, by native copy we would mean be(cpu)->be(dspi) or le(cpu)->le(dspi) accesses, so my fix shouldn't break anything, but i couldn't test it on LS family, so every test is really appreciated. Fixes: 53fadb4d90c7 ("spi: spi-fsl-dspi: Simplify bytes_per_word gymnastics") Signed-off-by: Angelo Dureghello Tested-by: Vladimir Oltean Reviewed-by: Vladimir Oltean Link: https://lore.kernel.org/r/20200529195756.184677-1-angelo.dureghello@timesys.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- drivers/spi/spi-fsl-dspi.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/drivers/spi/spi-fsl-dspi.c b/drivers/spi/spi-fsl-dspi.c index 50e41f66a2d7..2e9f9adc5900 100644 --- a/drivers/spi/spi-fsl-dspi.c +++ b/drivers/spi/spi-fsl-dspi.c @@ -246,13 +246,33 @@ struct fsl_dspi { static void dspi_native_host_to_dev(struct fsl_dspi *dspi, u32 *txdata) { - memcpy(txdata, dspi->tx, dspi->oper_word_size); + switch (dspi->oper_word_size) { + case 1: + *txdata = *(u8 *)dspi->tx; + break; + case 2: + *txdata = *(u16 *)dspi->tx; + break; + case 4: + *txdata = *(u32 *)dspi->tx; + break; + } dspi->tx += dspi->oper_word_size; } static void dspi_native_dev_to_host(struct fsl_dspi *dspi, u32 rxdata) { - memcpy(dspi->rx, &rxdata, dspi->oper_word_size); + switch (dspi->oper_word_size) { + case 1: + *(u8 *)dspi->rx = rxdata; + break; + case 2: + *(u16 *)dspi->rx = rxdata; + break; + case 4: + *(u32 *)dspi->rx = rxdata; + break; + } dspi->rx += dspi->oper_word_size; } -- 2.25.1