words_available = bytes_available / sizeof(u32);
if (bytes_available > len) {
- dev_err(fifo->dt_device, "user read buffer too small (available bytes=%zu user buffer bytes=%zu)\n",
- bytes_available, len);
ret = -EINVAL;
goto err_flush_rx;
}
u32 *txbuf;
int ret;
- if (len % sizeof(u32)) {
- dev_err(fifo->dt_device,
- "tried to send a packet that isn't word-aligned\n");
- return -EINVAL;
- }
-
words_to_write = len / sizeof(u32);
- if (!words_to_write) {
- dev_err(fifo->dt_device,
- "tried to send a packet of length 0\n");
- return -EINVAL;
- }
-
/*
* In 'Store-and-Forward' mode, the maximum packet that can be
* transmitted is limited by the size of the FIFO, which is
* otherwise a 'Transmit Packet Overrun Error' interrupt will be
* raised, which requires a reset of the TX circuit to recover.
*/
- if (words_to_write > (fifo->tx_fifo_depth - 4))
+ if (!words_to_write || (len % sizeof(u32)) ||
+ (words_to_write > (fifo->tx_fifo_depth - 4)))
return -EINVAL;
if (f->f_flags & O_NONBLOCK) {