[PATCH v2 2/8] spi: add to_spi_device helper

Michael Tretter m.tretter at pengutronix.de
Thu Dec 23 08:03:58 PST 2021


Port the helper to get the spi_device from the device_d from Linux.
This macro makes SPI device drivers look a bit nicer.

Signed-off-by: Michael Tretter <m.tretter at pengutronix.de>
---
Changelog:

v2:

- new patch
---
 include/spi/spi.h | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/include/spi/spi.h b/include/spi/spi.h
index bca996d8d8f9..c5ad6bd39ff9 100644
--- a/include/spi/spi.h
+++ b/include/spi/spi.h
@@ -108,6 +108,11 @@ struct spi_device {
 	 */
 };
 
+static inline struct spi_device *to_spi_device(struct device_d *dev)
+{
+        return dev ? container_of(dev, struct spi_device, dev) : NULL;
+}
+
 struct spi_message;
 
 /**
-- 
2.30.2




More information about the barebox mailing list