lkml.org 
[lkml]   [2017]   [Jun]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH NET] net/hns:bugfix of ethtool -t phy self_test
> drivers/net/ph/marvell.c
> marvell_set_loopback(struct phy_device *dev, bool enable)
> {
> /* do some device specific setting */
> ........
>
> return genphy_loopback(dev, enable);
> }
>
> I don't know if this makes sense or not?

Nope, you want something in phy.c like this. Not compiled, not
tested....

int phy_loopback(struct phy_device *dev, bool enable)
{

int err;

mutex_lock(dev->mutex);

if (enable && dev->loopback_enabled) {
err = -EBUSY;
goto out;
}

if (!enable && !dev->loopback_enabled) {
err = -EINVAL;
goto out;
}

if (dev->drv->loopback)
err = dev->drv->loopback(dev, enable);

if (!err)
dev->loopback_enabled = enable

mutex_unlock(dev->mutex);

out:
return err;
}
EXPORT_SYMBOL(phy_loopback);

The interesting part is how to handle two attempts to enable loopback.
Should the MAC driver be responsible for preventing that? Or do it in
the PHY driver? And what will the MAC driver do if it gets EBUSY?
Return it to user space?

Andrew

\
 
 \ /
  Last update: 2017-06-21 15:35    [W:0.053 / U:0.088 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site