Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp3567910pxu; Tue, 15 Dec 2020 09:56:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJxgfvSNh3E+TNiDTBfHX8xUav/WBjl667dYZoCb8Ljchau4psNPXKdpz7Q3lMlKskiEdVLS X-Received: by 2002:a05:6402:310f:: with SMTP id dc15mr30598157edb.225.1608054983832; Tue, 15 Dec 2020 09:56:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608054983; cv=none; d=google.com; s=arc-20160816; b=ue1qJl61jcmNLZUctg6KROviY1o6Q9TtPBnWdy4woYiupIz+2oVZjU2tLvLqHgAEa+ rvMjx6g+TIW3UfiCbsHEvj2V4sCwnvJUaWLl19I61hWlarole5vLM0jLev2HGgDG3Hjh m9G3PH7gZWxIA8LuB4x7id3A8jSP1e0SYGldHUw665mEpHK2RlC2lo7wGy2bpROuy7uV rdGFAlheP/vmlTE69vSjOUFuOKnKJ5uDH0+E/B5prtQqp2A50PfKiMog0cE/sQdFTQTH oh2F/y60lLA4Wh7QJG9fUAs7paOsnM1+Nog4S8a3fuTN9W0Vf1H7nRmVZn8mC2jZ3noy CRrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=mkDN3OhG3zHdAnqKmxuoGLzOmpvtxuJkY47LUS1oics=; b=IlH93TjREEwu2dyk6kVWFdEnZLsigNNhLlF8D3nHDiyaz1LqxUUJzFko1ce0OQrcAm 4swcixGa2S67SY5fD3s4o4wF2zXFZrktLNq9dp8HjPKVmeShd4Z8wVnFhO/F7VYHxaE2 e8v+8BJPqtvcdh/uFDiSk9eiQVYZdDgbcU7VrdmkumQl1+Ws+2CCkyxP3h8lIku3hwDc cRqlayL+B6KnySBnVFG0qaFMRp9xe7MpaXYn/9Vf5Twjq5yS5ySfp29WBrhX9GmLUfaW o/2FYsfkdSXDPKABi2M04lIf15W8FcFchV5Lwc5cbau45q+G2Dtx+eq/bX3cc6DY8HCJ PqaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=LvnEcb4E; 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 rn2si1286935ejb.251.2020.12.15.09.56.00; Tue, 15 Dec 2020 09:56:23 -0800 (PST) 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=LvnEcb4E; 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 S1730478AbgLORxg (ORCPT + 99 others); Tue, 15 Dec 2020 12:53:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45632 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729584AbgLORxS (ORCPT ); Tue, 15 Dec 2020 12:53:18 -0500 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 437E2C06179C; Tue, 15 Dec 2020 09:52:38 -0800 (PST) Received: by mail-pg1-x544.google.com with SMTP id c22so299551pgg.13; Tue, 15 Dec 2020 09:52:38 -0800 (PST) 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=mkDN3OhG3zHdAnqKmxuoGLzOmpvtxuJkY47LUS1oics=; b=LvnEcb4Ed6FsrS9J7UIvbGKW9E1moNmJZl8FcXlzJm7XILWLwfsOWyR+BtEefBLXil AOrK72cRwPvj007XWHoyeuzGmGfbn04Y3zwTWDdueyCfY4dkpbePe9TrOi2C9PVUsRlY +dVUCcT0Ykx5PRrO4Y+DnMyH69mTIUa7ZYeQWOZmj0qBDykLyalroL7Sq5zQwPdac+CA mHBYuFSrjbcKKs7XuoHGfgUivqQv9ZC7JEYgSUX8kNqkQPejzyA2aJAMCEEN02NZnDuz Z0ANzdcBTVCJzGtcc28B9b2SNUjFrsg0IcA4hNKHrtPQgKIBj1Nj1aMVtJCYt9LlyoA+ 5VuQ== 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=mkDN3OhG3zHdAnqKmxuoGLzOmpvtxuJkY47LUS1oics=; b=MoZj0NltX6PPm8r0vkC48Q0Sc8ep5W2lQBLa6BFXfd8jSMlQ89IpMek0qvv/sYF3oY syDRsN+OwAvyKhwvtU8dZ8v4CXXfGvDA7SdlfJS+EC1F8yoVo5fcejC3uzX2YS3m6PsY 4zrLAvEPSBXyNK00Q4fULXH+S4suMWD/qndf2bBjxI6i0lQZNiobzwwwQiqtdETq2lvg uYYfaJUso1+kBfp1X0q6f/jDt3wNBz7mkLYjzl7UQ0ERpIZBQtn+qp280+gzg8qG4Rsm 3931A8BraS2dRq4lCFkqFgXAAeo9yjPGxjfzt9A/p9Cn37GLcGxw1/8mNRvtXxLDCc8c TsUQ== X-Gm-Message-State: AOAM530kkFm0ap8Er7rfB0c4GymvtZsq24KkyG9/SlZakkth1TJrbOBc xww00dcly+BXgiWZygB2nQYVmSilOA+sTb2xoEs= X-Received: by 2002:a63:b1e:: with SMTP id 30mr30019652pgl.203.1608054757866; Tue, 15 Dec 2020 09:52:37 -0800 (PST) MIME-Version: 1.0 References: <20201215164315.3666-1-calvin.johnson@oss.nxp.com> <20201215164315.3666-9-calvin.johnson@oss.nxp.com> In-Reply-To: <20201215164315.3666-9-calvin.johnson@oss.nxp.com> From: Andy Shevchenko Date: Tue, 15 Dec 2020 19:53:26 +0200 Message-ID: Subject: Re: [net-next PATCH v2 08/14] net: mdiobus: Introduce fwnode_mdiobus_register() To: Calvin Johnson Cc: Grant Likely , "Rafael J . Wysocki" , Jeremy Linton , Andrew Lunn , Florian Fainelli , Russell King - ARM Linux admin , Cristi Sovaiala , Florin Laurentiu Chiculita , Ioana Ciornei , Madalin Bucur , Heikki Krogerus , Marcin Wojtas , Pieter Jansen Van Vuuren , Jon , "linux.cj" , Laurentiu Tudor , Diana Madalina Craciun , ACPI Devel Maling List , Linux Kernel Mailing List , linux-arm Mailing List , netdev , "David S. Miller" , Heiner Kallweit , Jakub Kicinski Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Dec 15, 2020 at 6:44 PM Calvin Johnson wrote: > > Introduce fwnode_mdiobus_register() to register PHYs on the mdiobus. > If the fwnode is DT node, then call of_mdiobus_register(). > If it is an ACPI node, then: > - disable auto probing of mdiobus > - register mdiobus > - save fwnode to mdio structure > - loop over child nodes & register a phy_device for each PHY ... > +/** > + * fwnode_mdiobus_register - Register mii_bus and create PHYs from fwnode > + * @mdio: pointer to mii_bus structure > + * @fwnode: pointer to fwnode of MDIO bus. > + * > + * This function registers the mii_bus structure and registers a phy_device > + * for each child node of @fwnode. > + */ > +int fwnode_mdiobus_register(struct mii_bus *mdio, struct fwnode_handle *fwnode) > +{ > + struct fwnode_handle *child; > + unsigned long long addr; > + acpi_status status; > + int ret; > + > + if (is_of_node(fwnode)) { > + return of_mdiobus_register(mdio, to_of_node(fwnode)); > + } else if (is_acpi_node(fwnode)) { I would rather see this as simple as if (is_of_node(fwnode)) return of_mdiobus_register(mdio, to_of_node(fwnode)); if (is_acpi_node(fwnode)) return acpi_mdiobus_register(mdio, fwnode); where the latter one is defined somewhere in drivers/acpi/. > + /* Mask out all PHYs from auto probing. */ > + mdio->phy_mask = ~0; > + ret = mdiobus_register(mdio); > + if (ret) > + return ret; > + > + mdio->dev.fwnode = fwnode; > + /* Loop over the child nodes and register a phy_device for each PHY */ > + fwnode_for_each_child_node(fwnode, child) { > + status = acpi_evaluate_integer(ACPI_HANDLE_FWNODE(child), > + "_ADR", NULL, &addr); > + if (ACPI_FAILURE(status)) { Isn't it fwnode_get_id() now? > + pr_debug("_ADR returned %d\n", status); > + continue; > + } > + if (addr < 0 || addr >= PHY_MAX_ADDR) > + continue; addr can't be less than 0. > + ret = fwnode_mdiobus_register_phy(mdio, child, addr); > + if (ret == -ENODEV) > + dev_err(&mdio->dev, > + "MDIO device at address %lld is missing.\n", > + addr); > + } > + return 0; > + } > + return -EINVAL; > +} -- With Best Regards, Andy Shevchenko