Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp777448ybj; Tue, 5 May 2020 07:25:04 -0700 (PDT) X-Google-Smtp-Source: APiQypJwmlvm47u8aJxe2WWZWsbX7kXycrHijbMlPdRK6Rt7Fzp1oyRWWta68F7T+iG2HpcKFO6m X-Received: by 2002:a05:6402:1d88:: with SMTP id dk8mr3001374edb.52.1588688704574; Tue, 05 May 2020 07:25:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588688704; cv=none; d=google.com; s=arc-20160816; b=Py41RfA9Zq6YSg7nPMTTtn5dNz8MBWihg0TErDYnvEDGbwTlZRfW1gYSM6wB+HBwRI 1Iu6oaMMmD9+PbuwrzH1D+5zjDTstjkYECMPBxp0LLoTavHiTge1F/PC3C77Mw9OHNBj ewRYjDsu3oUHvM/xKOkiJGk2pfQqemDIgqhYcbFDdDY4FfEX4DJXmMbpi8ZHcThWqcqn PHaIKnOsNrsKboYBPe5bXw1rjwVcohkVV59VYYA2k64MrzMkaDild+EHGudygtkYq4PP kuQz7iIxSvTURpwRzoiR9mGbcUqTTvBeUjSknHRRzlPrXhbyRplBtYZHDHYcP8afcWfl QpHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=DGtEu1KsY1dr41QJrz50PNo/qEe9hhqV40ULoK/JQEY=; b=vZW2fc1xuvNUiYA8yMBhBteV5GXf75F+Hgpqinb/nMeKOVqZuxNGKj6s5ABY6l+Gtl bwpHSBz1BfKJ+aD2p81PEpHPgO48prmriK5XHdIAwCOT2AOubI1QFlNDMyWaO6Qqb5z3 1KdEWx2N8DAR6I/yajP3X0YyrDVrHA1qXsSCE/e/DRuGRnxEu9rLwCEq0MNtJzk6Oe7u KD9Mf6ZBxivUt7TXPFWxoRz6jt9eZUkdeWxMacyU9GXwpHqJSIjz1D1chcYBLlRGGDDS zwRt/u3Y43PM455n2oLw2rZ8UnqrWQRcYpxwjvFA+w033IN/csugBYvXcEFMOHymU4Xc RbNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=fppBqTIE; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id sd18si1194072ejb.534.2020.05.05.07.24.41; Tue, 05 May 2020 07:25:04 -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=pass header.i=@gmail.com header.s=20161025 header.b=fppBqTIE; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730623AbgEEOWJ (ORCPT + 99 others); Tue, 5 May 2020 10:22:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1730616AbgEEOWH (ORCPT ); Tue, 5 May 2020 10:22:07 -0400 Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A521AC061A0F; Tue, 5 May 2020 07:22:07 -0700 (PDT) Received: by mail-pg1-x542.google.com with SMTP id b8so1072278pgi.11; Tue, 05 May 2020 07:22:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=DGtEu1KsY1dr41QJrz50PNo/qEe9hhqV40ULoK/JQEY=; b=fppBqTIEYFEQOtLCh6kQJwvY3nR8D9p8ij1Nzx+hThzSI07ASyz3kBNezKy+tic7KP Zsf+wOm64CalAwkvMC2Mn9o9GRINg584C08ghOx8sZ4R8wGd/azhLscwrtMcgP/mYDnB ZgRFeECtreW8oFOaEZr6Qg21KCWVxM01TVWPcQxJ2DMZ9UR37Nzdv0e41hgJ0k7F79h8 2JYbgfr495aRcvDK02NYDBI3LfbGcvRNNJN+672pBDjqas9b7zmCfil/XJjjqPYnS0P7 sIoQmrXY0ZceG8GEVLvJ9Y3oGMXtLSJXeRx2/ukitX0em9Qy7H+YEvjg3qurclkmeY3s xjnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=DGtEu1KsY1dr41QJrz50PNo/qEe9hhqV40ULoK/JQEY=; b=r4QbKiuehOirAHmkQXQ9+tylWtr3Hanltq1D8hA0eP7+WTUmIMWi8mq9pHgE+HmzMu JinNsrox4nMxR+Z6OvnSaaEZZ/sZ/BiVTfoNlO3ofiPJ9OKLrrWrsGEKQCaZKFYR/BEX TijO9TswO0CNGBBRxrTxPa6/bd3y/E32q5y3HurziAfIuKC8V4+j608C8PlfI45TQIYX 1LQCU1E73fSpkyn5++mF7MaPd6Ym7LO6FuG1fdIc88ZaCdJpmW0izyTg6gBJ9KjaTRHf 37GjCFttVhTbJIiJWUjGY9sO9FED/QKRvc+2DUxREyEGnI5wWbYIYzAxcZBApT4ldSmm CurQ== X-Gm-Message-State: AGi0PublH/Gc2piZWPhx7oErDGWNGwdyQFs9Zo5gH9jMPlmKmYTNFhqq cHAfJs1WGZSH8UKaLtrSPHIxIyeySjkEfb2uUgI= X-Received: by 2002:a65:6251:: with SMTP id q17mr3052332pgv.4.1588688527041; Tue, 05 May 2020 07:22:07 -0700 (PDT) MIME-Version: 1.0 References: <20200505132905.10276-1-calvin.johnson@oss.nxp.com> <20200505132905.10276-6-calvin.johnson@oss.nxp.com> In-Reply-To: <20200505132905.10276-6-calvin.johnson@oss.nxp.com> From: Andy Shevchenko Date: Tue, 5 May 2020 17:22:00 +0300 Message-ID: Subject: Re: [net-next PATCH v3 5/5] net: mdiobus: Introduce fwnode_mdiobus_register_phy() To: Calvin Johnson Cc: "Rafael J . Wysocki" , Russell King - ARM Linux admin , linux.cj@gmail.com, Jeremy Linton , Andrew Lunn , Florian Fainelli , Cristi Sovaiala , Florin Laurentiu Chiculita , Ioana Ciornei , Madalin Bucur , Greg Kroah-Hartman , Heikki Krogerus , Varun Sethi , "Rajesh V . Bikkina" , ACPI Devel Maling List , Linux Kernel Mailing List , Diana Madalina Craciun , netdev , Marcin Wojtas , Laurentiu Tudor , Makarand Pawagi , linux-arm Mailing List , Pankaj Bansal , "David S. Miller" , Heiner Kallweit Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 5, 2020 at 4:30 PM Calvin Johnson wrote: > > Introduce fwnode_mdiobus_register_phy() to register PHYs on the > mdiobus. From the compatible string, identify whether the PHY is > c45 and based on this create a PHY device instance which is > registered on the mdiobus. ... > +int fwnode_mdiobus_register_phy(struct mii_bus *bus, > + struct fwnode_handle *child, u32 addr) > +{ > + struct phy_device *phy; > + bool is_c45 = false; Redundant assignment, see below. > + const char *cp; > + u32 phy_id; > + int rc; > + > + fwnode_property_read_string(child, "compatible", &cp); Consider rc = ...; otherwise you will have UB below. > + if (!strcmp(cp, "ethernet-phy-ieee802.3-c45")) UB! > + is_c45 = true; is_c45 = !(rc || strcmp(...)); > + if (!is_c45 && !fwnode_get_phy_id(child, &phy_id)) Perhaps positive conditional if (is_c45 || fwnode_...(...)) get_phy_device(); else ... > + 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); Shouldn't mdio.dev.fwnode be put rather than child (yes, I see the assignment) > + return rc; > + } > + > + dev_dbg(&bus->dev, "registered phy at address %i\n", addr); > + > + return 0; > +} -- With Best Regards, Andy Shevchenko