static int ispstat_bufs_alloc(struct ispstat *stat, u32 size) { unsigned long flags; spin_lock_irqsave(&stat->isp->stat_lock, flags); BUG_ON(stat->locked_buf != NULL); /* Are the old buffers big enough? */ if (stat->buf_alloc_size >= size) { spin_unlock_irqrestore(&stat->isp->stat_lock, flags); return 0; } if (stat->state != ISPSTAT_DISABLED || stat->buf_processing) { dev_info(stat->isp->dev, "%s: trying to allocate memory when busy\n", stat->subdev.name); spin_unlock_irqrestore(&stat->isp->stat_lock, flags); return -EBUSY; } spin_unlock_irqrestore(&stat->isp->stat_lock, flags); ispstat_bufs_free(stat); if (IS_COHERENT_BUF(stat)) return ispstat_bufs_alloc_dma(stat, size); else return ispstat_bufs_alloc_iommu(stat, size); }
int ispstat_bufs_alloc(struct ispstat *stat, unsigned int size, int dma_buf) { struct isp_device *isp = dev_get_drvdata(stat->dev); unsigned long flags; int ret = 0; int i; spin_lock_irqsave(&stat->lock, flags); BUG_ON(stat->locked_buf != NULL); dma_buf = dma_buf ? 1 : 0; /* Are the old buffers big enough? */ if ((stat->buf_alloc_size >= size) && (stat->dma_buf == dma_buf)) { for (i = 0; i < stat->nbufs; i++) stat->buf[i].frame_number = stat->max_frame; spin_unlock_irqrestore(&stat->lock, flags); goto out; } if (isp->running != ISP_STOPPED) { dev_info(stat->dev, "%s stat: trying to configure when busy\n", stat->tag); spin_unlock_irqrestore(&stat->lock, flags); return -EBUSY; } spin_unlock_irqrestore(&stat->lock, flags); ispstat_bufs_free(stat); if (dma_buf) ret = ispstat_bufs_alloc_dma(stat, size); else ret = ispstat_bufs_alloc_iommu(stat, size); if (ret) size = 0; out: stat->buf_size = size; stat->active_buf = NULL; return ret; }