Skip to content

Commit

Permalink
net: fman: Pass params directly to mac init
Browse files Browse the repository at this point in the history
Instead of having the mac init functions call back into the fman core to
get their params, just pass them directly to the init functions.

Signed-off-by: Sean Anderson <sean.anderson@seco.com>
Acked-by: Camelia Groza <camelia.groza@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Sean Anderson authored and David S. Miller committed Sep 5, 2022
1 parent 262f2b7 commit c6b7b1b
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 49 deletions.
10 changes: 3 additions & 7 deletions drivers/net/ethernet/freescale/fman/fman_dtsec.c
Original file line number Diff line number Diff line change
Expand Up @@ -1474,10 +1474,10 @@ static struct fman_mac *dtsec_config(struct fman_mac_params *params)
}

int dtsec_initialization(struct mac_device *mac_dev,
struct device_node *mac_node)
struct device_node *mac_node,
struct fman_mac_params *params)
{
int err;
struct fman_mac_params params;
struct fman_mac *dtsec;
struct device_node *phy_node;

Expand All @@ -1495,11 +1495,7 @@ int dtsec_initialization(struct mac_device *mac_dev,
mac_dev->enable = dtsec_enable;
mac_dev->disable = dtsec_disable;

err = set_fman_mac_params(mac_dev, &params);
if (err)
goto _return;

mac_dev->fman_mac = dtsec_config(&params);
mac_dev->fman_mac = dtsec_config(params);
if (!mac_dev->fman_mac) {
err = -EINVAL;
goto _return;
Expand Down
3 changes: 2 additions & 1 deletion drivers/net/ethernet/freescale/fman/fman_dtsec.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
struct mac_device;

int dtsec_initialization(struct mac_device *mac_dev,
struct device_node *mac_node);
struct device_node *mac_node,
struct fman_mac_params *params);

#endif /* __DTSEC_H */
14 changes: 5 additions & 9 deletions drivers/net/ethernet/freescale/fman/fman_memac.c
Original file line number Diff line number Diff line change
Expand Up @@ -1154,11 +1154,11 @@ static struct fman_mac *memac_config(struct fman_mac_params *params)
}

int memac_initialization(struct mac_device *mac_dev,
struct device_node *mac_node)
struct device_node *mac_node,
struct fman_mac_params *params)
{
int err;
struct device_node *phy_node;
struct fman_mac_params params;
struct fixed_phy_status *fixed_link;
struct fman_mac *memac;

Expand All @@ -1176,14 +1176,10 @@ int memac_initialization(struct mac_device *mac_dev,
mac_dev->enable = memac_enable;
mac_dev->disable = memac_disable;

err = set_fman_mac_params(mac_dev, &params);
if (err)
goto _return;

if (params.max_speed == SPEED_10000)
params.phy_if = PHY_INTERFACE_MODE_XGMII;
if (params->max_speed == SPEED_10000)
params->phy_if = PHY_INTERFACE_MODE_XGMII;

mac_dev->fman_mac = memac_config(&params);
mac_dev->fman_mac = memac_config(params);
if (!mac_dev->fman_mac) {
err = -EINVAL;
goto _return;
Expand Down
3 changes: 2 additions & 1 deletion drivers/net/ethernet/freescale/fman/fman_memac.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
struct mac_device;

int memac_initialization(struct mac_device *mac_dev,
struct device_node *mac_node);
struct device_node *mac_node,
struct fman_mac_params *params);

#endif /* __MEMAC_H */
10 changes: 3 additions & 7 deletions drivers/net/ethernet/freescale/fman/fman_tgec.c
Original file line number Diff line number Diff line change
Expand Up @@ -783,10 +783,10 @@ static struct fman_mac *tgec_config(struct fman_mac_params *params)
}

int tgec_initialization(struct mac_device *mac_dev,
struct device_node *mac_node)
struct device_node *mac_node,
struct fman_mac_params *params)
{
int err;
struct fman_mac_params params;
struct fman_mac *tgec;

mac_dev->set_promisc = tgec_set_promiscuous;
Expand All @@ -803,11 +803,7 @@ int tgec_initialization(struct mac_device *mac_dev,
mac_dev->enable = tgec_enable;
mac_dev->disable = tgec_disable;

err = set_fman_mac_params(mac_dev, &params);
if (err)
goto _return;

mac_dev->fman_mac = tgec_config(&params);
mac_dev->fman_mac = tgec_config(params);
if (!mac_dev->fman_mac) {
err = -EINVAL;
goto _return;
Expand Down
3 changes: 2 additions & 1 deletion drivers/net/ethernet/freescale/fman/fman_tgec.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
struct mac_device;

int tgec_initialization(struct mac_device *mac_dev,
struct device_node *mac_node);
struct device_node *mac_node,
struct fman_mac_params *params);

#endif /* __TGEC_H */
36 changes: 15 additions & 21 deletions drivers/net/ethernet/freescale/fman/mac.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,25 +57,6 @@ static void mac_exception(void *handle, enum fman_mac_exceptions ex)
__func__, ex);
}

