diff --git a/driver/linux/crystalhd_cmds.c b/driver/linux/crystalhd_cmds.c index cecd710..b62811b 100644 --- a/driver/linux/crystalhd_cmds.c +++ b/driver/linux/crystalhd_cmds.c @@ -154,7 +154,7 @@ static BC_STATUS bc_cproc_get_hwtype(struct crystalhd_cmd *ctx, crystalhd_ioctl_ static BC_STATUS bc_cproc_reg_rd(struct crystalhd_cmd *ctx, crystalhd_ioctl_data *idata) { - if (!ctx || !idata) + if (!ctx || !ctx->hw_ctx || !idata) return BC_STS_INV_ARG; idata->udata.u.regAcc.Value = ctx->hw_ctx->pfnReadDevRegister(ctx->adp, idata->udata.u.regAcc.Offset); @@ -164,7 +164,7 @@ static BC_STATUS bc_cproc_reg_rd(struct crystalhd_cmd *ctx, static BC_STATUS bc_cproc_reg_wr(struct crystalhd_cmd *ctx, crystalhd_ioctl_data *idata) { - if (!ctx || !idata) + if (!ctx || !ctx->hw_ctx || !idata) return BC_STS_INV_ARG; ctx->hw_ctx->pfnWriteDevRegister(ctx->adp, idata->udata.u.regAcc.Offset, @@ -176,7 +176,7 @@ static BC_STATUS bc_cproc_reg_wr(struct crystalhd_cmd *ctx, static BC_STATUS bc_cproc_link_reg_rd(struct crystalhd_cmd *ctx, crystalhd_ioctl_data *idata) { - if (!ctx || !idata) + if (!ctx || !ctx->hw_ctx || !idata) return BC_STS_INV_ARG; idata->udata.u.regAcc.Value = ctx->hw_ctx->pfnReadFPGARegister(ctx->adp, @@ -187,7 +187,7 @@ static BC_STATUS bc_cproc_link_reg_rd(struct crystalhd_cmd *ctx, static BC_STATUS bc_cproc_link_reg_wr(struct crystalhd_cmd *ctx, crystalhd_ioctl_data *idata) { - if (!ctx || !idata) + if (!ctx || !ctx->hw_ctx || !idata) return BC_STS_INV_ARG; ctx->hw_ctx->pfnWriteFPGARegister(ctx->adp, idata->udata.u.regAcc.Offset, @@ -201,7 +201,7 @@ static BC_STATUS bc_cproc_mem_rd(struct crystalhd_cmd *ctx, { BC_STATUS sts = BC_STS_SUCCESS; - if (!ctx || !idata || !idata->add_cdata) + if (!ctx || !ctx->hw_ctx || !idata || !idata->add_cdata) return BC_STS_INV_ARG; if (idata->udata.u.devMem.NumDwords > (idata->add_cdata_sz / 4)) { @@ -220,7 +220,7 @@ static BC_STATUS bc_cproc_mem_wr(struct crystalhd_cmd *ctx, { BC_STATUS sts = BC_STS_SUCCESS; - if (!ctx || !idata || !idata->add_cdata) + if (!ctx || !ctx->hw_ctx || !idata || !idata->add_cdata) return BC_STS_INV_ARG; if (idata->udata.u.devMem.NumDwords > (idata->add_cdata_sz / 4)) { @@ -307,7 +307,7 @@ static BC_STATUS bc_cproc_download_fw(struct crystalhd_cmd *ctx, dev_dbg(chddev(), "Downloading FW\n"); - if (!ctx || !idata || !idata->add_cdata || !idata->add_cdata_sz) { + if (!ctx || !ctx->hw_ctx || !idata || !idata->add_cdata || !idata->add_cdata_sz) { dev_err(chddev(), "%s: Invalid Arg\n", __func__); return BC_STS_INV_ARG; } @@ -350,7 +350,7 @@ static BC_STATUS bc_cproc_do_fw_cmd(struct crystalhd_cmd *ctx, crystalhd_ioctl_d BC_STATUS sts; uint32_t *cmd; - if (!(ctx->state & BC_LINK_INIT)) { + if ( !ctx || !idata || !(ctx->state & BC_LINK_INIT) || !ctx->hw_ctx) { dev_dbg(dev, "Link invalid state do fw cmd %x \n", ctx->state); return BC_STS_ERR_USAGE; } @@ -432,7 +432,7 @@ static BC_STATUS bc_cproc_hw_txdma(struct crystalhd_cmd *ctx, wait_queue_head_t event; int rc = 0; - if (!ctx || !idata || !dio) { + if (!ctx || !ctx->hw_ctx || !idata || !dio) { dev_err(dev, "%s: Invalid Arg\n", __func__); return BC_STS_INV_ARG; } @@ -573,7 +573,7 @@ static BC_STATUS bc_cproc_add_cap_buff(struct crystalhd_cmd *ctx, struct crystalhd_dio_req *dio_hnd = NULL; BC_STATUS sts = BC_STS_SUCCESS; - if (!ctx || !idata) { + if (!ctx || !ctx->hw_ctx || !idata) { dev_err(dev, "%s: Invalid Arg\n", __func__); return BC_STS_INV_ARG; } @@ -631,7 +631,7 @@ static BC_STATUS bc_cproc_fetch_frame(struct crystalhd_cmd *ctx, BC_STATUS sts = BC_STS_SUCCESS; BC_DEC_OUT_BUFF *frame; - if (!ctx || !idata) { + if (!ctx || !ctx->hw_ctx || !idata) { dev_err(dev, "%s: Invalid Arg\n", __func__); return BC_STS_INV_ARG; } @@ -673,6 +673,10 @@ static BC_STATUS bc_cproc_fetch_frame(struct crystalhd_cmd *ctx, static BC_STATUS bc_cproc_start_capture(struct crystalhd_cmd *ctx, crystalhd_ioctl_data *idata) { + if (!ctx || !ctx->hw_ctx || !idata) { + return BC_STS_INV_ARG; + } + ctx->state |= BC_LINK_CAP_EN; if( idata->udata.u.RxCap.PauseThsh ) @@ -705,7 +709,7 @@ static BC_STATUS bc_cproc_flush_cap_buffs(struct crystalhd_cmd *ctx, struct device *dev = chddev(); struct crystalhd_rx_dma_pkt *rpkt; - if (!ctx || !idata) { + if (!ctx || !ctx->hw_ctx || !idata) { dev_err(dev, "%s: Invalid Arg\n", __func__); return BC_STS_INV_ARG; } @@ -745,7 +749,7 @@ static BC_STATUS bc_cproc_get_stats(struct crystalhd_cmd *ctx, bool readTxOnly = false; unsigned long irqflags; - if (!ctx || !idata) { + if (!ctx || !ctx->hw_ctx || !idata) { dev_err(chddev(), "%s: Invalid Arg\n", __func__); return BC_STS_INV_ARG; } @@ -948,9 +952,9 @@ BC_STATUS crystalhd_suspend(struct crystalhd_cmd *ctx, crystalhd_ioctl_data *ida BC_STATUS sts = BC_STS_SUCCESS; struct crystalhd_rx_dma_pkt *rpkt = NULL; - if (!ctx || !idata) { - dev_err(dev, "Invalid Parameters\n"); - return BC_STS_ERROR; + if (!ctx || !ctx->hw_ctx || !idata) { + dev_err(dev, "%s: Invalid Arg\n", __func__); + return BC_STS_INV_ARG; } if (ctx->state & BC_LINK_SUSPEND)