Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp734910ybj; Thu, 7 May 2020 06:31:41 -0700 (PDT) X-Google-Smtp-Source: APiQypIqcWIzl9gdR69rJ2uCI8+Y3DCy+7XudeoIThaLIQHnmW77yaLtSU4nrg6YYaBmmrSBtvoL X-Received: by 2002:a05:6402:1596:: with SMTP id c22mr12396307edv.100.1588858301361; Thu, 07 May 2020 06:31:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588858301; cv=none; d=google.com; s=arc-20160816; b=0ZqD8yszHAuvhDEgw8dCGdejf8BlCt4zGdzaAk6ZkXbFUey85DeMQLREKsSpyaiV/p ZmjUUVj4AWW8mjRne8ImgZdJJT6huvasD82Zwjv/ucae3V9IiJlmwzg+2vqK4fxg5p0l JD2NyB/g2ylfcrXId9jSFGCTlgAMFYleReVc7YEKzY7HSUZfd9RbJquBRlERifXF4Wlb hIb/inNQYDWhxKLuRCXE1yCmBqZWXpKMHdPutDo7rePvgFhWmz0W/AE11M+aYZXX/hxb LETEVkSXe1pODzymujvYhUJFa50l9/yJo73EvtUovC31NgfEIfnlO2A3b33Tol1tubvW Jesw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=Sv5j29Tl5TDpyyHB1d4Pc+8yuo1bvw3Pe98XWOuw5hI=; b=ySTDpyJFBUYPhaGY6PiJDkWFqDqw1sJ+VIv1D+blPs38fOGSUrSAW52TRnd84yXs0L abwl+iOR4m0nEr6gXigt8aSObgQZWuSdx8r4yp06LbbM+hwSNbXSvgAFWBiTJAyOkYgh fWWZLF6wUsk7bOt0pAqF9OQhKyIVc2c+ufUREuVAq+s5ZGtAqGaJGyAcimBGI0o0CKzz oO856m89eguI9yr2q4e41Q10un/ao6X/DSFvhngpdOOKsy4uVSp9D2/B4c/e4Fwe6lIn mFeLhE5xxMdC8y/l/XMAYhNq7YRsz+ENes9dyWpXKU3Tu4/UsfG+d1a/B0il1Nfvd3ZW 8RaQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i10si3191822ejc.284.2020.05.07.06.31.13; Thu, 07 May 2020 06:31:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727084AbgEGN0l (ORCPT + 99 others); Thu, 7 May 2020 09:26:41 -0400 Received: from foss.arm.com ([217.140.110.172]:59364 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725914AbgEGN0k (ORCPT ); Thu, 7 May 2020 09:26:40 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 06F3C101E; Thu, 7 May 2020 06:26:40 -0700 (PDT) Received: from [192.168.122.166] (unknown [10.119.48.73]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 24FBF3F68F; Thu, 7 May 2020 06:26:39 -0700 (PDT) Subject: Re: [net-next PATCH v3 4/5] net: phy: Introduce fwnode_get_phy_id() To: Calvin Johnson , "Rafael J . Wysocki" , Russell King - ARM Linux admin , linux.cj@gmail.com, Andrew Lunn , Andy Shevchenko , Florian Fainelli , Cristi Sovaiala , Florin Laurentiu Chiculita , Ioana Ciornei , Madalin Bucur , Greg Kroah-Hartman , Heikki Krogerus Cc: Varun Sethi , "Rajesh V . Bikkina" , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, Diana Madalina Craciun , netdev@vger.kernel.org, Marcin Wojtas , Laurentiu Tudor , Makarand Pawagi , linux-arm-kernel@lists.infradead.org, Pankaj Bansal , "David S. Miller" , Heiner Kallweit References: <20200505132905.10276-1-calvin.johnson@oss.nxp.com> <20200505132905.10276-5-calvin.johnson@oss.nxp.com> From: Jeremy Linton Message-ID: <67e263cf-5cd7-98d1-56ff-ebd9ac2265b6@arm.com> Date: Thu, 7 May 2020 08:26:38 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: <20200505132905.10276-5-calvin.johnson@oss.nxp.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On 5/5/20 8:29 AM, Calvin Johnson wrote: > Extract phy_id from compatible string. This will be used by > fwnode_mdiobus_register_phy() to create phy device using the > phy_id. > > Signed-off-by: Calvin Johnson > --- > > Changes in v3: None > Changes in v2: None > > drivers/net/phy/phy_device.c | 21 +++++++++++++++++++++ > include/linux/phy.h | 5 +++++ > 2 files changed, 26 insertions(+) > > diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c > index 4204d49586cd..f4ad47f73f8d 100644 > --- a/drivers/net/phy/phy_device.c > +++ b/drivers/net/phy/phy_device.c > @@ -662,6 +662,27 @@ struct phy_device *phy_device_create(struct mii_bus *bus, int addr, u32 phy_id, > } > EXPORT_SYMBOL(phy_device_create); > > +/* Extract the phy ID from the compatible string of the form > + * ethernet-phy-idAAAA.BBBB. > + */ > +int fwnode_get_phy_id(struct fwnode_handle *fwnode, u32 *phy_id) > +{ > + const char *cp; > + unsigned int upper, lower; > + int ret; > + > + ret = fwnode_property_read_string(fwnode, "compatible", &cp); > + if (!ret) { > + if (sscanf(cp, "ethernet-phy-id%4x.%4x", > + &upper, &lower) == 2) { > + *phy_id = ((upper & 0xFFFF) << 16) | (lower & 0xFFFF); > + return 0; > + } Isn't the ACPI _CID() conceptually similar to the DT compatible property? It even appears to be getting used in a similar way to identify particular phy drivers in this case. Thanks,