spi: fix the divide by 0 error when calculating xfer waiting time
authorXu Yilun <yilun.xu@intel.com>
Mon, 4 Jan 2021 01:29:09 +0000 (09:29 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 19 Jan 2021 17:27:25 +0000 (18:27 +0100)
commit501e1875da3237a876f8d09e1a286ec2ff83d4fe
tree475fbe6d29de06e85d3d946a3846612817db859c
parent17a08680ab6a6c057949cb48c352933e09ea377a
spi: fix the divide by 0 error when calculating xfer waiting time

[ Upstream commit 6170d077bf92c5b3dfbe1021688d3c0404f7c9e9 ]

The xfer waiting time is the result of xfer->len / xfer->speed_hz. This
patch makes the assumption of 100khz xfer speed if the xfer->speed_hz is
not assigned and stays 0. This avoids the divide by 0 issue and ensures
a reasonable tolerant waiting time.

Signed-off-by: Xu Yilun <yilun.xu@intel.com>
Link: https://lore.kernel.org/r/1609723749-3557-1-git-send-email-yilun.xu@intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/spi/spi.c