All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] media: staging/intel-ipu3: css: simplify expression
@ 2020-03-13 21:37 Deepak R Varma
  2020-03-13 22:09 ` [Outreachy kernel] " Julia Lawall
  0 siblings, 1 reply; 2+ messages in thread
From: Deepak R Varma @ 2020-03-13 21:37 UTC (permalink / raw)
  To: outreachy-kernel
  Cc: sakari.ailus, mchehab, gregkh, daniel.baluta, kieran.bingham

An array index computed inside square brackets leading to complexity
and code line exceeding 80 character. Add new variable to compute
array index separately and use it as an index during assignment.

Signed-off-by: Deepak R Varma <mh12gx2825@gmail.com>
---
Changes since v1:
  - Added feedback from Helen
	1. Updated variable type to "unsigned int" from earlier "int"
	2. Implemented the change in another area in same scope
	3. Left newly added variable unintialised.
  

 drivers/staging/media/ipu3/ipu3-css-params.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/media/ipu3/ipu3-css-params.c b/drivers/staging/media/ipu3/ipu3-css-params.c
index 4533dacad4be..5622319b69ff 100644
--- a/drivers/staging/media/ipu3/ipu3-css-params.c
+++ b/drivers/staging/media/ipu3/ipu3-css-params.c
@@ -49,13 +49,13 @@ imgu_css_scaler_setup_lut(unsigned int taps, unsigned int input_width,
 	int tap, phase, phase_sum_left, phase_sum_right;
 	int exponent = imgu_css_scaler_get_exp(output_width, input_width);
 	int mantissa = (1 << exponent) * output_width;
-	unsigned int phase_step;
+	unsigned int phase_step, phase_taps;
 
 	if (input_width == output_width) {
 		for (phase = 0; phase < IMGU_SCALER_PHASES; phase++) {
+			phase_taps = phase * IMGU_SCALER_FILTER_TAPS;
 			for (tap = 0; tap < taps; tap++) {
-				coeff_lut[phase * IMGU_SCALER_FILTER_TAPS + tap]
-					= 0;
+				coeff_lut[phase_taps + tap] = 0;
 			}
 		}
 
@@ -82,8 +82,8 @@ imgu_css_scaler_setup_lut(unsigned int taps, unsigned int input_width,
 			coeff += 1 << (IMGU_SCALER_COEFF_BITS - 1);
 			coeff >>= IMGU_SCALER_COEFF_BITS;
 
-			coeff_lut[phase * IMGU_SCALER_FILTER_TAPS + tap] =
-				coeff;
+			phase_taps = phase * IMGU_SCALER_FILTER_TAPS + tap;
+			coeff_lut[phase_taps] = coeff;
 		}
 	}
 
-- 
2.17.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Outreachy kernel] [PATCH v2] media: staging/intel-ipu3: css: simplify expression
  2020-03-13 21:37 [PATCH v2] media: staging/intel-ipu3: css: simplify expression Deepak R Varma
@ 2020-03-13 22:09 ` Julia Lawall
  0 siblings, 0 replies; 2+ messages in thread
From: Julia Lawall @ 2020-03-13 22:09 UTC (permalink / raw)
  To: Deepak R Varma
  Cc: outreachy-kernel, sakari.ailus, mchehab, gregkh, daniel.baluta,
	kieran.bingham



On Sat, 14 Mar 2020, Deepak R Varma wrote:

> An array index computed inside square brackets leading to complexity
> and code line exceeding 80 character.

This needs a verb.  "leading to complexity" is not precise enough to be
useful.

julia

> Add new variable to compute
> array index separately and use it as an index during assignment.
>
> Signed-off-by: Deepak R Varma <mh12gx2825@gmail.com>
> ---
> Changes since v1:
>   - Added feedback from Helen
> 	1. Updated variable type to "unsigned int" from earlier "int"
> 	2. Implemented the change in another area in same scope
> 	3. Left newly added variable unintialised.
>
>
>  drivers/staging/media/ipu3/ipu3-css-params.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/staging/media/ipu3/ipu3-css-params.c b/drivers/staging/media/ipu3/ipu3-css-params.c
> index 4533dacad4be..5622319b69ff 100644
> --- a/drivers/staging/media/ipu3/ipu3-css-params.c
> +++ b/drivers/staging/media/ipu3/ipu3-css-params.c
> @@ -49,13 +49,13 @@ imgu_css_scaler_setup_lut(unsigned int taps, unsigned int input_width,
>  	int tap, phase, phase_sum_left, phase_sum_right;
>  	int exponent = imgu_css_scaler_get_exp(output_width, input_width);
>  	int mantissa = (1 << exponent) * output_width;
> -	unsigned int phase_step;
> +	unsigned int phase_step, phase_taps;
>
>  	if (input_width == output_width) {
>  		for (phase = 0; phase < IMGU_SCALER_PHASES; phase++) {
> +			phase_taps = phase * IMGU_SCALER_FILTER_TAPS;
>  			for (tap = 0; tap < taps; tap++) {
> -				coeff_lut[phase * IMGU_SCALER_FILTER_TAPS + tap]
> -					= 0;
> +				coeff_lut[phase_taps + tap] = 0;
>  			}
>  		}
>
> @@ -82,8 +82,8 @@ imgu_css_scaler_setup_lut(unsigned int taps, unsigned int input_width,
>  			coeff += 1 << (IMGU_SCALER_COEFF_BITS - 1);
>  			coeff >>= IMGU_SCALER_COEFF_BITS;
>
> -			coeff_lut[phase * IMGU_SCALER_FILTER_TAPS + tap] =
> -				coeff;
> +			phase_taps = phase * IMGU_SCALER_FILTER_TAPS + tap;
> +			coeff_lut[phase_taps] = coeff;
>  		}
>  	}
>
> --
> 2.17.1
>
> --
> You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to outreachy-kernel+unsubscribe@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20200313213755.GA5213%40deeUbuntu.
>


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-03-13 22:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-13 21:37 [PATCH v2] media: staging/intel-ipu3: css: simplify expression Deepak R Varma
2020-03-13 22:09 ` [Outreachy kernel] " Julia Lawall

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.