diff options
Diffstat (limited to 'drivers/spi/spi.c')
-rw-r--r-- | drivers/spi/spi.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 51ad42fad567..200ca228d885 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c | |||
@@ -960,7 +960,7 @@ static int spi_transfer_one_message(struct spi_master *master, | |||
960 | struct spi_transfer *xfer; | 960 | struct spi_transfer *xfer; |
961 | bool keep_cs = false; | 961 | bool keep_cs = false; |
962 | int ret = 0; | 962 | int ret = 0; |
963 | unsigned long ms = 1; | 963 | unsigned long long ms = 1; |
964 | struct spi_statistics *statm = &master->statistics; | 964 | struct spi_statistics *statm = &master->statistics; |
965 | struct spi_statistics *stats = &msg->spi->statistics; | 965 | struct spi_statistics *stats = &msg->spi->statistics; |
966 | 966 | ||
@@ -991,9 +991,13 @@ static int spi_transfer_one_message(struct spi_master *master, | |||
991 | 991 | ||
992 | if (ret > 0) { | 992 | if (ret > 0) { |
993 | ret = 0; | 993 | ret = 0; |
994 | ms = xfer->len * 8 * 1000 / xfer->speed_hz; | 994 | ms = 8LL * 1000LL * xfer->len; |
995 | do_div(ms, xfer->speed_hz); | ||
995 | ms += ms + 100; /* some tolerance */ | 996 | ms += ms + 100; /* some tolerance */ |
996 | 997 | ||
998 | if (ms > UINT_MAX) | ||
999 | ms = UINT_MAX; | ||
1000 | |||
997 | ms = wait_for_completion_timeout(&master->xfer_completion, | 1001 | ms = wait_for_completion_timeout(&master->xfer_completion, |
998 | msecs_to_jiffies(ms)); | 1002 | msecs_to_jiffies(ms)); |
999 | } | 1003 | } |
@@ -1159,6 +1163,7 @@ static void __spi_pump_messages(struct spi_master *master, bool in_kthread) | |||
1159 | if (ret < 0) { | 1163 | if (ret < 0) { |
1160 | dev_err(&master->dev, "Failed to power device: %d\n", | 1164 | dev_err(&master->dev, "Failed to power device: %d\n", |
1161 | ret); | 1165 | ret); |
1166 | mutex_unlock(&master->io_mutex); | ||
1162 | return; | 1167 | return; |
1163 | } | 1168 | } |
1164 | } | 1169 | } |
@@ -1174,6 +1179,7 @@ static void __spi_pump_messages(struct spi_master *master, bool in_kthread) | |||
1174 | 1179 | ||
1175 | if (master->auto_runtime_pm) | 1180 | if (master->auto_runtime_pm) |
1176 | pm_runtime_put(master->dev.parent); | 1181 | pm_runtime_put(master->dev.parent); |
1182 | mutex_unlock(&master->io_mutex); | ||
1177 | return; | 1183 | return; |
1178 | } | 1184 | } |
1179 | } | 1185 | } |