diff options
Diffstat (limited to 'drivers/media/spi/cxd2880-spi.c')
-rw-r--r-- | drivers/media/spi/cxd2880-spi.c | 32 |
1 files changed, 10 insertions, 22 deletions
diff --git a/drivers/media/spi/cxd2880-spi.c b/drivers/media/spi/cxd2880-spi.c index 4df3bd312f48..11ce5101e19f 100644 --- a/drivers/media/spi/cxd2880-spi.c +++ b/drivers/media/spi/cxd2880-spi.c @@ -60,14 +60,13 @@ DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); static int cxd2880_write_spi(struct spi_device *spi, u8 *data, u32 size) { struct spi_message msg; - struct spi_transfer tx; + struct spi_transfer tx = {}; if (!spi || !data) { pr_err("invalid arg\n"); return -EINVAL; } - memset(&tx, 0, sizeof(tx)); tx.tx_buf = data; tx.len = size; @@ -88,7 +87,7 @@ static int cxd2880_write_reg(struct spi_device *spi, pr_err("invalid arg\n"); return -EINVAL; } - if (size > BURST_WRITE_MAX) { + if (size > BURST_WRITE_MAX || size > U8_MAX) { pr_err("data size > WRITE_MAX\n"); return -EINVAL; } @@ -101,24 +100,14 @@ static int cxd2880_write_reg(struct spi_device *spi, send_data[0] = 0x0e; write_data_top = data; - while (size > 0) { - send_data[1] = sub_address; - if (size > 255) - send_data[2] = 255; - else - send_data[2] = (u8)size; + send_data[1] = sub_address; + send_data[2] = (u8)size; - memcpy(&send_data[3], write_data_top, send_data[2]); + memcpy(&send_data[3], write_data_top, send_data[2]); - ret = cxd2880_write_spi(spi, send_data, send_data[2] + 3); - if (ret) { - pr_err("write spi failed %d\n", ret); - break; - } - sub_address += send_data[2]; - write_data_top += send_data[2]; - size -= send_data[2]; - } + ret = cxd2880_write_spi(spi, send_data, send_data[2] + 3); + if (ret) + pr_err("write spi failed %d\n", ret); return ret; } @@ -130,7 +119,7 @@ static int cxd2880_spi_read_ts(struct spi_device *spi, int ret; u8 data[3]; struct spi_message message; - struct spi_transfer transfer[2]; + struct spi_transfer transfer[2] = {}; if (!spi || !read_data || !packet_num) { pr_err("invalid arg\n"); @@ -146,7 +135,6 @@ static int cxd2880_spi_read_ts(struct spi_device *spi, data[2] = packet_num; spi_message_init(&message); - memset(transfer, 0, sizeof(transfer)); transfer[0].len = 3; transfer[0].tx_buf = data; @@ -383,7 +371,7 @@ static int cxd2880_start_feed(struct dvb_demux_feed *feed) } } if (i == CXD2880_MAX_FILTER_SIZE) { - pr_err("PID filter is full. Assumed bug.\n"); + pr_err("PID filter is full.\n"); return -EINVAL; } if (!dvb_spi->all_pid_feed_count) |