diff mbox series

drm/imx/dcss: fix 64-bit divisions

Message ID 20200911134827.32142-1-laurentiu.palcu@oss.nxp.com (mailing list archive)
State New, archived
Headers show
Series drm/imx/dcss: fix 64-bit divisions | expand

Commit Message

Laurentiu Palcu Sept. 11, 2020, 1:48 p.m. UTC
Use div_s64() for the 64-bit divisions. This would allow the driver to compile
on 32-bit architectures, if needed.

Signed-off-by: Laurentiu Palcu <laurentiu.palcu@oss.nxp.com>
---
 drivers/gpu/drm/imx/dcss/dcss-scaler.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Ville Syrjälä Sept. 11, 2020, 1:56 p.m. UTC | #1
On Fri, Sep 11, 2020 at 04:48:27PM +0300, Laurentiu Palcu wrote:
> Use div_s64() for the 64-bit divisions. This would allow the driver to compile
> on 32-bit architectures, if needed.
> 
> Signed-off-by: Laurentiu Palcu <laurentiu.palcu@oss.nxp.com>
> ---
>  drivers/gpu/drm/imx/dcss/dcss-scaler.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/imx/dcss/dcss-scaler.c b/drivers/gpu/drm/imx/dcss/dcss-scaler.c
> index cd21905de580..7c1e0e461244 100644
> --- a/drivers/gpu/drm/imx/dcss/dcss-scaler.c
> +++ b/drivers/gpu/drm/imx/dcss/dcss-scaler.c
> @@ -134,7 +134,7 @@ static int div_q(int A, int B)
>  	else
>  		temp -= B / 2;
>  
> -	result = (int)(temp / B);
> +	result = (int)(div_s64(temp, B));
>  	return result;
>  }
>  
> @@ -237,7 +237,7 @@ static void dcss_scaler_gaussian_filter(int fc_q, bool use_5_taps,
>  			ll_temp = coef[phase][i];
>  			ll_temp <<= PSC_COEFF_PRECISION;
>  			ll_temp += sum >> 1;
> -			ll_temp /= sum;

That looks like hand rolled DIV_ROUND_CLOSEST_ULL()

> +			ll_temp = div_s64(ll_temp, sum);
>  			coef[phase][i] = (int)ll_temp;
>  		}
>  	}
> -- 
> 2.17.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
diff mbox series

Patch

diff --git a/drivers/gpu/drm/imx/dcss/dcss-scaler.c b/drivers/gpu/drm/imx/dcss/dcss-scaler.c
index cd21905de580..7c1e0e461244 100644
--- a/drivers/gpu/drm/imx/dcss/dcss-scaler.c
+++ b/drivers/gpu/drm/imx/dcss/dcss-scaler.c
@@ -134,7 +134,7 @@  static int div_q(int A, int B)
 	else
 		temp -= B / 2;
 
-	result = (int)(temp / B);
+	result = (int)(div_s64(temp, B));
 	return result;
 }
 
@@ -237,7 +237,7 @@  static void dcss_scaler_gaussian_filter(int fc_q, bool use_5_taps,
 			ll_temp = coef[phase][i];
 			ll_temp <<= PSC_COEFF_PRECISION;
 			ll_temp += sum >> 1;
-			ll_temp /= sum;
+			ll_temp = div_s64(ll_temp, sum);
 			coef[phase][i] = (int)ll_temp;
 		}
 	}