From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754257AbdFWD62 (ORCPT ); Thu, 22 Jun 2017 23:58:28 -0400 Received: from szxga02-in.huawei.com ([45.249.212.188]:8822 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753779AbdFWD6Z (ORCPT ); Thu, 22 Jun 2017 23:58:25 -0400 Subject: Re: [PATCH NET 1/2] net: phy: Add phy loopback support in net phy framework To: Andrew Lunn CC: , , , , , , , , , , , , , References: <1498121602-64322-1-git-send-email-linyunsheng@huawei.com> <20170623031627.GA5432@lunn.ch> From: Yunsheng Lin Message-ID: <436ddf50-93d6-f15a-e9f6-bf8e43b63fec@huawei.com> Date: Fri, 23 Jun 2017 11:57:56 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.2.0 MIME-Version: 1.0 In-Reply-To: <20170623031627.GA5432@lunn.ch> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.74.190.125] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020201.594C91D2.005A,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 1e68b24947a7005626bdb822ad9b9283 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Andrew On 2017/6/23 11:16, Andrew Lunn wrote: >> +int genphy_loopback(struct phy_device *phydev, bool enable) >> +{ >> + int value; >> + >> + if (enable) { >> + value = phy_read(phydev, MII_BMCR); >> + phy_write(phydev, MII_BMCR, value | BMCR_LOOPBACK); >> + } else { >> + value = phy_read(phydev, MII_BMCR); >> + phy_write(phydev, MII_BMCR, value & ~BMCR_LOOPBACK); >> + } > > You should add error checking here. Both phy_read and phy_write can > return an error. Also, do the read and write once. Thanks for pointing out, will do that next vesion. > >> + >> + return 0; >> +} >> +EXPORT_SYMBOL(genphy_loopback); >> + >> +static int gen10g_loopback(struct phy_device *phydev, bool enable) >> +{ >> + return 0; >> +} > > This is pointless. The core code in phy.c should first check if the > function exists before calling it. So not having a 10g method is fine. > will remove it next vesion. Best Regards Yunsheng Lin