@@ -181,7 +181,7 @@ static irqreturn_t zynq_fpga_isr(int irq, void *data)
*/
static bool zynq_fpga_has_sync(const char *buf, size_t count)
{
- for (; count > 4; buf += 4, --count)
+ for (; count > 4; buf += 4, count -= 4)
if (buf[0] == 0x66 && buf[1] == 0x55 && buf[2] == 0x99 &&
buf[3] == 0xaa)
return true;
@@ -200,8 +200,11 @@ static int zynq_fpga_ops_write_init(struct fpga_manager *mgr, u32 flags,
/* The hardware can only DMA multiples of 4 bytes, and we need at
* least the sync word and something else to do anything.
*/
- if (count <= 4 || (count % 4) != 0)
+ if (count <= 4 || (count % 4) != 0) {
+ dev_err(priv->dev,
+ "Invalid bitstream size, must be multiples of 4 bytes");
return -EINVAL;
+ }
err = clk_enable(priv->clk);
if (err)
@@ -210,6 +213,8 @@ static int zynq_fpga_ops_write_init(struct fpga_manager *mgr, u32 flags,
/* don't globally reset PL if we're doing partial reconfig */
if (!(flags & FPGA_MGR_PARTIAL_RECONFIG)) {
if (!zynq_fpga_has_sync(buf, count)) {
+ dev_err(priv->dev,
+ "Invalid bitstream, could not find a sync word. Bitstream must be a byte swaped .bin file");
err = -EINVAL;
goto out_err;
}