Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp587348ybt; Fri, 19 Jun 2020 08:47:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxOp8f6WBNnv6PFry9k7PimGfMrDh95VRDJPTOXwTeb13NQ3IbmLO8F0X5BoSDEluw9n173 X-Received: by 2002:a17:906:28da:: with SMTP id p26mr3820657ejd.551.1592581621596; Fri, 19 Jun 2020 08:47:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592581621; cv=none; d=google.com; s=arc-20160816; b=mvhbdT0s86jcXp3LfJcnr/6nVsXTdclLJPWH07/5FLCOrg/PEOj1s+Ui9YozyCvLM1 0+7P647TK3xvTvSPihV1Gftd+DpHFOhxCY1sA4QI5ZADx5FdJwn7bslizPVzqcMPGbV0 EqtA0kZEkjT+m2KeZZ2IMgx6BZe+7Qg11y6jy00ZHgqeGrhBOvAylhWFC49y0lK3W6eE /BgnjGpZuw6+KeaipuKe0mkmbp8m4WfSvdtXj+n2+rsKPuofWU05u+++jTeKpLae09ZU lFHA07D/y0i9VbkHPs5+JFCY7OEZ3a5jmP2LCdYJMdB2sJNsyuB7IHemmtn/UWCTSMKr cxYw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=s+eMORbSgXQ59wiCn9qpCqSkMNqxMFgY+tjIknFeMY4=; b=uUt3UO26ea0+xY3ki/dJdq5542wHtWMiF2pJjCZs3OyQmWleIN80QyETx9BoE51kxa REMwL3d35TIc7cxrTMeAm7Un0FjNPnacI67hgKublNtqFiM0SUtGKrUTqYACx2fj+R+t rOsqb0tXAt/9rt5a65PMwQeUnBLZko3mODP8W3Xns1yww6mExL8ObXYsXoQTRBueq4VP 39Tbnva+fE6kLXO3AQ9XWOplVx7Ha7hoXuz8X5Y2tarFIV4kH90h8CWWvBUN1Q1mHL50 vA9AqSA1q/58Ic/0ARTbhSR/exZ0ysjKzeD32uNbKrPlk1AHz+33KsbljKv8jTS9imm2 fNfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=G0BqSmM9; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dt4si4703304ejc.34.2020.06.19.08.46.39; Fri, 19 Jun 2020 08:47:01 -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=G0BqSmM9; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404486AbgFSP2E (ORCPT + 99 others); Fri, 19 Jun 2020 11:28:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:58742 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2393371AbgFSP1A (ORCPT ); Fri, 19 Jun 2020 11:27:00 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6CBD320734; Fri, 19 Jun 2020 15:26:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592580419; bh=T+jPFC0lA+eBgkxLgd3PN4lxPcbqGMXjwaRExUrc1pA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=G0BqSmM9amzxL8kRl/jfwTfZCN2DtPofx9jKO32pBjjqgzoyaunklC772B+xrOZ51 cau8TwxAnUNqkL7klmJLHsok5lFpnQx3Wfx58oLZ+7wURAOjvPd6ltim5dE4fBE41g BoSIpDqxPHzKQ+ryGIuYg25egUzjV1rrTYDzf2yc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Angelo Dureghello , Vladimir Oltean , Mark Brown , Sasha Levin Subject: [PATCH 5.7 240/376] spi: spi-fsl-dspi: fix native data copy Date: Fri, 19 Jun 2020 16:32:38 +0200 Message-Id: <20200619141721.690045233@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619141710.350494719@linuxfoundation.org> References: <20200619141710.350494719@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 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