mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Paul Geurts <paul.geurts@prodrive-technologies.com>
To: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: [PATCH 3/4] net: dsa: b53: fail switch initialization for unsupported switch types
Date: Mon, 27 Feb 2023 19:44:08 +0000	[thread overview]
Message-ID: <AM0PR02MB5524DDFDD40371F2546C2E77BDAF9@AM0PR02MB5524.eurprd02.prod.outlook.com> (raw)
In-Reply-To: <20221212135640.3590545-4-paul.geurts@prodrive-technologies.com>

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@prodrive-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


  parent reply	other threads:[~2023-02-27 19:45 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20221212135640.3590545-1-paul.geurts@prodrive-technologies.com>
2023-02-27 19:44 ` [PATCH 0/4] b53: Add BCM53134 support Paul Geurts
     [not found] ` <20221212135640.3590545-2-paul.geurts@prodrive-technologies.com>
2023-02-27 19:44   ` [PATCH 1/4] net: dsa: b53: Add support for Broadcom BCM53134 managed Ethernet switch Paul Geurts
2023-02-28 11:35     ` Krzysztof Kozlowski
     [not found] ` <20221212135640.3590545-3-paul.geurts@prodrive-technologies.com>
2023-02-27 19:44   ` [PATCH 2/4] dt-bindings: net/dsa/: add brcm,bcm53134 as compatible flag Paul Geurts
2023-02-28 11:33     ` Krzysztof Kozlowski
     [not found]       ` <20230301085531.3713797-1-paul.geurts@prodrive-technologies.com>
2023-03-01  8:58         ` Paul Geurts
     [not found] ` <20221212135640.3590545-4-paul.geurts@prodrive-technologies.com>
2023-02-27 19:44   ` Paul Geurts [this message]
     [not found] ` <20221212135640.3590545-5-paul.geurts@prodrive-technologies.com>
2023-02-27 19:44   ` [PATCH 4/4] net: dsa: b53: mdio: Add optional reset gpio Paul Geurts
2023-02-28 11:34     ` Krzysztof Kozlowski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=AM0PR02MB5524DDFDD40371F2546C2E77BDAF9@AM0PR02MB5524.eurprd02.prod.outlook.com \
    --to=paul.geurts@prodrive-technologies.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®