hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/spi/spi-gpio.c
....@@ -244,9 +244,19 @@
244244 if (output)
245245 return gpiod_direction_output(spi_gpio->mosi, 1);
246246
247
- ret = gpiod_direction_input(spi_gpio->mosi);
248
- if (ret)
249
- return ret;
247
+ /*
248
+ * Only change MOSI to an input if using 3WIRE mode.
249
+ * Otherwise, MOSI could be left floating if there is
250
+ * no pull resistor connected to the I/O pin, or could
251
+ * be left logic high if there is a pull-up. Transmitting
252
+ * logic high when only clocking MISO data in can put some
253
+ * SPI devices in to a bad state.
254
+ */
255
+ if (spi->mode & SPI_3WIRE) {
256
+ ret = gpiod_direction_input(spi_gpio->mosi);
257
+ if (ret)
258
+ return ret;
259
+ }
250260 /*
251261 * Send a turnaround high impedance cycle when switching
252262 * from output to input. Theoretically there should be