linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] spi-topcliff-pch: Fix count calculation issue
@ 2011-11-17  6:37 Tomoya MORINAGA
  2011-12-07 20:43 ` Wolfram Sang
  0 siblings, 1 reply; 3+ messages in thread
From: Tomoya MORINAGA @ 2011-11-17  6:37 UTC (permalink / raw)
  To: Grant Likely, spi-devel-general, linux-kernel
  Cc: qi.wang, yong.y.wang, joel.clark, kok.howg.ewe, Tomoya MORINAGA

Currently, count value is not correct more than len=8193 like below.

len	Current-cnt	New-cnt		Anticipated-cnt
4095	1		1		1
4096	1		1		1
4097	2		2		2

8191	2		2		2
8192	2		2		2
8193	2(NG)		3		3

12287	3		3		3
12288	3		3		3
12289	3(NG)		4		4

This patch fixes the issue.

Signed-off-by: Tomoya MORINAGA <tomoya.rohm@gmail.com>
---
 drivers/spi/spi-topcliff-pch.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/drivers/spi/spi-topcliff-pch.c b/drivers/spi/spi-topcliff-pch.c
index 9fb0541..08b5f31 100644
--- a/drivers/spi/spi-topcliff-pch.c
+++ b/drivers/spi/spi-topcliff-pch.c
@@ -1247,7 +1247,9 @@ static void pch_spi_process_messages(struct work_struct *pwork)
 		}
 		spin_unlock(&data->lock);
 
-		cnt = data->cur_trans->len / (PCH_BUF_SIZE + 1) + 1;
+		if (!data->cur_trans->len)
+			goto out;
+		cnt = (data->cur_trans->len - 1) / PCH_BUF_SIZE + 1;
 		data->save_total_len = data->cur_trans->len;
 		if (data->use_dma) {
 			int i;
-- 
1.7.4.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-12-08  9:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-17  6:37 [PATCH] spi-topcliff-pch: Fix count calculation issue Tomoya MORINAGA
2011-12-07 20:43 ` Wolfram Sang
     [not found]   ` <20111207204344.GC3744-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2011-12-08  9:00     ` Tomoya MORINAGA

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).