From patchwork Mon Jun 15 16:19:02 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joshua Clayton X-Patchwork-Id: 6610621 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id CEB46C0020 for ; Mon, 15 Jun 2015 16:24:51 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 028BE2076A for ; Mon, 15 Jun 2015 16:24:51 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 276BC20768 for ; Mon, 15 Jun 2015 16:24:50 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Z4X9H-0007I0-1O; Mon, 15 Jun 2015 16:22:11 +0000 Received: from mail-pa0-x235.google.com ([2607:f8b0:400e:c03::235]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Z4X6x-0004wF-3x for linux-arm-kernel@lists.infradead.org; Mon, 15 Jun 2015 16:19:47 +0000 Received: by padev16 with SMTP id ev16so68619898pad.0 for ; Mon, 15 Jun 2015 09:19:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=sQeVC7BHNFcB1m7tHcyVyf8vd/hBe48gBXo+Q/7GlTw=; b=dHEM9BgTHj0JKw9aIDPQ0QiSmAjyKkjBb3lY2EcOCa/piFFnqP45dS02s4sSMurw80 I7JoiSZEDlC7tZM8ikCxOueCRn7+YA0U8LXQ0R9v6+KXZW4wKji3BlbMrTG3F65g3SMl +2TIL4O/N5TiBITFbveW8Vd03GIHQqp/6UFgCs1WWAlp+UFXwvB9ni16W641KX92UJsy EB5JVW/LZJaw2adNOUf/nE+E6T0BR1MHEv5Y6m/u2OPrigfXcNDV82jL5VioWVvA73+M hqYFaHLjE20cVgQXoFTe4TyHwSph8tDk3m4vkmezsQZCPaGpkf+HWSiTJvITPAwgcSDZ /uxA== X-Received: by 10.70.49.43 with SMTP id r11mr49327889pdn.91.1434385165302; Mon, 15 Jun 2015 09:19:25 -0700 (PDT) Received: from localhost.localdomain (68-185-59-186.static.knwc.wa.charter.com. [68.185.59.186]) by mx.google.com with ESMTPSA id qg5sm12717637pdb.13.2015.06.15.09.19.23 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 15 Jun 2015 09:19:24 -0700 (PDT) From: Joshua Clayton To: Vinod Koul Subject: [PATCH 07/10] dma: imx-sdma: validate word size when set Date: Mon, 15 Jun 2015 09:19:02 -0700 Message-Id: <1434385144-4432-8-git-send-email-stillcompiling@gmail.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1434385144-4432-1-git-send-email-stillcompiling@gmail.com> References: <1434385144-4432-1-git-send-email-stillcompiling@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150615_091947_250666_C8335411 X-CRM114-Status: GOOD ( 12.48 ) X-Spam-Score: -0.8 (/) Cc: Joshua Clayton , linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org, Dan Williams , Shawn Guo , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Rather than failing during an sdma prep command, dma_config_channel should fail if an invalid word size is selected. Signed-off-by: Joshua Clayton --- drivers/dma/imx-sdma.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c index a13383b..c9badd4 100644 --- a/drivers/dma/imx-sdma.c +++ b/drivers/dma/imx-sdma.c @@ -858,6 +858,13 @@ static int sdma_config_channel(struct sdma_channel *sdmac, dmaengine_cfg->dst_addr_width; sdmac->word_size = dmaengine_cfg->dst_addr_width; } + + if (sdmac->word_size > DMA_SLAVE_BUSWIDTH_4_BYTES) { + dev_err(sdma->dev, "SDMA channel %d: invalid word size: %d\n", + sdmac->channel, sdmac->word_size); + return -EINVAL; + } + sdmac->direction = dmaengine_cfg->direction; sdma_disable_channel(sdma, channel); @@ -1088,11 +1095,6 @@ static struct dma_async_tx_descriptor *sdma_prep_slave_sg( bd->mode.count = count; sdmac->chn_count += count; - if (sdmac->word_size > DMA_SLAVE_BUSWIDTH_4_BYTES) { - ret = -EINVAL; - goto err_out; - } - switch (sdmac->word_size) { case DMA_SLAVE_BUSWIDTH_4_BYTES: bd->mode.command = 0; @@ -1183,8 +1185,6 @@ static struct dma_async_tx_descriptor *sdma_prep_dma_cyclic( bd->mode.count = period_len; - if (sdmac->word_size > DMA_SLAVE_BUSWIDTH_4_BYTES) - goto err_out; if (sdmac->word_size == DMA_SLAVE_BUSWIDTH_4_BYTES) bd->mode.command = 0; else