Skip to content

Commit 5cf11be

Browse files
lunndavem330
authored andcommitted
phy_device: Move phy attributes into phy_device
The mdio_bus exports three attributes: - PHY ID is the unique 32-bits identifier for a MDIO device implementing standard MII registers MII_PHYSID1/2, which is not guaranteed to be the case for non-standard compliant devices (e.g: Ethernet switches) - PHY interface describes the data-path of the PHY/MDIO device, which is not strictly a PHY thing, but is required and needed for PHY devices to function, a MDIO device could be a control device exclusively - PHY has fixups describes what the PHY driver may have done, so completely PHY specific These are all phy attributes, not generic mdio attributes. So move the attributes into the phy device code. Signed-off-by: Andrew Lunn <[email protected]> Reviewed-by: Florian Fainelli <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 7f85442 commit 5cf11be

File tree

2 files changed

+44
-42
lines changed

2 files changed

+44
-42
lines changed

drivers/net/phy/mdio_bus.c

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -670,52 +670,10 @@ static const struct dev_pm_ops mdio_bus_pm_ops = {
670670

671671
#endif /* CONFIG_PM */
672672

673-
static ssize_t
674-
phy_id_show(struct device *dev, struct device_attribute *attr, char *buf)
675-
{
676-
struct phy_device *phydev = to_phy_device(dev);
677-
678-
return sprintf(buf, "0x%.8lx\n", (unsigned long)phydev->phy_id);
679-
}
680-
static DEVICE_ATTR_RO(phy_id);
681-
682-
static ssize_t
683-
phy_interface_show(struct device *dev, struct device_attribute *attr, char *buf)
684-
{
685-
struct phy_device *phydev = to_phy_device(dev);
686-
const char *mode = NULL;
687-
688-
if (phy_is_internal(phydev))
689-
mode = "internal";
690-
else
691-
mode = phy_modes(phydev->interface);
692-
693-
return sprintf(buf, "%s\n", mode);
694-
}
695-
static DEVICE_ATTR_RO(phy_interface);
696-
697-
static ssize_t
698-
phy_has_fixups_show(struct device *dev, struct device_attribute *attr, char *buf)
699-
{
700-
struct phy_device *phydev = to_phy_device(dev);
701-
702-
return sprintf(buf, "%d\n", phydev->has_fixups);
703-
}
704-
static DEVICE_ATTR_RO(phy_has_fixups);
705-
706-
static struct attribute *mdio_dev_attrs[] = {
707-
&dev_attr_phy_id.attr,
708-
&dev_attr_phy_interface.attr,
709-
&dev_attr_phy_has_fixups.attr,
710-
NULL,
711-
};
712-
ATTRIBUTE_GROUPS(mdio_dev);
713-
714673
struct bus_type mdio_bus_type = {
715674
.name = "mdio_bus",
716675
.match = mdio_bus_match,
717676
.pm = MDIO_BUS_PM_OPS,
718-
.dev_groups = mdio_dev_groups,
719677
};
720678
EXPORT_SYMBOL(mdio_bus_type);
721679

drivers/net/phy/phy_device.c

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,48 @@ struct phy_device *get_phy_device(struct mii_bus *bus, int addr, bool is_c45)
376376
}
377377
EXPORT_SYMBOL(get_phy_device);
378378

379+
static ssize_t
380+
phy_id_show(struct device *dev, struct device_attribute *attr, char *buf)
381+
{
382+
struct phy_device *phydev = to_phy_device(dev);
383+
384+
return sprintf(buf, "0x%.8lx\n", (unsigned long)phydev->phy_id);
385+
}
386+
static DEVICE_ATTR_RO(phy_id);
387+
388+
static ssize_t
389+
phy_interface_show(struct device *dev, struct device_attribute *attr, char *buf)
390+
{
391+
struct phy_device *phydev = to_phy_device(dev);
392+
const char *mode = NULL;
393+
394+
if (phy_is_internal(phydev))
395+
mode = "internal";
396+
else
397+
mode = phy_modes(phydev->interface);
398+
399+
return sprintf(buf, "%s\n", mode);
400+
}
401+
static DEVICE_ATTR_RO(phy_interface);
402+
403+
static ssize_t
404+
phy_has_fixups_show(struct device *dev, struct device_attribute *attr,
405+
char *buf)
406+
{
407+
struct phy_device *phydev = to_phy_device(dev);
408+
409+
return sprintf(buf, "%d\n", phydev->has_fixups);
410+
}
411+
static DEVICE_ATTR_RO(phy_has_fixups);
412+
413+
static struct attribute *phy_dev_attrs[] = {
414+
&dev_attr_phy_id.attr,
415+
&dev_attr_phy_interface.attr,
416+
&dev_attr_phy_has_fixups.attr,
417+
NULL,
418+
};
419+
ATTRIBUTE_GROUPS(phy_dev);
420+
379421
/**
380422
* phy_device_register - Register the phy device on the MDIO bus
381423
* @phydev: phy_device structure to be added to the MDIO bus
@@ -395,6 +437,8 @@ int phy_device_register(struct phy_device *phydev)
395437
goto out;
396438
}
397439

440+
phydev->mdio.dev.groups = phy_dev_groups;
441+
398442
err = device_add(&phydev->mdio.dev);
399443
if (err) {
400444
pr_err("PHY %d failed to add\n", phydev->mdio.addr);

0 commit comments

Comments
 (0)