Skip to content

Commit cb9d8ba

Browse files
danieldegrassecarlescufi
authored andcommitted
drivers: sdhc: sdhc_spi: release bus on error
Properly release SPI bus on transmit error within the SDHC SPI driver. In these cases return code is not checked, as we wish to return the error code from the failed transfer to the SD stack. Fixes #72364 Signed-off-by: Daniel DeGrasse <[email protected]>
1 parent 696a1a0 commit cb9d8ba

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

drivers/sdhc/sdhc_spi.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2022 NXP
2+
* Copyright 2022,2024 NXP
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -143,6 +143,7 @@ static int sdhc_spi_init_card(const struct device *dev)
143143
spi_cfg->operation |= SPI_CS_ACTIVE_HIGH;
144144
ret = sdhc_spi_rx(config->spi_dev, spi_cfg, data->scratch, 10);
145145
if (ret != 0) {
146+
spi_release(config->spi_dev, spi_cfg);
146147
spi_cfg->operation &= ~SPI_CS_ACTIVE_HIGH;
147148
return ret;
148149
}
@@ -638,6 +639,8 @@ static int sdhc_spi_request(const struct device *dev,
638639
} while ((ret != 0) && (retries-- > 0));
639640
}
640641
if (ret) {
642+
/* Release SPI bus */
643+
spi_release(config->spi_dev, dev_data->spi_cfg);
641644
return ret;
642645
}
643646
/* Release SPI bus */

0 commit comments

Comments
 (0)