[PATCH rtems 5/6] cpukit/spi: Allow driver specific ioctl

Christian Mauderer christian.mauderer at embedded-brains.de
Mon Dec 14 15:28:22 UTC 2020


This allows a SPI driver to add a hardware specific ioctl.
---
 cpukit/dev/spi/spi-bus.c     | 3 +++
 cpukit/include/dev/spi/spi.h | 7 +++++++
 2 files changed, 10 insertions(+)

diff --git a/cpukit/dev/spi/spi-bus.c b/cpukit/dev/spi/spi-bus.c
index 5308603216..42b70aa6c9 100644
--- a/cpukit/dev/spi/spi-bus.c
+++ b/cpukit/dev/spi/spi-bus.c
@@ -199,6 +199,8 @@ static int spi_bus_ioctl(
           arg,
           IOCPARM_LEN(command) / sizeof(struct spi_ioc_transfer)
         );
+      } else if (bus->ioctl != NULL) {
+        err = (*bus->ioctl)(bus, command, arg);
       } else {
         err = -EINVAL;
       }
@@ -300,6 +302,7 @@ static int spi_bus_do_init(
   bus->transfer = spi_bus_transfer_default;
   bus->setup = spi_bus_setup_default;
   bus->destroy = destroy;
+  bus->ioctl = NULL;
   bus->bits_per_word = 8;
 
   return 0;
diff --git a/cpukit/include/dev/spi/spi.h b/cpukit/include/dev/spi/spi.h
index dfe9cf512b..8850b288fe 100644
--- a/cpukit/include/dev/spi/spi.h
+++ b/cpukit/include/dev/spi/spi.h
@@ -141,6 +141,13 @@ struct spi_bus {
    * devices.
    */
   uint16_t delay_usecs;
+
+  /**
+   * @brief Driver specific ioctl.
+   *
+   * @param[in] bus The bus control.
+   */
+  int (*ioctl)(spi_bus *bus, ioctl_command_t command, void *arg);
 };
 
 /**
-- 
2.26.2



More information about the devel mailing list