Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1607843ybz; Sat, 18 Apr 2020 04:43:23 -0700 (PDT) X-Google-Smtp-Source: APiQypL+Ny2teQ836XZWNveMzqqcA/jQjRsqXBvYIDwmD768sssq0jMhl0SUMvkKbEmF5ER31goV X-Received: by 2002:a17:906:35d0:: with SMTP id p16mr7240919ejb.77.1587210203047; Sat, 18 Apr 2020 04:43:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587210203; cv=none; d=google.com; s=arc-20160816; b=O7zKb+Ot1tlTypC7+39yojISkVkmnSu7kQOSQcOK3GZrJ/dQn66OkvGoAm0ACq+bP1 /TPwU++/0rHBaAPQf1p/BsijP0bD7Nmx+q8lQMBMmH9Q7yKhlbCvthNUFxuczVX+uQWF Hp5RU95bDtEXH6/AxdPcVBVstHvUBMo4CZr3rAgcmuyGtNX+iRMR8GoLJJWKpIucDoNo 0mSIBR983UFAbhgmImhYTY0WLGM5xFGO3ZxaIFmtPBNHmxmd5qDKnHDmHz9gFAUINudX UJSFkUNJJRivBnQGd1aIYfKv8LwComsir9wVtlLnT7giaySK6DsQJ3LhlYJDjGCnkUbt fOPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=f0yHxPnJ4f0dB3+aObaskVJwqP9Vh3YSIkWQwfwhGfY=; b=d+Ai4+WDdDkK8DGfJ1OCQeK34Y2Fo4YbcXRFtHd7CeTbSWOsC8I//a3EXnLo8ZLbDS JVYCCr8aAGn29vr+a6mFXj/v/UvmsrOhF+NVb7KeLwWmW0S0H9dIczCoxU5earsDYIfX 5PLxnID40VJZICeNbmIPcIeIo+FHJ5uGo3nqehtdS9q9qWQOfT+La4rGHdHsCtXedRQn uWp45FOymSpQzU/Rw3NJU5qrgtlpry+1GTQ154wKkFQ2UuV+Xi9sdWIiv2r9JGfW9UuH F5SUlyJ61g5q01TYpP9Ax3hkjYExuIFltKtxdliBy2UIqsRKFIbs/yoLPP0OiisD2gdI VdEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=nAUQPpYP; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j3si16101958ejb.482.2020.04.18.04.42.58; Sat, 18 Apr 2020 04:43:23 -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; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=nAUQPpYP; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725985AbgDRLle (ORCPT + 99 others); Sat, 18 Apr 2020 07:41:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33682 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1725826AbgDRLle (ORCPT ); Sat, 18 Apr 2020 07:41:34 -0400 Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [IPv6:2001:4d48:ad52:3201:214:fdff:fe10:1be6]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A0ED1C061A0C; Sat, 18 Apr 2020 04:41:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=f0yHxPnJ4f0dB3+aObaskVJwqP9Vh3YSIkWQwfwhGfY=; b=nAUQPpYPImHaOkKUw8FoF83Mh UeQPgLagCtSswt3JODiv30UXzLVtA1mLDzsumB09CfWIGMItowEg8dGwHxoBsEdnbK0RkWTR6hqpu rkonsHEFM/EZIr++vc7Veu5fWAQgRt1jweHDBE87ZsEnH3GL3tafalW3AhXshpgjh8ETeuJWl9XfL Y4MOnqOB9FNkf7N2PtpYNnzYAdJb0kNNq8SJCbNhoV8iIeGIGz7V952OXpf1Q2cnZWhAVmROfh7dF A3pED/rVM7Tj6TD81pcG6maoNNvpa3DtlPnFjL9TPeWt2b8wjPYh6gZO58Zi1/AO6N7mONHdW4XeJ VHPxZTgeQ==; Received: from shell.armlinux.org.uk ([2002:4e20:1eda:1:5054:ff:fe00:4ec]:47572) by pandora.armlinux.org.uk with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jPlqX-0007qT-PX; Sat, 18 Apr 2020 12:41:17 +0100 Received: from linux by shell.armlinux.org.uk with local (Exim 4.92) (envelope-from ) id 1jPlqW-0003qM-3f; Sat, 18 Apr 2020 12:41:16 +0100 Date: Sat, 18 Apr 2020 12:41:16 +0100 From: Russell King - ARM Linux admin To: Calvin Johnson Cc: linux.cj@gmail.com, Jeremy Linton , Andrew Lunn , Andy Shevchenko , Florian Fainelli , Cristi Sovaiala , Florin Laurentiu Chiculita , Ioana Ciornei , Madalin Bucur , netdev@vger.kernel.org, Laurentiu Tudor , linux-acpi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Diana Madalina Craciun , linux-kernel@vger.kernel.org, Varun Sethi , Marcin Wojtas , "Rajesh V . Bikkina" , Pankaj Bansal , Makarand Pawagi , "David S. Miller" Subject: Re: [RFC net-next PATCH v2 1/2] net/fsl: add ACPI support for mdio bus Message-ID: <20200418114116.GU25745@shell.armlinux.org.uk> References: <20200418105432.11233-1-calvin.johnson@oss.nxp.com> <20200418105432.11233-2-calvin.johnson@oss.nxp.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200418105432.11233-2-calvin.johnson@oss.nxp.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Apr 18, 2020 at 04:24:31PM +0530, Calvin Johnson wrote: > @@ -241,18 +244,81 @@ static int xgmac_mdio_read(struct mii_bus *bus, int phy_id, int regnum) > return value; > } > > +/* Extract the clause 22 phy ID from the compatible string of the form > + * ethernet-phy-idAAAA.BBBB This comment is incorrect. What about clause 45 PHYs? > + */ > +static int xgmac_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; > + } > + } > + return -EINVAL; > +} > + > +static int xgmac_mdiobus_register_phy(struct mii_bus *bus, > + struct fwnode_handle *child, u32 addr) > +{ > + struct phy_device *phy; > + bool is_c45 = false; > + int rc; > + const char *cp; > + u32 phy_id; > + > + fwnode_property_read_string(child, "compatible", &cp); > + if (!strcmp(cp, "ethernet-phy-ieee802.3-c45")) > + is_c45 = true; > + > + if (!is_c45 && !xgmac_get_phy_id(child, &phy_id)) > + phy = phy_device_create(bus, addr, phy_id, 0, NULL); > + else > + phy = get_phy_device(bus, addr, is_c45); > + if (IS_ERR(phy)) > + return PTR_ERR(phy); > + > + phy->irq = bus->irq[addr]; > + > + /* Associate the fwnode with the device structure so it > + * can be looked up later. > + */ > + phy->mdio.dev.fwnode = child; > + > + /* All data is now stored in the phy struct, so register it */ > + rc = phy_device_register(phy); > + if (rc) { > + phy_device_free(phy); > + fwnode_handle_put(child); > + return rc; > + } > + > + dev_dbg(&bus->dev, "registered phy at address %i\n", addr); > + > + return 0; You seem to be duplicating the OF implementation in a private driver, converting it to fwnode. This is not how we develop the Linux kernel. We fix subsystem problems by fixing the subsystems, not by throwing what should be subsystem code into private drivers. -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTC broadband for 0.8mile line in suburbia: sync at 10.2Mbps down 587kbps up