mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH v1 1/4] drivers: net: fec_imx: fix receive issue with external switch
@ 2022-11-02 10:07 Oleksij Rempel
  2022-11-02 10:07 ` [PATCH v1 2/4] net: dsa: fix of_device_ensure_probed*() for switch ports Oleksij Rempel
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Oleksij Rempel @ 2022-11-02 10:07 UTC (permalink / raw)
  To: barebox; +Cc: Oleksij Rempel

Enable poromisc mode by default to allow using multiple MAC address on
same FEC interfaces.

We already use poromisc mode on designware stmmac, so it will make
behavior more consistent on different systems.

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
 drivers/net/fec_imx.c | 3 +++
 drivers/net/fec_imx.h | 1 +
 2 files changed, 4 insertions(+)

diff --git a/drivers/net/fec_imx.c b/drivers/net/fec_imx.c
index 673555a48a..9aa4b4f595 100644
--- a/drivers/net/fec_imx.c
+++ b/drivers/net/fec_imx.c
@@ -262,6 +262,9 @@ static int fec_init(struct eth_device *dev)
 	 */
 	rcntl = FEC_R_CNTRL_MAX_FL(1518);
 
+	/* Set promisc mode to make switches with different ethaddr work */
+	rcntl |= FEC_R_CNTRL_PROMISC;
+
 	rcntl |= FEC_R_CNTRL_MII_MODE;
 	/*
 	 * Set MII_SPEED = (1/(mii_speed * 2)) * System Clock
diff --git a/drivers/net/fec_imx.h b/drivers/net/fec_imx.h
index 316eefe48f..9bb1c64b55 100644
--- a/drivers/net/fec_imx.h
+++ b/drivers/net/fec_imx.h
@@ -58,6 +58,7 @@
 #define FEC_R_CNTRL_RMII_10T		(1 << 9) /* i.MX28 specific */
 #define FEC_R_CNTRL_RMII_MODE		(1 << 8) /* i.MX28 specific */
 #define FEC_R_CNTRL_FCE			(1 << 5)
+#define FEC_R_CNTRL_PROMISC		(1 << 3)
 #define FEC_R_CNTRL_MII_MODE		(1 << 2)
 
 #define FEC_IEVENT_HBERR                0x80000000 /* Note: Not on i.MX28 */
-- 
2.30.2




^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v1 2/4] net: dsa: fix of_device_ensure_probed*() for switch ports
  2022-11-02 10:07 [PATCH v1 1/4] drivers: net: fec_imx: fix receive issue with external switch Oleksij Rempel
@ 2022-11-02 10:07 ` Oleksij Rempel
  2022-11-02 10:07 ` [PATCH v1 3/4] ARM: boards: skov-imx6: assigned separate MAC address to LAN2 Oleksij Rempel
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Oleksij Rempel @ 2022-11-02 10:07 UTC (permalink / raw)
  To: barebox; +Cc: Oleksij Rempel

Crete ports by using of_platform_device_create() in the same way as it
is used by of_device_ensure_probed*(). Otherwise we are creating
multiple devices for the same node.

At same time we need to link dummy driver to make this logic work.

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
 drivers/net/dsa.c | 18 +++++-------------
 include/dsa.h     |  2 +-
 2 files changed, 6 insertions(+), 14 deletions(-)

diff --git a/drivers/net/dsa.c b/drivers/net/dsa.c
index 040ba897e2..ee07f08eef 100644
--- a/drivers/net/dsa.c
+++ b/drivers/net/dsa.c
@@ -59,7 +59,7 @@ static int dsa_port_probe(struct eth_device *edev)
 	int ret;
 
 	if (ops->port_probe) {
-		interface = of_get_phy_mode(dp->dev.device_node);
+		interface = of_get_phy_mode(dp->dev->device_node);
 		ret = ops->port_probe(dp, dp->index, interface);
 		if (ret)
 			return ret;
@@ -93,7 +93,7 @@ static int dsa_port_start(struct eth_device *edev)
 	if (dp->enabled)
 		return -EBUSY;
 
-	interface = of_get_phy_mode(dp->dev.device_node);
+	interface = of_get_phy_mode(dp->dev->device_node);
 
 	if (ops->port_pre_enable) {
 		/* In case of RMII interface we need to enable RMII clock
@@ -235,21 +235,13 @@ static int dsa_switch_register_edev(struct dsa_switch *ds,
 	struct eth_device *edev;
 	struct device_d *dev;
 	struct dsa_port *dp;
-	int ret;
 
 	ds->dp[port] = xzalloc(sizeof(*dp));
-
 	dp = ds->dp[port];
-	dev = &dp->dev;
-
-	dev_set_name(dev, "dsa_port");
-	dev->id = DEVICE_ID_DYNAMIC;
-	dev->parent = ds->dev;
-	dev->device_node = dn;
 
-	ret = register_device(dev);
-	if (ret)
-		return ret;
+	dev = of_platform_device_create(dn, ds->dev);
+	of_platform_device_dummy_drv(dev);
+	dp->dev = dev;
 
 	dp->rx_buf = xmalloc(DSA_PKTSIZE);
 	dp->ds = ds;
diff --git a/include/dsa.h b/include/dsa.h
index 75a939f2cb..f428aa74a5 100644
--- a/include/dsa.h
+++ b/include/dsa.h
@@ -58,7 +58,7 @@ struct dsa_ops {
 };
 
 struct dsa_port {
-	struct device_d dev;
+	struct device_d *dev;
 	struct dsa_switch *ds;
 	unsigned int index;
 	struct eth_device edev;
-- 
2.30.2




^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v1 3/4] ARM: boards: skov-imx6: assigned separate MAC address to LAN2
  2022-11-02 10:07 [PATCH v1 1/4] drivers: net: fec_imx: fix receive issue with external switch Oleksij Rempel
  2022-11-02 10:07 ` [PATCH v1 2/4] net: dsa: fix of_device_ensure_probed*() for switch ports Oleksij Rempel
