Skip to content

Commit

Permalink
net: dsa: microchip: ksz8795: move variable assignments from detect t…
Browse files Browse the repository at this point in the history
…o init

This patch moves all variable assignments to the init function. It
leaves the detect function for its single purpose to detect which chip
version is found.

Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Michael Grzeschik authored and Jakub Kicinski committed Dec 3, 2020
1 parent 68a1b67 commit 7fc32b4
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions drivers/net/dsa/microchip/ksz8795.c
Original file line number Diff line number Diff line change
Expand Up @@ -1150,9 +1150,6 @@ static int ksz8795_switch_detect(struct ksz_device *dev)
(id2 != CHIP_ID_94 && id2 != CHIP_ID_95))
return -ENODEV;

dev->mib_port_cnt = TOTAL_PORT_NUM;
dev->phy_port_cnt = SWITCH_PORT_NUM;

if (id2 == CHIP_ID_95) {
u8 val;

Expand All @@ -1167,9 +1164,6 @@ static int ksz8795_switch_detect(struct ksz_device *dev)
id16 |= id2;
dev->chip_id = id16;

dev->cpu_port = dev->mib_port_cnt - 1;
dev->host_mask = BIT(dev->cpu_port);

return 0;
}

Expand Down Expand Up @@ -1244,6 +1238,12 @@ static int ksz8795_switch_init(struct ksz_device *dev)
dev->reg_mib_cnt = SWITCH_COUNTER_NUM;
dev->mib_cnt = TOTAL_SWITCH_COUNTER_NUM;

dev->mib_port_cnt = TOTAL_PORT_NUM;
dev->phy_port_cnt = SWITCH_PORT_NUM;

dev->cpu_port = dev->mib_port_cnt - 1;
dev->host_mask = BIT(dev->cpu_port);

i = dev->mib_port_cnt;
dev->ports = devm_kzalloc(dev->dev, sizeof(struct ksz_port) * i,
GFP_KERNEL);
Expand Down

0 comments on commit 7fc32b4

Please sign in to comment.