int set_fman_mac_params(struct mac_device *mac_dev,
struct fman_mac_params *params)
{
struct mac_priv_s *priv = mac_dev->priv;

params->base_addr = mac_dev->vaddr;
memcpy(&params->addr, mac_dev->addr, sizeof(mac_dev->addr));
params->max_speed = priv->max_speed;
params->phy_if = mac_dev->phy_if;
params->basex_if = false;
params->mac_id = priv->cell_index;
params->fm = (void *)priv->fman;
params->exception_cb = mac_exception;
params->event_cb = mac_exception;
params->dev_id = mac_dev;

return 0;
}

int fman_set_multi(struct net_device *net_dev, struct mac_device *mac_dev)
{
struct mac_priv_s *priv;
Expand Down Expand Up @@ -294,13 +275,15 @@ MODULE_DEVICE_TABLE(of, mac_match);
static int mac_probe(struct platform_device *_of_dev)
{
int err, i, nph;
int (*init)(struct mac_device *mac_dev, struct device_node *mac_node);
int (*init)(struct mac_device *mac_dev, struct device_node *mac_node,
struct fman_mac_params *params);
struct device *dev;
struct device_node *mac_node, *dev_node;
struct mac_device *mac_dev;
struct platform_device *of_dev;
struct resource *res;
struct mac_priv_s *priv;
struct fman_mac_params params;
u32 val;
u8 fman_id;
phy_interface_t phy_if;
Expand Down Expand Up @@ -474,7 +457,18 @@ static int mac_probe(struct platform_device *_of_dev)
/* Get the rest of the PHY information */
mac_dev->phy_node = of_parse_phandle(mac_node, "phy-handle", 0);

err = init(mac_dev, mac_node);
params.base_addr = mac_dev->vaddr;
memcpy(&params.addr, mac_dev->addr, sizeof(mac_dev->addr));
params.max_speed = priv->max_speed;
params.phy_if = mac_dev->phy_if;
params.basex_if = false;
params.mac_id = priv->cell_index;
params.fm = (void *)priv->fman;
params.exception_cb = mac_exception;
params.event_cb = mac_exception;
params.dev_id = mac_dev;

err = init(mac_dev, mac_node, &params);
if (err < 0) {
dev_err(dev, "mac_dev->init() = %d\n", err);
of_node_put(mac_dev->phy_node);
Expand Down
2 changes: 0 additions & 2 deletions drivers/net/ethernet/freescale/fman/mac.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@ int fman_set_mac_active_pause(struct mac_device *mac_dev, bool rx, bool tx);

void fman_get_pause_cfg(struct mac_device *mac_dev, bool *rx_pause,
bool *tx_pause);
int set_fman_mac_params(struct mac_device *mac_dev,
struct fman_mac_params *params);
int fman_set_multi(struct net_device *net_dev, struct mac_device *mac_dev);

#endif /* __MAC_H */

0 comments on commit c6b7b1b

Please sign in to comment.