[<prev] [next>] [day] [month] [year] [list]
Message-ID: <AM0PR02MB5524DDFDD40371F2546C2E77BDAF9@AM0PR02MB5524.eurprd02.prod.outlook.com>
Date: Mon, 27 Feb 2023 19:44:08 +0000
From: Paul Geurts <paul.geurts@...drive-technologies.com>
To: "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: [PATCH 3/4] net: dsa: b53: fail switch initialization for unsupported
switch types
When no supported switch device is found in the b53_switch_chips array is found, the driver continues to do a best effort initialization, wihch most likely results in an error and most definetely a non-functional Ethernet switch.
Now, the switch_init function just returns -EINVAL immediately when no valid chip data is found.
Signed-off-by: Paul Geurts <paul.geurts@...drive-technologies.com>
---
drivers/net/dsa/b53/b53_common.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c
index 6aa76cb4f992..3aa0672f2ba9 100644
--- a/drivers/net/dsa/b53/b53_common.c
+++ b/drivers/net/dsa/b53/b53_common.c
@@ -2572,11 +2572,13 @@ static int b53_switch_init(struct b53_device *dev) {
unsigned int i;
int ret;
+ bool config_found = false;
for (i = 0; i < ARRAY_SIZE(b53_switch_chips); i++) {
const struct b53_chip_data *chip = &b53_switch_chips[i];
if (chip->chip_id == dev->chip_id) {
+ config_found = true;
if (!dev->enabled_ports)
dev->enabled_ports = chip->enabled_ports;
dev->name = chip->dev_name;
@@ -2593,6 +2595,11 @@ static int b53_switch_init(struct b53_device *dev)
}
}
+ if (!config_found) {
+ dev_err(dev->dev, "No configuration found for switch id 0x%X\n", dev->chip_id);
+ return -EINVAL;
+ }
+
/* check which BCM5325x version we have */
if (is5325(dev)) {
u8 vc4;
--
2.30.2
Powered by blists - more mailing lists