Skip to content

Commit

Permalink
net: fman: Remove internal_phy_node from params
Browse files Browse the repository at this point in the history
This member was used to pass the phy node between mac_probe and the
mac-specific initialization function. But now that the phy node is
gotten in the initialization function, this parameter does not serve a
purpose. Remove it, and do the grabbing of the node/grabbing of the phy
in the same place.

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 4498862 commit 45fa34b
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 35 deletions.
33 changes: 17 additions & 16 deletions drivers/net/ethernet/freescale/fman/fman_dtsec.c
Original file line number Diff line number Diff line change
Expand Up @@ -1463,26 +1463,11 @@ static struct fman_mac *dtsec_config(struct fman_mac_params *params)
dtsec->fm = params->fm;
dtsec->basex_if = params->basex_if;

if (!params->internal_phy_node) {
pr_err("TBI PHY node is not available\n");
goto err_dtsec_drv_param;
}

dtsec->tbiphy = of_phy_find_device(params->internal_phy_node);
if (!dtsec->tbiphy) {
pr_err("of_phy_find_device (TBI PHY) failed\n");
goto err_dtsec_drv_param;
}

put_device(&dtsec->tbiphy->mdio.dev);

/* Save FMan revision */
fman_get_revision(dtsec->fm, &dtsec->fm_rev_info);

return dtsec;

err_dtsec_drv_param:
kfree(dtsec_drv_param);
err_dtsec:
kfree(dtsec);
return NULL;
Expand All @@ -1494,6 +1479,7 @@ int dtsec_initialization(struct mac_device *mac_dev,
int err;
struct fman_mac_params params;
struct fman_mac *dtsec;
struct device_node *phy_node;

mac_dev->set_promisc = dtsec_set_promiscuous;
mac_dev->change_addr = dtsec_modify_mac_address;
Expand All @@ -1512,7 +1498,6 @@ int dtsec_initialization(struct mac_device *mac_dev,
err = set_fman_mac_params(mac_dev, &params);
if (err)
goto _return;
params.internal_phy_node = of_parse_phandle(mac_node, "tbi-handle", 0);

mac_dev->fman_mac = dtsec_config(&params);
if (!mac_dev->fman_mac) {
Expand All @@ -1523,6 +1508,22 @@ int dtsec_initialization(struct mac_device *mac_dev,
dtsec = mac_dev->fman_mac;
dtsec->dtsec_drv_param->maximum_frame = fman_get_max_frm();
dtsec->dtsec_drv_param->tx_pad_crc = true;

phy_node = of_parse_phandle(mac_node, "tbi-handle", 0);
if (!phy_node) {
pr_err("TBI PHY node is not available\n");
err = -EINVAL;
goto _return_fm_mac_free;
}

dtsec->tbiphy = of_phy_find_device(phy_node);
if (!dtsec->tbiphy) {
pr_err("of_phy_find_device (TBI PHY) failed\n");
err = -EINVAL;
goto _return_fm_mac_free;
}
put_device(&dtsec->tbiphy->mdio.dev);

err = dtsec_init(dtsec);
if (err < 0)
goto _return_fm_mac_free;
Expand Down
2 changes: 0 additions & 2 deletions drivers/net/ethernet/freescale/fman/fman_mac.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,6 @@ struct fman_mac_params {
* synchronize with far-end phy at 10Mbps, 100Mbps or 1000Mbps
*/
bool basex_if;
/* Pointer to TBI/PCS PHY node, used for TBI/PCS PHY access */
struct device_node *internal_phy_node;
};

struct eth_hash_t {
Expand Down
34 changes: 17 additions & 17 deletions drivers/net/ethernet/freescale/fman/fman_memac.c
Original file line number Diff line number Diff line change
Expand Up @@ -1150,29 +1150,14 @@ static struct fman_mac *memac_config(struct fman_mac_params *params)
/* Save FMan revision */
fman_get_revision(memac->fm, &memac->fm_rev_info);

if (memac->phy_if == PHY_INTERFACE_MODE_SGMII ||
memac->phy_if == PHY_INTERFACE_MODE_QSGMII) {
if (!params->internal_phy_node) {
pr_err("PCS PHY node is not available\n");
memac_free(memac);
return NULL;
}

memac->pcsphy = of_phy_find_device(params->internal_phy_node);
if (!memac->pcsphy) {
pr_err("of_phy_find_device (PCS PHY) failed\n");
memac_free(memac);
return NULL;
}
}

return memac;
}

int memac_initialization(struct mac_device *mac_dev,
struct device_node *mac_node)
{
int err;
struct device_node *phy_node;
struct fman_mac_params params;
struct fixed_phy_status *fixed_link;
struct fman_mac *memac;
Expand All @@ -1194,7 +1179,6 @@ int memac_initialization(struct mac_device *mac_dev,
err = set_fman_mac_params(mac_dev, &params);
if (err)
goto _return;
params.internal_phy_node = of_parse_phandle(mac_node, "pcsphy-handle", 0);

if (params.max_speed == SPEED_10000)
params.phy_if = PHY_INTERFACE_MODE_XGMII;
Expand All @@ -1208,6 +1192,22 @@ int memac_initialization(struct mac_device *mac_dev,
memac = mac_dev->fman_mac;
memac->memac_drv_param->max_frame_length = fman_get_max_frm();
memac->memac_drv_param->reset_on_init = true;
if (memac->phy_if == PHY_INTERFACE_MODE_SGMII ||
memac->phy_if == PHY_INTERFACE_MODE_QSGMII) {
phy_node = of_parse_phandle(mac_node, "pcsphy-handle", 0);
if (!phy_node) {
pr_err("PCS PHY node is not available\n");
err = -EINVAL;
goto _return_fm_mac_free;
}

memac->pcsphy = of_phy_find_device(phy_node);
if (!memac->pcsphy) {
pr_err("of_phy_find_device (PCS PHY) failed\n");
err = -EINVAL;
goto _return_fm_mac_free;
}
}

if (!mac_dev->phy_node && of_phy_is_fixed_link(mac_node)) {
struct phy_device *phy;
Expand Down

0 comments on commit 45fa34b

Please sign in to comment.