summaryrefslogtreecommitdiffstats
path: root/include/linux/spi
diff options
context:
space:
mode:
authorMark Brown2019-05-12 05:08:03 +0200
committerMark Brown2019-05-12 05:08:03 +0200
commite727d4cbc785e9c1b4d239eef274dc63bc1aff24 (patch)
treea10ba6c1e779731d281f9f8916cfb0e7a730ea6b /include/linux/spi
parentspi: rockchip: turn down tx dma bursts (diff)
parentspi: Add spi_is_bpw_supported() (diff)
downloadkernel-qcow2-linux-e727d4cbc785e9c1b4d239eef274dc63bc1aff24.tar.gz
kernel-qcow2-linux-e727d4cbc785e9c1b4d239eef274dc63bc1aff24.tar.xz
kernel-qcow2-linux-e727d4cbc785e9c1b4d239eef274dc63bc1aff24.zip
Merge tag 'spi-bpw-is-supported' of https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi into spi-5.3
spi: Add spi_is_bpw_supported() Lets client drivers check and potentially handle issues.
Diffstat (limited to 'include/linux/spi')
-rw-r--r--include/linux/spi/spi.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h
index e552a036cb4d..f55b20254612 100644
--- a/include/linux/spi/spi.h
+++ b/include/linux/spi/spi.h
@@ -1005,6 +1005,26 @@ spi_max_transfer_size(struct spi_device *spi)
return min(tr_max, msg_max);
}
+/**
+ * spi_is_bpw_supported - Check if bits per word is supported
+ * @spi: SPI device
+ * @bpw: Bits per word
+ *
+ * This function checks to see if the SPI controller supports @bpw.
+ *
+ * Returns:
+ * True if @bpw is supported, false otherwise.
+ */
+static inline bool spi_is_bpw_supported(struct spi_device *spi, u32 bpw)
+{
+ u32 bpw_mask = spi->master->bits_per_word_mask;
+
+ if (bpw == 8 || (bpw <= 32 && bpw_mask & SPI_BPW_MASK(bpw)))
+ return true;
+
+ return false;
+}
+
/*---------------------------------------------------------------------------*/
/* SPI transfer replacement methods which make use of spi_res */