media: staging/intel-ipu3: css: simplify expression
authorDeepak R Varma <mh12gx2825@gmail.com>
Wed, 25 Mar 2020 20:38:24 +0000 (21:38 +0100)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Tue, 14 Apr 2020 10:18:03 +0000 (12:18 +0200)
An array index computed inside square brackets complicates the code
and also extends the line beyond 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>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
drivers/staging/media/ipu3/ipu3-css-params.c

index 4533dac..fbd53d7 100644 (file)
@@ -49,14 +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++) {
-                       for (tap = 0; tap < taps; tap++) {
-                               coeff_lut[phase * IMGU_SCALER_FILTER_TAPS + tap]
-                                       = 0;
-                       }
+                       phase_taps = phase * IMGU_SCALER_FILTER_TAPS;
+                       for (tap = 0; tap < taps; tap++)
+                               coeff_lut[phase_taps + tap] = 0;
                }
 
                info->phase_step = IMGU_SCALER_PHASES *
@@ -71,6 +70,7 @@ imgu_css_scaler_setup_lut(unsigned int taps, unsigned int input_width,
        }
 
        for (phase = 0; phase < IMGU_SCALER_PHASES; phase++) {
+               phase_taps = phase * IMGU_SCALER_FILTER_TAPS;
                for (tap = 0; tap < taps; tap++) {
                        /* flip table to for convolution reverse indexing */
                        s64 coeff = coeffs[coeffs_size -
@@ -81,9 +81,7 @@ imgu_css_scaler_setup_lut(unsigned int taps, unsigned int input_width,
                        /* Add +"0.5" */
                        coeff += 1 << (IMGU_SCALER_COEFF_BITS - 1);
                        coeff >>= IMGU_SCALER_COEFF_BITS;
-
-                       coeff_lut[phase * IMGU_SCALER_FILTER_TAPS + tap] =
-                               coeff;
+                       coeff_lut[phase_taps + tap] = coeff;
                }
        }