From: Luiz Angelo Daros de Luca <luizluca@gmail.com>
To: netdev@vger.kernel.org
Cc: linus.walleij@linaro.org, alsi@bang-olufsen.dk, andrew@lunn.ch,
f.fainelli@gmail.com, olteanv@gmail.com, davem@davemloft.net,
edumazet@google.com, kuba@kernel.org, pabeni@redhat.com,
arinc.unal@arinc9.com, ansuelsmth@gmail.com,
Luiz Angelo Daros de Luca <luizluca@gmail.com>
Subject: [PATCH net-next v4 04/11] net: dsa: realtek: keep variant reference in realtek_priv
Date: Tue, 23 Jan 2024 18:55:56 -0300 [thread overview]
Message-ID: <20240123215606.26716-5-luizluca@gmail.com> (raw)
In-Reply-To: <20240123215606.26716-1-luizluca@gmail.com>
Instead of copying values from the variant, we can keep a reference in
realtek_priv.
This is a preliminary change for sharing code betwen interfaces. It will
allow to move most of the probe into a common module while still allow
code specific to each interface to read variant fields.
Signed-off-by: Luiz Angelo Daros de Luca <luizluca@gmail.com>
---
drivers/net/dsa/realtek/realtek-mdio.c | 4 +---
drivers/net/dsa/realtek/realtek-smi.c | 10 ++++------
drivers/net/dsa/realtek/realtek.h | 5 ++---
3 files changed, 7 insertions(+), 12 deletions(-)
diff --git a/drivers/net/dsa/realtek/realtek-mdio.c b/drivers/net/dsa/realtek/realtek-mdio.c
index 22a63f41e3f2..57bd5d8814c2 100644
--- a/drivers/net/dsa/realtek/realtek-mdio.c
+++ b/drivers/net/dsa/realtek/realtek-mdio.c
@@ -197,9 +197,7 @@ int realtek_mdio_probe(struct mdio_device *mdiodev)
priv->dev = &mdiodev->dev;
priv->chip_data = (void *)priv + sizeof(*priv);
- priv->clk_delay = var->clk_delay;
- priv->cmd_read = var->cmd_read;
- priv->cmd_write = var->cmd_write;
+ priv->variant = var;
priv->ops = var->ops;
priv->write_reg_noack = realtek_mdio_write;
diff --git a/drivers/net/dsa/realtek/realtek-smi.c b/drivers/net/dsa/realtek/realtek-smi.c
index 618547befa13..274dd96b099c 100644
--- a/drivers/net/dsa/realtek/realtek-smi.c
+++ b/drivers/net/dsa/realtek/realtek-smi.c
@@ -46,7 +46,7 @@
static inline void realtek_smi_clk_delay(struct realtek_priv *priv)
{
- ndelay(priv->clk_delay);
+ ndelay(priv->variant->clk_delay);
}
static void realtek_smi_start(struct realtek_priv *priv)
@@ -209,7 +209,7 @@ static int realtek_smi_read_reg(struct realtek_priv *priv, u32 addr, u32 *data)
realtek_smi_start(priv);
/* Send READ command */
- ret = realtek_smi_write_byte(priv, priv->cmd_read);
+ ret = realtek_smi_write_byte(priv, priv->variant->cmd_read);
if (ret)
goto out;
@@ -250,7 +250,7 @@ static int realtek_smi_write_reg(struct realtek_priv *priv,
realtek_smi_start(priv);
/* Send WRITE command */
- ret = realtek_smi_write_byte(priv, priv->cmd_write);
+ ret = realtek_smi_write_byte(priv, priv->variant->cmd_write);
if (ret)
goto out;
@@ -460,9 +460,7 @@ int realtek_smi_probe(struct platform_device *pdev)
/* Link forward and backward */
priv->dev = dev;
- priv->clk_delay = var->clk_delay;
- priv->cmd_read = var->cmd_read;
- priv->cmd_write = var->cmd_write;
+ priv->variant = var;
priv->ops = var->ops;
priv->setup_interface = realtek_smi_setup_mdio;
diff --git a/drivers/net/dsa/realtek/realtek.h b/drivers/net/dsa/realtek/realtek.h
index e9ee778665b2..0c51b5132c61 100644
--- a/drivers/net/dsa/realtek/realtek.h
+++ b/drivers/net/dsa/realtek/realtek.h
@@ -58,9 +58,6 @@ struct realtek_priv {
struct mii_bus *bus;
int mdio_addr;
- unsigned int clk_delay;
- u8 cmd_read;
- u8 cmd_write;
spinlock_t lock; /* Locks around command writes */
struct dsa_switch *ds;
struct irq_domain *irqdomain;
@@ -79,6 +76,8 @@ struct realtek_priv {
int vlan_enabled;
int vlan4k_enabled;
+ const struct realtek_variant *variant;
+
char buf[4096];
void *chip_data; /* Per-chip extra variant data */
};
--
2.43.0
next prev parent reply other threads:[~2024-01-23 21:57 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-23 21:55 [PATCH net-next v4 00/11] net: dsa: realtek: variants to drivers, interfaces to a common module Luiz Angelo Daros de Luca
2024-01-23 21:55 ` [PATCH net-next v4 01/11] net: dsa: realtek: drop cleanup from realtek_ops Luiz Angelo Daros de Luca
2024-01-23 21:55 ` [PATCH net-next v4 02/11] net: dsa: realtek: introduce REALTEK_DSA namespace Luiz Angelo Daros de Luca
2024-01-25 10:02 ` Vladimir Oltean
2024-01-29 16:09 ` Florian Fainelli
2024-01-23 21:55 ` [PATCH net-next v4 03/11] net: dsa: realtek: convert variants into real drivers Luiz Angelo Daros de Luca
2024-01-24 19:19 ` Jakub Kicinski
2024-01-25 10:25 ` Vladimir Oltean
2024-01-28 23:34 ` Luiz Angelo Daros de Luca
2024-01-29 16:21 ` Vladimir Oltean
2024-01-23 21:55 ` Luiz Angelo Daros de Luca [this message]
2024-01-25 10:26 ` [PATCH net-next v4 04/11] net: dsa: realtek: keep variant reference in realtek_priv Vladimir Oltean
2024-01-29 16:10 ` Florian Fainelli
2024-01-29 17:36 ` Luiz Angelo Daros de Luca
2024-01-23 21:55 ` [PATCH net-next v4 05/11] net: dsa: realtek: common rtl83xx module Luiz Angelo Daros de Luca
2024-01-25 10:45 ` Vladimir Oltean
2024-01-29 0:09 ` Luiz Angelo Daros de Luca
2024-01-29 16:18 ` Vladimir Oltean
2024-01-26 23:19 ` kernel test robot
2024-01-23 21:55 ` [PATCH net-next v4 06/11] net: dsa: realtek: merge rtl83xx and interface modules into realtek-dsa Luiz Angelo Daros de Luca
2024-01-25 11:00 ` Vladimir Oltean
2024-01-29 16:13 ` Florian Fainelli
2024-01-23 21:55 ` [PATCH net-next v4 07/11] net: dsa: realtek: get internal MDIO node by name Luiz Angelo Daros de Luca
2024-01-29 16:11 ` Florian Fainelli
2024-01-23 21:56 ` [PATCH net-next v4 08/11] net: dsa: realtek: clean user_mii_bus setup Luiz Angelo Daros de Luca
2024-01-25 11:17 ` Vladimir Oltean
2024-01-29 2:12 ` Luiz Angelo Daros de Luca
2024-01-29 16:15 ` Vladimir Oltean
2024-01-29 16:22 ` Florian Fainelli
2024-01-29 16:43 ` Vladimir Oltean
2024-01-29 16:54 ` Florian Fainelli
2024-01-30 14:40 ` Arınç ÜNAL
2024-01-30 15:02 ` Andrew Lunn
2024-01-30 18:17 ` Luiz Angelo Daros de Luca
2024-01-23 21:56 ` [PATCH net-next v4 09/11] net: dsa: realtek: migrate user_mii_bus setup to realtek-dsa Luiz Angelo Daros de Luca
2024-01-25 16:05 ` Vladimir Oltean
2024-01-29 2:49 ` Luiz Angelo Daros de Luca
2024-01-29 15:19 ` Vladimir Oltean
2024-01-23 21:56 ` [PATCH net-next v4 10/11] net: dsa: realtek: use the same mii bus driver for both interfaces Luiz Angelo Daros de Luca
2024-01-23 21:56 ` [PATCH net-next v4 11/11] net: dsa: realtek: embed dsa_switch into realtek_priv Luiz Angelo Daros de Luca
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=20240123215606.26716-5-luizluca@gmail.com \
--to=luizluca@gmail.com \
--cc=alsi@bang-olufsen.dk \
--cc=andrew@lunn.ch \
--cc=ansuelsmth@gmail.com \
--cc=arinc.unal@arinc9.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=f.fainelli@gmail.com \
--cc=kuba@kernel.org \
--cc=linus.walleij@linaro.org \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=pabeni@redhat.com \
/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;
as well as URLs for NNTP newsgroup(s).