From: Oleksij Rempel <o.rempel@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Oleksij Rempel <o.rempel@pengutronix.de>
Subject: [PATCH v1 2/4] net: dsa: fix of_device_ensure_probed*() for switch ports
Date: Wed, 2 Nov 2022 11:07:42 +0100 [thread overview]
Message-ID: <20221102100744.1949741-2-o.rempel@pengutronix.de> (raw)
In-Reply-To: <20221102100744.1949741-1-o.rempel@pengutronix.de>
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
next prev parent reply other threads:[~2022-11-02 10:09 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
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=20221102100744.1949741-2-o.rempel@pengutronix.de \
--to=o.rempel@pengutronix.de \
--cc=barebox@lists.infradead.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