@ 2022-11-02 10:07 ` Oleksij Rempel
  2022-11-02 11:18   ` Sascha Hauer
  2022-11-02 10:07 ` [PATCH v1 4/4] ARM: boards: skov-imx6: convert all pr_ to dev_ prints Oleksij Rempel
  2022-11-02 11:08 ` [PATCH v1 1/4] drivers: net: fec_imx: fix receive issue with external switch Sascha Hauer
  3 siblings, 1 reply; 7+ messages in thread
From: Oleksij Rempel @ 2022-11-02 10:07 UTC (permalink / raw)
  To: barebox; +Cc: Oleksij Rempel

We have two external ports and different MAC addresses on each port. So,
assign different MAC to the LAN2. The address on LAN1 is the
system default address.

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
 arch/arm/boards/skov-imx6/board.c | 47 ++++++++++++++++++++++++++++++-
 1 file changed, 46 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boards/skov-imx6/board.c b/arch/arm/boards/skov-imx6/board.c
index 3c51b76735..ab8b229a69 100644
--- a/arch/arm/boards/skov-imx6/board.c
+++ b/arch/arm/boards/skov-imx6/board.c
@@ -17,6 +17,12 @@
 
 #include "version.h"
 
+struct skov_imx6_priv {
+	struct device_d *dev;
+};
+
+static struct skov_imx6_priv *skov_priv;
+
 static int eth_of_fixup_node(struct device_node *root, const char *node_path,
 			     const u8 *ethaddr)
 {
@@ -542,6 +548,34 @@ static void skov_init_board(const struct board_description *variant)
 	}
 }
 
+/* */
+static int skov_set_switch_lan2_mac(struct skov_imx6_priv *priv)
+{
+	const char *state = "/state/ethaddr/eth2";
+	struct device_node *lan2_np;
+	u8 ethaddr[ETH_ALEN];
+	int ret;
+
+	ret = get_mac_address_from_env_variable("state.ethaddr.eth2", ethaddr);
+	if (ret || !is_valid_ether_addr(ethaddr)) {
+		ret = get_default_mac_address_from_state_node(state, ethaddr);
+		if (ret || !is_valid_ether_addr(ethaddr)) {
+			dev_err(priv->dev, "can't get MAC for LAN2\n");
+			return -ENODEV;
+		}
+	}
+
+	lan2_np = of_find_node_by_path("/mdio/switch@0/ports/ports@1");
+	if (!lan2_np) {
+		dev_err(priv->dev, "LAN2 node not found\n");
+		return -ENODEV;
+	}
+
+	of_eth_register_ethaddr(lan2_np, ethaddr);
+
+	return 0;
+}
+
 static int skov_switch_test(void)
 {
 	struct device_d *sw_dev;
@@ -561,8 +595,11 @@ static int skov_switch_test(void)
 		goto no_switch;
 	}
 
