Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753100AbbBXRMF (ORCPT ); Tue, 24 Feb 2015 12:12:05 -0500 Received: from ns.mm-sol.com ([37.157.136.199]:41569 "EHLO extserv.mm-sol.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751682AbbBXRMC (ORCPT ); Tue, 24 Feb 2015 12:12:02 -0500 Message-ID: <1424797916.2340.19.camel@mm-sol.com> Subject: Re: [PATCH v2] spi: qup: Add DMA capabilities From: "Ivan T. Ivanov" To: Stanimir Varbanov Cc: Mark Brown , linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-spi@vger.kernel.org, Rob Herring , Mark Rutland , Kumar Gala , Andy Gross , Sagar Dharia , Daniel Sneddon Date: Tue, 24 Feb 2015 19:11:56 +0200 In-Reply-To: <1424782803-13103-1-git-send-email-stanimir.varbanov@linaro.org> References: <1424782803-13103-1-git-send-email-stanimir.varbanov@linaro.org> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.13.7-fta1.2~trusty Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1784 Lines: 62 Hi Stan, Sorry I didn't saw this first look. On Tue, 2015-02-24 at 15:00 +0200, Stanimir Varbanov wrote: > > +static bool spi_qup_can_dma(struct spi_master *master, struct spi_device *spi, > + struct spi_transfer *xfer) > +{ > + struct spi_qup *qup = spi_master_get_devdata(master); > + size_t dma_align = dma_get_cache_alignment(); > + int n_words, w_size; > + > + qup->dma_available = 0; > + > + if (xfer->rx_buf && xfer->len % qup->in_blk_sz) > + return false; > + > + if (xfer->tx_buf && xfer->len % qup->out_blk_sz) > + return false; > + Actually we can end up here with tx_buf or rx_buf to be NULL. Which voids my previous comments about these pointers. It will be simpler if you just check transfer length. And better return false if both are NULL. > + if (IS_ERR_OR_NULL(master->dma_rx) || IS_ERR_OR_NULL(master->dma_tx)) > + return false; > + > + if (!IS_ALIGNED((size_t)xfer->tx_buf, dma_align) || > + !IS_ALIGNED((size_t)xfer->rx_buf, dma_align)) > + return false; Testing NULL for alignment is fine, right? > + w_size = spi_qup_get_word_sz(xfer); > + n_words = xfer->len / w_size; > + > + /* will use fifo mode */ > + if (n_words <= (qup->in_fifo_sz / sizeof(u32))) > + return false; > + > + qup->dma_available = 1; > + > + return true; > +} > + Regards, Ivan -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/