From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A9F14C169C4 for ; Fri, 8 Feb 2019 18:17:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7203E20863 for ; Fri, 8 Feb 2019 18:17:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="HzjN7cOk" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726747AbfBHSRD (ORCPT ); Fri, 8 Feb 2019 13:17:03 -0500 Received: from mail-wm1-f66.google.com ([209.85.128.66]:37779 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727882AbfBHSRC (ORCPT ); Fri, 8 Feb 2019 13:17:02 -0500 Received: by mail-wm1-f66.google.com with SMTP id g67so4537595wmd.2 for ; Fri, 08 Feb 2019 10:17:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=t3q1AFeQVd/K+WOiYHOW0zE7kE9tnf2n1zBxlZAFNLc=; b=HzjN7cOkT1K6XJkH5TZj3GR/S5W8N2w4xoOKnUpduo8YDpm+QX1FGCcpOb8zgUOgv7 2aJPPjd94i1nDyRoeB1ApFpSP7zEadSV6KYfhaHr9gEF3goMY4sqWGCcWfzOKzPudU/G Ki+NdoTN8a8Lkuqc1rW1wbEguHidAtsoiBsOraFGO16llcotDGoIhhi1Ix4S/n4KqsdK RthltNVg+r0scVT4PzqO1GOL5bIXwc/lMGJKESrmq71mypy0s314DLd0tAJYeBjPpI44 EopOlB5GMMxUHECotdQiQKxMjRt4DcuL2JqoTPwUa45ybXkUAwq0jn7wWt6dGRCESMng kUAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=t3q1AFeQVd/K+WOiYHOW0zE7kE9tnf2n1zBxlZAFNLc=; b=jJ/kuntJWtg7CJ9X+rT8E4OCLsY9tkr73sqz696ENE6PAdIg99veKeJ5keuc+ef6iY T/SjHD+7M56GdGuhrklup9np0CpYTKvQJtg69KytBFRN6EpT6r6vWl1Cdv1imcxVt98S MYToOPoaFUcBXEw2LExnaoOGU6cuJj4koZBBywIuIcsjade6rxrsTwbV8iRNzi8WBywj l7MnW79LH2DFPXEHUk3lxvwAJdVDwiv5D4BJUfKj7K6mMOqTvqL1lQlbkPPxM3xbITqB BlTwuVE/re+S1Uk5TRHr8PWzGEBCpUbkaJUmWJPAcvkQIflega5N4dWK8fAta6QsYrxl 8ZwA== X-Gm-Message-State: AHQUAua20ke5lyhzemplSEGIb5FBFL6LJneL86bOacmczKQA/08yKUfv nLUxr7h+Dc0AjPi3qm9pCKV8Mv7q X-Google-Smtp-Source: AHgI3IZ2KRgYejnLdfSWVD84G76M4eBq9ogufiS7xyq2ExIMXaNCqn1ogV+ypWajeB69QDnonPlsuQ== X-Received: by 2002:a5d:5111:: with SMTP id s17mr17108040wrt.43.1549649820234; Fri, 08 Feb 2019 10:17:00 -0800 (PST) Received: from ?IPv6:2003:ea:8bf1:e200:7cef:f5e9:d82c:bb62? (p200300EA8BF1E2007CEFF5E9D82CBB62.dip0.t-ipconnect.de. [2003:ea:8bf1:e200:7cef:f5e9:d82c:bb62]) by smtp.googlemail.com with ESMTPSA id h4sm1549578wre.5.2019.02.08.10.16.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 08 Feb 2019 10:16:59 -0800 (PST) Subject: Re: [PATCH net-next] net: phy: disregard "Clause 22 registers present" bit in get_phy_c45_devs_in_pkg To: Andrew Lunn Cc: Florian Fainelli , David Miller , "netdev@vger.kernel.org" References: <47ec59c0-27c0-32e3-c75e-7bdfa99551c9@gmail.com> <20190208140206.GE26594@lunn.ch> From: Heiner Kallweit Message-ID: <467d5d6b-86d9-2f81-836c-52e17f28bc6c@gmail.com> Date: Fri, 8 Feb 2019 19:16:52 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.5.0 MIME-Version: 1.0 In-Reply-To: <20190208140206.GE26594@lunn.ch> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On 08.02.2019 15:02, Andrew Lunn wrote: > On Fri, Feb 08, 2019 at 08:12:47AM +0100, Heiner Kallweit wrote: >> Bit 0 in register 1.5 doesn't represent a device but is a flag that >> Clause 22 registers are present. Therefore disregard this bit when >> populating the device list. If code needs this information it >> should read register 1.5 directly instead of accessing the device >> list. Because this bit doesn't represent a device I didn't add a >> MDIO_MMD_C22PRESENT constant or similar. >> >> Signed-off-by: Heiner Kallweit >> --- >> drivers/net/phy/phy_device.c | 3 ++- >> include/uapi/linux/mdio.h | 1 + >> 2 files changed, 3 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c >> index 9369e1323..c2316a117 100644 >> --- a/drivers/net/phy/phy_device.c >> +++ b/drivers/net/phy/phy_device.c >> @@ -682,7 +682,8 @@ static int get_phy_c45_devs_in_pkg(struct mii_bus *bus, int addr, int dev_addr, >> phy_reg = mdiobus_read(bus, addr, reg_addr); >> if (phy_reg < 0) >> return -EIO; >> - *devices_in_package |= (phy_reg & 0xffff); >> + /* Bit 0 doesn't represent a device, it indicates c22 regs presence */ >> + *devices_in_package |= (phy_reg & 0xfffe); > > Hi Heiner > > Just for readability, can we use BIT(0) in there somehow? > You think 0xfffe together with the comment is still not clear enough? But sure, I can make it more explicit. >> >> return 0; >> } >> diff --git a/include/uapi/linux/mdio.h b/include/uapi/linux/mdio.h >> index 2e6e309f0..0e012b168 100644 >> --- a/include/uapi/linux/mdio.h >> +++ b/include/uapi/linux/mdio.h >> @@ -115,6 +115,7 @@ >> >> /* Device present registers. */ >> #define MDIO_DEVS_PRESENT(devad) (1 << (devad)) >> +#define MDIO_DEVS_C22PRESENT MDIO_DEVS_PRESENT(0) > > Err. The commit message says you did not add this... > Maybe I'm not clear enough in the commit message. Typically we have two constants for a device: MDIO_MMD_XXX (for the device) MDIO_DEVS_XXX (for the bit of the device in the device list bitmap) For the C22PRESENT flag I don't define the first one (because it's not a device) but the second one (because it uses a bit in the device list bitmap). > Andrew > Heiner