From: Philipp Tomsich Date: Sun, 3 Feb 2019 15:17:28 +0000 (+0100) Subject: rockchip: spi: fix off-by-one in chunk size computation X-Git-Url: http://git.dujemihanovic.xyz/%22http:/www.sics.se/static/git-logo.png?a=commitdiff_plain;h=e647decdd93c7408741329432f26758fbec04c7a;p=u-boot.git rockchip: spi: fix off-by-one in chunk size computation The maximum transfer length (in a single transaction) for the Rockchip SPI controller is 64Kframes (i.e. 0x10000 frames) of 8bit or 16bit frames and is encoded as (num_frames - 1) in CTRLR1. The existing code subtracted the "minus 1" twice for a maximum transfer length of 0xffff (64K - 1) frames. While this is not strictly an error (the existing code is correct, but leads to a bit of head-scrating), fix this off-by-one situation. Signed-off-by: Philipp Tomsich --- diff --git a/drivers/spi/rk_spi.c b/drivers/spi/rk_spi.c index 1df497df63..e7b2df8d02 100644 --- a/drivers/spi/rk_spi.c +++ b/drivers/spi/rk_spi.c @@ -356,7 +356,7 @@ static int rockchip_spi_xfer(struct udevice *dev, unsigned int bitlen, spi_cs_activate(dev, slave_plat->cs); while (len > 0) { - int todo = min(len, 0xffff); + int todo = min(len, 0x10000); rkspi_enable_chip(regs, false); writel(todo - 1, ®s->ctrlr1);