History

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.

Mark Brown committed 7 years ago

Commit e727d4c2 parents 4730072 e6f3f7e1 file · +20 −0Browse files

Unified · Split

include/linux/spi/spi.h+20−0
@@ -1005,6 +1005,26 @@ spi_max_transfer_size(struct spi_device *spi) · 1004 unmodified lines
10051005 return min(tr_max, msg_max);
10061006 }
10071007
1008+/**
1009+ * spi_is_bpw_supported - Check if bits per word is supported
1010+ * @spi: SPI device
1011+ * @bpw: Bits per word
1012+ *
1013+ * This function checks to see if the SPI controller supports @bpw.
1014+ *
1015+ * Returns:
1016+ * True if @bpw is supported, false otherwise.
1017+ */
1018+static inline bool spi_is_bpw_supported(struct spi_device *spi, u32 bpw)
1019+{
1020+ u32 bpw_mask = spi->master->bits_per_word_mask;
1021+
1022+ if (bpw == 8 || (bpw <= 32 && bpw_mask & SPI_BPW_MASK(bpw)))
1023+ return true;
1024+
1025+ return false;
1026+}
1027+
10081028 /*---------------------------------------------------------------------------*/
10091029
10101030 /* SPI transfer replacement methods which make use of spi_res */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t