From patchwork Mon Feb 8 15:12:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Calvin Johnson X-Patchwork-Id: 12075837 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AE78EC433E6 for ; Mon, 8 Feb 2021 15:15:31 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5B2E164F1D for ; Mon, 8 Feb 2021 15:15:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5B2E164F1D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oss.nxp.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=NmwV1q83iiZ6yhgPNt9EjB4G3gZDKPNGVI4ISY939E0=; b=U1KKXAagTNsQG0hVfc6v0S7Vp lKlTp3veTE18ceMtWhKrRwxgU0ocEBeO7m2389Dn0fFrCWcgQpm4rNKfp3LRwupX+t5MQwPAIrzC3 cS+P/ID4SAwLhZBA3LcUjB5S+ZN26BLj2UgFjuH9ud3mRY7IkRF5P7MVwAuGp3y5xkrBFzY1yjMEL kox0DJ4dgoUfC7ggp7pFlxL2ziXnSnUmmDnAIBNbTyRL+6+XPJpRvwkTcxNrcFunj10Qzf1maChWl Xz1/DFa/w1A7h/Zv3lg0ztADCX7S2aQVa4TQZ60kWXs8tgYv0HtM8xJauYBFia4h8+oD/A47K5/8s xmMpDE51Q==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l98EV-00056T-Cg; Mon, 08 Feb 2021 15:13:47 +0000 Received: from mail-db8eur05on2061.outbound.protection.outlook.com ([40.107.20.61] helo=EUR05-DB8-obe.outbound.protection.outlook.com) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1l98EN-00051q-AU for linux-arm-kernel@lists.infradead.org; Mon, 08 Feb 2021 15:13:40 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TtepjvLnH6jtwLyMFAXaSNy2V2AfcRhAYQmFvdoNKFDS4nHhePEFL9CXVnobuJ71ybEdLXvlme3YlHLg+Lnp/XUPgBU6X4nxb+gNzt2lo2/XtK/1IWmADhDYKMiSxePrdnGli1fZ5/TxM/SHMZiLRzszhAZiksDRKBhlC0n57xMmrtCFJYw0cKFi55wlgnXw0XQdPXedNJxG1LAKr/T5VlxDss6d0R+byZAZxR9VR8LBPOP1/xQnrGu+dhTqKH9gsbB0+eIagiFJxCOx7U13EUpIF3ghMNQN7s2s2JPNBSAwqJS/8skiNBGT8twRu7h04gf+HNVZAr85Qe6ilUm2pQ== 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=UZ/gH5MpDExS/V5Jml4xSI44t2ZxUavt+yfu94WPViQ=; b=CvG0jrmUn5aM1kikcorjLl20M0rPB0XlolIkKlFL90RhlYdRnGDUkN7K9mRa1kQj4jx4Xs4XsCsbXli050YvmPWUh/Pr7gRTIL4THeNzmSiP6ut+eCsIGSgZLPzTtlbkn7mxKqQGjxUzTkbyJuxnD6MzH2aVEku6bZs8VwMrQrzZUi8SXC8pVOVqriY8FyzOfunXhzlgWNQc+/yY9toPcEmin/vZrpS+xOSParvzDGesdkfMSIWs32vMvBN/hMXbURz5vHpD0hY57hkkWAfNd9lc3Y4RY+sZDuzpD8Iwwi3kB6pmF/X68vBsv6AZUxdw0XoVvE7qwkJ/OeSuYi+H+A== 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=UZ/gH5MpDExS/V5Jml4xSI44t2ZxUavt+yfu94WPViQ=; b=geTM3QI4+FaGkOaVIONo381+hbvpYjTjws/SBjiaiQIPB8I6nWDZtB0/k9rjUNXnAMKbs2xv9Ug2gxllCQxEM5YBOocVuEhwILbV6qtU5NnZ8UX744WZC69+SUsXGgBueu3IQ6E9Tz6/v1DSBicYQyZZHR9vaMEtUexjLybHhNw= 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 AM0PR04MB6435.eurprd04.prod.outlook.com (2603:10a6:208:176::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.23; Mon, 8 Feb 2021 15:13:31 +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.3825.030; Mon, 8 Feb 2021 15:13:31 +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 Subject: [net-next PATCH v5 02/15] net: phy: Introduce fwnode_mdio_find_device() Date: Mon, 8 Feb 2021 20:42:31 +0530 Message-Id: <20210208151244.16338-3-calvin.johnson@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210208151244.16338-1-calvin.johnson@oss.nxp.com> References: <20210208151244.16338-1-calvin.johnson@oss.nxp.com> X-Originating-IP: [14.142.151.118] X-ClientProxiedBy: SG2PR04CA0176.apcprd04.prod.outlook.com (2603:1096:4:14::14) 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 SG2PR04CA0176.apcprd04.prod.outlook.com (2603:1096:4:14::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.19 via Frontend Transport; Mon, 8 Feb 2021 15:13:25 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: cc86f187-1312-40fd-dff2-08d8cc44187b X-MS-TrafficTypeDiagnostic: AM0PR04MB6435: 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: GFBnEMKX2foI/nNq3PjWQ2nxKM/Ufs9bXFo7DeTzpH5Y/m3T3nkEJb2/54Oc+i/pnDkxsOwcdoSy2PqA/UCOGyi3Sk2FVs/LSkBvPSadmlHiMKL2dMa9ZIYD2gELRGr2CwN5m6IHpGJq44fUHdQMVIGnP/1kUVmPY11UGSWxpA+PByHOqrhfZU5tAMkOr3EEzrCWKFUbhC7OpGoGR5vvJcWdaI3HQwV02bkPxYbM6IOlpZxquzkAcDaeYB8rWTvWQRx92A+5rD3dm8r9BolkQD9+imrAKfA1lXqyuFipt0BGAVM7DyWLWzqiHmmtGZLdROnJGl0xq1SONJBbYupxvyg/ygnU0yZjCJXml6lHScYGA5y1hlM5OosZIwGSOl7a6vjxgjCZ/ruAg0BZhvC6w8GPrzhV8QlEV8WrwjhOOOv/63r2k4z7cXsR0Qb7FOAH+W+TACCW1sb1Ts5/ykNJS5cMfQSe7tXi931tDItk1ooUYjF+z91vjCldu53UolB/tpxcyn+tc8Y0eIP9ugT0PgoOKe3l7nqWrh2aMHkeaO39vWVdR26IhwFIgNlYpV7nBgcshM76vItho2FdHc5ViREBkxzk9uPtDz2PVWLPL6I= 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)(39860400002)(136003)(376002)(346002)(396003)(8936002)(54906003)(7416002)(52116002)(110136005)(186003)(16526019)(316002)(55236004)(956004)(6486002)(6666004)(1006002)(4326008)(2906002)(478600001)(6512007)(1076003)(6506007)(5660300002)(921005)(44832011)(83380400001)(86362001)(66556008)(26005)(2616005)(66476007)(66946007)(8676002)(110426009); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: eyOsrh9O5Y5Dkg1ZQUy8gHs7MyJZtdjM0KI7+Gno4o8LVbKWysjktlQfkhOuhBlFTbbWxRgAZMk1+2KKmTGs7Zn+LhDP0OaULLu5JJcpPmu+ZMni8yBpXevTlfGY32PzXKI6VeRxAn0tSrdRw5o/hbrUPAFnB1fnRD2ZkeD6F+CYIqG6u5OK4CZWaMD9GYGkn69Gym7wFwpuWgXtOs5npN4nAVlvwu9f9IWBd53feAvkup+9cTEaImbavzzTsalnXt08mt3pldp26KULZn8WEXWx0dsf1Lujrp33FoeHFUcxAiCmjYTsOeu6QZ0MrdgWi1F/Zl2FbdlFclWrM51v3dFdpbB9qdiZFqcKBz0p/dLOD/W5OctF6L8D3h/l/p7RqV8sUR7UaXPk+D64aRP8orRqxjrqVbmwGu4fPxuNpbFfFd2OeCEQPb25Gs5/LVcvvWBppWx66OfsoDDExdLANweVpS1bS/HKPYhAyRr+PXlo6ilKHcnGGGJHBScDltIFYT1Ci5OhHmVFstvbDFMPZZHQulgoMZEp6sGKegstpX3G15S2GTG2aIECz9SfXkDltTcBPWP2OHR3g3BV/QpzsPN7NUDXwRZEyDfIOR7LQ2pFAbj87k4fFzGrmpJpsAitB6ftNFB0OlnurWQ6Tt0HerJ5MclWPg98Re1BdvLeM1KXufbQGd4JyLPoFJdy7BpVgXVDTFmcuAFKB04Zn5dNA2ns9tjSRRIf2A0GLatqHLLiNxWLfgaGj0WAduxTGP74X/3XLI0Xh/LCzYC3gOrkIPoVfXLaFKUe4qPHGy7zgwGU9J+8yp/cAmEYH5M5T0Dcy6bGosEZ+oRUhgwU2Qqween3voWViOTXo3C+aIvzNAUFBW41lLn9iJKeJH8GHZ9HFhmfRSuFN5fvciM+C9sowI3sWjmlB0MgWBxy4C0wifNgYsSyiDHHtyMPKzHywHg7uOy7PP2xFadmDrbSgMMMfSgwQuCKawcjd46ivRSsHsEN17uvXNrUGmC167um6gjdNqP3dyqfDHgQ42UkclgHE2T0dlIucXVjzZwqAbKOnKuRwJSkEKEM43Z2aD6ufMbSoLxehDgzM1voZlNZsA0ENS6usolhhSSpTTfb/Xza9OlRec47odQNKpTqm9kyHS9xqv7ZJIcMG6QVKrG0+YwRyc5YsGV5XN1MiR69ekqIAojRhKEzCfp8uCKZDwRnXwOpplvxZlg7dLuVyYAbX6tkuYn+bx6l/v1O283b1BOKp6oTt51cyMz5orndoCgzzfSolF6rlWDU+Qf3neTiZyUeNLLJWGb7C5l4eXmJoZT9bBJqmz1DK9QKNTc3L4zygd5aZlYeYg/iFAfvZ86aeVQi/w== X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: cc86f187-1312-40fd-dff2-08d8cc44187b X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB5636.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Feb 2021 15:13:31.6827 (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: SWzSnfYyT+ZRTcqRbjrSESXHl+u+XA8MLcEHtxxpuToVlznycBdhUEgasR0XGVeTnXaN4NDAfecUBrOAvzYrdw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB6435 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210208_101339_425800_D478FD15 X-CRM114-Status: GOOD ( 16.91 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Calvin Johnson , Diana Madalina Craciun , linux-acpi@vger.kernel.org, linux.cj@gmail.com, Jakub Kicinski , Heiner Kallweit , "David S. Miller" , linux-arm-kernel@lists.infradead.org, Laurentiu Tudor Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 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 4daf94bb56a5..7bd33b930116 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 8447e56ba572..06e0ddcca8c9 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -2829,6 +2829,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 bc323fbdd21e..8314051d384a 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -1349,11 +1349,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;