From: Vinod Koul <vinod.koul@intel.com>
To: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Cc: linux-kernel@vger.kernel.org,
Linus Walleij <linus.walleij@linaro.org>,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] DMA: ste_dma40: use a power of 2 check
Date: Mon, 23 Sep 2013 09:51:43 +0530 [thread overview]
Message-ID: <20130923042143.GB17188@intel.com> (raw)
In-Reply-To: <Pine.LNX.4.64.1309180919470.30215@axis700.grange>
On Wed, Sep 18, 2013 at 09:33:08AM +0200, Guennadi Liakhovetski wrote:
> 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
typo ^^^^^
> to 1 or even. This however leaves an invalid value of 6 uncaught. Use an
> explicit power of 2 check instead.
>
Applied, with typo fix above..
~Vinod
> Signed-off-by: Guennadi Liakhovetski <g.liakhovetski+renesas@gmail.com>
> ---
>
> 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 <linux/platform_device.h>
> #include <linux/clk.h>
> #include <linux/delay.h>
> +#include <linux/log2.h>
> #include <linux/pm.h>
> #include <linux/pm_runtime.h>
> #include <linux/err.h>
> @@ -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;
--
prev parent reply other threads:[~2013-09-23 5:12 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-18 7:33 Guennadi Liakhovetski
2013-09-23 4:21 ` Vinod Koul [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130923042143.GB17188@intel.com \
--to=vinod.koul@intel.com \
--cc=g.liakhovetski@gmx.de \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome