From 8d07b1fae80f4005f2227e5e93cd3278f888af13 Mon Sep 17 00:00:00 2001 From: Michael Tretter Date: Thu, 23 Dec 2021 17:03:58 +0100 Subject: spi: add to_spi_device helper 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 Link: https://lore.barebox.org/20211223160404.119970-3-m.tretter@pengutronix.de Signed-off-by: Sascha Hauer --- include/spi/spi.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'include') diff --git a/include/spi/spi.h b/include/spi/spi.h index bca996d8d8..c5ad6bd39f 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; /** -- cgit v1.2.3