Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752623AbbHEOoN (ORCPT ); Wed, 5 Aug 2015 10:44:13 -0400 Received: from mail-bn1on0139.outbound.protection.outlook.com ([157.56.110.139]:29415 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751383AbbHEOoK (ORCPT ); Wed, 5 Aug 2015 10:44:10 -0400 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=freescale.com; freescale.mail.onmicrosoft.com; dkim=none (message not signed) header.d=none; From: Madalin Bucur To: , , , CC: , , , Madalin Bucur Subject: [PATCH RFC 1/2] of: separate fixed link parsing from registration Date: Wed, 5 Aug 2015 17:42:24 +0300 Message-ID: <1438785745-15517-2-git-send-email-madalin.bucur@freescale.com> X-Mailer: git-send-email 1.5.6.5 In-Reply-To: <1438785745-15517-1-git-send-email-madalin.bucur@freescale.com> References: <1438785745-15517-1-git-send-email-madalin.bucur@freescale.com> Reply-To: X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1;BY2FFO11FD008;1:E+gPxSCEHmhFtO4YsvwLNenLnFOKRY5DJPGb2dNiHZDVQg7a+rmGDVHcMzkLqwnD/micRCkgSFdBqMnnirhwBt2LNkfcctW/rMrq1f/mU1OH1+gM/hJtnpROLXciJTOaBm5i33fBClgIOyJ9+3uMW6iUX965Cw380+TtEcJeePy6hd2kdU+Lwv8f7L7AjtG272q9UaqIlZ1ZLwkp2RrnXX3Lp15hsoysn1t3BKWt8stMEWXYgdW7sNqUI0oDdL/2HwmvPOvmyu64FOF58+zEXximYRZGGk73bP4cg1b8hfE8nnDc727P/goQlrvSJA3z+SmXmNMt/b2bCCAH0a7U4A== X-Forefront-Antispam-Report: CIP:192.88.168.50;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10019020)(6009001)(2980300002)(339900001)(199003)(189002)(50466002)(19580405001)(19580395003)(6806004)(97736004)(5001770100001)(33646002)(4001540100001)(87936001)(48376002)(46102003)(189998001)(5001860100001)(85426001)(81156007)(64706001)(47776003)(49486002)(76176999)(106466001)(105606002)(50986999)(43066003)(104016003)(36756003)(50226001)(2950100001)(5001830100001)(77096005)(229853001)(68736005)(62966003)(86362001)(107886002)(77156002)(5001960100002)(5003940100001)(53806999)(217873001)(4001430100001);DIR:OUT;SFP:1102;SCL:1;SRVR:BLUPR03MB503;H:tx30smr01.am.freescale.net;FPR:;SPF:Fail;PTR:InfoDomainNonexistent;A:1;MX:1;LANG:en; MIME-Version: 1.0 Content-Type: text/plain X-Microsoft-Exchange-Diagnostics: 1;BLUPR03MB503;2:KIePHtu0VDCY88NIv40qDxe/Ut3wRPsIj/E/eoF7qEqLlEG2ub/2BtBqoGhTPgKRFlbjRecxK8qORKzRSL+lDuESE+FOi3FJOiU1abcAOVMiIHyA9Rfh1+t1QUAiOq5fDoBt39/eZdwtst6o1Q21MB+dxieY2T71AN2Oa/CA+KU=;3:zTktU5qjU5SJ5Tp8SQ7/YsGFhfRNx+JJdqbr9WnJDBrzRjGoYzJ4Dajg3wnXSV8NI7OzvYtXIqGHvcGT/y8iC9nIRi32qQTw1r5huJaj5AF86vJVwyYKV72ieLAWl4fd9ph6l9zbIbmZonHSxOWlp7HX9DDsYtQ2FEyhZ16mJyuHUUSEitYfnHwfUoW/is+yEZ2ZdKP6tizXPxck9eq5LstqxGosWVDRapmm6XZKvcY=;25:GaTbbwvYJWJALZLzNh9EFZ8hzFhPOy2LoO7tmKIJupQb0eXM982uLCvwWG+zEH5RimFWdr2BmDy33HpzIW7yMezYBRfU04JfbcEknltlx6MLtCmAvTfpWmrp1qICDGVbTlw/jTX9yGnXfMUp5v5xkHH+srXFQ2R+cnujcdtKcpNn9t09vSUrA3jNs6hKkk2pyuRBek2C77QjmrYEemjBmvpF0JCHab3DXh5CaAB5RvEN0oOBbFv0gCPVcu26wt5p9uVwuc4/x9YXzEeyXbGTEw== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BLUPR03MB503; X-Microsoft-Exchange-Diagnostics: 1;BLUPR03MB503;20:OdjJuT4LRPWnOfo8vhb+encpl383L7X1DEb9f5RXTJvcARgxKnxhfAObCLFHQXzIy4pbgHAErGPIe0CqziphpYUKpzyxa7Q4FPTyRpGgeZ8YZ0CqX+6TiWO+NVXJv2oNsw9qb544jEyaRvVWKZ12t7by1FqbZu2rG4BzjrE6EqsQbkQ7Q/ADFThH2FuO5ZceHkBXjI9w/xaMpQ6mXORggWxqnXBFU2bgpgMG4SaHUzyncg+nOORi7Eamxmh9MBLWdCLjkAB7DSJ6uAdbo9upstbR3tvclnSfASD6W6xLumpKcb18XsFQCIJgPCMc2BxTEZzSOaALpwHvDwKfYqntzXCP4u9rVwwXCAcnGziyWlM=;4:4ld/MzuJqMEoScq6cuDvdef3mjSkIvnMYQG87n8Y2sF8O1GspOudHCabvfcriR91P7UHgrqy+vybBZXQ8yNO9MFrIRj4hJsUtAYQ0bAaLZK5VeKgaSV4nsgxUBv5l4FRdY0s78Gsd1hOVjiEHDqaoNpxZEZCWvsSEDAWvH11H1thLADYSxML6+NCb2VgD2lJY+z6WqfTdqOsiZFrADBEROXBFKmZgZPba/IwOwNnXv9G+B5FkxEgWYqVcV2N6KU1tuEfhp22RenWJmRJ69XfwVXnY3uCRWLTyk4oKQU/YHo= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(5005006)(3002001);SRVR:BLUPR03MB503;BCL:0;PCL:0;RULEID:;SRVR:BLUPR03MB503; X-Forefront-PRVS: 06592CCE58 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BLUPR03MB503;23:UiGxqBThQHEac6FxJ/VOH9+0OeO1huDXJkneSSnevb?= =?us-ascii?Q?PXMH7Y/WTEovjB8iqn9l3psV7LenQOfLFBAhnjd7fT3yN5YXjIG5Rd1KkUoM?=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8bmL4q7qWxP+3TXLmdtJp7b94WVjjA9/8?= =?us-ascii?Q?IIU+gniRRKRFQJ7re/wFMfN5BNsUS5p/fxyohyqCnc0GCFMmH0lOHOgv4y9I?= =?us-ascii?Q?/MULO+sJtwaJ0P6E3iaa4SWBgCMOFXlGfd09Bb/zT8ibBtxlSHNrFwJWQwTp?= =?us-ascii?Q?WRoymM3Rop7SH4m0dg6v6iDfoBhmHHYIJdAXEBHlcIbWubSKXuYFV3l/JcAg?= =?us-ascii?Q?hSzpk2Ez5VC0/QEeLYWDDqS38RDwsN6AdD?= X-Microsoft-Exchange-Diagnostics: 1;BLUPR03MB503;5:Pi0+ukP3alq0CiAXVhjHby6eq8XAjzs/I4s5I8yTU3CMfl2Tcorom6Qiu6n+hy4DmG4FgABdKJLo6ONTYVGgPW2IgEg9cPWVU4GMpPeYROs0jdq+M/qU5ptL2IfPrX6tUGbB/Fd8437GQYmCfzUHRA==;24:fED5pJTYQwJyTsiWZKZgcgSV7+7qB5XcMgsdkseEOQmnYh+0hUtwEUKtseI4JE8qpEDjyLDzJvGF52kZn2/aqSd43exgPCz69Uuw6iuwQRk=;20:EVPjy8IFwn+MYVuJLizDuEh9aopI4TGq6u0f/gmrdYUHr/PkjKsD94l0Rfqy02ENy3Ksu76X5AKYd4mZztZKSA== X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Aug 2015 14:44:07.1169 (UTC) X-MS-Exchange-CrossTenant-Id: 710a03f5-10f6-4d38-9ff4-a80b81da590d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=710a03f5-10f6-4d38-9ff4-a80b81da590d;Ip=[192.88.168.50];Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR03MB503 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4390 Lines: 129 Some drivers may need to parse the fixed link values before registering the fixed link phy or access the status values. Separate the parsing from the actual registration and provide an export for the added parsing function. Signed-off-by: Madalin Bucur --- drivers/of/of_mdio.c | 52 +++++++++++++++++++++++++++++++------------------ include/linux/of_mdio.h | 9 +++++++++ 2 files changed, 42 insertions(+), 19 deletions(-) diff --git a/drivers/of/of_mdio.c b/drivers/of/of_mdio.c index fdc60db..b7e8288 100644 --- a/drivers/of/of_mdio.c +++ b/drivers/of/of_mdio.c @@ -284,43 +284,57 @@ bool of_phy_is_fixed_link(struct device_node *np) } EXPORT_SYMBOL(of_phy_is_fixed_link); -int of_phy_register_fixed_link(struct device_node *np) +int of_phy_parse_fixed_link(struct device_node *np, + struct fixed_phy_status *status) { - struct fixed_phy_status status = {}; struct device_node *fixed_link_node; const __be32 *fixed_link_prop; int len; - struct phy_device *phy; /* New binding */ fixed_link_node = of_get_child_by_name(np, "fixed-link"); if (fixed_link_node) { - status.link = 1; - status.duplex = of_property_read_bool(fixed_link_node, - "full-duplex"); - if (of_property_read_u32(fixed_link_node, "speed", &status.speed)) + status->link = 1; + status->duplex = of_property_read_bool(fixed_link_node, + "full-duplex"); + if (of_property_read_u32(fixed_link_node, "speed", + &status->speed)) return -EINVAL; - status.pause = of_property_read_bool(fixed_link_node, "pause"); - status.asym_pause = of_property_read_bool(fixed_link_node, - "asym-pause"); + status->pause = of_property_read_bool(fixed_link_node, + "pause"); + status->asym_pause = of_property_read_bool(fixed_link_node, + "asym-pause"); of_node_put(fixed_link_node); - phy = fixed_phy_register(PHY_POLL, &status, np); - return IS_ERR(phy) ? PTR_ERR(phy) : 0; + + return 0; } /* Old binding */ fixed_link_prop = of_get_property(np, "fixed-link", &len); if (fixed_link_prop && len == (5 * sizeof(__be32))) { - status.link = 1; - status.duplex = be32_to_cpu(fixed_link_prop[1]); - status.speed = be32_to_cpu(fixed_link_prop[2]); - status.pause = be32_to_cpu(fixed_link_prop[3]); - status.asym_pause = be32_to_cpu(fixed_link_prop[4]); - phy = fixed_phy_register(PHY_POLL, &status, np); - return IS_ERR(phy) ? PTR_ERR(phy) : 0; + status->link = 1; + status->duplex = be32_to_cpu(fixed_link_prop[1]); + status->speed = be32_to_cpu(fixed_link_prop[2]); + status->pause = be32_to_cpu(fixed_link_prop[3]); + status->asym_pause = be32_to_cpu(fixed_link_prop[4]); + + return 0; } return -ENODEV; } +EXPORT_SYMBOL(of_phy_parse_fixed_link); + +int of_phy_register_fixed_link(struct device_node *np) +{ + struct phy_device *phy; + struct fixed_phy_status status = {}; + + if (of_phy_parse_fixed_link(np, &status)) + return -ENODEV; + + phy = fixed_phy_register(PHY_POLL, &status, np); + return IS_ERR(phy) ? PTR_ERR(phy) : 0; +} EXPORT_SYMBOL(of_phy_register_fixed_link); #endif diff --git a/include/linux/of_mdio.h b/include/linux/of_mdio.h index 8f2237e..311b2cf 100644 --- a/include/linux/of_mdio.h +++ b/include/linux/of_mdio.h @@ -12,6 +12,8 @@ #include #include +struct fixed_phy_status; + #ifdef CONFIG_OF extern int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np); extern struct phy_device *of_phy_find_device(struct device_node *phy_np); @@ -70,9 +72,16 @@ static inline int of_mdio_parse_addr(struct device *dev, #endif /* CONFIG_OF */ #if defined(CONFIG_OF) && defined(CONFIG_FIXED_PHY) +extern int of_phy_parse_fixed_link(struct device_node *np, + struct fixed_phy_status *status); extern int of_phy_register_fixed_link(struct device_node *np); extern bool of_phy_is_fixed_link(struct device_node *np); #else +static inline int of_phy_parse_fixed_link(struct device_node *np, + struct fixed_phy_status *status) +{ + return -EINVAL; +} static inline int of_phy_register_fixed_link(struct device_node *np) { return -ENOSYS; -- 1.7.11.7 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/