-	if (dev_is_probed(sw_dev))
+	if (dev_is_probed(sw_dev)) {
+		skov_set_switch_lan2_mac(skov_priv);
+		/* even if we fail, continue to boot as good as possible */
 		return 0;
+	}
 
 no_switch:
 	skov_have_switch = false;
@@ -584,6 +621,7 @@ late_initcall(skov_switch_test);
 
 static int skov_imx6_probe(struct device_d *dev)
 {
+	struct skov_imx6_priv *priv;
 	unsigned v = 0;
 	const struct board_description *variant;
 
@@ -603,6 +641,13 @@ static int skov_imx6_probe(struct device_d *dev)
 
 	skov_board_no = v;
 
+	priv = xzalloc(sizeof(*priv));
+	if (!priv)
+		return -ENOMEM;
+
+	priv->dev = dev;
+	skov_priv = priv;
+
 	globalvar_add_simple_int("board.no", &skov_board_no, "%u");
 	globalvar_add_simple("board.variant", variant->variant);
 	globalvar_add_simple("board.revision",variant->revision);
-- 
2.30.2




^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v1 4/4] ARM: boards: skov-imx6: convert all pr_ to dev_ prints
  2022-11-02 10:07 [PATCH v1 1/4] drivers: net: fec_imx: fix receive issue with external switch Oleksij Rempel
  2022-11-02 10:07 ` [PATCH v1 2/4] net: dsa: fix of_device_ensure_probed*() for switch ports Oleksij Rempel
  2022-11-02 10:07 ` [PATCH v1 3/4] ARM: boards: skov-imx6: assigned separate MAC address to LAN2 Oleksij Rempel
