From patchwork Tue Jul 21 00:49:56 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Fainelli X-Patchwork-Id: 497973 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id A860C140DCD for ; Tue, 21 Jul 2015 10:53:01 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=mo4USmZE; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757587AbbGUAv7 (ORCPT ); Mon, 20 Jul 2015 20:51:59 -0400 Received: from mail-pd0-f181.google.com ([209.85.192.181]:34827 "EHLO mail-pd0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755995AbbGUAv6 (ORCPT ); Mon, 20 Jul 2015 20:51:58 -0400 Received: by pdrg1 with SMTP id g1so109644056pdr.2; Mon, 20 Jul 2015 17:51:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=NO+IFSVSzHSwfS7X+aRIufRHVkrb4/zIBGLeP9EXeJY=; b=mo4USmZEMeakS9UQNgKkADeZtvmW4VX+KFl3cqwO4GhrLfg0QGeDHCOdVdzhYpzbRc gZfIBeEzidzU38/iA2SAlANg1WGqFPMdZvxkTzzAXuENn+/OQhLHimMlm9YeLLpirjSk QTcohZ39i8/07fePIsF/++sEO0jK9Xt3LLMHKnPCyHFYutTF9/hDWtVMgVXxXcuBF9dI rSbf58XKei9kFackUKTfD2Hl7VMhdHD9fsPJnAyftJlYQptUOYQXqOduKiy8IZIFJDmn HXLzP0YiaTs3JBVi6aF8Vfug3gjFYVYNPrLUol1+jMQSoJRA5LqrKIrn2Edc2nDTecHo r+Qw== X-Received: by 10.70.134.70 with SMTP id pi6mr66028585pdb.100.1437439917645; Mon, 20 Jul 2015 17:51:57 -0700 (PDT) Received: from fainelli-desktop.broadcom.com (5520-maca-inet1-outside.broadcom.com. [216.31.211.11]) by smtp.gmail.com with ESMTPSA id bf5sm24083515pad.43.2015.07.20.17.51.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 20 Jul 2015 17:51:56 -0700 (PDT) From: Florian Fainelli To: netdev@vger.kernel.org Cc: davem@davemloft.net, linux-kernel@vger.kernel.org, mxs@sbrk.org, arno@natisbad.org, stsp@users.sourceforge.net, devicetree@vger.kernel.org, thomas.petazzoni@free-electrons.com, Stas Sergeev , Florian Fainelli Subject: [PATCH net v5 2/4] net: phy: fixed_phy: handle link-down case Date: Mon, 20 Jul 2015 17:49:56 -0700 Message-Id: <1437439798-12622-3-git-send-email-f.fainelli@gmail.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1437439798-12622-1-git-send-email-f.fainelli@gmail.com> References: <1437439798-12622-1-git-send-email-f.fainelli@gmail.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Stas Sergeev fixed_phy_register() currently hardcodes the fixed PHY link to 1, and expects to find a "speed" parameter to provide correct information towards the fixed PHY consumer. In a subsequent change, where we allow "managed" (e.g: (RS)GMII in-band status auto-negotiation) fixed PHYs, none of these parameters can be provided since they will be auto-negotiated, hence, we just provide a zero-initialized fixed_phy_status to fixed_phy_register() which makes it fail when we call fixed_phy_update_regs() since status.speed = 0 which makes us hit the "default" label and error out. Without this change, we would also see potentially inconsistent speed/duplex parameters for fixed PHYs when the link is DOWN. CC: netdev@vger.kernel.org CC: linux-kernel@vger.kernel.org Signed-off-by: Stas Sergeev [florian: add more background to why this is correct and desirable] Signed-off-by: Florian Fainelli --- drivers/net/phy/fixed_phy.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/net/phy/fixed_phy.c b/drivers/net/phy/fixed_phy.c index 1960b46add65..479b93f9581c 100644 --- a/drivers/net/phy/fixed_phy.c +++ b/drivers/net/phy/fixed_phy.c @@ -52,6 +52,10 @@ static int fixed_phy_update_regs(struct fixed_phy *fp) u16 lpagb = 0; u16 lpa = 0; + if (!fp->status.link) + goto done; + bmsr |= BMSR_LSTATUS | BMSR_ANEGCOMPLETE; + if (fp->status.duplex) { bmcr |= BMCR_FULLDPLX; @@ -96,15 +100,13 @@ static int fixed_phy_update_regs(struct fixed_phy *fp) } } - if (fp->status.link) - bmsr |= BMSR_LSTATUS | BMSR_ANEGCOMPLETE; - if (fp->status.pause) lpa |= LPA_PAUSE_CAP; if (fp->status.asym_pause) lpa |= LPA_PAUSE_ASYM; +done: fp->regs[MII_PHYSID1] = 0; fp->regs[MII_PHYSID2] = 0;