Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp7006296pxb; Wed, 17 Feb 2021 21:31:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJzM6sJ5v4wz93no93CJNFHIJfkoSlygxZw+jktTBLcXNM4evIDegjDQ/Q3Vw5C7aNPxHsp5 X-Received: by 2002:a17:906:46c4:: with SMTP id k4mr2223238ejs.169.1613626292881; Wed, 17 Feb 2021 21:31:32 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1613626292; cv=pass; d=google.com; s=arc-20160816; b=xV5QDjsEHxUoe3e1OMhNu22RjUUO6lSleYO94NIFXQ2ZZ6XNQJT0CyLVhPR4nW0NJN hydg9ieER/yYFtFf/dIqQoa+rEmz80WlHC8f3Ma6IxE47c2v2SCzWs57A8v6EH4vWlOa h9b79Y9OQNOGOa8JuEB5Lzn8H6axNNgM+2lJBvpe6DBmyc0W7+eu6YGE46H+pRnp1IJ9 pE89wMFtJBQA4LfTAti5b23bBv1x6131tZ99rQYSHepkIT4yO/EpXdJHu7Lvlb8qXI9I 7zjFKDI96Aev5kOV9qduABG0ka6uENFCDFy1L2d9jHQHYarNsElFZ406D6j3oucXmuRp Hk8w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=LBeDkuzCmQMK4Qo7UTjtAPfm2bUt3Hpd3KuDb3+ywv4=; b=FIgNcpFVTx3k8qkoX/RYQuwZZtPdPL2E+To1GOOXWrhOu30RXnwDWaFuHnsVBTxOEe ini7NFzbTzsyXi2dmT7PGvKeRbmi5f2/qbHYI5sRX/EsnNwJbkSZ2oeioECKF0MaanWG jEQI+aM8FMtx2RmRGCE1Nlpy7W8JItkwSA4Fb6ToCBy97IGi2ma09js0VOuW4xhfRGdP bAOLc/USs5qJugKbdR+zs+La7qAGdoVdZMSFyKDXMHl7fKaBm40AP807Kp5KTmZwbATo 1/FREQeCP9HMSgI9ydVbnRvH/3lVV0N63St1UN/678HNEipKovxOPyluoYrDYj0bOUFH 7bow== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@NXP1.onmicrosoft.com header.s=selector2-NXP1-onmicrosoft-com header.b=F2RaNgIM; arc=pass (i=1 spf=pass spfdomain=oss.nxp.com dkim=pass dkdomain=oss.nxp.com dmarc=pass fromdomain=oss.nxp.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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j3si2782619edy.96.2021.02.17.21.31.09; Wed, 17 Feb 2021 21:31:32 -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=@NXP1.onmicrosoft.com header.s=selector2-NXP1-onmicrosoft-com header.b=F2RaNgIM; arc=pass (i=1 spf=pass spfdomain=oss.nxp.com dkim=pass dkdomain=oss.nxp.com dmarc=pass fromdomain=oss.nxp.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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230228AbhBRF26 (ORCPT + 99 others); Thu, 18 Feb 2021 00:28:58 -0500 Received: from mail-am6eur05on2076.outbound.protection.outlook.com ([40.107.22.76]:48096 "EHLO EUR05-AM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S230175AbhBRF2q (ORCPT ); Thu, 18 Feb 2021 00:28:46 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XAeWtntu4jgIWImd62bTScVkx2ic8WAoIiuv44/jea0rAR//DUh36ogwBzxHo6qdPm4d543x7dOf6BagnrFHBbexi5NI7uPPOGDDc8NV/qWGwKrP7cJoEkPvt3judJmHAiYGv8A6P+GZev3cuRSplxzRrECj0/ffemP2c1Qw2LxsYCENvMHTTX7qG9Kn/vwo/BIPrIWFjgkWCecfNbJPjIYikXrfmkCo1OC74hoNtDSr/cnxO7VfcTEk0wy2DFC5VszlF6BFwJHGYjXsWhDlhMMo+YZFa397TSlI+3FzRrJWFOkpUdY0XBdxXnu0b6p3Y6LkEm6xlSq8vShxCCOTfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=LBeDkuzCmQMK4Qo7UTjtAPfm2bUt3Hpd3KuDb3+ywv4=; b=F+xmM8mnv3iTakxoH1iunOLItEza3XWYS5I8ocEb8C0LxXY9wt2lM3vHaLDffOZ8iKIdwm6X/CS05ChO8go2vMEdgvtuu6rdiH9ujFTI6vbEGd7bhQ81ovi0TRFRgSfknPvHx2RtjOwk+38X9sVowxnNHkHzGU+WFgiyMcePtnhU7XE/xU9nm6KnAq+vYs5vN9hxRAFvXlCqPZz1iZiRonc17C1rO4j7K+l/n2G9V/SzhqQ9EqzEZc/2mnDBUT4qREKKXR5AjBNdXbogoZO6LmKzOc1rw47fH7xXGuLFYWnBKqsmpyUuLY9u10D0drxY1D2/pDSRfN/C6JbgEKbuOg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=LBeDkuzCmQMK4Qo7UTjtAPfm2bUt3Hpd3KuDb3+ywv4=; b=F2RaNgIMLmafjQvn4XhXlbNfx+d9p1Y0XNag8xhy3Yq55Jvt9tA49cBtQWdTFjM5F8Ny7AS/8zF+tsTnkP5nURltQcOYOWArTjwSG50QGubBCxFHzwXA4xSutAb5FUXop8zRWX0Vzj1TtI3xrZanNpzVwXf2vEImZDvTFKvBSxA= Authentication-Results: arm.com; dkim=none (message not signed) header.d=none;arm.com; dmarc=none action=none header.from=oss.nxp.com; Received: from AM0PR04MB5636.eurprd04.prod.outlook.com (2603:10a6:208:130::22) by AM0PR0402MB3442.eurprd04.prod.outlook.com (2603:10a6:208:21::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.42; Thu, 18 Feb 2021 05:27:39 +0000 Received: from AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::e90e:b1d6:18a2:2d42]) by AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::e90e:b1d6:18a2:2d42%6]) with mapi id 15.20.3846.042; Thu, 18 Feb 2021 05:27:39 +0000 From: Calvin Johnson To: Grant Likely , "Rafael J . Wysocki" , Jeremy Linton , Andrew Lunn , Andy Shevchenko , 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 , Saravana Kannan , Randy Dunlap Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-acpi@vger.kernel.org, Laurentiu Tudor , Diana Madalina Craciun , linux-arm-kernel@lists.infradead.org, linux.cj@gmail.com, Calvin Johnson , "David S. Miller" , Heiner Kallweit , Jakub Kicinski Subject: [net-next PATCH v6 02/15] net: phy: Introduce fwnode_mdio_find_device() Date: Thu, 18 Feb 2021 10:56:41 +0530 Message-Id: <20210218052654.28995-3-calvin.johnson@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210218052654.28995-1-calvin.johnson@oss.nxp.com> References: <20210218052654.28995-1-calvin.johnson@oss.nxp.com> Content-Type: text/plain X-Originating-IP: [14.142.151.118] X-ClientProxiedBy: SG2PR02CA0051.apcprd02.prod.outlook.com (2603:1096:4:54::15) To AM0PR04MB5636.eurprd04.prod.outlook.com (2603:10a6:208:130::22) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from lsv03152.swis.in-blr01.nxp.com (14.142.151.118) by SG2PR02CA0051.apcprd02.prod.outlook.com (2603:1096:4:54::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3868.27 via Frontend Transport; Thu, 18 Feb 2021 05:27:32 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: b664096e-4c90-431c-0fc1-08d8d3cde82e X-MS-TrafficTypeDiagnostic: AM0PR0402MB3442: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5797; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: v81HzRA+wT4eR1b7kmK3QKUnnH6X7VF86bZjmihw4UURQaYKnUxnPwnT7tEQx7Y8vyWZg/cr5O0grApaZLsgdkP7gVB8X+Gzo+zeh362OYMPv7mENdBfreCE6WbUw5H0fMOC2JgRwEyprbwml6UT7bkeSZJuKBrMfZlCrGDCHmTNWRfaAbAPR2kk/xfTcpHjaEl+oV7p36easM26dUZlKqj6l1GnkrFTMaYUHbAEE/8w6aYW7y189RPZXAg4qYHQ268Q6goz2m7iy1utlt8uI3DocuewHcg8BnDULDNa891DkbPOVkG86KGOGI2/lZIDuFYCqBJ8Yi4l6AXImGlJYtFNczikQ+Nf0eHbY7vpxXA91oLGrKhr0ckiV7n38Mqodk0tH0P3hizePjozwMVQVIr3lUmxwVJmEZO4BMHwUtQKX4iQ4elcIdBtbsn0oNtSjK9ilDK29l1cyeXtFJknfxWIUOHpUErJbeddwlMgAb9/B8yASNuCOg2LATTI+ks9A0MrUscFF+JLlUpMdFcmdo6UJr47Qjg6orwyRhxvc32PvGLjTz2+XU+7/XCVsXDDf4LeWg6Q1yVrc7+nM9kPaacRXchOfGZFJdljl1AoP7c= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM0PR04MB5636.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(346002)(136003)(39860400002)(376002)(396003)(44832011)(6486002)(26005)(7416002)(16526019)(110136005)(956004)(2616005)(186003)(55236004)(83380400001)(1076003)(6666004)(4326008)(316002)(1006002)(54906003)(8936002)(5660300002)(921005)(2906002)(52116002)(478600001)(86362001)(8676002)(6512007)(66946007)(6506007)(66476007)(66556008)(110426009);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?JUGdmB0o8Duj/J8d2ewXZRi5hBeum2uuN5p+Hf0/1Wx30VcmuhgkD+d7XsWV?= =?us-ascii?Q?SBCfSO4Zby240aSfI6GiSW25NgTFSj21K8Uq7iwk/aaSuQNpBOrnK2fMflen?= =?us-ascii?Q?5HZZXoVLVIaSgart4bWveTrPFW/K4F+p4pri7/qzfeoiIBoh8s5k16ntPBn7?= =?us-ascii?Q?VziRC5uUbSX7pCcSuWZ/nj2x2H/4TnIb13X07UD+jEtJaXOYdXHuysyS4s0W?= =?us-ascii?Q?L+6frbeL45IHk1dEFBmSSnGFGwW2UAsauhyVn8NTotr3PUbzxnNvLdHgz/o+?= =?us-ascii?Q?ZbXM0SLJvJ/pJNh13Fm7NnYFjGYSNBRO9kN6WcZkA93Xvhx/9DgpyefZhUOr?= =?us-ascii?Q?V/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9zfeudrMaEN260lmBh4w3ZBMMeKQW?= =?us-ascii?Q?sgh2uOGSALD8qhP2GcOAwA+qwntDNM1sNZUVah3w/IX5eU41UJ1N8xD5Q9q6?= =?us-ascii?Q?EyYSuvZ0gps1hlAVXFSLIUFk?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: b664096e-4c90-431c-0fc1-08d8d3cde82e X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB5636.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Feb 2021 05:27:39.6140 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: aBWaaSCsXuquNffhoYIcOVTT8keHyw+9zNtNKm0HLHUFs5xSSivWLIC4rT9NkMnEow+H3rTp1tzuIfN/h7Tbhw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR0402MB3442 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Define fwnode_mdio_find_device() to get a pointer to the mdio_device from fwnode passed to the function. Refactor of_mdio_find_device() to use fwnode_mdio_find_device(). Signed-off-by: Calvin Johnson --- Changes in v6: None Changes in v5: None Changes in v4: None Changes in v3: None Changes in v2: None drivers/net/mdio/of_mdio.c | 11 +---------- drivers/net/phy/phy_device.c | 23 +++++++++++++++++++++++ include/linux/phy.h | 6 ++++++ 3 files changed, 30 insertions(+), 10 deletions(-) diff --git a/drivers/net/mdio/of_mdio.c b/drivers/net/mdio/of_mdio.c index ea9d5855fb52..d5e0970b2561 100644 --- a/drivers/net/mdio/of_mdio.c +++ b/drivers/net/mdio/of_mdio.c @@ -347,16 +347,7 @@ EXPORT_SYMBOL(of_mdiobus_register); */ struct mdio_device *of_mdio_find_device(struct device_node *np) { - struct device *d; - - if (!np) - return NULL; - - d = bus_find_device_by_of_node(&mdio_bus_type, np); - if (!d) - return NULL; - - return to_mdio_device(d); + return fwnode_mdio_find_device(of_fwnode_handle(np)); } EXPORT_SYMBOL(of_mdio_find_device); diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index ce495473cd5d..e673912e8938 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -2821,6 +2821,29 @@ static bool phy_drv_supports_irq(struct phy_driver *phydrv) return phydrv->config_intr && phydrv->handle_interrupt; } +/** + * fwnode_mdio_find_device - Given a fwnode, find the mdio_device + * @np: pointer to the mdio_device's fwnode + * + * If successful, returns a pointer to the mdio_device with the embedded + * struct device refcount incremented by one, or NULL on failure. + * The caller should call put_device() on the mdio_device after its use + */ +struct mdio_device *fwnode_mdio_find_device(struct fwnode_handle *fwnode) +{ + struct device *d; + + if (!fwnode) + return NULL; + + d = bus_find_device_by_fwnode(&mdio_bus_type, fwnode); + if (!d) + return NULL; + + return to_mdio_device(d); +} +EXPORT_SYMBOL(fwnode_mdio_find_device); + /** * phy_probe - probe and init a PHY device * @dev: device to probe and init diff --git a/include/linux/phy.h b/include/linux/phy.h index 1a12e4436b5b..f5eb1e3981a1 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -1366,11 +1366,17 @@ struct phy_device *phy_device_create(struct mii_bus *bus, int addr, u32 phy_id, bool is_c45, struct phy_c45_device_ids *c45_ids); #if IS_ENABLED(CONFIG_PHYLIB) +struct mdio_device *fwnode_mdio_find_device(struct fwnode_handle *fwnode); struct phy_device *get_phy_device(struct mii_bus *bus, int addr, bool is_c45); int phy_device_register(struct phy_device *phy); void phy_device_free(struct phy_device *phydev); #else static inline +struct mdio_device *fwnode_mdio_find_device(struct fwnode_handle *fwnode) +{ + return 0; +} +static inline struct phy_device *get_phy_device(struct mii_bus *bus, int addr, bool is_c45) { return NULL; -- 2.17.1