Re: [PATCH] net: tulip: remove redundant assignment to variable new_csr6

From: Jakub Kicinski
Date: Mon Jan 24 2022 - 13:30:44 EST


On Sun, 23 Jan 2022 18:34:40 +0000 Colin Ian King wrote:
> Variable new_csr6 is being initialized with a value that is never
> read, it is being re-assigned later on. The assignment is redundant
> and can be removed.

> @@ -21,7 +21,7 @@ void pnic_do_nway(struct net_device *dev)
> struct tulip_private *tp = netdev_priv(dev);
> void __iomem *ioaddr = tp->base_addr;
> u32 phy_reg = ioread32(ioaddr + 0xB8);
> - u32 new_csr6 = tp->csr6 & ~0x40C40200;
> + u32 new_csr6;
>
> if (phy_reg & 0x78000000) { /* Ignore baseT4 */
> if (phy_reg & 0x20000000) dev->if_port = 5;

I can't say I see what you mean, it's not set in some cases:

if (tp->medialock) {
} else if (tp->nwayset && (dev->if_port & 1)) {
next_tick = 1*HZ;
} else if (dev->if_port == 0) {
dev->if_port = 3;
iowrite32(0x33, ioaddr + CSR12);
new_csr6 = 0x01860000;
iowrite32(0x1F868, ioaddr + 0xB8);
} else {
dev->if_port = 0;
iowrite32(0x32, ioaddr + CSR12);
new_csr6 = 0x00420000;
iowrite32(0x1F078, ioaddr + 0xB8);
}
if (tp->csr6 != new_csr6) {
tp->csr6 = new_csr6;


That said clang doesn't complain so maybe I'm missing something static
analysis had figured out about this code.