@ 2022-11-02 10:07 ` Oleksij Rempel
  2022-11-02 11:20   ` Sascha Hauer
  2022-11-02 11:08 ` [PATCH v1 1/4] drivers: net: fec_imx: fix receive issue with external switch Sascha Hauer
  3 siblings, 1 reply; 7+ messages in thread
From: Oleksij Rempel @ 2022-11-02 10:07 UTC (permalink / raw)
  To: barebox; +Cc: Oleksij Rempel

Unify all printing messages and make use of dev_ instead of pr_.

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
 arch/arm/boards/skov-imx6/board.c | 62 +++++++++++++++----------------
 1 file changed, 31 insertions(+), 31 deletions(-)

diff --git a/arch/arm/boards/skov-imx6/board.c b/arch/arm/boards/skov-imx6/board.c
index ab8b229a69..d23730221f 100644
--- a/arch/arm/boards/skov-imx6/board.c
+++ b/arch/arm/boards/skov-imx6/board.c
@@ -33,21 +33,21 @@ static int eth_of_fixup_node(struct device_node *root, const char *node_path,
 		unsigned char ethaddr_str[sizeof("xx:xx:xx:xx:xx:xx")];
 
 		ethaddr_to_string(ethaddr, ethaddr_str);
-		pr_err("The mac-address %s is invalid.\n", ethaddr_str);
+		dev_err(skov_priv->dev, "The mac-address %s is invalid.\n", ethaddr_str);
 		return -EINVAL;
 	}
 
 	node = of_find_node_by_path_from(root, node_path);
 	if (!node) {
-		pr_err("Did not find node %s to fix up with stored mac-address.\n",
-		       node_path);
+		dev_err(skov_priv->dev, "Did not find node %s to fix up with stored mac-address.\n",
+		        node_path);
 		return -ENOENT;
 	}
 
 	ret = of_set_property(node, "mac-address", ethaddr, ETH_ALEN, 1);
 	if (ret)
-		pr_err("Setting mac-address property of %s failed with: %s.\n",
-		       node->full_name, strerror(-ret));
+		dev_err(skov_priv->dev, "Setting mac-address property of %s failed with: %s.\n",
+		        node->full_name, strerror(-ret));
 
 	return ret;
 }
@@ -60,7 +60,7 @@ static int eth_of_fixup_node_from_eth_device(struct device_node *root,
 
 	edev = eth_get_byname(ethname);
 	if (!edev) {
-		pr_err("Did not find eth device \"%s\" to copy mac-address from.\n", ethname);
+		dev_err(skov_priv->dev, "Did not find eth device \"%s\" to copy mac-address from.\n", ethname);
 		return -ENOENT;
 	}
 
@@ -74,14 +74,14 @@ static int get_mac_address_from_env_variable(const char *env, u8 ethaddr[ETH_ALE
 
 	ethaddr_str = getenv(env);
 	if (!ethaddr_str) {
-		pr_err("State variable %s storing the mac-address not found.\n", env);
+		dev_err(skov_priv->dev, "State variable %s storing the mac-address not found.\n", env);
 		return -ENOENT;
 	}
 
 	ret = string_to_ethaddr(ethaddr_str, ethaddr);
 	if (ret < 0) {
-		pr_err("Could not convert \"%s\" in state variable %s into mac-address.\n",
-		       ethaddr_str, env);
+		dev_err(skov_priv->dev, "Could not convert \"%s\" in state variable %s into mac-address.\n",
+		        ethaddr_str, env);
 		return -EINVAL;
 	}
 
@@ -96,13 +96,13 @@ static int get_default_mac_address_from_state_node(const char *state_node_path,
 
 	node = of_find_node_by_path(state_node_path);
 	if (!node) {
-		pr_err("Node %s defining the state variable not found.\n", state_node_path);
+		dev_err(skov_priv->dev, "Node %s defining the state variable not found.\n", state_node_path);
 		return -ENOENT;
 	}
 
 	ret = of_property_read_u8_array(node, "default", ethaddr, ETH_ALEN);
 	if (ret) {
-		pr_err("Node %s has no property \"default\" of proper type.\n", state_node_path);
+		dev_err(skov_priv->dev, "Node %s has no property \"default\" of proper type.\n", state_node_path);
 		return -ENOENT;
 	}
 
@@ -346,18 +346,18 @@ static void skov_imx6_no_switch(struct device_node *root)
 	if (node) {
 		ret = of_device_disable(node);
 		if (ret)
-			pr_warn("Can't disable %s\n", fec_alias);
+			dev_warn(skov_priv->dev, "Can't disable %s\n", fec_alias);
 	} else {
-		pr_warn("Can't find node by alias: %s\n", fec_alias);
+		dev_warn(skov_priv->dev, "Can't find node by alias: %s\n", fec_alias);
 	}
 
 	node = of_find_node_by_alias(root, "mdio-gpio0");
 	if (node) {
 		ret = of_device_disable(node);
 		if (ret)
-			pr_warn("Can't disable mdio-gpio0 node\n");
+			dev_warn(skov_priv->dev, "Can't disable mdio-gpio0 node\n");
 	} else {
-		pr_warn("Can't find mdio-gpio0 node\n");
+		dev_warn(skov_priv->dev, "Can't find mdio-gpio0 node\n");
 	}
 }
 
@@ -404,7 +404,7 @@ static void skov_imx6_switch(struct device_node *root)
 	if (ret) {
 		ret = skov_imx6_switch_port(root, old);
 		if (ret)
-			pr_err("Filed to set mac address\n");
+			dev_err(skov_priv->dev, "Filed to set mac address\n");
 	}
 }
 
@@ -429,7 +429,7 @@ static int skov_imx6_fixup(struct device_node *root, void *unused)
 	default:
 		val = getenv("state.display.brightness");
 		if (!val) {
-			pr_err("could not get default display brightness\n");
+			dev_err(skov_priv->dev, "could not get default display brightness\n");
 			return 0;
 		}
 
@@ -440,7 +440,7 @@ static int skov_imx6_fixup(struct device_node *root, void *unused)
 	for_each_compatible_node_from(node, root, NULL, "pwm-backlight") {
 		ret = of_property_write_u32(node, "default-brightness-level", brightness);
 		if (ret)
-			pr_err("error %d while setting default-brightness-level property on node %s to %d\n",
+			dev_err(skov_priv->dev, "error %d while setting default-brightness-level property on node %s to %d\n",
 				ret, node->name, brightness);
 	}
 
@@ -469,9 +469,9 @@ static void skov_init_board(const struct board_description *variant)
 	if (gpio_np) {
 		ret = of_device_ensure_probed(gpio_np);
 		if (ret)
-			pr_warn("Can't probe GPIO node\n");
+			dev_warn(skov_priv->dev, "Can't probe GPIO node\n");
 	} else {
-		pr_warn("Can't get GPIO node\n");
+		dev_warn(skov_priv->dev, "Can't get GPIO node\n");
 	}
 
 	imx6_bbu_internal_spi_i2c_register_handler("spiflash", "/dev/m25p0.barebox",
@@ -490,12 +490,12 @@ static void skov_init_board(const struct board_description *variant)
 		break;
 	}
 
-	pr_notice("Using environment in %s\n", envdev);
+	dev_notice(skov_priv->dev, "Using environment in %s\n", envdev);
 
 	ret = of_device_enable_path(environment_path);
 	if (ret < 0)
-		pr_warn("Failed to enable environment partition '%s' (%d)\n",
-			environment_path, ret);
+		dev_warn(skov_priv->dev, "Failed to enable environment partition '%s' (%d)\n",
+			 environment_path, ret);
 
 	if (variant->flags & SKOV_NEED_ENABLE_RMII) {
 		/*
@@ -529,7 +529,7 @@ static void skov_init_board(const struct board_description *variant)
 		if (np)
 			of_device_enable_and_register(np);
 		else
-			pr_err("Cannot find \"fsl,imx-parallel-display\" node\n");
+			dev_err(skov_priv->dev, "Cannot find \"fsl,imx-parallel-display\" node\n");
 	}
 
 	if (variant->flags & SKOV_DISPLAY_LVDS) {
@@ -537,14 +537,14 @@ static void skov_init_board(const struct board_description *variant)
 		if (np)
 			of_device_enable_and_register(np);
 		else
-			pr_err("Cannot find \"fsl,imx6q-ldb\" node\n");
+			dev_err(skov_priv->dev, "Cannot find \"fsl,imx6q-ldb\" node\n");
 
 		/* ... as well as its channel 0 */
 		np = of_find_node_by_name_address(np, "lvds-channel@0");
 		if (np)
 			of_device_enable(np);
 		else
-			pr_err("Cannot find \"lvds-channel@0\" node\n");
+			dev_err(skov_priv->dev, "Cannot find \"lvds-channel@0\" node\n");
 	}
 }
 
@@ -591,7 +591,7 @@ static int skov_switch_test(void)
 	 */
 	sw_dev = of_find_device_by_node_path("/mdio/switch@0");
 	if (!sw_dev) {
-		pr_err("switch@0 device was not created!\n");
+		dev_err(skov_priv->dev, "switch@0 device was not created!\n");
 		goto no_switch;
 	}
 
@@ -604,15 +604,15 @@ static int skov_switch_test(void)
 no_switch:
 	skov_have_switch = false;
 
-	pr_notice("No-switch variant is detected\n");
+	dev_notice(skov_priv->dev, "No-switch variant is detected\n");
 
 	eth0 = get_device_by_name("eth0");
 	if (eth0) {
 		ret = dev_set_param(eth0, "mode", "disabled");
 		if (ret)
-			pr_warn("Can't set eth0 mode\n");
+			dev_warn(skov_priv->dev, "Can't set eth0 mode\n");
 	} else {
-		pr_warn("Can't disable eth0\n");
+		dev_warn(skov_priv->dev, "Can't disable eth0\n");
 	}
 
 	return 0;
@@ -689,7 +689,7 @@ static void skov_imx6_devices_shutdown(void)
 
 	external = getenv("state.display.external");
 	if (!external) {
-		pr_err("could not get state variable display.external\n");
+		dev_err(skov_priv->dev, "could not get state variable display.external\n");
 		return;
 	}
 
-- 
2.30.2




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v1 1/4] drivers: net: fec_imx: fix receive issue with external switch
  2022-11-02 10:07 [PATCH v1 1/4] drivers: net: fec_imx: fix receive issue with external switch Oleksij Rempel
                   ` (2 preceding siblings ...)
  2022-11-02 10:07 ` [PATCH v1 4/4] ARM: boards: skov-imx6: convert all pr_ to dev_ prints Oleksij Rempel
@ 2022-11-02 11:08 ` Sascha Hauer
  3 siblings, 0 replies; 7+ messages in thread
