[PATCH 3/3] net/eth: fix link handling

Jean-Christophe PLAGNIOL-VILLARD plagnioj at jcrosoft.com
Wed Sep 26 09:05:19 EDT 2012


On 14:43 Wed 26 Sep     , Sascha Hauer wrote:
> On Wed, Sep 26, 2012 at 01:53:31PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > The current code handle just the send where we are supposed to the same on rx
> > 
> > Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
> > ---
> 
> This is broken. For better readability I refer to the result, not to the
> patch:
> 
> > int eth_open(void)
> > {
> > 	int ret;
> > 
> > 	if (!eth_current)
> > 		return -ENODEV;
> > 
> > 	if (!eth_current->active) {
> > 		ret = eth_current->open(eth_current);
> > 		if (ret)
> > 			return ret;
> > 
> > 		if (eth_current->phydev)
> > 			eth_current->active = eth_current->phydev->link;
> > 		else
> > 			eth_current->active = 1;
> > 	}
> > 
> > 	if (!eth_current->active)
> > 		return -ENETDOWN;
> > 
> > 	return 0;
> > }
> 
> The eth->active is for tracking whether a device is opened (thus we have
> to call eth->halt). With this patch eth->active == 0 could mean:
> 
> a) device not opened
> b) opened, but no link
> 
> This is asking for trouble. A bit only has two states, you should not
> encode three states in it.
ok we can have both but the current will not not monitor the phy status

Best Regards,
J.



More information about the barebox mailing list