From patchwork Tue Dec 21 01:27:02 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hu Mingkai-B21284 X-Patchwork-Id: 423231 Received: from lists.sourceforge.net (lists.sourceforge.net [216.34.181.88]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id oBL274mg029916 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 21 Dec 2010 02:07:25 GMT Received: from localhost ([127.0.0.1] helo=sfs-ml-2.v29.ch3.sourceforge.com) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.69) (envelope-from ) id 1PUrck-0004BB-9U; Tue, 21 Dec 2010 02:06:46 +0000 Received: from sog-mx-1.v43.ch3.sourceforge.com ([172.29.43.191] helo=mx.sourceforge.net) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.69) (envelope-from ) id 1PUrcj-0004B6-SR for spi-devel-general@lists.sourceforge.net; Tue, 21 Dec 2010 02:06:45 +0000 X-ACL-Warn: Received: from am1ehsobe002.messaging.microsoft.com ([213.199.154.205] helo=AM1EHSOBE002.bigfish.com) by sog-mx-1.v43.ch3.sourceforge.com with esmtps (TLSv1:AES128-SHA:128) (Exim 4.72) id 1PUrci-00089M-Ec for spi-devel-general@lists.sourceforge.net; Tue, 21 Dec 2010 02:06:45 +0000 Received: from mail6-am1-R.bigfish.com (10.3.201.247) by AM1EHSOBE002.bigfish.com (10.3.204.22) with Microsoft SMTP Server id 14.1.225.8; Tue, 21 Dec 2010 02:06:38 +0000 Received: from mail6-am1 (localhost.localdomain [127.0.0.1]) by mail6-am1-R.bigfish.com (Postfix) with ESMTP id E8A471E815E; Tue, 21 Dec 2010 02:06:37 +0000 (UTC) X-SpamScore: -3 X-BigFish: VS-3(zzbb2cKzz1202hzz8275bhz2dh2a8h668h62h) X-Spam-TCS-SCL: 1:0 X-Forefront-Antispam-Report: KIP:(null); UIP:(null); IPVD:NLI; H:de01egw02.freescale.net; RD:de01egw02.freescale.net; EFVD:NLI Received: from mail6-am1 (localhost.localdomain [127.0.0.1]) by mail6-am1 (MessageSwitch) id 1292897197801503_21612; Tue, 21 Dec 2010 02:06:37 +0000 (UTC) Received: from AM1EHSMHS010.bigfish.com (unknown [10.3.201.252]) by mail6-am1.bigfish.com (Postfix) with ESMTP id BEFA9448050; Tue, 21 Dec 2010 02:06:37 +0000 (UTC) Received: from de01egw02.freescale.net (192.88.165.103) by AM1EHSMHS010.bigfish.com (10.3.207.110) with Microsoft SMTP Server (TLS) id 14.1.225.8; Tue, 21 Dec 2010 02:06:37 +0000 Received: from az33smr01.freescale.net (az33smr01.freescale.net [10.64.34.199]) by de01egw02.freescale.net (8.14.3/8.14.3) with ESMTP id oBL26YrK014834; Mon, 20 Dec 2010 19:06:34 -0700 (MST) Received: from localhost (rock.ap.freescale.net [10.193.20.106]) by az33smr01.freescale.net (8.13.1/8.13.0) with ESMTP id oBL26VAk002749; Mon, 20 Dec 2010 20:06:32 -0600 (CST) From: Mingkai Hu To: , Subject: [PATCH 2/2] eSPI: fix wrong setting of the address in the command buffer Date: Tue, 21 Dec 2010 09:27:02 +0800 Message-ID: <1292894822-7983-1-git-send-email-Mingkai.hu@freescale.com> X-Mailer: git-send-email 1.6.4 MIME-Version: 1.0 X-OriginatorOrg: freescale.com X-Spam-Score: -0.0 (/) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -0.0 AWL AWL: From: address is in the auto white-list X-Headers-End: 1PUrci-00089M-Ec Cc: kumar.gala@freescale.com, tie-fei.zang@freescale.com, Mingkai Hu X-BeenThere: spi-devel-general@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list List-Id: Linux SPI core/device drivers discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: spi-devel-general-bounces@lists.sourceforge.net X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Tue, 21 Dec 2010 02:07:25 +0000 (UTC) diff --git a/drivers/spi/spi_fsl_espi.c b/drivers/spi/spi_fsl_espi.c index ae78926..a99e233 100644 --- a/drivers/spi/spi_fsl_espi.c +++ b/drivers/spi/spi_fsl_espi.c @@ -258,18 +258,18 @@ static int fsl_espi_bufs(struct spi_device *spi, struct spi_transfer *t) return mpc8xxx_spi->count; } -static void fsl_espi_addr2cmd(unsigned int addr, u8 *cmd) +static inline void fsl_espi_addr2cmd(unsigned int addr, u8 *cmd) { - if (cmd[1] && cmd[2] && cmd[3]) { + if (cmd) { cmd[1] = (u8)(addr >> 16); cmd[2] = (u8)(addr >> 8); cmd[3] = (u8)(addr >> 0); } } -static unsigned int fsl_espi_cmd2addr(u8 *cmd) +static inline unsigned int fsl_espi_cmd2addr(u8 *cmd) { - if (cmd[1] && cmd[2] && cmd[3]) + if (cmd) return cmd[1] << 16 | cmd[2] << 8 | cmd[3] << 0; return 0; @@ -395,9 +395,11 @@ static void fsl_espi_rw_trans(struct spi_message *m, } } - addr = fsl_espi_cmd2addr(local_buf); - addr += pos; - fsl_espi_addr2cmd(addr, local_buf); + if (pos > 0) { + addr = fsl_espi_cmd2addr(local_buf); + addr += pos; + fsl_espi_addr2cmd(addr, local_buf); + } espi_trans->n_tx = n_tx; espi_trans->n_rx = trans_len;