From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3FF0E53A7; Fri, 6 Dec 2024 15:06:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733497594; cv=none; b=hMRJ5woEDwCFyKulowhBEkdHuI3AmHCRvF8egRj1GlD6ceb9h0v7eeZTaYsHhgKIS0mwmFD97pE+IHV4xqXpH2BT4O1u1s9X0hP4DGBYDU4ImNAF+q4Fljr8w8ev3ZG0JReqXdraZdRZk90nXutf+d0WJUGXHOm9r67mKh9nRU0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733497594; c=relaxed/simple; bh=+TPfEJE+KdiUPtWlxoi0HpCzdLydOKJCt+wSNTj4d8I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DwUCkJGz6JZ+fB0ZIKkRtS6hY3ODObDVCFBNZt8F6HQWrPZxH5+1f0Ni62NCz3VHqMqfIGiH2tLd02bvdCBfupg4kul7b0G/GkrTx3DKtSqPYKgIEW5OuX50kF24rRl/hXJv+CBpzy7XIHO6tYCES1eoudeYreqDEiyXHfDSZsM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=P6qXSwkL; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="P6qXSwkL" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5BC4DC4CED1; Fri, 6 Dec 2024 15:06:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1733497593; bh=+TPfEJE+KdiUPtWlxoi0HpCzdLydOKJCt+wSNTj4d8I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P6qXSwkLI/wWzvAlOhdDeWFLzvl8aK9AxiArEwV4F+SIwA+zKOH6qQuv/2flHrKqk 5Ch7vr0b5NOVdUxYdJYpriK6WKBSZ9UC/s8KG+OshWcMUJHEAXUqb3XiaVOAoCse4+ LTheuBVBSp3WxNXRubhvmNRdghRqiYfUDgeV1Jxc= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Dan Carpenter , Viresh Kumar , Jassi Brar , Sasha Levin Subject: [PATCH 6.6 334/676] mailbox: arm_mhuv2: clean up loop in get_irq_chan_comb() Date: Fri, 6 Dec 2024 15:32:33 +0100 Message-ID: <20241206143706.392822913@linuxfoundation.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241206143653.344873888@linuxfoundation.org> References: <20241206143653.344873888@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Dan Carpenter [ Upstream commit 192a16a3430ca459c4e986f3d10758c4d6b1aa29 ] 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 Acked-by: Viresh Kumar Signed-off-by: Jassi Brar Signed-off-by: Sasha Levin --- drivers/mailbox/arm_mhuv2.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/mailbox/arm_mhuv2.c b/drivers/mailbox/arm_mhuv2.c index 0ec21dcdbde72..cff7c343ee082 100644 --- a/drivers/mailbox/arm_mhuv2.c +++ b/drivers/mailbox/arm_mhuv2.c @@ -500,7 +500,7 @@ static const struct mhuv2_protocol_ops mhuv2_data_transfer_ops = { static struct mbox_chan *get_irq_chan_comb(struct mhuv2 *mhu, u32 __iomem *reg) { struct mbox_chan *chans = mhu->mbox.chans; - int channel = 0, i, offset = 0, windows, protocol, ch_wn; + int channel = 0, i, j, offset = 0, windows, protocol, ch_wn; u32 stat; for (i = 0; i < MHUV2_CMB_INT_ST_REG_CNT; i++) { @@ -510,9 +510,9 @@ static struct mbox_chan *get_irq_chan_comb(struct mhuv2 *mhu, u32 __iomem *reg) ch_wn = i * MHUV2_STAT_BITS + __builtin_ctz(stat); - for (i = 0; i < mhu->length; i += 2) { - protocol = mhu->protocols[i]; - windows = mhu->protocols[i + 1]; + for (j = 0; j < mhu->length; j += 2) { + protocol = mhu->protocols[j]; + windows = mhu->protocols[j + 1]; if (ch_wn >= offset + windows) { if (protocol == DOORBELL) -- 2.43.0