Received: by 10.223.148.5 with SMTP id 5csp7395264wrq; Thu, 18 Jan 2018 05:03:14 -0800 (PST) X-Google-Smtp-Source: ACJfBotfokuMM2VIlNk5WLi36B6+wwV/6FhibnkQf+pRMvP27zffQiWAr8aoHF/62LBq2wzgJ/T+ X-Received: by 10.202.226.199 with SMTP id z190mr3034518oig.353.1516280594110; Thu, 18 Jan 2018 05:03:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516280593; cv=none; d=google.com; s=arc-20160816; b=hQshlVqCuQrVLFmmBlAaKrwRLQdsUss9EeRYcjYGWqHLTy5Tpfv+QR3i2uQprynCe6 G1nuB8sT5sCjiDxHwQBX5NN1QdubmmLiT3LZ9sGBf45hHdim4hSpnI/Iso+pPFAfq5mU PSU04feT8F+4ZB11VySLpy4oQxczthjNU1PK6WbwOc9PbG99qsqVmHTmQMEhyeMHk2UE 8Kv5sc/Lry7m+yS4pu6VEM4TUO+jj/sYNPwpyRHye97GHkHHl7RzydQ/Uh2mAgmEVM8U K6XOA1Z6mNeXhNZsttnY/KgkfBQx0grcaZcZwLpbMqlv1yXLcKQGrDx1D2M0GYFCx2Mg FBgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=059l5gKkJlkImR9aCud73phj979kYw7YJcePrZ6w1b4=; b=NgoDoVQNwUijsIC4Twucrocb1wy+l5H3RlK+oF/DRhzrYHfWm04ulQHopDzlzrenYl oTp9KOQLVo6AUaQDJNZoTpBVp8FTviGfB7t1DL7I6tkkJUoEgWIRypNnC8gYMhR6U3wf WsC57CIjJsW/kZTILBwJfcmxASemN2PQkUWABmPoCdtmi9vxfeJXvwX3gG2N+xxtwEFO 8IrcgQPMrfl6hHUNbf836U77RZ1/7Qr4LsN3vVjdb69hQrSTVYRS5tZTKaWEjeTcnHwj SOiAB1NzXUO2SH+3ggwFVHzfE7MK7+CXjVJkwQpwr4Y62YjIbCgnJ1/DLCaFvyFai/ax CZBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@semihalf-com.20150623.gappssmtp.com header.s=20150623 header.b=Qmtis4CO; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k12si5255487pgc.587.2018.01.18.05.02.59; Thu, 18 Jan 2018 05:03:13 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@semihalf-com.20150623.gappssmtp.com header.s=20150623 header.b=Qmtis4CO; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932347AbeARMcO (ORCPT + 99 others); Thu, 18 Jan 2018 07:32:14 -0500 Received: from mail-lf0-f67.google.com ([209.85.215.67]:41434 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932352AbeARMcJ (ORCPT ); Thu, 18 Jan 2018 07:32:09 -0500 Received: by mail-lf0-f67.google.com with SMTP id f136so4967817lff.8 for ; Thu, 18 Jan 2018 04:32:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=059l5gKkJlkImR9aCud73phj979kYw7YJcePrZ6w1b4=; b=Qmtis4COC1iXSD3JEkEgTQtvefyCaTo/0r4ipqNbY9XgVhXznN5c5eO/BGXaP6f1dQ Cjf8145X0dQbmWrZ476kqc1A7rL7GX5T42odYC0+cwQmS+cgCtX6ron8EAQFL7yZAGoz uvNXtDuqdjX9x97JmhSuqXbP5ZeCGU7duCyYk1xiM1LI97Hs9yzDPIkCvh8gDiOhm8zP IXHd+rBU2IxgKhIpR8zD6G+12tUyxB8Kvq8VSg1iDz2LuuPexa1WxdvNjsLvMP6n8lJs cJ3YttQ0rxUGcy1/1r5fkEhLQ4oe9Ysnm/tgZpYk48FQYJqX66J3bxsrMlPqI2JOg6c4 1yrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=059l5gKkJlkImR9aCud73phj979kYw7YJcePrZ6w1b4=; b=UsI0tTXhHUaN5MRXObkJ768VvftF2Q7c4FRc8JALHBAAZfmIhe9lhzBtFvvTZ9GaGt NiJgCXsMof2yqcXE1uzQ9hchwbq9kvmqp15lS7oUlp2BX17uzqd2Jxudouu//2674kez 7O4ylmNHQbN4ALpZMPF80bdcTtv9+KbHJc4vG/pQC8Ov57I7cdJJ5OH1RCyH8z8Ri88b WQM+lmTntXX9XILgJBDZ+Np07NupInneooYbrtcoD6tvBOBHOqeYearkAkUEQ1HGyYgT 5rbqgYJ6QGqazaGLEfprUAEkYeJao4VxqYdNY9ZzB3JMI+UZKuyvLTyfKU92x8FlAQTS RJUg== X-Gm-Message-State: AKwxyteXv+LROPzwHhkVOAGjW1R0u2ezuEddCwMephUw4uEUI2BSe8/D 5dik40EQCvLobtdmz5dwZsz5+JSGjA4= X-Received: by 10.25.167.85 with SMTP id q82mr7518038lfe.112.1516278727782; Thu, 18 Jan 2018 04:32:07 -0800 (PST) Received: from gilgamesh.semihalf.com (31-172-191-173.noc.fibertech.net.pl. [31.172.191.173]) by smtp.gmail.com with ESMTPSA id s23sm1303906ljs.1.2018.01.18.04.32.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 18 Jan 2018 04:32:06 -0800 (PST) From: Marcin Wojtas To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, linux-acpi@vger.kernel.org Cc: graeme.gregory@linaro.org, davem@davemloft.net, linux@armlinux.org.uk, rafael.j.wysocki@intel.com, andrew@lunn.ch, f.fainelli@gmail.com, antoine.tenart@free-electrons.com, thomas.petazzoni@free-electrons.com, gregory.clement@free-electrons.com, stefanc@marvell.com, nadavh@marvell.com, neta@marvell.com, ard.biesheuvel@linaro.org, mw@semihalf.com, jaz@semihalf.com, tn@semihalf.com Subject: [net-next: PATCH v4 6/7] net: mvpp2: use device_*/fwnode_* APIs instead of of_* Date: Thu, 18 Jan 2018 13:31:43 +0100 Message-Id: <1516278704-17141-7-git-send-email-mw@semihalf.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1516278704-17141-1-git-send-email-mw@semihalf.com> References: <1516278704-17141-1-git-send-email-mw@semihalf.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org OF functions can be used only for the driver using DT. As a preparation for introducing ACPI support in mvpp2 driver, use struct fwnode_handle in order to obtain properties from the hardware description. This patch replaces of_* function with device_*/fwnode_* where possible in the mvpp2. Signed-off-by: Marcin Wojtas --- drivers/net/ethernet/marvell/mvpp2.c | 45 +++++++++++--------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/drivers/net/ethernet/marvell/mvpp2.c b/drivers/net/ethernet/marvell/mvpp2.c index 7f42d90..f16448e 100644 --- a/drivers/net/ethernet/marvell/mvpp2.c +++ b/drivers/net/ethernet/marvell/mvpp2.c @@ -932,6 +932,9 @@ struct mvpp2_port { struct mvpp2 *priv; + /* Firmware node associated to the port */ + struct fwnode_handle *fwnode; + /* Per-port registers' base address */ void __iomem *base; void __iomem *stats_base; @@ -7711,17 +7714,16 @@ static bool mvpp2_port_has_tx_irqs(struct mvpp2 *priv, } static void mvpp2_port_copy_mac_addr(struct net_device *dev, struct mvpp2 *priv, - struct device_node *port_node, + struct fwnode_handle *fwnode, char **mac_from) { struct mvpp2_port *port = netdev_priv(dev); char hw_mac_addr[ETH_ALEN] = {0}; - const char *dt_mac_addr; + char fw_mac_addr[ETH_ALEN]; - dt_mac_addr = of_get_mac_address(port_node); - if (dt_mac_addr && is_valid_ether_addr(dt_mac_addr)) { - *mac_from = "device tree"; - ether_addr_copy(dev->dev_addr, dt_mac_addr); + if (fwnode_get_mac_address(fwnode, fw_mac_addr, ETH_ALEN)) { + *mac_from = "firmware node"; + ether_addr_copy(dev->dev_addr, fw_mac_addr); return; } @@ -7740,13 +7742,14 @@ static void mvpp2_port_copy_mac_addr(struct net_device *dev, struct mvpp2 *priv, /* Ports initialization */ static int mvpp2_port_probe(struct platform_device *pdev, - struct device_node *port_node, + struct fwnode_handle *port_fwnode, struct mvpp2 *priv) { struct device_node *phy_node; struct phy *comphy; struct mvpp2_port *port; struct mvpp2_port_pcpu *port_pcpu; + struct device_node *port_node = to_of_node(port_fwnode); struct net_device *dev; struct resource *res; char *mac_from = ""; @@ -7773,7 +7776,7 @@ static int mvpp2_port_probe(struct platform_device *pdev, return -ENOMEM; phy_node = of_parse_phandle(port_node, "phy", 0); - phy_mode = of_get_phy_mode(port_node); + phy_mode = fwnode_get_phy_mode(port_fwnode); if (phy_mode < 0) { dev_err(&pdev->dev, "incorrect phy mode\n"); err = phy_mode; @@ -7789,7 +7792,7 @@ static int mvpp2_port_probe(struct platform_device *pdev, comphy = NULL; } - if (of_property_read_u32(port_node, "port-id", &id)) { + if (fwnode_property_read_u32(port_fwnode, "port-id", &id)) { err = -EINVAL; dev_err(&pdev->dev, "missing port-id value\n"); goto err_free_netdev; @@ -7820,7 +7823,7 @@ static int mvpp2_port_probe(struct platform_device *pdev, /* the link irq is optional */ port->link_irq = 0; - if (of_property_read_bool(port_node, "marvell,loopback")) + if (fwnode_property_read_bool(port_fwnode, "marvell,loopback")) port->flags |= MVPP2_F_LOOPBACK; port->id = id; @@ -7845,8 +7848,8 @@ static int mvpp2_port_probe(struct platform_device *pdev, MVPP21_MIB_COUNTERS_OFFSET + port->gop_id * MVPP21_MIB_COUNTERS_PORT_SZ; } else { - if (of_property_read_u32(port_node, "gop-port-id", - &port->gop_id)) { + if (fwnode_property_read_u32(port_fwnode, "gop-port-id", + &port->gop_id)) { err = -EINVAL; dev_err(&pdev->dev, "missing gop-port-id value\n"); goto err_deinit_qvecs; @@ -7876,7 +7879,7 @@ static int mvpp2_port_probe(struct platform_device *pdev, mutex_init(&port->gather_stats_lock); INIT_DELAYED_WORK(&port->stats_work, mvpp2_gather_hw_statistics); - mvpp2_port_copy_mac_addr(dev, priv, port_node, &mac_from); + mvpp2_port_copy_mac_addr(dev, priv, port_fwnode, &mac_from); port->tx_ring_size = MVPP2_MAX_TXD_DFLT; port->rx_ring_size = MVPP2_MAX_RXD_DFLT; @@ -8194,8 +8197,8 @@ static int mvpp2_init(struct platform_device *pdev, struct mvpp2 *priv) static int mvpp2_probe(struct platform_device *pdev) { - struct device_node *dn = pdev->dev.of_node; - struct device_node *port_node; + struct fwnode_handle *fwnode = pdev->dev.fwnode; + struct fwnode_handle *port_fwnode; struct mvpp2 *priv; struct resource *res; void __iomem *base; @@ -8315,8 +8318,8 @@ static int mvpp2_probe(struct platform_device *pdev) } /* Initialize ports */ - for_each_available_child_of_node(dn, port_node) { - err = mvpp2_port_probe(pdev, port_node, priv); + fwnode_for_each_available_child_node(fwnode, port_fwnode) { + err = mvpp2_port_probe(pdev, port_fwnode, priv); if (err < 0) goto err_port_probe; } @@ -8347,7 +8350,7 @@ static int mvpp2_probe(struct platform_device *pdev) err_port_probe: i = 0; - for_each_available_child_of_node(dn, port_node) { + fwnode_for_each_available_child_node(fwnode, port_fwnode) { if (priv->port_list[i]) mvpp2_port_remove(priv->port_list[i]); i++; @@ -8366,14 +8369,14 @@ static int mvpp2_probe(struct platform_device *pdev) static int mvpp2_remove(struct platform_device *pdev) { struct mvpp2 *priv = platform_get_drvdata(pdev); - struct device_node *dn = pdev->dev.of_node; - struct device_node *port_node; + struct fwnode_handle *fwnode = pdev->dev.fwnode; + struct fwnode_handle *port_fwnode; int i = 0; flush_workqueue(priv->stats_queue); destroy_workqueue(priv->stats_queue); - for_each_available_child_of_node(dn, port_node) { + fwnode_for_each_available_child_node(fwnode, port_fwnode) { if (priv->port_list[i]) { mutex_destroy(&priv->port_list[i]->gather_stats_lock); mvpp2_port_remove(priv->port_list[i]); -- 2.7.4