[PORT FROM R2]:HDMI-Audio: Avoiding infinite loop corner case during BUFFER_DONE...
authorShreyas Neerebailoor <shreyasx.neerebailoor@intel.com>
Thu, 1 Mar 2012 09:52:54 +0000 (15:22 +0530)
committerbuildbot <buildbot@intel.com>
Wed, 7 Mar 2012 11:19:46 +0000 (03:19 -0800)
BZ: 24383

During the reprogramming of the registers during BUFFER_DONE event
the loop iteration variable used is modified inside the loop which
in some case lead to an infinite loop. This condition is avoided
by using a temporary variable to hold the calculated value.

Change-Id: Icce13cf019c04a70673fa774c274937dec7c48ff
Signed-off-by: Shreyas Neerebailoor <shreyasx.neerebailoor@intel.com>
Reviewed-on: http://android.intel.com:8080/37244
Reviewed-by: Monroy, German <german.monroy@intel.com>
Reviewed-by: Agarwal, Vaibhav <vaibhav.agarwal@intel.com>
Reviewed-by: Koul, Vinod <vinod.koul@intel.com>
Reviewed-by: M, Arulselvan <arulselvan.m@intel.com>
Tested-by: M, Arulselvan <arulselvan.m@intel.com>
Reviewed-by: Abdullah, Omair M <omair.m.abdullah@intel.com>
Reviewed-by: buildbot <buildbot@intel.com>
Tested-by: buildbot <buildbot@intel.com>
sound/drivers/intel_mid_hdmi/intel_mid_hdmi_audio_if.c

index 772da21..0108da9 100644 (file)
@@ -155,13 +155,13 @@ static inline int had_chk_intrmiss(struct snd_intelhad *intelhaddata,
                buf_id += (intr_count - 1);
                /* Reprogram registers*/
                for (i = buff_done; i < buf_id; i++) {
-                       i = i % 4;
-                       buf_size = intelhaddata->buf_info[i].buf_size;
-                       buf_addr = intelhaddata->buf_info[i].buf_addr;
+                       int j = i % 4;
+                       buf_size = intelhaddata->buf_info[j].buf_size;
+                       buf_addr = intelhaddata->buf_info[j].buf_addr;
                        had_write_register(AUD_BUF_A_LENGTH +
-                                       (i * HAD_REG_WIDTH), buf_size);
+                                       (j * HAD_REG_WIDTH), buf_size);
                        had_write_register(
-                                       AUD_BUF_A_ADDR+(i * HAD_REG_WIDTH),
+                                       AUD_BUF_A_ADDR+(j * HAD_REG_WIDTH),
                                        (buf_addr | BIT(0) | BIT(1)));
                }
                buf_id = buf_id % 4;