mirror of
https://github.com/vsergeev/c-periphery.git
synced 2026-02-07 16:02:14 +08:00
spi: fix unused variable warnings when building without 32-bit mode support
Fix these warnings to allow for clean build:
src/spi.c:75:14: warning: unused variable 'data32' [-Wunused-variable]
uint32_t data32;
src/spi.c:237:49: warning: unused parameter 'extra_flags' [-Wunused-parameter]
int spi_get_extra_flags32(spi_t *spi, uint32_t *extra_flags) {
src/spi.c:308:48: warning: unused parameter ‘extra_flags’ [-Wunused-parameter]
int spi_set_extra_flags32(spi_t *spi, uint32_t extra_flags) {
Signed-off-by: Ryan Barnett <ryanbarnett3@gmail.com>
Modifications to original commit:
* Remove "Suppress warning..." comments.
* Remove unneeded unused variable suppression for `extra_flags` in
`spi_open_advanced2()`.
* Refactor `data32` unused variable suppression in
`spi_open_advanced2()`.
Signed-off-by: Vanya A. Sergeev <v@sergeev.io>
This commit is contained in:
committed by
Vanya A. Sergeev
parent
708f7fe239
commit
21c1b7a48c
@@ -93,6 +93,8 @@ int spi_open_advanced2(spi_t *spi, const char *path, unsigned int mode, uint32_t
|
||||
|
||||
/* Set mode, bit order, extra flags */
|
||||
#ifndef SPI_IOC_WR_MODE32
|
||||
(void)data32;
|
||||
|
||||
data8 = mode | ((bit_order == LSB_FIRST) ? SPI_LSB_FIRST : 0) | extra_flags;
|
||||
if (ioctl(spi->fd, SPI_IOC_WR_MODE, &data8) < 0) {
|
||||
int errsv = errno;
|
||||
@@ -246,6 +248,8 @@ int spi_get_extra_flags32(spi_t *spi, uint32_t *extra_flags) {
|
||||
|
||||
return 0;
|
||||
#else
|
||||
(void)extra_flags;
|
||||
|
||||
return _spi_error(spi, SPI_ERROR_UNSUPPORTED, 0, "Kernel version does not support 32-bit SPI mode flags");
|
||||
#endif
|
||||
}
|
||||
@@ -319,6 +323,8 @@ int spi_set_extra_flags32(spi_t *spi, uint32_t extra_flags) {
|
||||
|
||||
return 0;
|
||||
#else
|
||||
(void)extra_flags;
|
||||
|
||||
return _spi_error(spi, SPI_ERROR_UNSUPPORTED, 0, "Kernel version does not support 32-bit SPI mode flags");
|
||||
#endif
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user