On Sun, Aug 27, 2017 at 4:28 AM, Vinod Koul <vinod.koul@xxxxxxxxx> wrote: > DMAengine core has BUG_ON to checks for mandatory ops and based on > capabilities, but they use BUG_ON, so remove and move to error returns and > logging the errors gracefully > > Signed-off-by: Vinod Koul <vinod.koul@xxxxxxxxx> > --- > cc: Dan Williams <dan.j.williams@xxxxxxxxx> > cc: Dave Jiang <dave.jiang@xxxxxxxxx> > > drivers/dma/dmaengine.c | 83 ++++++++++++++++++++++++++++++++++++------------- > 1 file changed, 61 insertions(+), 22 deletions(-) > > diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c > index 428b1414263a..fd0384708e34 100644 > --- a/drivers/dma/dmaengine.c > +++ b/drivers/dma/dmaengine.c > @@ -923,28 +923,67 @@ int dma_async_device_register(struct dma_device *device) > return -ENODEV; > > /* validate device routines */ > - BUG_ON(dma_has_cap(DMA_MEMCPY, device->cap_mask) && > - !device->device_prep_dma_memcpy); > - BUG_ON(dma_has_cap(DMA_XOR, device->cap_mask) && > - !device->device_prep_dma_xor); > - BUG_ON(dma_has_cap(DMA_XOR_VAL, device->cap_mask) && > - !device->device_prep_dma_xor_val); > - BUG_ON(dma_has_cap(DMA_PQ, device->cap_mask) && > - !device->device_prep_dma_pq); > - BUG_ON(dma_has_cap(DMA_PQ_VAL, device->cap_mask) && > - !device->device_prep_dma_pq_val); > - BUG_ON(dma_has_cap(DMA_MEMSET, device->cap_mask) && > - !device->device_prep_dma_memset); > - BUG_ON(dma_has_cap(DMA_INTERRUPT, device->cap_mask) && > - !device->device_prep_dma_interrupt); > - BUG_ON(dma_has_cap(DMA_CYCLIC, device->cap_mask) && > - !device->device_prep_dma_cyclic); > - BUG_ON(dma_has_cap(DMA_INTERLEAVE, device->cap_mask) && > - !device->device_prep_interleaved_dma); > - > - BUG_ON(!device->device_tx_status); > - BUG_ON(!device->device_issue_pending); > - BUG_ON(!device->dev); > + if (!device->dev) { > + pr_err("Device must have dev set\n"); > + return -EIO; > + } > + > + if (dma_has_cap(DMA_MEMCPY, device->cap_mask) && !device->device_prep_dma_memcpy) { > + dev_err(device->dev, "Device support memcpy but no ops\n"); > + return -EIO; How about fixing up the error message to the form: "Device claims the capability, but the %s operation is not defined." Otherwise, looks good to me: Acked-by: Dan Williams <dan.j.williams@xxxxxxxxx> -- To unsubscribe from this list: send the line "unsubscribe dmaengine" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html