[PATCH v4 08/25] net: fman: Move struct dev to mac_device

From: Sean Anderson
Date: Mon Jul 25 2022 - 11:11:55 EST


Move the reference to our device to mac_device. This way, macs can use
it in their log messages.

Signed-off-by: Sean Anderson <sean.anderson@xxxxxxxx>
Acked-by: Camelia Groza <camelia.groza@xxxxxxx>
---

(no changes since v2)

Changes in v2:
- Remove some unused variables

drivers/net/ethernet/freescale/fman/mac.c | 31 ++++++++---------------
drivers/net/ethernet/freescale/fman/mac.h | 1 +
2 files changed, 12 insertions(+), 20 deletions(-)

diff --git a/drivers/net/ethernet/freescale/fman/mac.c b/drivers/net/ethernet/freescale/fman/mac.c
index 8dd6a5b12922..5b3a6ea2d0e2 100644
--- a/drivers/net/ethernet/freescale/fman/mac.c
+++ b/drivers/net/ethernet/freescale/fman/mac.c
@@ -28,7 +28,6 @@ MODULE_LICENSE("Dual BSD/GPL");
MODULE_DESCRIPTION("FSL FMan MAC API based driver");

struct mac_priv_s {
- struct device *dev;
void __iomem *vaddr;
u8 cell_index;
struct fman *fman;
@@ -47,20 +46,16 @@ struct mac_address {

static void mac_exception(void *handle, enum fman_mac_exceptions ex)
{
- struct mac_device *mac_dev;
- struct mac_priv_s *priv;
-
- mac_dev = handle;
- priv = mac_dev->priv;
+ struct mac_device *mac_dev = handle;

if (ex == FM_MAC_EX_10G_RX_FIFO_OVFL) {
/* don't flag RX FIFO after the first */
mac_dev->set_exception(mac_dev->fman_mac,
FM_MAC_EX_10G_RX_FIFO_OVFL, false);
- dev_err(priv->dev, "10G MAC got RX FIFO Error = %x\n", ex);
+ dev_err(mac_dev->dev, "10G MAC got RX FIFO Error = %x\n", ex);
}

- dev_dbg(priv->dev, "%s:%s() -> %d\n", KBUILD_BASENAME ".c",
+ dev_dbg(mac_dev->dev, "%s:%s() -> %d\n", KBUILD_BASENAME ".c",
__func__, ex);
}

@@ -70,7 +65,7 @@ static int set_fman_mac_params(struct mac_device *mac_dev,
struct mac_priv_s *priv = mac_dev->priv;

params->base_addr = (typeof(params->base_addr))
- devm_ioremap(priv->dev, mac_dev->res->start,
+ devm_ioremap(mac_dev->dev, mac_dev->res->start,
resource_size(mac_dev->res));
if (!params->base_addr)
return -ENOMEM;
@@ -244,7 +239,7 @@ static void adjust_link_dtsec(struct mac_device *mac_dev)
fman_get_pause_cfg(mac_dev, &rx_pause, &tx_pause);
err = fman_set_mac_active_pause(mac_dev, rx_pause, tx_pause);
if (err < 0)
- dev_err(mac_dev->priv->dev, "fman_set_mac_active_pause() = %d\n",
+ dev_err(mac_dev->dev, "fman_set_mac_active_pause() = %d\n",
err);
}

@@ -261,7 +256,7 @@ static void adjust_link_memac(struct mac_device *mac_dev)
fman_get_pause_cfg(mac_dev, &rx_pause, &tx_pause);
err = fman_set_mac_active_pause(mac_dev, rx_pause, tx_pause);
if (err < 0)
- dev_err(mac_dev->priv->dev, "fman_set_mac_active_pause() = %d\n",
+ dev_err(mac_dev->dev, "fman_set_mac_active_pause() = %d\n",
err);
}

@@ -269,11 +264,9 @@ static int tgec_initialization(struct mac_device *mac_dev,
struct device_node *mac_node)
{
int err;
- struct mac_priv_s *priv;
struct fman_mac_params params;
u32 version;

- priv = mac_dev->priv;
mac_dev->set_promisc = tgec_set_promiscuous;
mac_dev->change_addr = tgec_modify_mac_address;
mac_dev->add_hash_mac_addr = tgec_add_hash_mac_address;
@@ -316,7 +309,7 @@ static int tgec_initialization(struct mac_device *mac_dev,
if (err < 0)
goto _return_fm_mac_free;

- dev_info(priv->dev, "FMan XGEC version: 0x%08x\n", version);
+ dev_info(mac_dev->dev, "FMan XGEC version: 0x%08x\n", version);

goto _return;

@@ -331,11 +324,9 @@ static int dtsec_initialization(struct mac_device *mac_dev,
struct device_node *mac_node)
{
int err;
- struct mac_priv_s *priv;
struct fman_mac_params params;
u32 version;

- priv = mac_dev->priv;
mac_dev->set_promisc = dtsec_set_promiscuous;
mac_dev->change_addr = dtsec_modify_mac_address;
mac_dev->add_hash_mac_addr = dtsec_add_hash_mac_address;
@@ -383,7 +374,7 @@ static int dtsec_initialization(struct mac_device *mac_dev,
if (err < 0)
goto _return_fm_mac_free;

- dev_info(priv->dev, "FMan dTSEC version: 0x%08x\n", version);
+ dev_info(mac_dev->dev, "FMan dTSEC version: 0x%08x\n", version);

goto _return;

@@ -446,7 +437,7 @@ static int memac_initialization(struct mac_device *mac_dev,
if (err < 0)
goto _return_fm_mac_free;

- dev_info(priv->dev, "FMan MEMAC\n");
+ dev_info(mac_dev->dev, "FMan MEMAC\n");

goto _return;

@@ -507,7 +498,7 @@ static struct platform_device *dpaa_eth_add_device(int fman_id,
goto no_mem;
}

- pdev->dev.parent = priv->dev;
+ pdev->dev.parent = mac_dev->dev;

ret = platform_device_add_data(pdev, &data, sizeof(data));
if (ret)
@@ -569,7 +560,7 @@ static int mac_probe(struct platform_device *_of_dev)

/* Save private information */
mac_dev->priv = priv;
- priv->dev = dev;
+ mac_dev->dev = dev;

INIT_LIST_HEAD(&priv->mc_addr_list);

diff --git a/drivers/net/ethernet/freescale/fman/mac.h b/drivers/net/ethernet/freescale/fman/mac.h
index fed3835a8473..05dbb8b5a704 100644
--- a/drivers/net/ethernet/freescale/fman/mac.h
+++ b/drivers/net/ethernet/freescale/fman/mac.h
@@ -19,6 +19,7 @@ struct fman_mac;
struct mac_priv_s;

struct mac_device {
+ struct device *dev;
struct resource *res;
u8 addr[ETH_ALEN];
struct fman_port *port[2];
--
2.35.1.1320.gc452695387.dirty