Skip to content

Commit

Permalink
net: fman: Move struct dev to mac_device
Browse files Browse the repository at this point in the history
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@seco.com>
Acked-by: Camelia Groza <camelia.groza@nxp.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Sean Anderson authored and Jakub Kicinski committed Aug 19, 2022
1 parent 28c3948 commit 7bd6396
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 20 deletions.
31 changes: 11 additions & 20 deletions drivers/net/ethernet/freescale/fman/mac.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}

Expand All @@ -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;
Expand Down Expand Up @@ -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);
}

Expand All @@ -261,19 +256,17 @@ 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);
}

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;
Expand Down Expand Up @@ -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;

Expand All @@ -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;
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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);

Expand Down
1 change: 1 addition & 0 deletions drivers/net/ethernet/freescale/fman/mac.h
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down

0 comments on commit 7bd6396

Please sign in to comment.