From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753027AbbC0NgH (ORCPT ); Fri, 27 Mar 2015 09:36:07 -0400 Received: from smtp1.mail.ru ([94.100.179.111]:50567 "EHLO smtp1.mail.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752600AbbC0NgE (ORCPT ); Fri, 27 Mar 2015 09:36:04 -0400 X-Greylist: delayed 77694 seconds by postgrey-1.27 at vger.kernel.org; Fri, 27 Mar 2015 09:36:03 EDT Message-ID: <55155CBC.6010402@list.ru> Date: Fri, 27 Mar 2015 16:35:56 +0300 From: Stas Sergeev User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: netdev@vger.kernel.org CC: Linux kernel , Stas Sergeev , Florian Fainelli , Grant Likely , Rob Herring , devicetree@vger.kernel.org Subject: [PATCH 3/6] of_mdio: restructure of_phy_register_fixed_link() for further modifications References: <55155AFC.4050800@list.ru> In-Reply-To: <55155AFC.4050800@list.ru> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Spam: Not detected X-Mras: Ok Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is a no-op patch needed to separate code rearrangements from the actual changes. It allows to easily add code to the function without duplicating it for new and old fixed-phy DT binding. The subsequent patch therefore happily adds the code without duplications. CC: Florian Fainelli CC: Grant Likely CC: Rob Herring CC: netdev@vger.kernel.org CC: devicetree@vger.kernel.org CC: linux-kernel@vger.kernel.org Signed-off-by: Stas Sergeev --- drivers/of/of_mdio.c | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/drivers/of/of_mdio.c b/drivers/of/of_mdio.c index 1bd4305..b3dc1e6 100644 --- a/drivers/of/of_mdio.c +++ b/drivers/of/of_mdio.c @@ -301,22 +301,26 @@ int of_phy_register_fixed_link(struct device_node *np) "asym-pause"); of_node_put(fixed_link_node); phy = fixed_phy_register(PHY_POLL, &status, np); - return IS_ERR(phy) ? PTR_ERR(phy) : 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; + if (IS_ERR(phy)) + return PTR_ERR(phy); + } else { + /* 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); + if (IS_ERR(phy)) + return PTR_ERR(phy); + } else { + return -ENODEV; + } } - return -ENODEV; + return 0; } EXPORT_SYMBOL(of_phy_register_fixed_link); #endif -- 1.7.9.5