diff options
author | Michael Tretter <m.tretter@pengutronix.de> | 2021-12-23 17:03:58 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2022-01-03 09:06:19 +0100 |
commit | 8d07b1fae80f4005f2227e5e93cd3278f888af13 (patch) | |
tree | a676e661f2dc63d465ea84d230477ad37aee147d /include | |
parent | 22c446c204c9c347e487b3accf5fd4554a77bd74 (diff) | |
download | barebox-8d07b1fae80f4005f2227e5e93cd3278f888af13.tar.gz barebox-8d07b1fae80f4005f2227e5e93cd3278f888af13.tar.xz |
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 <m.tretter@pengutronix.de>
Link: https://lore.barebox.org/20211223160404.119970-3-m.tretter@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'include')
-rw-r--r-- | include/spi/spi.h | 5 |
1 files changed, 5 insertions, 0 deletions
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; /** |