From: Sascha Hauer @ 2022-11-02 11:08 UTC (permalink / raw)
  To: Oleksij Rempel; +Cc: barebox

On Wed, Nov 02, 2022 at 11:07:41AM +0100, Oleksij Rempel wrote:
> Enable poromisc mode by default to allow using multiple MAC address on
> same FEC interfaces.

s/poromisc/promiscuous/

> 
> We already use poromisc mode on designware stmmac, so it will make
> behavior more consistent on different systems.
> 
> Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
> ---
>  drivers/net/fec_imx.c | 3 +++
>  drivers/net/fec_imx.h | 1 +
>  2 files changed, 4 insertions(+)
> 
> diff --git a/drivers/net/fec_imx.c b/drivers/net/fec_imx.c
> index 673555a48a..9aa4b4f595 100644
> --- a/drivers/net/fec_imx.c
> +++ b/drivers/net/fec_imx.c
> @@ -262,6 +262,9 @@ static int fec_init(struct eth_device *dev)
>  	 */
>  	rcntl = FEC_R_CNTRL_MAX_FL(1518);
>  
> +	/* Set promisc mode to make switches with different ethaddr work */
> +	rcntl |= FEC_R_CNTRL_PROMISC;
> +

Shouldn't we rather enable promiscuous mode in an extra callback?
In the end we want promiscuous mode only in specific cases, not
generally.

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v1 3/4] ARM: boards: skov-imx6: assigned separate MAC address to LAN2
  2022-11-02 10:07 ` [PATCH v1 3/4] ARM: boards: skov-imx6: assigned separate MAC address to LAN2 Oleksij Rempel
@ 2022-11-02 11:18   ` Sascha Hauer
  0 siblings, 0 replies; 7+ messages in thread
