i2c: xlp9xx: Fix issue seen when updating receive length
authorGeorge Cherian <george.cherian@cavium.com>
Wed, 16 May 2018 07:00:17 +0000 (00:00 -0700)
committerWolfram Sang <wsa@the-dreams.de>
Tue, 22 May 2018 12:06:25 +0000 (14:06 +0200)
commit8d504d804ab657779254bdd37079d2442d75cbe8
tree5cd936b894bc94749cb54f48d2dee3fbd64866b8
parent40f4e372cba8a6729c997c0bda1fa03adf7f956e
i2c: xlp9xx: Fix issue seen when updating receive length

The hardware does not handle updates to the length register gracefully
if the new value is less than the number of bytes received so far. If
this happens, the i2c controller will not stop the receive transaction
properly.

Fix this by ensuring that the updated length is ok. This is done by
making sure that the new length written to hardware is at least few
bytes more than the bytes received so far.

While at that refactor the length updation to a new function.

Signed-off-by: Jayachandran C <jnair@caviumnetworks.com>
Signed-off-by: George Cherian <george.cherian@cavium.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
drivers/i2c/busses/i2c-xlp9xx.c