* [PATCH] thunderbolt: rename shadowed variables bit to interrupt_bit and auto_clear_bit
@ 2023-03-15 22:04 Tom Rix
2023-03-16 10:20 ` Mika Westerberg
0 siblings, 1 reply; 5+ messages in thread
From: Tom Rix @ 2023-03-15 22:04 UTC (permalink / raw)
To: andreas.noever, michael.jamet, mika.westerberg, YehezkelShB
Cc: linux-usb, linux-kernel, Tom Rix
cppcheck reports
drivers/thunderbolt/nhi.c:74:7: style: Local variable 'bit' shadows outer variable [shadowVariable]
int bit;
^
drivers/thunderbolt/nhi.c:66:6: note: Shadowed declaration
int bit = ring_interrupt_index(ring) & 31;
^
drivers/thunderbolt/nhi.c:74:7: note: Shadow variable
int bit;
^
For readablity rename the outer to interrupt_bit and the innner
to auto_clear_bit.
Signed-off-by: Tom Rix <trix@redhat.com>
---
drivers/thunderbolt/nhi.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/drivers/thunderbolt/nhi.c b/drivers/thunderbolt/nhi.c
index 318d20bd5b69..d0d26d288be8 100644
--- a/drivers/thunderbolt/nhi.c
+++ b/drivers/thunderbolt/nhi.c
@@ -63,15 +63,15 @@ static void ring_interrupt_active(struct tb_ring *ring, bool active)
{
int reg = REG_RING_INTERRUPT_BASE +
ring_interrupt_index(ring) / 32 * 4;
- int bit = ring_interrupt_index(ring) & 31;
- int mask = 1 << bit;
+ int interrupt_bit = ring_interrupt_index(ring) & 31;
+ int mask = 1 << interrupt_bit;
u32 old, new;
if (ring->irq > 0) {
u32 step, shift, ivr, misc;
void __iomem *ivr_base;
+ int auto_clear_bit;
int index;
- int bit;
if (ring->is_tx)
index = ring->hop;
@@ -91,11 +91,11 @@ static void ring_interrupt_active(struct tb_ring *ring, bool active)
*/
misc = ioread32(ring->nhi->iobase + REG_DMA_MISC);
if (ring->nhi->quirks & QUIRK_AUTO_CLEAR_INT)
- bit = REG_DMA_MISC_INT_AUTO_CLEAR;
+ auto_clear_bit = REG_DMA_MISC_INT_AUTO_CLEAR;
else
- bit = REG_DMA_MISC_DISABLE_AUTO_CLEAR;
- if (!(misc & bit))
- iowrite32(misc | bit, ring->nhi->iobase + REG_DMA_MISC);
+ auto_clear_bit = REG_DMA_MISC_DISABLE_AUTO_CLEAR;
+ if (!(misc & auto_clear_bit))
+ iowrite32(misc | auto_clear_bit, ring->nhi->iobase + REG_DMA_MISC);
ivr_base = ring->nhi->iobase + REG_INT_VEC_ALLOC_BASE;
step = index / REG_INT_VEC_ALLOC_REGS * REG_INT_VEC_ALLOC_BITS;
@@ -115,7 +115,7 @@ static void ring_interrupt_active(struct tb_ring *ring, bool active)
dev_dbg(&ring->nhi->pdev->dev,
"%s interrupt at register %#x bit %d (%#x -> %#x)\n",
- active ? "enabling" : "disabling", reg, bit, old, new);
+ active ? "enabling" : "disabling", reg, interrupt_bit, old, new);
if (new == old)
dev_WARN(&ring->nhi->pdev->dev,
--
2.27.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] thunderbolt: rename shadowed variables bit to interrupt_bit and auto_clear_bit
2023-03-15 22:04 [PATCH] thunderbolt: rename shadowed variables bit to interrupt_bit and auto_clear_bit Tom Rix
@ 2023-03-16 10:20 ` Mika Westerberg
2023-03-16 10:37 ` Mika Westerberg
0 siblings, 1 reply; 5+ messages in thread
From: Mika Westerberg @ 2023-03-16 10:20 UTC (permalink / raw)
To: Tom Rix
Cc: andreas.noever, michael.jamet, YehezkelShB, linux-usb,
linux-kernel, Mario Limonciello
+Cc Mario
On Wed, Mar 15, 2023 at 06:04:50PM -0400, Tom Rix wrote:
> cppcheck reports
> drivers/thunderbolt/nhi.c:74:7: style: Local variable 'bit' shadows outer variable [shadowVariable]
> int bit;
> ^
> drivers/thunderbolt/nhi.c:66:6: note: Shadowed declaration
> int bit = ring_interrupt_index(ring) & 31;
> ^
> drivers/thunderbolt/nhi.c:74:7: note: Shadow variable
> int bit;
> ^
> For readablity rename the outer to interrupt_bit and the innner
> to auto_clear_bit.
Thanks for the patch! Yeah, this did not show up in any of the kbuild
tests perhaps they are missing cppcheck :(
I'm thinking that I'll just move the two commits from "fixes" to "next"
and add this one on top (and drop the stable tags) as the code that we
should be sending to stable should not need additional fixes IMHO. I
know Mario is on vacation so probably cannot answer here so let's deal
with this when he is back.
> Signed-off-by: Tom Rix <trix@redhat.com>
> ---
> drivers/thunderbolt/nhi.c | 16 ++++++++--------
> 1 file changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/thunderbolt/nhi.c b/drivers/thunderbolt/nhi.c
> index 318d20bd5b69..d0d26d288be8 100644
> --- a/drivers/thunderbolt/nhi.c
> +++ b/drivers/thunderbolt/nhi.c
> @@ -63,15 +63,15 @@ static void ring_interrupt_active(struct tb_ring *ring, bool active)
> {
> int reg = REG_RING_INTERRUPT_BASE +
> ring_interrupt_index(ring) / 32 * 4;
> - int bit = ring_interrupt_index(ring) & 31;
> - int mask = 1 << bit;
> + int interrupt_bit = ring_interrupt_index(ring) & 31;
> + int mask = 1 << interrupt_bit;
> u32 old, new;
>
> if (ring->irq > 0) {
> u32 step, shift, ivr, misc;
> void __iomem *ivr_base;
> + int auto_clear_bit;
> int index;
> - int bit;
>
> if (ring->is_tx)
> index = ring->hop;
> @@ -91,11 +91,11 @@ static void ring_interrupt_active(struct tb_ring *ring, bool active)
> */
> misc = ioread32(ring->nhi->iobase + REG_DMA_MISC);
> if (ring->nhi->quirks & QUIRK_AUTO_CLEAR_INT)
> - bit = REG_DMA_MISC_INT_AUTO_CLEAR;
> + auto_clear_bit = REG_DMA_MISC_INT_AUTO_CLEAR;
> else
> - bit = REG_DMA_MISC_DISABLE_AUTO_CLEAR;
> - if (!(misc & bit))
> - iowrite32(misc | bit, ring->nhi->iobase + REG_DMA_MISC);
> + auto_clear_bit = REG_DMA_MISC_DISABLE_AUTO_CLEAR;
> + if (!(misc & auto_clear_bit))
> + iowrite32(misc | auto_clear_bit, ring->nhi->iobase + REG_DMA_MISC);
>
> ivr_base = ring->nhi->iobase + REG_INT_VEC_ALLOC_BASE;
> step = index / REG_INT_VEC_ALLOC_REGS * REG_INT_VEC_ALLOC_BITS;
> @@ -115,7 +115,7 @@ static void ring_interrupt_active(struct tb_ring *ring, bool active)
>
> dev_dbg(&ring->nhi->pdev->dev,
> "%s interrupt at register %#x bit %d (%#x -> %#x)\n",
> - active ? "enabling" : "disabling", reg, bit, old, new);
> + active ? "enabling" : "disabling", reg, interrupt_bit, old, new);
>
> if (new == old)
> dev_WARN(&ring->nhi->pdev->dev,
> --
> 2.27.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] thunderbolt: rename shadowed variables bit to interrupt_bit and auto_clear_bit
2023-03-16 10:20 ` Mika Westerberg
@ 2023-03-16 10:37 ` Mika Westerberg
2023-03-19 1:33 ` Mario Limonciello
0 siblings, 1 reply; 5+ messages in thread
From: Mika Westerberg @ 2023-03-16 10:37 UTC (permalink / raw)
To: Tom Rix
Cc: andreas.noever, michael.jamet, YehezkelShB, linux-usb,
linux-kernel, Mario Limonciello
On Thu, Mar 16, 2023 at 12:20:48PM +0200, Mika Westerberg wrote:
> +Cc Mario
>
> On Wed, Mar 15, 2023 at 06:04:50PM -0400, Tom Rix wrote:
> > cppcheck reports
> > drivers/thunderbolt/nhi.c:74:7: style: Local variable 'bit' shadows outer variable [shadowVariable]
> > int bit;
> > ^
> > drivers/thunderbolt/nhi.c:66:6: note: Shadowed declaration
> > int bit = ring_interrupt_index(ring) & 31;
> > ^
> > drivers/thunderbolt/nhi.c:74:7: note: Shadow variable
> > int bit;
> > ^
> > For readablity rename the outer to interrupt_bit and the innner
> > to auto_clear_bit.
>
> Thanks for the patch! Yeah, this did not show up in any of the kbuild
> tests perhaps they are missing cppcheck :(
>
> I'm thinking that I'll just move the two commits from "fixes" to "next"
> and add this one on top (and drop the stable tags) as the code that we
> should be sending to stable should not need additional fixes IMHO. I
> know Mario is on vacation so probably cannot answer here so let's deal
> with this when he is back.
Applied to thunderbolt.git/next (along with the two commits from Mario).
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] thunderbolt: rename shadowed variables bit to interrupt_bit and auto_clear_bit
2023-03-16 10:37 ` Mika Westerberg
@ 2023-03-19 1:33 ` Mario Limonciello
2023-03-20 7:42 ` Mika Westerberg
0 siblings, 1 reply; 5+ messages in thread
From: Mario Limonciello @ 2023-03-19 1:33 UTC (permalink / raw)
To: Mika Westerberg, Tom Rix
Cc: andreas.noever, michael.jamet, YehezkelShB, linux-usb, linux-kernel
On 3/16/23 05:37, Mika Westerberg wrote:
> On Thu, Mar 16, 2023 at 12:20:48PM +0200, Mika Westerberg wrote:
>> +Cc Mario
>>
>> On Wed, Mar 15, 2023 at 06:04:50PM -0400, Tom Rix wrote:
>>> cppcheck reports
>>> drivers/thunderbolt/nhi.c:74:7: style: Local variable 'bit' shadows outer variable [shadowVariable]
>>> int bit;
>>> ^
>>> drivers/thunderbolt/nhi.c:66:6: note: Shadowed declaration
>>> int bit = ring_interrupt_index(ring) & 31;
>>> ^
>>> drivers/thunderbolt/nhi.c:74:7: note: Shadow variable
>>> int bit;
>>> ^
>>> For readablity rename the outer to interrupt_bit and the innner
>>> to auto_clear_bit.
>> Thanks for the patch! Yeah, this did not show up in any of the kbuild
>> tests perhaps they are missing cppcheck :(
>>
>> I'm thinking that I'll just move the two commits from "fixes" to "next"
>> and add this one on top (and drop the stable tags) as the code that we
>> should be sending to stable should not need additional fixes IMHO. I
>> know Mario is on vacation so probably cannot answer here so let's deal
>> with this when he is back.
> Applied to thunderbolt.git/next (along with the two commits from Mario).
Thanks for the fix Tom!
Mika - It's unfortunate that a fixup was needed but I'd still like if we
can get these 3 commits into 6.3-rc and also to stable.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] thunderbolt: rename shadowed variables bit to interrupt_bit and auto_clear_bit
2023-03-19 1:33 ` Mario Limonciello
@ 2023-03-20 7:42 ` Mika Westerberg
0 siblings, 0 replies; 5+ messages in thread
From: Mika Westerberg @ 2023-03-20 7:42 UTC (permalink / raw)
To: Mario Limonciello
Cc: Tom Rix, andreas.noever, michael.jamet, YehezkelShB, linux-usb,
linux-kernel
On Sat, Mar 18, 2023 at 08:33:58PM -0500, Mario Limonciello wrote:
>
> On 3/16/23 05:37, Mika Westerberg wrote:
> > On Thu, Mar 16, 2023 at 12:20:48PM +0200, Mika Westerberg wrote:
> > > +Cc Mario
> > >
> > > On Wed, Mar 15, 2023 at 06:04:50PM -0400, Tom Rix wrote:
> > > > cppcheck reports
> > > > drivers/thunderbolt/nhi.c:74:7: style: Local variable 'bit' shadows outer variable [shadowVariable]
> > > > int bit;
> > > > ^
> > > > drivers/thunderbolt/nhi.c:66:6: note: Shadowed declaration
> > > > int bit = ring_interrupt_index(ring) & 31;
> > > > ^
> > > > drivers/thunderbolt/nhi.c:74:7: note: Shadow variable
> > > > int bit;
> > > > ^
> > > > For readablity rename the outer to interrupt_bit and the innner
> > > > to auto_clear_bit.
> > > Thanks for the patch! Yeah, this did not show up in any of the kbuild
> > > tests perhaps they are missing cppcheck :(
> > >
> > > I'm thinking that I'll just move the two commits from "fixes" to "next"
> > > and add this one on top (and drop the stable tags) as the code that we
> > > should be sending to stable should not need additional fixes IMHO. I
> > > know Mario is on vacation so probably cannot answer here so let's deal
> > > with this when he is back.
> > Applied to thunderbolt.git/next (along with the two commits from Mario).
>
> Thanks for the fix Tom!
>
> Mika - It's unfortunate that a fixup was needed but I'd still like if we
> can get these 3 commits into 6.3-rc and also to stable.
Fair enough. I moved them into fixes now.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-03-20 7:42 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-15 22:04 [PATCH] thunderbolt: rename shadowed variables bit to interrupt_bit and auto_clear_bit Tom Rix
2023-03-16 10:20 ` Mika Westerberg
2023-03-16 10:37 ` Mika Westerberg
2023-03-19 1:33 ` Mario Limonciello
2023-03-20 7:42 ` Mika Westerberg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).