Skip to content

Commit 42c9486

Browse files
committed
drivers: ethernet: phy_mii: Return -ENOTSUP for fixed-link config
Return -ENOTSUP in phy_mii_cfg_link when a fixed-link configuration is set, indicating that MDIO read/write operations are not supported. Signed-off-by: Ofir Shemesh <ofirshemesh777@gmail.com>
1 parent ef95483 commit 42c9486

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

drivers/ethernet/phy/phy_mii.c

+22-2
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,14 @@ static inline int phy_mii_reg_read(const struct device *dev, uint16_t reg_addr,
5050
const struct phy_mii_dev_config *const cfg = dev->config;
5151

5252
/* if there is no mdio (fixed-link) it is not supported to read */
53-
if (cfg->mdio == NULL) {
53+
if (cfg->fixed) {
5454
return -ENOTSUP;
5555
}
56+
57+
if (cfg->mdio == NULL) {
58+
return -ENODEV;
59+
}
60+
5661
return mdio_read(cfg->mdio, cfg->phy_addr, reg_addr, value);
5762
}
5863

@@ -62,9 +67,14 @@ static inline int phy_mii_reg_write(const struct device *dev, uint16_t reg_addr,
6267
const struct phy_mii_dev_config *const cfg = dev->config;
6368

6469
/* if there is no mdio (fixed-link) it is not supported to write */
65-
if (cfg->mdio == NULL) {
70+
if (cfg->fixed) {
6671
return -ENOTSUP;
6772
}
73+
74+
if (cfg->mdio == NULL) {
75+
return -ENODEV;
76+
}
77+
6878
return mdio_write(cfg->mdio, cfg->phy_addr, reg_addr, value);
6979
}
7080

@@ -315,10 +325,20 @@ static int phy_mii_cfg_link(const struct device *dev,
315325
enum phy_link_speed adv_speeds)
316326
{
317327
struct phy_mii_dev_data *const data = dev->data;
328+
const struct phy_mii_dev_config *const cfg = dev->config;
318329
uint16_t anar_reg;
319330
uint16_t bmcr_reg;
320331
uint16_t c1kt_reg;
321332

333+
/* if there is no mdio (fixed-link) it is not supported to configure link */
334+
if (cfg->fixed) {
335+
return -ENOTSUP;
336+
}
337+
338+
if (cfg->mdio == NULL) {
339+
return -ENODEV;
340+
}
341+
322342
if (phy_mii_reg_read(dev, MII_ANAR, &anar_reg) < 0) {
323343
return -EIO;
324344
}

0 commit comments

Comments
 (0)