Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752944AbbDMAmG (ORCPT ); Sun, 12 Apr 2015 20:42:06 -0400 Received: from shards.monkeyblade.net ([149.20.54.216]:48075 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752045AbbDMAmD (ORCPT ); Sun, 12 Apr 2015 20:42:03 -0400 Date: Sun, 12 Apr 2015 20:42:01 -0400 (EDT) Message-Id: <20150412.204201.2242904202939074517.davem@davemloft.net> To: Shengzhou.Liu@freescale.com Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, f.fainelli@gmail.com Subject: Re: [PATCH] net/phy: tune get_phy_c45_ids to support more c45 phy From: David Miller In-Reply-To: <1428657020-11191-1-git-send-email-Shengzhou.Liu@freescale.com> References: <1428657020-11191-1-git-send-email-Shengzhou.Liu@freescale.com> X-Mailer: Mew version 6.6 on Emacs 24.4 / Mule 6.0 (HANACHIRUSATO) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.5.12 (shards.monkeyblade.net [149.20.54.216]); Sun, 12 Apr 2015 17:42:03 -0700 (PDT) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1266 Lines: 33 From: Shengzhou Liu Date: Fri, 10 Apr 2015 17:10:20 +0800 > if ((c45_ids->devices_in_package & 0x1fffffff) == 0x1fffffff) { > - *phy_id = 0xffffffff; > - return 0; > + reg_addr = MII_ADDR_C45 | 0 << 16 | 6; > + phy_reg = mdiobus_read(bus, addr, reg_addr); > + if (phy_reg < 0) > + return -EIO; Why are you reading this same register again, and why are you doing it with the magic constant "6". That's not '6', it's 'MDIO_DEVS2'. The first loop executed here should have read from this address, and placed the value into the ->devices_in_package. > + c45_ids->devices_in_package = (phy_reg & 0xffff) << 16; > + reg_addr = MII_ADDR_C45 | 0 << 16 | 5; Again, this isn't '5', it's 'MDIO_DEVS1'. This looks really like a hack. You're reading again the same registers, by hand, that the loop should already be reading properly. Why not restructure the loop to actually probe naturally for the presence bits in a way that works on the chip you are trying to make work? -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/