diff mbox series

[RFC,net-next,3/9] net: phy: Add phy_standalone sysfs entry

Message ID 20190523011958.14944-4-ioana.ciornei@nxp.com
State RFC
Delegated to: David Miller
Headers show
Series Decoupling PHYLINK from struct net_device | expand

Commit Message

Ioana Ciornei May 23, 2019, 1:20 a.m. UTC
Export a phy_standalone device attribute that is meant to give the
indication that this PHY lacks an attached_dev and its corresponding
sysfs link.

Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
---
 drivers/net/phy/phy_device.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

Comments

Florian Fainelli May 23, 2019, 2:05 a.m. UTC | #1
On 5/22/2019 6:20 PM, Ioana Ciornei wrote:
> Export a phy_standalone device attribute that is meant to give the
> indication that this PHY lacks an attached_dev and its corresponding
> sysfs link.
> 
> Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>

I would rather have that attribute be conditionally visible/created upon
a PHY device being associated with a NULL net_device and not have it for
"non-standalone" PHY devices, that would be confusing.

> ---
>  drivers/net/phy/phy_device.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
> index 25cc7c33f8dd..30e0e73d5f86 100644
> --- a/drivers/net/phy/phy_device.c
> +++ b/drivers/net/phy/phy_device.c
> @@ -537,10 +537,22 @@ phy_has_fixups_show(struct device *dev, struct device_attribute *attr,
>  }
>  static DEVICE_ATTR_RO(phy_has_fixups);
>  
> +static ssize_t phy_standalone_show(struct device *dev,
> +				   struct device_attribute *attr,
> +				   char *buf)
> +{
> +	struct phy_device *phydev = to_phy_device(dev);
> +
> +	return sprintf(buf, "%d\n", !phydev->attached_dev);
> +}
> +
> +static DEVICE_ATTR_RO(phy_standalone);
> +
>  static struct attribute *phy_dev_attrs[] = {
>  	&dev_attr_phy_id.attr,
>  	&dev_attr_phy_interface.attr,
>  	&dev_attr_phy_has_fixups.attr,
> +	&dev_attr_phy_standalone.attr,
>  	NULL,
>  };
>  ATTRIBUTE_GROUPS(phy_dev);
>
Ioana Ciornei May 24, 2019, 10:52 a.m. UTC | #2
> Subject: Re: [RFC PATCH net-next 3/9] net: phy: Add phy_standalone sysfs entry
> 
> 
> 
> On 5/22/2019 6:20 PM, Ioana Ciornei wrote:
> > Export a phy_standalone device attribute that is meant to give the
> > indication that this PHY lacks an attached_dev and its corresponding
> > sysfs link.
> >
> > Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
> 
> I would rather have that attribute be conditionally visible/created upon a PHY
> device being associated with a NULL net_device and not have it for "non-
> standalone" PHY devices, that would be confusing.
> 

Ok, I understand the reasoning and will change it in v2.

--
Ioana

> > ---
> >  drivers/net/phy/phy_device.c | 12 ++++++++++++
> >  1 file changed, 12 insertions(+)
> >
> > diff --git a/drivers/net/phy/phy_device.c
> > b/drivers/net/phy/phy_device.c index 25cc7c33f8dd..30e0e73d5f86 100644
> > --- a/drivers/net/phy/phy_device.c
> > +++ b/drivers/net/phy/phy_device.c
> > @@ -537,10 +537,22 @@ phy_has_fixups_show(struct device *dev, struct
> > device_attribute *attr,  }  static DEVICE_ATTR_RO(phy_has_fixups);
> >
> > +static ssize_t phy_standalone_show(struct device *dev,
> > +				   struct device_attribute *attr,
> > +				   char *buf)
> > +{
> > +	struct phy_device *phydev = to_phy_device(dev);
> > +
> > +	return sprintf(buf, "%d\n", !phydev->attached_dev); }
> > +
> > +static DEVICE_ATTR_RO(phy_standalone);
> > +
> >  static struct attribute *phy_dev_attrs[] = {
> >  	&dev_attr_phy_id.attr,
> >  	&dev_attr_phy_interface.attr,
> >  	&dev_attr_phy_has_fixups.attr,
> > +	&dev_attr_phy_standalone.attr,
> >  	NULL,
> >  };
> >  ATTRIBUTE_GROUPS(phy_dev);
> >
> 
> --
> Florian
diff mbox series

Patch

diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 25cc7c33f8dd..30e0e73d5f86 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -537,10 +537,22 @@  phy_has_fixups_show(struct device *dev, struct device_attribute *attr,
 }
 static DEVICE_ATTR_RO(phy_has_fixups);
 
+static ssize_t phy_standalone_show(struct device *dev,
+				   struct device_attribute *attr,
+				   char *buf)
+{
+	struct phy_device *phydev = to_phy_device(dev);
+
+	return sprintf(buf, "%d\n", !phydev->attached_dev);
+}
+
+static DEVICE_ATTR_RO(phy_standalone);
+
 static struct attribute *phy_dev_attrs[] = {
 	&dev_attr_phy_id.attr,
 	&dev_attr_phy_interface.attr,
 	&dev_attr_phy_has_fixups.attr,
+	&dev_attr_phy_standalone.attr,
 	NULL,
 };
 ATTRIBUTE_GROUPS(phy_dev);