From patchwork Wed Sep 18 07:33:08 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guennadi Liakhovetski X-Patchwork-Id: 2904851 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.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 85731BFF05 for ; Wed, 18 Sep 2013 07:34:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id F3377202F0 for ; Wed, 18 Sep 2013 07:33:55 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9B9FA202EB for ; Wed, 18 Sep 2013 07:33:53 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VMCGi-0001uo-3h; Wed, 18 Sep 2013 07:33:48 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VMCGf-0001s6-UU; Wed, 18 Sep 2013 07:33:45 +0000 Received: from moutng.kundenserver.de ([212.227.17.10]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VMCGc-0001qw-Tm for linux-arm-kernel@lists.infradead.org; Wed, 18 Sep 2013 07:33:43 +0000 Received: from axis700.grange (dslb-094-220-152-131.pools.arcor-ip.net [94.220.152.131]) by mrelayeu.kundenserver.de (node=mreu4) with ESMTP (Nemesis) id 0MFE0F-1V75xP28HD-00GGAi; Wed, 18 Sep 2013 09:33:08 +0200 Received: by axis700.grange (Postfix, from userid 1000) id 1DCB740BB4; Wed, 18 Sep 2013 09:33:08 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by axis700.grange (Postfix) with ESMTP id 1BA3040BB3; Wed, 18 Sep 2013 09:33:08 +0200 (CEST) Date: Wed, 18 Sep 2013 09:33:08 +0200 (CEST) From: Guennadi Liakhovetski X-X-Sender: lyakh@axis700.grange To: linux-kernel@vger.kernel.org Subject: [PATCH] DMA: ste_dma40: use a power of 2 check Message-ID: MIME-Version: 1.0 X-Provags-ID: V02:K0:yraSnf0W9zYtNbEjtqG2EiUYHctzyHsbIPBkfKYQ0c/ +JtHPU1UnpQvM4y3FBgvTp1zKQJmvh6LLCqBUTFi2NsVII0OsZ DxP38xfwEqeUskhUxouyefSzqyaqMBJX424/wAd1SRSpvnjBWY P3GkNN3d875ixLpCwDzer+utqwE/zJBahVun72/3vRrkCn1ANX OJnjPnw8SP4O8x0TWMQ3eqWNDyiW42eP55+ggzVRfV6GNPt948 A6r+gE6FR1u0RHKVaobJDsY/BGIr9SHJtvWggeoLu8r3mpd7hl qfcdN6pz+pdo3Tc9yhu/5km5E0x90i/g1G+bnK1t2fkMYk+tna o3ibO/VHoKYI3dXm8kLUjUjYQ4KIVEHaR2j9Tm0MKwKo8y+Ejy tfrgeYSX8lEzg== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130918_033343_199121_0A49628F X-CRM114-Status: GOOD ( 10.41 ) X-Spam-Score: -2.6 (--) Cc: "Koul, Vinod" , Linus Walleij , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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.8 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 dst_addr_width and src_addr_width should be a power of 2. Currently the driver checks, that they both lie between 1 and 8 and that they are eqal to 1 or even. This however leaves an invalid value of 6 uncaught. Use an explicit power of 2 check instead. Signed-off-by: Guennadi Liakhovetski --- Compile tested only. I think 6 is an invalid value in this case, and since you check for odd calues, it seems to me that any value can be supplied here, so, looks like a power of 2 test is a better match for this. diff --git a/drivers/dma/ste_dma40.c b/drivers/dma/ste_dma40.c index 82d2b97..3d5e4ee 100644 --- a/drivers/dma/ste_dma40.c +++ b/drivers/dma/ste_dma40.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -2796,8 +2797,8 @@ static int d40_set_runtime_config(struct dma_chan *chan, src_addr_width > DMA_SLAVE_BUSWIDTH_8_BYTES || dst_addr_width <= DMA_SLAVE_BUSWIDTH_UNDEFINED || dst_addr_width > DMA_SLAVE_BUSWIDTH_8_BYTES || - ((src_addr_width > 1) && (src_addr_width & 1)) || - ((dst_addr_width > 1) && (dst_addr_width & 1))) + !is_power_of_2(src_addr_width) || + !is_power_of_2(dst_addr_width)) return -EINVAL; cfg->src_info.data_width = src_addr_width;