All of lore.kernel.org
 help / color / mirror / Atom feed
From: walter harms <wharms@bfs.de>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Cc: mripard@kernel.org, mchehab@kernel.org,
	linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
	kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] media: v4l: cadence: Fix how unsued lanes are handled in 'csi2rx_start()'
Date: Fri, 13 Sep 2019 07:14:58 +0000	[thread overview]
Message-ID: <5D7B41F2.2080607@bfs.de> (raw)
In-Reply-To: <20190912204450.17625-1-christophe.jaillet@wanadoo.fr>



Am 12.09.2019 22:44, schrieb Christophe JAILLET:
> The 2nd parameter of 'find_first_zero_bit()' is a number of bits, not of
> bytes. So use 'BITS_PER_LONG' instead of 'sizeof(lanes_used)'.
> 
> Fixes: 1fc3b37f34f6 ("media: v4l: cadence: Add Cadence MIPI-CSI2 RX driver")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> This patch is purely speculative. Using BITS_PER_LONG looks logical to me,
> but I'm not 100% sure that it is what is expected here. 'csi2rx->max_lanes'
> could also be a good candidate.
> ---
>  drivers/media/platform/cadence/cdns-csi2rx.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/media/platform/cadence/cdns-csi2rx.c b/drivers/media/platform/cadence/cdns-csi2rx.c
> index 31ace114eda1..28765ccb1b12 100644
> --- a/drivers/media/platform/cadence/cdns-csi2rx.c
> +++ b/drivers/media/platform/cadence/cdns-csi2rx.c
> @@ -129,7 +129,7 @@ static int csi2rx_start(struct csi2rx_priv *csi2rx)
>  	 */
>  	for (i = csi2rx->num_lanes; i < csi2rx->max_lanes; i++) {
>  		unsigned int idx = find_first_zero_bit(&lanes_used,
> -						       sizeof(lanes_used));
> +						       BITS_PER_LONG);

why not CHAR_BIT*sizeof(lanes_used) ?
 this would have the advantage that it is independent of future changes of lanes_used.

re,
 wh

>  		set_bit(idx, &lanes_used);
>  		reg |= CSI2RX_STATIC_CFG_DLANE_MAP(i, i + 1);
>  	}

WARNING: multiple messages have this Message-ID (diff)
From: walter harms <wharms@bfs.de>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Cc: mripard@kernel.org, mchehab@kernel.org,
	linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
	kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] media: v4l: cadence: Fix how unsued lanes are handled in 'csi2rx_start()'
Date: Fri, 13 Sep 2019 09:14:58 +0200	[thread overview]
Message-ID: <5D7B41F2.2080607@bfs.de> (raw)
In-Reply-To: <20190912204450.17625-1-christophe.jaillet@wanadoo.fr>



Am 12.09.2019 22:44, schrieb Christophe JAILLET:
> The 2nd parameter of 'find_first_zero_bit()' is a number of bits, not of
> bytes. So use 'BITS_PER_LONG' instead of 'sizeof(lanes_used)'.
> 
> Fixes: 1fc3b37f34f6 ("media: v4l: cadence: Add Cadence MIPI-CSI2 RX driver")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> This patch is purely speculative. Using BITS_PER_LONG looks logical to me,
> but I'm not 100% sure that it is what is expected here. 'csi2rx->max_lanes'
> could also be a good candidate.
> ---
>  drivers/media/platform/cadence/cdns-csi2rx.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/media/platform/cadence/cdns-csi2rx.c b/drivers/media/platform/cadence/cdns-csi2rx.c
> index 31ace114eda1..28765ccb1b12 100644
> --- a/drivers/media/platform/cadence/cdns-csi2rx.c
> +++ b/drivers/media/platform/cadence/cdns-csi2rx.c
> @@ -129,7 +129,7 @@ static int csi2rx_start(struct csi2rx_priv *csi2rx)
>  	 */
>  	for (i = csi2rx->num_lanes; i < csi2rx->max_lanes; i++) {
>  		unsigned int idx = find_first_zero_bit(&lanes_used,
> -						       sizeof(lanes_used));
> +						       BITS_PER_LONG);

why not CHAR_BIT*sizeof(lanes_used) ?
 this would have the advantage that it is independent of future changes of lanes_used.

re,
 wh

>  		set_bit(idx, &lanes_used);
>  		reg |= CSI2RX_STATIC_CFG_DLANE_MAP(i, i + 1);
>  	}

  reply	other threads:[~2019-09-13  7:14 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-12 20:44 [PATCH] media: v4l: cadence: Fix how unsued lanes are handled in 'csi2rx_start()' Christophe JAILLET
2019-09-12 20:44 ` Christophe JAILLET
2019-09-13  7:14 ` walter harms [this message]
2019-09-13  7:14   ` walter harms
2019-09-13  7:57 ` Maxime Ripard
2019-09-13  7:57   ` Maxime Ripard
2019-09-16  6:28   ` Dan Carpenter
2019-09-16  6:28     ` Dan Carpenter
2019-09-16 19:24     ` Christophe JAILLET
2019-09-16 19:24       ` Christophe JAILLET
2019-09-17  7:06       ` Dan Carpenter
2019-09-17  7:06         ` Dan Carpenter
2019-09-17  7:52 ` Marc Gonzalez

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=5D7B41F2.2080607@bfs.de \
    --to=wharms@bfs.de \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=mripard@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.