Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752883AbbDMHOX (ORCPT ); Mon, 13 Apr 2015 03:14:23 -0400 Received: from mail-bl2on0143.outbound.protection.outlook.com ([65.55.169.143]:22432 "EHLO na01-bl2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751455AbbDMHOV convert rfc822-to-8bit (ORCPT ); Mon, 13 Apr 2015 03:14:21 -0400 From: "Shengzhou.Liu@freescale.com" To: David Miller 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 Thread-Topic: [PATCH] net/phy: tune get_phy_c45_ids to support more c45 phy Thread-Index: AQHQc26q36oE5K2zmUm5dM3i8ki1AZ1KHnGAgABjtQA= Date: Mon, 13 Apr 2015 06:59:52 +0000 Message-ID: References: <1428657020-11191-1-git-send-email-Shengzhou.Liu@freescale.com> <20150412.204201.2242904202939074517.davem@davemloft.net> In-Reply-To: <20150412.204201.2242904202939074517.davem@davemloft.net> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: davemloft.net; dkim=none (message not signed) header.d=none; x-originating-ip: [199.59.231.64] x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:DM2PR03MB400; x-microsoft-antispam-prvs: x-forefront-antispam-report: BMV:1;SFV:NSPM;SFS:(10019020)(6009001)(51704005)(377454003)(40100003)(46102003)(66066001)(99286002)(122556002)(33656002)(77156002)(2950100001)(19580405001)(62966003)(74316001)(92566002)(110136001)(86362001)(106116001)(2656002)(76576001)(102836002)(50986999)(77096005)(54356999)(87936001)(19580395003)(76176999);DIR:OUT;SFP:1102;SCL:1;SRVR:DM2PR03MB400;H:DM2PR03MB398.namprd03.prod.outlook.com;FPR:;SPF:None;MLV:sfv;LANG:en; x-exchange-antispam-report-test: UriScan:; x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(601004)(5005006)(5002010);SRVR:DM2PR03MB400;BCL:0;PCL:0;RULEID:;SRVR:DM2PR03MB400; x-forefront-prvs: 0545EFAC9A Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-originalarrivaltime: 13 Apr 2015 06:59:52.6638 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 710a03f5-10f6-4d38-9ff4-a80b81da590d X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR03MB400 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1995 Lines: 44 > -----Original Message----- > From: David Miller [mailto:davem@davemloft.net] > Sent: Monday, April 13, 2015 8:42 AM > To: Liu Shengzhou-B36685 > 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: 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. > > 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? Some PHYs(e.g. Cortina CS4315/CS4340) have zero Devices In package, If we first probe zero Devices In package by loop for(i = 0; i < num_ids && c45_ids->devices_in_package == 0; i++), it will cause the probe fail on those C45 PHYs with non-zero Devices In package. So we must first probe non-zero Devices In package in the loop, if the return value of c45_ids->devices_in_package is 0x1fffffff, then try to probe zero Devices In package. Yes, will use MDIO_DEVS1 and MDIO_DEVS2 instead of constant '6', '5' in next version. -- 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/