drm/tinydrm: Use spi_is_bpw_supported()
This means that tinydrm_spi_bpw_supported() can be removed. Reviewed-by: Sam Ravnborg <sam@ravnborg.org> Signed-off-by: Noralf Trønnes <noralf@tronnes.org> Link: https://patchwork.freedesktop.org/patch/msgid/20190719155916.62465-4-noralf@tronnes.org
This commit is contained in:
parent
e6652156a3
commit
cfcc8fcb11
@ -53,36 +53,6 @@ size_t tinydrm_spi_max_transfer_size(struct spi_device *spi, size_t max_len)
|
|||||||
}
|
}
|
||||||
EXPORT_SYMBOL(tinydrm_spi_max_transfer_size);
|
EXPORT_SYMBOL(tinydrm_spi_max_transfer_size);
|
||||||
|
|
||||||
/**
|
|
||||||
* tinydrm_spi_bpw_supported - Check if bits per word is supported
|
|
||||||
* @spi: SPI device
|
|
||||||
* @bpw: Bits per word
|
|
||||||
*
|
|
||||||
* This function checks to see if the SPI master driver supports @bpw.
|
|
||||||
*
|
|
||||||
* Returns:
|
|
||||||
* True if @bpw is supported, false otherwise.
|
|
||||||
*/
|
|
||||||
bool tinydrm_spi_bpw_supported(struct spi_device *spi, u8 bpw)
|
|
||||||
{
|
|
||||||
u32 bpw_mask = spi->master->bits_per_word_mask;
|
|
||||||
|
|
||||||
if (bpw == 8)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
if (!bpw_mask) {
|
|
||||||
dev_warn_once(&spi->dev,
|
|
||||||
"bits_per_word_mask not set, assume 8-bit only\n");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bpw_mask & SPI_BPW_MASK(bpw))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
EXPORT_SYMBOL(tinydrm_spi_bpw_supported);
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
tinydrm_dbg_spi_print(struct spi_device *spi, struct spi_transfer *tr,
|
tinydrm_dbg_spi_print(struct spi_device *spi, struct spi_transfer *tr,
|
||||||
const void *buf, int idx, bool tx)
|
const void *buf, int idx, bool tx)
|
||||||
@ -159,7 +129,7 @@ int tinydrm_spi_transfer(struct spi_device *spi, u32 speed_hz,
|
|||||||
pr_debug("[drm:%s] bpw=%u, max_chunk=%zu, transfers:\n",
|
pr_debug("[drm:%s] bpw=%u, max_chunk=%zu, transfers:\n",
|
||||||
__func__, bpw, max_chunk);
|
__func__, bpw, max_chunk);
|
||||||
|
|
||||||
if (bpw == 16 && !tinydrm_spi_bpw_supported(spi, 16)) {
|
if (bpw == 16 && !spi_is_bpw_supported(spi, 16)) {
|
||||||
tr.bits_per_word = 8;
|
tr.bits_per_word = 8;
|
||||||
if (tinydrm_machine_little_endian()) {
|
if (tinydrm_machine_little_endian()) {
|
||||||
swap_buf = kmalloc(min(len, max_chunk), GFP_KERNEL);
|
swap_buf = kmalloc(min(len, max_chunk), GFP_KERNEL);
|
||||||
|
@ -782,7 +782,7 @@ static int mipi_dbi_spi1_transfer(struct mipi_dbi *mipi, int dc,
|
|||||||
u16 *dst16;
|
u16 *dst16;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (!tinydrm_spi_bpw_supported(spi, 9))
|
if (!spi_is_bpw_supported(spi, 9))
|
||||||
return mipi_dbi_spi1e_transfer(mipi, dc, buf, len, bpw);
|
return mipi_dbi_spi1e_transfer(mipi, dc, buf, len, bpw);
|
||||||
|
|
||||||
tr.speed_hz = mipi_dbi_spi_cmd_max_speed(spi, len);
|
tr.speed_hz = mipi_dbi_spi_cmd_max_speed(spi, len);
|
||||||
@ -1003,8 +1003,7 @@ int mipi_dbi_spi_init(struct spi_device *spi, struct mipi_dbi *mipi,
|
|||||||
if (dc) {
|
if (dc) {
|
||||||
mipi->command = mipi_dbi_typec3_command;
|
mipi->command = mipi_dbi_typec3_command;
|
||||||
mipi->dc = dc;
|
mipi->dc = dc;
|
||||||
if (tinydrm_machine_little_endian() &&
|
if (tinydrm_machine_little_endian() && !spi_is_bpw_supported(spi, 16))
|
||||||
!tinydrm_spi_bpw_supported(spi, 16))
|
|
||||||
mipi->swap_bytes = true;
|
mipi->swap_bytes = true;
|
||||||
} else {
|
} else {
|
||||||
mipi->command = mipi_dbi_typec1_command;
|
mipi->command = mipi_dbi_typec1_command;
|
||||||
|
@ -43,7 +43,6 @@ int tinydrm_display_pipe_init(struct drm_device *drm,
|
|||||||
unsigned int rotation);
|
unsigned int rotation);
|
||||||
|
|
||||||
size_t tinydrm_spi_max_transfer_size(struct spi_device *spi, size_t max_len);
|
size_t tinydrm_spi_max_transfer_size(struct spi_device *spi, size_t max_len);
|
||||||
bool tinydrm_spi_bpw_supported(struct spi_device *spi, u8 bpw);
|
|
||||||
int tinydrm_spi_transfer(struct spi_device *spi, u32 speed_hz,
|
int tinydrm_spi_transfer(struct spi_device *spi, u32 speed_hz,
|
||||||
struct spi_transfer *header, u8 bpw, const void *buf,
|
struct spi_transfer *header, u8 bpw, const void *buf,
|
||||||
size_t len);
|
size_t len);
|
||||||
|
Loading…
Reference in New Issue
Block a user