From: Sascha Hauer @ 2022-11-02 11:18 UTC (permalink / raw)
  To: Oleksij Rempel; +Cc: barebox

On Wed, Nov 02, 2022 at 11:07:43AM +0100, Oleksij Rempel wrote:
> We have two external ports and different MAC addresses on each port. So,
> assign different MAC to the LAN2. The address on LAN1 is the
> system default address.
> 
> Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
> ---
>  arch/arm/boards/skov-imx6/board.c | 47 ++++++++++++++++++++++++++++++-
>  1 file changed, 46 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm/boards/skov-imx6/board.c b/arch/arm/boards/skov-imx6/board.c
> index 3c51b76735..ab8b229a69 100644
> --- a/arch/arm/boards/skov-imx6/board.c
> +++ b/arch/arm/boards/skov-imx6/board.c
> @@ -17,6 +17,12 @@
>  
>  #include "version.h"
>  
> +struct skov_imx6_priv {
> +	struct device_d *dev;
> +};
> +
> +static struct skov_imx6_priv *skov_priv;
> +
>  static int eth_of_fixup_node(struct device_node *root, const char *node_path,
>  			     const u8 *ethaddr)
>  {
> @@ -542,6 +548,34 @@ static void skov_init_board(const struct board_description *variant)
>  	}
>  }
>  
> +/* */

Did you want to write a comment here?

