1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-18 12:52:44 +01:00

Merge pull request #2700 from gebart/pr/lis3dh-add-missing-spi-release

lis3dh: Add missing spi_release in error cases.
This commit is contained in:
Hauke Petersen 2015-03-25 21:26:01 +01:00
commit a5cf137cc4

View File

@ -76,6 +76,9 @@ int lis3dh_read_xyz(const lis3dh_t *dev, lis3dh_data_t *acc_data)
if (spi_transfer_regs(dev->spi, addr, NULL, (char *)acc_data,
sizeof(lis3dh_data_t)) != sizeof(lis3dh_data_t)) {
/* Transfer error */
gpio_set(dev->cs);
/* Release the bus for other threads. */
spi_release(dev->spi);
return -1;
}
@ -189,6 +192,9 @@ static int lis3dh_read_regs(const lis3dh_t *dev, const lis3dh_reg_t reg, const u
if (spi_transfer_regs(dev->spi, addr, NULL, (char *)buf, len) < 0) {
/* Transfer error */
gpio_set(dev->cs);
/* Release the bus for other threads. */
spi_release(dev->spi);
return -1;
}
@ -220,6 +226,9 @@ static int lis3dh_write_reg(const lis3dh_t *dev, const lis3dh_reg_t reg, const u
if (spi_transfer_reg(dev->spi, addr, value, NULL) < 0) {
/* Transfer error */
gpio_set(dev->cs);
/* Release the bus for other threads. */
spi_release(dev->spi);
return -1;
}