Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mailbox: arm_mhuv2: clean up loop in get_irq_chan_comb()

Both the inner and outer loops in this code use the "i" iterator.
The inner loop should really use a different iterator.

It doesn't affect things in practice because the data comes from the
device tree. The "protocol" and "windows" variables are going to be
zero. That means we're always going to hit the "return &chans[channel];"
statement and we're not going to want to iterate through the outer
loop again.

Still it's worth fixing this for future use cases.

Fixes: 5a6338cce9f4 ("mailbox: arm_mhuv2: Add driver")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Jassi Brar <jassisinghbrar@gmail.com>

authored by

Dan Carpenter and committed by
Jassi Brar
192a16a3 98fc87fe

+4 -4
+4 -4
drivers/mailbox/arm_mhuv2.c
··· 500 500 static struct mbox_chan *get_irq_chan_comb(struct mhuv2 *mhu, u32 __iomem *reg) 501 501 { 502 502 struct mbox_chan *chans = mhu->mbox.chans; 503 - int channel = 0, i, offset = 0, windows, protocol, ch_wn; 503 + int channel = 0, i, j, offset = 0, windows, protocol, ch_wn; 504 504 u32 stat; 505 505 506 506 for (i = 0; i < MHUV2_CMB_INT_ST_REG_CNT; i++) { ··· 510 510 511 511 ch_wn = i * MHUV2_STAT_BITS + __builtin_ctz(stat); 512 512 513 - for (i = 0; i < mhu->length; i += 2) { 514 - protocol = mhu->protocols[i]; 515 - windows = mhu->protocols[i + 1]; 513 + for (j = 0; j < mhu->length; j += 2) { 514 + protocol = mhu->protocols[j]; 515 + windows = mhu->protocols[j + 1]; 516 516 517 517 if (ch_wn >= offset + windows) { 518 518 if (protocol == DOORBELL)