diff mbox

mtd: nand: Declare tBERS, tR and tPROG as u64 to avoid integer overflow

Message ID 1501489887-7372-1-git-send-email-boris.brezillon@free-electrons.com
State Accepted
Delegated to: Boris Brezillon
Headers show

Commit Message

Boris Brezillon July 31, 2017, 8:31 a.m. UTC
All timings in nand_sdr_timings are expressed in picoseconds but some
of them may not fit in an u32.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Fixes: 204e7ecd47e2 ("mtd: nand: Add a few more timings to nand_sdr_timings")
Reported-by: Alexander Dahl <ada@thorsis.com>
Cc: <stable@vger.kernel.org>
---
 drivers/mtd/nand/nand_timings.c | 6 +++---
 include/linux/mtd/nand.h        | 6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

Comments

Alexander Dahl July 31, 2017, 12:06 p.m. UTC | #1
Hello,

Reviewed-by: Alexander Dahl <ada@thorsis.com>
Tested-by: Alexander Dahl <ada@thorsis.com>

Greets
Alex

Am Montag, 31. Juli 2017, 10:31:27 schrieb Boris Brezillon:
> All timings in nand_sdr_timings are expressed in picoseconds but some
> of them may not fit in an u32.
> 
> Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
> Fixes: 204e7ecd47e2 ("mtd: nand: Add a few more timings to
> nand_sdr_timings") Reported-by: Alexander Dahl <ada@thorsis.com>
> Cc: <stable@vger.kernel.org>
> ---
>  drivers/mtd/nand/nand_timings.c | 6 +++---
>  include/linux/mtd/nand.h        | 6 +++---
>  2 files changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/mtd/nand/nand_timings.c
> b/drivers/mtd/nand/nand_timings.c index f06312df3669..7e36d7d13c26
> 100644
> --- a/drivers/mtd/nand/nand_timings.c
> +++ b/drivers/mtd/nand/nand_timings.c
> @@ -311,9 +311,9 @@ int onfi_init_data_interface(struct nand_chip
> *chip, struct nand_sdr_timings *timings = &iface->timings.sdr;
> 
>  		/* microseconds -> picoseconds */
> -		timings->tPROG_max = 1000000UL * le16_to_cpu(params->t_prog);
> -		timings->tBERS_max = 1000000UL * le16_to_cpu(params->t_bers);
> -		timings->tR_max = 1000000UL * le16_to_cpu(params->t_r);
> +		timings->tPROG_max = 1000000ULL * le16_to_cpu(params->t_prog);
> +		timings->tBERS_max = 1000000ULL * le16_to_cpu(params->t_bers);
> +		timings->tR_max = 1000000ULL * le16_to_cpu(params->t_r);
> 
>  		/* nanoseconds -> picoseconds */
>  		timings->tCCS_min = 1000UL * le16_to_cpu(params->t_ccs);
> diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h
> index 892148c448cc..5216d2eb2289 100644
> --- a/include/linux/mtd/nand.h
> +++ b/include/linux/mtd/nand.h
> @@ -681,10 +681,10 @@ struct nand_buffers {
>   * @tWW_min: WP# transition to WE# low
>   */
>  struct nand_sdr_timings {
> -	u32 tBERS_max;
> +	u64 tBERS_max;
>  	u32 tCCS_min;
> -	u32 tPROG_max;
> -	u32 tR_max;
> +	u64 tPROG_max;
> +	u64 tR_max;
>  	u32 tALH_min;
>  	u32 tADL_min;
>  	u32 tALS_min;
Boris Brezillon July 31, 2017, 4:28 p.m. UTC | #2
On Mon, 31 Jul 2017 10:31:27 +0200
Boris Brezillon <boris.brezillon@free-electrons.com> wrote:

> All timings in nand_sdr_timings are expressed in picoseconds but some
> of them may not fit in an u32.

Applied to nand/fixes.

> 
> Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
> Fixes: 204e7ecd47e2 ("mtd: nand: Add a few more timings to nand_sdr_timings")
> Reported-by: Alexander Dahl <ada@thorsis.com>
> Cc: <stable@vger.kernel.org>
> ---
>  drivers/mtd/nand/nand_timings.c | 6 +++---
>  include/linux/mtd/nand.h        | 6 +++---
>  2 files changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/mtd/nand/nand_timings.c b/drivers/mtd/nand/nand_timings.c
> index f06312df3669..7e36d7d13c26 100644
> --- a/drivers/mtd/nand/nand_timings.c
> +++ b/drivers/mtd/nand/nand_timings.c
> @@ -311,9 +311,9 @@ int onfi_init_data_interface(struct nand_chip *chip,
>  		struct nand_sdr_timings *timings = &iface->timings.sdr;
>  
>  		/* microseconds -> picoseconds */
> -		timings->tPROG_max = 1000000UL * le16_to_cpu(params->t_prog);
> -		timings->tBERS_max = 1000000UL * le16_to_cpu(params->t_bers);
> -		timings->tR_max = 1000000UL * le16_to_cpu(params->t_r);
> +		timings->tPROG_max = 1000000ULL * le16_to_cpu(params->t_prog);
> +		timings->tBERS_max = 1000000ULL * le16_to_cpu(params->t_bers);
> +		timings->tR_max = 1000000ULL * le16_to_cpu(params->t_r);
>  
>  		/* nanoseconds -> picoseconds */
>  		timings->tCCS_min = 1000UL * le16_to_cpu(params->t_ccs);
> diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h
> index 892148c448cc..5216d2eb2289 100644
> --- a/include/linux/mtd/nand.h
> +++ b/include/linux/mtd/nand.h
> @@ -681,10 +681,10 @@ struct nand_buffers {
>   * @tWW_min: WP# transition to WE# low
>   */
>  struct nand_sdr_timings {
> -	u32 tBERS_max;
> +	u64 tBERS_max;
>  	u32 tCCS_min;
> -	u32 tPROG_max;
> -	u32 tR_max;
> +	u64 tPROG_max;
> +	u64 tR_max;
>  	u32 tALH_min;
>  	u32 tADL_min;
>  	u32 tALS_min;
diff mbox

Patch

diff --git a/drivers/mtd/nand/nand_timings.c b/drivers/mtd/nand/nand_timings.c
index f06312df3669..7e36d7d13c26 100644
--- a/drivers/mtd/nand/nand_timings.c
+++ b/drivers/mtd/nand/nand_timings.c
@@ -311,9 +311,9 @@  int onfi_init_data_interface(struct nand_chip *chip,
 		struct nand_sdr_timings *timings = &iface->timings.sdr;
 
 		/* microseconds -> picoseconds */
-		timings->tPROG_max = 1000000UL * le16_to_cpu(params->t_prog);
-		timings->tBERS_max = 1000000UL * le16_to_cpu(params->t_bers);
-		timings->tR_max = 1000000UL * le16_to_cpu(params->t_r);
+		timings->tPROG_max = 1000000ULL * le16_to_cpu(params->t_prog);
+		timings->tBERS_max = 1000000ULL * le16_to_cpu(params->t_bers);
+		timings->tR_max = 1000000ULL * le16_to_cpu(params->t_r);
 
 		/* nanoseconds -> picoseconds */
 		timings->tCCS_min = 1000UL * le16_to_cpu(params->t_ccs);
diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h
index 892148c448cc..5216d2eb2289 100644
--- a/include/linux/mtd/nand.h
+++ b/include/linux/mtd/nand.h
@@ -681,10 +681,10 @@  struct nand_buffers {
  * @tWW_min: WP# transition to WE# low
  */
 struct nand_sdr_timings {
-	u32 tBERS_max;
+	u64 tBERS_max;
 	u32 tCCS_min;
-	u32 tPROG_max;
-	u32 tR_max;
+	u64 tPROG_max;
+	u64 tR_max;
 	u32 tALH_min;
 	u32 tADL_min;
 	u32 tALS_min;