aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/spi/spi.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/spi/spi.h')
-rw-r--r--include/linux/spi/spi.h44
1 files changed, 29 insertions, 15 deletions
diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h
index 6b00f18f5e6b..cce80e6dc7d1 100644
--- a/include/linux/spi/spi.h
+++ b/include/linux/spi/spi.h
@@ -51,6 +51,8 @@ extern struct bus_type spi_bus_type;
51 * @bytes_tx: number of bytes sent to device 51 * @bytes_tx: number of bytes sent to device
52 * @bytes_rx: number of bytes received from device 52 * @bytes_rx: number of bytes received from device
53 * 53 *
54 * @transfer_bytes_histo:
55 * transfer bytes histogramm
54 */ 56 */
55struct spi_statistics { 57struct spi_statistics {
56 spinlock_t lock; /* lock for the whole structure */ 58 spinlock_t lock; /* lock for the whole structure */
@@ -68,6 +70,8 @@ struct spi_statistics {
68 unsigned long long bytes_rx; 70 unsigned long long bytes_rx;
69 unsigned long long bytes_tx; 71 unsigned long long bytes_tx;
70 72
73#define SPI_STATISTICS_HISTO_SIZE 17
74 unsigned long transfer_bytes_histo[SPI_STATISTICS_HISTO_SIZE];
71}; 75};
72 76
73void spi_statistics_add_transfer_stats(struct spi_statistics *stats, 77void spi_statistics_add_transfer_stats(struct spi_statistics *stats,
@@ -250,7 +254,7 @@ static inline struct spi_driver *to_spi_driver(struct device_driver *drv)
250 return drv ? container_of(drv, struct spi_driver, driver) : NULL; 254 return drv ? container_of(drv, struct spi_driver, driver) : NULL;
251} 255}
252 256
253extern int spi_register_driver(struct spi_driver *sdrv); 257extern int __spi_register_driver(struct module *owner, struct spi_driver *sdrv);
254 258
255/** 259/**
256 * spi_unregister_driver - reverse effect of spi_register_driver 260 * spi_unregister_driver - reverse effect of spi_register_driver
@@ -263,6 +267,10 @@ static inline void spi_unregister_driver(struct spi_driver *sdrv)
263 driver_unregister(&sdrv->driver); 267 driver_unregister(&sdrv->driver);
264} 268}
265 269
270/* use a define to avoid include chaining to get THIS_MODULE */
271#define spi_register_driver(driver) \
272 __spi_register_driver(THIS_MODULE, driver)
273
266/** 274/**
267 * module_spi_driver() - Helper macro for registering a SPI driver 275 * module_spi_driver() - Helper macro for registering a SPI driver
268 * @__spi_driver: spi_driver struct 276 * @__spi_driver: spi_driver struct
@@ -843,8 +851,10 @@ extern int spi_bus_unlock(struct spi_master *master);
843 * @len: data buffer size 851 * @len: data buffer size
844 * Context: can sleep 852 * Context: can sleep
845 * 853 *
846 * This writes the buffer and returns zero or a negative error code. 854 * This function writes the buffer @buf.
847 * Callable only from contexts that can sleep. 855 * Callable only from contexts that can sleep.
856 *
857 * Return: zero on success, else a negative error code.
848 */ 858 */
849static inline int 859static inline int
850spi_write(struct spi_device *spi, const void *buf, size_t len) 860spi_write(struct spi_device *spi, const void *buf, size_t len)
@@ -867,8 +877,10 @@ spi_write(struct spi_device *spi, const void *buf, size_t len)
867 * @len: data buffer size 877 * @len: data buffer size
868 * Context: can sleep 878 * Context: can sleep
869 * 879 *
870 * This reads the buffer and returns zero or a negative error code. 880 * This function reads the buffer @buf.
871 * Callable only from contexts that can sleep. 881 * Callable only from contexts that can sleep.
882 *
883 * Return: zero on success, else a negative error code.
872 */ 884 */
873static inline int 885static inline int
874spi_read(struct spi_device *spi, void *buf, size_t len) 886spi_read(struct spi_device *spi, void *buf, size_t len)
@@ -895,7 +907,7 @@ spi_read(struct spi_device *spi, void *buf, size_t len)
895 * 907 *
896 * For more specific semantics see spi_sync(). 908 * For more specific semantics see spi_sync().
897 * 909 *
898 * It returns zero on success, else a negative error code. 910 * Return: Return: zero on success, else a negative error code.
899 */ 911 */
900static inline int 912static inline int
901spi_sync_transfer(struct spi_device *spi, struct spi_transfer *xfers, 913spi_sync_transfer(struct spi_device *spi, struct spi_transfer *xfers,
@@ -919,9 +931,10 @@ extern int spi_write_then_read(struct spi_device *spi,
919 * @cmd: command to be written before data is read back 931 * @cmd: command to be written before data is read back
920 * Context: can sleep 932 * Context: can sleep
921 * 933 *
922 * This returns the (unsigned) eight bit number returned by the 934 * Callable only from contexts that can sleep.
923 * device, or else a negative error code. Callable only from 935 *
924 * contexts that can sleep. 936 * Return: the (unsigned) eight bit number returned by the
937 * device, or else a negative error code.
925 */ 938 */
926static inline ssize_t spi_w8r8(struct spi_device *spi, u8 cmd) 939static inline ssize_t spi_w8r8(struct spi_device *spi, u8 cmd)
927{ 940{
@@ -940,12 +953,13 @@ static inline ssize_t spi_w8r8(struct spi_device *spi, u8 cmd)
940 * @cmd: command to be written before data is read back 953 * @cmd: command to be written before data is read back
941 * Context: can sleep 954 * Context: can sleep
942 * 955 *
943 * This returns the (unsigned) sixteen bit number returned by the
944 * device, or else a negative error code. Callable only from
945 * contexts that can sleep.
946 *
947 * The number is returned in wire-order, which is at least sometimes 956 * The number is returned in wire-order, which is at least sometimes
948 * big-endian. 957 * big-endian.
958 *
959 * Callable only from contexts that can sleep.
960 *
961 * Return: the (unsigned) sixteen bit number returned by the
962 * device, or else a negative error code.
949 */ 963 */
950static inline ssize_t spi_w8r16(struct spi_device *spi, u8 cmd) 964static inline ssize_t spi_w8r16(struct spi_device *spi, u8 cmd)
951{ 965{
@@ -964,13 +978,13 @@ static inline ssize_t spi_w8r16(struct spi_device *spi, u8 cmd)
964 * @cmd: command to be written before data is read back 978 * @cmd: command to be written before data is read back
965 * Context: can sleep 979 * Context: can sleep
966 * 980 *
967 * This returns the (unsigned) sixteen bit number returned by the device in cpu
968 * endianness, or else a negative error code. Callable only from contexts that
969 * can sleep.
970 *
971 * This function is similar to spi_w8r16, with the exception that it will 981 * This function is similar to spi_w8r16, with the exception that it will
972 * convert the read 16 bit data word from big-endian to native endianness. 982 * convert the read 16 bit data word from big-endian to native endianness.
973 * 983 *
984 * Callable only from contexts that can sleep.
985 *
986 * Return: the (unsigned) sixteen bit number returned by the device in cpu
987 * endianness, or else a negative error code.
974 */ 988 */
975static inline ssize_t spi_w8r16be(struct spi_device *spi, u8 cmd) 989static inline ssize_t spi_w8r16be(struct spi_device *spi, u8 cmd)
976 990