> +static int skov_set_switch_lan2_mac(struct skov_imx6_priv *priv)
> +{
> +	const char *state = "/state/ethaddr/eth2";
> +	struct device_node *lan2_np;
> +	u8 ethaddr[ETH_ALEN];
> +	int ret;
> +
> +	ret = get_mac_address_from_env_variable("state.ethaddr.eth2", ethaddr);
> +	if (ret || !is_valid_ether_addr(ethaddr)) {
> +		ret = get_default_mac_address_from_state_node(state, ethaddr);
> +		if (ret || !is_valid_ether_addr(ethaddr)) {
> +			dev_err(priv->dev, "can't get MAC for LAN2\n");
> +			return -ENODEV;
> +		}
> +	}
> +
> +	lan2_np = of_find_node_by_path("/mdio/switch@0/ports/ports@1");
> +	if (!lan2_np) {
> +		dev_err(priv->dev, "LAN2 node not found\n");
> +		return -ENODEV;
> +	}
> +
> +	of_eth_register_ethaddr(lan2_np, ethaddr);
> +
> +	return 0;
> +}
> +
>  static int skov_switch_test(void)
>  {
>  	struct device_d *sw_dev;
> @@ -561,8 +595,11 @@ static int skov_switch_test(void)
>  		goto no_switch;
>  	}
>  
> -	if (dev_is_probed(sw_dev))
> +	if (dev_is_probed(sw_dev)) {
> +		skov_set_switch_lan2_mac(skov_priv);
> +		/* even if we fail, continue to boot as good as possible */
>  		return 0;
> +	}

This introduction of skov_priv to have a struct device_d * around for
dev_err is good, but is not subject to this patch. Please either make an
extra patch from it and use dev_err consistently or just stick to the
currently used pr_err.

>  
>  no_switch:
>  	skov_have_switch = false;
> @@ -584,6 +621,7 @@ late_initcall(skov_switch_test);
>  
>  static int skov_imx6_probe(struct device_d *dev)
>  {
> +	struct skov_imx6_priv *priv;
>  	unsigned v = 0;
>  	const struct board_description *variant;
>  
> @@ -603,6 +641,13 @@ static int skov_imx6_probe(struct device_d *dev)
>  
>  	skov_board_no = v;
>  
> +	priv = xzalloc(sizeof(*priv));
> +	if (!priv)
> +		return -ENOMEM;

xzalloc does not return with an error.

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v1 4/4] ARM: boards: skov-imx6: convert all pr_ to dev_ prints
  2022-11-02 10:07 ` [PATCH v1 4/4] ARM: boards: skov-imx6: convert all pr_ to dev_ prints Oleksij Rempel
@ 2022-11-02 11:20   ` Sascha Hauer
  0 siblings, 0 replies; 7+ messages in thread
From: Sascha Hauer @ 2022-11-02 11:20 UTC (permalink / raw)
  To: Oleksij Rempel; +Cc: barebox

On Wed, Nov 02, 2022 at 11:07:44AM +0100, Oleksij Rempel wrote:
> Unify all printing messages and make use of dev_ instead of pr_.
> 
> Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
> ---
>  arch/arm/boards/skov-imx6/board.c | 62 +++++++++++++++----------------
>  1 file changed, 31 insertions(+), 31 deletions(-)
> 
> diff --git a/arch/arm/boards/skov-imx6/board.c b/arch/arm/boards/skov-imx6/board.c
> index ab8b229a69..d23730221f 100644
> --- a/arch/arm/boards/skov-imx6/board.c
> +++ b/arch/arm/boards/skov-imx6/board.c
> @@ -33,21 +33,21 @@ static int eth_of_fixup_node(struct device_node *root, const char *node_path,
>  		unsigned char ethaddr_str[sizeof("xx:xx:xx:xx:xx:xx")];
>  
>  		ethaddr_to_string(ethaddr, ethaddr_str);
> -		pr_err("The mac-address %s is invalid.\n", ethaddr_str);
> +		dev_err(skov_priv->dev, "The mac-address %s is invalid.\n", ethaddr_str);

Ah, ok, here is that change. This patch should rather be before 3/4.

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-11-02 11:21 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-02 10:07 [PATCH v1 1/4] drivers: net: fec_imx: fix receive issue with external switch Oleksij Rempel
2022-11-02 10:07 ` [PATCH v1 2/4] net: dsa: fix of_device_ensure_probed*() for switch ports Oleksij Rempel
2022-11-02 10:07 ` [PATCH v1 3/4] ARM: boards: skov-imx6: assigned separate MAC address to LAN2 Oleksij Rempel
2022-11-02 11:18   ` Sascha Hauer
2022-11-02 10:07 ` [PATCH v1 4/4] ARM: boards: skov-imx6: convert all pr_ to dev_ prints Oleksij Rempel
2022-11-02 11:20   ` Sascha Hauer
2022-11-02 11:08 ` [PATCH v1 1/4] drivers: net: fec_imx: fix receive issue with external switch Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox