From patchwork Fri Nov 1 13:02:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 178305 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp456595ill; Fri, 1 Nov 2019 06:02:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqzOOvN45gWiOMtBCwFoa2kKhRVMv1JBcQMrMCT6SyKL9vnkcVR7gPtaIZO55ILU1LcWmdh+ X-Received: by 2002:a17:906:6d84:: with SMTP id h4mr9770970ejt.262.1572613355783; Fri, 01 Nov 2019 06:02:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572613355; cv=none; d=google.com; s=arc-20160816; b=D5O6gb6/cWEFoI+Ck+KOqLVxqO2S8wPMHN0uEEHayH0haZx235QueB7BYiwc4zw1In 6yrr1BBxzMhLjY660IWtv4ZPYqZcms9iXxWoiCgsEQsm7DRqkDPLl7jvgqOsNYSZgOta fHbhqqqjNaYGxfxCLSCtUaeZ7wYBpRyQUs0/hWZwlNyAC105voiQoodWyOibem7aIXhM LzMwYPuDoTkIPcs1QC/BKfnZg9fo4cs21MIpjZW5ifgV6frb5uvrVbXVlABRBcOG3o7S 3pSUvltl7tg+h6j6d1g9z3Zu6XSPKDl7LDMQD7TedteJ1ZGYxNitgW4DDE+8XtfO1T3z c9rA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=qWrGmW+JKfE+kYfM3N9oChJLu02yWLmRgyqdy1iXI+Y=; b=r62ik75IMcKTymrLQiZXtrHjkB7Ed6Jqwmy5N/n961tmO9YBEp5B03txnpnlS/2+oO D1/QDuLMqPRWkrX6FFo7Ha06f3GYW1CsyeyNUmJf/Vk6qoP7vi/6QZfi+wVVGdCnf61s HlsP/FPZLOghQAuEyeMLztoREzGhwXQZczusyWMOBP6SUUBDOvhXRbUUfspj3DGet/y5 /OYgsqzmKGRlTPEyLi6p9bitXVSrkqaS1NsT7WWQnQuGZjz4biv8eAqkE9175IdVnr8T vvqb49p0N7PrwYXGGxNiJ8rPDbYCSGdjijMqe+wSQOPzJmOdGH2Lne4cNhIIGLSC+Z7i fcxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zPuFRVJF; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q8si281981edi.445.2019.11.01.06.02.35; Fri, 01 Nov 2019 06:02:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of netdev-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=@linaro.org header.s=google header.b=zPuFRVJF; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727083AbfKANCe (ORCPT + 9 others); Fri, 1 Nov 2019 09:02:34 -0400 Received: from mail-lf1-f67.google.com ([209.85.167.67]:42641 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726832AbfKANCe (ORCPT ); Fri, 1 Nov 2019 09:02:34 -0400 Received: by mail-lf1-f67.google.com with SMTP id z12so7175164lfj.9 for ; Fri, 01 Nov 2019 06:02:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=qWrGmW+JKfE+kYfM3N9oChJLu02yWLmRgyqdy1iXI+Y=; b=zPuFRVJFf0nZV1hHZgd/tJ25N032iYOUBU/EDromfHD8lfw/iOGoTgArGujay2ZHph 08ejTwvWXxXD3Kt1EOpeBQ1mzpV1sX5gid7mDVtgIcvQLBMIOzNvz1+/GX8tk3hTxf6e 0xfQbjMhmHrhQOMkxbMCEZKna8lAHv5EwZwai3tToi4N/IR8op+iQWJtmZ/dswzQfkEo F+0yR/Hlay4H4JrRLk/tDUkUirVAV0a9TBuvTh1t9VAsGoSmSnKMOHiK90/l9chuoc3y KBHSHtRUjaIT8jFhQr6iNrSWW+zFh8URcHNqItgR3m20fl33FhxvXOv+xZB2F+FoIHYh a+oQ== 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:mime-version:content-transfer-encoding; bh=qWrGmW+JKfE+kYfM3N9oChJLu02yWLmRgyqdy1iXI+Y=; b=akatH+obobldXIllxK4826yb7VyyyfIvRIEcT2X0c8ftecGqUcndJQnW1OC1l5/d52 szYPKXiEAVIwdzyeBFW2RcWz0WXSkcyoRg1bkEQb072q18cfj8LhjuHesyHXAZBixdc1 fq8Uoh35DWUBCx8xzB4tquCghXtdJTveMtkGbhS12ByonNrEy3pWAd+5i59oghuwiPbB KijXIa8VP0p1XU8v4sPAfjhYbvQwldJvPios4nSR2qnLN37HWca8r2AS2+asRjlFzDMP JrjZV+dB8frxpbm5boWcl8Tzec/6gstA5N8Bgf3ohK3wW649FkCT1YTc2B+jXeXtV00u 67BA== X-Gm-Message-State: APjAAAXUpiPxvYc87P/wu7sb/r5potuYt3g0Cv2+/klXN8GRI5UxMzzN oQNFfFPJBJn1JbF7NOqwY2Ml9x31g58uRQ== X-Received: by 2002:a19:da1a:: with SMTP id r26mr1536302lfg.60.1572613351412; Fri, 01 Nov 2019 06:02:31 -0700 (PDT) Received: from localhost.bredbandsbolaget (c-79c8225c.014-348-6c756e10.bbcust.telenor.se. [92.34.200.121]) by smtp.gmail.com with ESMTPSA id c3sm2516749lfi.32.2019.11.01.06.02.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Nov 2019 06:02:30 -0700 (PDT) From: Linus Walleij To: netdev@vger.kernel.org, "David S . Miller" Cc: Arnd Bergmann , Jakub Kicinski , Linus Walleij Subject: [PATCH net-next 01/10 v2] wan: ixp4xx_hss: fix compile-testing on 64-bit Date: Fri, 1 Nov 2019 14:02:15 +0100 Message-Id: <20191101130224.7964-2-linus.walleij@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191101130224.7964-1-linus.walleij@linaro.org> References: <20191101130224.7964-1-linus.walleij@linaro.org> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Arnd Bergmann Change the driver to use portable integer types to avoid warnings during compile testing: drivers/net/wan/ixp4xx_hss.c:863:21: error: cast to 'u32 *' (aka 'unsigned int *') from smaller integer type 'int' [-Werror,-Wint-to-pointer-cast] memcpy_swab32(mem, (u32 *)((int)skb->data & ~3), bytes / 4); ^ drivers/net/wan/ixp4xx_hss.c:979:12: error: incompatible pointer types passing 'u32 *' (aka 'unsigned int *') to parameter of type 'dma_addr_t *' (aka 'unsigned long long *') [-Werror,-Wincompatible-pointer-types] &port->desc_tab_phys))) ^~~~~~~~~~~~~~~~~~~~ include/linux/dmapool.h:27:20: note: passing argument to parameter 'handle' here dma_addr_t *handle); ^ Signed-off-by: Arnd Bergmann Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Just resending with the rest --- drivers/net/wan/ixp4xx_hss.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.21.0 diff --git a/drivers/net/wan/ixp4xx_hss.c b/drivers/net/wan/ixp4xx_hss.c index ea6ee6a608ce..e7619cec978a 100644 --- a/drivers/net/wan/ixp4xx_hss.c +++ b/drivers/net/wan/ixp4xx_hss.c @@ -258,7 +258,7 @@ struct port { struct hss_plat_info *plat; buffer_t *rx_buff_tab[RX_DESCS], *tx_buff_tab[TX_DESCS]; struct desc *desc_tab; /* coherent */ - u32 desc_tab_phys; + dma_addr_t desc_tab_phys; unsigned int id; unsigned int clock_type, clock_rate, loopback; unsigned int initialized, carrier; @@ -858,7 +858,7 @@ static int hss_hdlc_xmit(struct sk_buff *skb, struct net_device *dev) dev->stats.tx_dropped++; return NETDEV_TX_OK; } - memcpy_swab32(mem, (u32 *)((int)skb->data & ~3), bytes / 4); + memcpy_swab32(mem, (u32 *)((uintptr_t)skb->data & ~3), bytes / 4); dev_kfree_skb(skb); #endif From patchwork Fri Nov 1 13:02:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 178306 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp456688ill; Fri, 1 Nov 2019 06:02:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqzRrXr+VJvKB11PuB+wG84QkAwKbW81BIZAMJtO1kcFGIThsNvx6I+GtptToTeupw6a6am3 X-Received: by 2002:aa7:db48:: with SMTP id n8mr12413486edt.179.1572613358721; Fri, 01 Nov 2019 06:02:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572613358; cv=none; d=google.com; s=arc-20160816; b=Y2QJFGZhAb5DGzDgtR4XgqCuQBehuHX8SxtqXF99iWTuNBipyVoceS7TbvDj5AAuFD qeyPbhmiCUXdgFnVgAMKkudu2JtpWa3NDjclPyURDhktH/Pun0VLfZUHSOfmp0xsXvph 3iGCQOfUghnzTUTTU/Em/Rp5Tz6nxoefXh63pS+zpAK1mMv44Hj1PwaHdQnEdOrgt1hR Ea1UZorfNgI9t+JqMuSvu+x87ds5ol8V5YKntLH8HSKR8Zun6sp4cuN61t2Q/MEbgryW yyWwe7V2otpqy9HSpr7FHRMXmkHGfajBxhy8WuapxwIpCQevf8notLwleBkfHMDusmYT bq5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=a4QFBGtv8Ambs2lPqLYyKhszNYgCXJYa4r0rQuatVxU=; b=lC8Nceo9TkauFO+fCIx51tGr0edpb/FEq9y+RlHldrS8VxVsspEKgk/ig/C4P39xOv bllVlFyH+j4srHnsBJGOOD+b4T71omtilski9duAGvn2esGmdSQDglRzKB0wLj3HSL93 Pvr9LtFtal+rXnjCYU8h5ikH+Rwyx95P01zLA6BQwi8KAxtcvnQ+6JxcNwHbXc/wF5kZ Sa7lvj/urPjwgXwzHv9YKN6jrAyP4cWXvVHuobDJPeA4g8iUbxtB9JDI55Vta8sWJlXy FERkvwv1sm0SaqXQ5x6bZ6RIbm9WZm1ydkzGbf9X+wq85TjmxpuL6B4mUEg7kOC0AVA1 W3EA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=P59WIHG4; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q8si281981edi.445.2019.11.01.06.02.38; Fri, 01 Nov 2019 06:02:38 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of netdev-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=@linaro.org header.s=google header.b=P59WIHG4; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727108AbfKANCh (ORCPT + 9 others); Fri, 1 Nov 2019 09:02:37 -0400 Received: from mail-lj1-f194.google.com ([209.85.208.194]:36348 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727085AbfKANCh (ORCPT ); Fri, 1 Nov 2019 09:02:37 -0400 Received: by mail-lj1-f194.google.com with SMTP id x9so5365247lji.3 for ; Fri, 01 Nov 2019 06:02:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=a4QFBGtv8Ambs2lPqLYyKhszNYgCXJYa4r0rQuatVxU=; b=P59WIHG4DsDRxEwbGNLTqhMTnFGqBqez++WKoCxBwO41FU4DIuFxzw89udcJbdi2pJ mqqXl4WkB99loqOWQZ1C/cB1Jgc443vzfVLjAA1g0zXgC70d0IRvw/f+qlXYewA5iRVX fw9g2XgdXnYu2BXYuOFyvRhgFwDX+gJWk7bXfRsGE/3KjafDQllJFjcfNEnNfE9dTXVo dJ07UTn46DePn4nWT1PUl00C8MbfaZBEtJmS4/A7XWYweZjnRt7X2/q71lEyULdDNZ4Y 2OLdLQOMhcMeEx4+H3KnqKTcUb+q17IhZFjQGepd1HyKoKxpKse3DDfebYBZNNJxFA3b /cOw== 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:mime-version:content-transfer-encoding; bh=a4QFBGtv8Ambs2lPqLYyKhszNYgCXJYa4r0rQuatVxU=; b=d3+rOZhj2FjcKzlIw4c+O41UenjtTjhcpBt2SaujVwuNsHqlzIyDHZU84t9KvDXpbC uBwz5AF8D/n7TrFrZ94oHUMxcsQN6tvg9tCY934oNqN4KUE4vVAqx/12n0zj/H1fHhO1 GOxgLeGM49v/J13xfIdo1+rdOzquRLfe5/EhPQEFQe+RHvonkiGRfvF9v4RTgIVJkVCU AUrHPEp4myhESwyqVuhJNdDy/JUa/mBrFvhq3AFfqUiyTDaZVyTtqga2kMLJ99aQnuvr E0uP/Wc4f+9yrsD/tahZp6Sn1+374LbfqmBZo/fm8O4UtR2omonma7jsYIwGbRaFh6HK bIfg== X-Gm-Message-State: APjAAAUd6yDo+Pi9zszE/zoEzvedQX4ytgZWrHj0xqE3XSZAoPbKMGj/ mRZwv9D9BKvQuW/+ZOFPjQTo8/eEKFzrXw== X-Received: by 2002:a05:651c:10c:: with SMTP id a12mr8190025ljb.93.1572613353735; Fri, 01 Nov 2019 06:02:33 -0700 (PDT) Received: from localhost.bredbandsbolaget (c-79c8225c.014-348-6c756e10.bbcust.telenor.se. [92.34.200.121]) by smtp.gmail.com with ESMTPSA id c3sm2516749lfi.32.2019.11.01.06.02.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Nov 2019 06:02:32 -0700 (PDT) From: Linus Walleij To: netdev@vger.kernel.org, "David S . Miller" Cc: Arnd Bergmann , Jakub Kicinski , Linus Walleij Subject: [PATCH net-next 02/10 v2] wan: ixp4xx_hss: prepare compile testing Date: Fri, 1 Nov 2019 14:02:16 +0100 Message-Id: <20191101130224.7964-3-linus.walleij@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191101130224.7964-1-linus.walleij@linaro.org> References: <20191101130224.7964-1-linus.walleij@linaro.org> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Arnd Bergmann The ixp4xx_hss driver needs the platform data definition and the system clock rate to be compiled. Move both into a new platform_data header file. This is a prerequisite for compile testing, but turning on compile testing requires further patches to isolate the SoC headers. Signed-off-by: Arnd Bergmann Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Drop the change actually enabling compile testing in Kconfig but keep the rest around so we are prepared. (Need the SoC include changes to actually enable it.) - Rename to "prepare" --- arch/arm/mach-ixp4xx/goramo_mlr.c | 4 +++ arch/arm/mach-ixp4xx/include/mach/platform.h | 9 ----- drivers/net/wan/Kconfig | 3 +- drivers/net/wan/ixp4xx_hss.c | 35 +++++++++++--------- include/linux/platform_data/wan_ixp4xx_hss.h | 17 ++++++++++ 5 files changed, 43 insertions(+), 25 deletions(-) create mode 100644 include/linux/platform_data/wan_ixp4xx_hss.h -- 2.21.0 diff --git a/arch/arm/mach-ixp4xx/goramo_mlr.c b/arch/arm/mach-ixp4xx/goramo_mlr.c index a0e0b6b7dc5c..93b7afeee142 100644 --- a/arch/arm/mach-ixp4xx/goramo_mlr.c +++ b/arch/arm/mach-ixp4xx/goramo_mlr.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -405,6 +406,9 @@ static void __init gmlr_init(void) if (hw_bits & CFG_HW_HAS_HSS1) device_tab[devices++] = &device_hss_tab[1]; /* max index 5 */ + hss_plat[0].timer_freq = ixp4xx_timer_freq; + hss_plat[1].timer_freq = ixp4xx_timer_freq; + gpio_request(GPIO_SCL, "SCL/clock"); gpio_request(GPIO_SDA, "SDA/data"); gpio_request(GPIO_STR, "strobe"); diff --git a/arch/arm/mach-ixp4xx/include/mach/platform.h b/arch/arm/mach-ixp4xx/include/mach/platform.h index 342acbe20f7c..04ef8025accc 100644 --- a/arch/arm/mach-ixp4xx/include/mach/platform.h +++ b/arch/arm/mach-ixp4xx/include/mach/platform.h @@ -104,15 +104,6 @@ struct eth_plat_info { u8 hwaddr[6]; }; -/* Information about built-in HSS (synchronous serial) interfaces */ -struct hss_plat_info { - int (*set_clock)(int port, unsigned int clock_type); - int (*open)(int port, void *pdev, - void (*set_carrier_cb)(void *pdev, int carrier)); - void (*close)(int port, void *pdev); - u8 txreadyq; -}; - /* * Frequency of clock used for primary clocksource */ diff --git a/drivers/net/wan/Kconfig b/drivers/net/wan/Kconfig index dd1a147f2971..4530840e15ef 100644 --- a/drivers/net/wan/Kconfig +++ b/drivers/net/wan/Kconfig @@ -315,7 +315,8 @@ config DSCC4_PCI_RST config IXP4XX_HSS tristate "Intel IXP4xx HSS (synchronous serial port) support" - depends on HDLC && ARM && ARCH_IXP4XX && IXP4XX_NPE && IXP4XX_QMGR + depends on HDLC && IXP4XX_NPE && IXP4XX_QMGR + depends on ARCH_IXP4XX help Say Y here if you want to use built-in HSS ports on IXP4xx processor. diff --git a/drivers/net/wan/ixp4xx_hss.c b/drivers/net/wan/ixp4xx_hss.c index e7619cec978a..7c5cf77e9ef1 100644 --- a/drivers/net/wan/ixp4xx_hss.c +++ b/drivers/net/wan/ixp4xx_hss.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -1182,14 +1183,14 @@ static int hss_hdlc_attach(struct net_device *dev, unsigned short encoding, } } -static u32 check_clock(u32 rate, u32 a, u32 b, u32 c, +static u32 check_clock(u32 timer_freq, u32 rate, u32 a, u32 b, u32 c, u32 *best, u32 *best_diff, u32 *reg) { /* a is 10-bit, b is 10-bit, c is 12-bit */ u64 new_rate; u32 new_diff; - new_rate = ixp4xx_timer_freq * (u64)(c + 1); + new_rate = timer_freq * (u64)(c + 1); do_div(new_rate, a * (c + 1) + b + 1); new_diff = abs((u32)new_rate - rate); @@ -1201,40 +1202,43 @@ static u32 check_clock(u32 rate, u32 a, u32 b, u32 c, return new_diff; } -static void find_best_clock(u32 rate, u32 *best, u32 *reg) +static void find_best_clock(u32 timer_freq, u32 rate, u32 *best, u32 *reg) { u32 a, b, diff = 0xFFFFFFFF; - a = ixp4xx_timer_freq / rate; + a = timer_freq / rate; if (a > 0x3FF) { /* 10-bit value - we can go as slow as ca. 65 kb/s */ - check_clock(rate, 0x3FF, 1, 1, best, &diff, reg); + check_clock(timer_freq, rate, 0x3FF, 1, 1, best, &diff, reg); return; } if (a == 0) { /* > 66.666 MHz */ a = 1; /* minimum divider is 1 (a = 0, b = 1, c = 1) */ - rate = ixp4xx_timer_freq; + rate = timer_freq; } - if (rate * a == ixp4xx_timer_freq) { /* don't divide by 0 later */ - check_clock(rate, a - 1, 1, 1, best, &diff, reg); + if (rate * a == timer_freq) { /* don't divide by 0 later */ + check_clock(timer_freq, rate, a - 1, 1, 1, best, &diff, reg); return; } for (b = 0; b < 0x400; b++) { u64 c = (b + 1) * (u64)rate; - do_div(c, ixp4xx_timer_freq - rate * a); + do_div(c, timer_freq - rate * a); c--; if (c >= 0xFFF) { /* 12-bit - no need to check more 'b's */ if (b == 0 && /* also try a bit higher rate */ - !check_clock(rate, a - 1, 1, 1, best, &diff, reg)) + !check_clock(timer_freq, rate, a - 1, 1, 1, best, + &diff, reg)) return; - check_clock(rate, a, b, 0xFFF, best, &diff, reg); + check_clock(timer_freq, rate, a, b, 0xFFF, best, + &diff, reg); return; } - if (!check_clock(rate, a, b, c, best, &diff, reg)) + if (!check_clock(timer_freq, rate, a, b, c, best, &diff, reg)) return; - if (!check_clock(rate, a, b, c + 1, best, &diff, reg)) + if (!check_clock(timer_freq, rate, a, b, c + 1, best, &diff, + reg)) return; } } @@ -1285,8 +1289,9 @@ static int hss_hdlc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) port->clock_type = clk; /* Update settings */ if (clk == CLOCK_INT) - find_best_clock(new_line.clock_rate, &port->clock_rate, - &port->clock_reg); + find_best_clock(port->plat->timer_freq, + new_line.clock_rate, + &port->clock_rate, &port->clock_reg); else { port->clock_rate = 0; port->clock_reg = CLK42X_SPEED_2048KHZ; diff --git a/include/linux/platform_data/wan_ixp4xx_hss.h b/include/linux/platform_data/wan_ixp4xx_hss.h new file mode 100644 index 000000000000..d525a0feb9e1 --- /dev/null +++ b/include/linux/platform_data/wan_ixp4xx_hss.h @@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __PLATFORM_DATA_WAN_IXP4XX_HSS_H +#define __PLATFORM_DATA_WAN_IXP4XX_HSS_H + +#include + +/* Information about built-in HSS (synchronous serial) interfaces */ +struct hss_plat_info { + int (*set_clock)(int port, unsigned int clock_type); + int (*open)(int port, void *pdev, + void (*set_carrier_cb)(void *pdev, int carrier)); + void (*close)(int port, void *pdev); + u8 txreadyq; + u32 timer_freq; +}; + +#endif From patchwork Fri Nov 1 13:02:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 178307 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp456733ill; Fri, 1 Nov 2019 06:02:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqzsFHHX44tsUeLxcg+PLTQqCciJq9Le15QXpJBzOOx9ao9EUeP/YeBEXKFe8sFARFbVfW6D X-Received: by 2002:a17:906:4f14:: with SMTP id t20mr9290943eju.239.1572613360544; Fri, 01 Nov 2019 06:02:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572613360; cv=none; d=google.com; s=arc-20160816; b=T65mgtBa4U5bi6nKGKGOyXcg52jf1G1bLue4PqaM6Du9Jb16Yi2Wi7l5wgCIrRlPPD S9OM//IHKDGoy0Xg1QjDA6VaEucabHY87wMlhvGvxsoZr94lENib7OqHln7tefPJbBxb u5iIyYURzGPvl3xqOI9YeZ9x/62wyMgautpEN1d8VHBR2IgSxtuf5CxReXO8lMsH7O4U HOTy+DipIW+0rc275Hbnmp+D7orUqwcow7dtWSNFx/c8pTqabxM22CUKEJ7PJzpdmJao XZSa9Qy4LrJekaapoiyUWSs2LYljY9s82sA73qxRTBZEuw010pSlPHN0AAi1YignYo87 tlHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Zz54zMJzggbWtIcnHgqBfeiMxFI1JgscU3OQIDKBU2Q=; b=OQNT7C/y1OJ/UGCLj2qRTtEj/3bRUt/shcbepT9Q8quFTGW/iaBtFA7LdCmEe5PgjH mmdbwTaCkR4cs12zZlrambXevyS2L8qM0uMQrJk8xLLay0snMe2qVm0YAkNnLMl6BdCD gXcuqG7xf5o/q5IMGy3dzP3HFbuMwspSFuiU2iptDUYcsMgrKLpf5TSBYWWRXGjBVaWb GGIwivuoaMaW0dJlBWp+RIC3xS97YE+omdvnYMQHMGy+gNsXwG6SaXpBS4GJDH54/PAL JUqbELq/xgQk7AKgTBBTgb5pvFtgRlxUrUc1OlR86qJrTlGcrAQfBRJ5jTcZjnfcyJcU 85CA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gU7SZg+h; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q8si281981edi.445.2019.11.01.06.02.40; Fri, 01 Nov 2019 06:02:40 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of netdev-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=@linaro.org header.s=google header.b=gU7SZg+h; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727128AbfKANCj (ORCPT + 9 others); Fri, 1 Nov 2019 09:02:39 -0400 Received: from mail-lf1-f65.google.com ([209.85.167.65]:40606 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726832AbfKANCi (ORCPT ); Fri, 1 Nov 2019 09:02:38 -0400 Received: by mail-lf1-f65.google.com with SMTP id f4so7177103lfk.7 for ; Fri, 01 Nov 2019 06:02:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Zz54zMJzggbWtIcnHgqBfeiMxFI1JgscU3OQIDKBU2Q=; b=gU7SZg+hT4fbYGkXl4l+zlp+12ZhsELfK+kRJCSPlLvZB7DwienEQLWzrimmix17kG IhHpeg4SRKpoV9/kVzvRVXT/4SssYhk9BjFOxjP+66TvLJFAnXxJ5xdKLkGGRZl6oBVj Ddw51wZg9RSjS6GGatqLSgCpgwHAQ2GMNmkbzl7gDBOcVcTzByVYhzYX/51HHtLPwswt CwlEGgN3sJ88eekzAdCwq1mfbJylDojH4qh8xm98Ka6d3/xfEP1+kwDpg0vH0kUcxNQR sfxrY3lhGOtfFfoDmPoj1w2tRYNc826QXxIrLMYqdPs4oO+M5nIJQB10uxdb7NyVhfEX UMrA== 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:mime-version:content-transfer-encoding; bh=Zz54zMJzggbWtIcnHgqBfeiMxFI1JgscU3OQIDKBU2Q=; b=VToecUfhXc2pJ8vOtIY33uE3Sxg9us3X9DgGvSS5DLBfE2cRoQOLRGVhRAgDfXryBN gJz+y0dXIPOeSrT9yHrJDycvDya0nIhDQMNVsg2tKNgYh61I6njuLVKG2q68Hb/Zo3Ba 3+0owHqieqMzedfjobNZ0+FgZEte973kG/wYEKCR7/5+vxM4DhlUwZm7aDbbnGfZVnz/ lnY3FyQNI2+NkUdo/O3WjIk0nM7vqLQqEFLx6HZ5YHyYNq6XaL6a1oBAlFMKtGT65m/x Y6Ibgb6H7MHJvmKFnJIeO32vjabT2Xxv6r9owh0/sfRzVvx3xu3syvgyRYTOBJmUp2GZ D55A== X-Gm-Message-State: APjAAAWPQjZX/9NewcdHWBjpo12gAV4EeRaSf9fSFv/8ervpEitGmRd8 643Jwn3depZw6PYu/phyGB6odIUGiJff7Q== X-Received: by 2002:ac2:4184:: with SMTP id z4mr7340781lfh.46.1572613355925; Fri, 01 Nov 2019 06:02:35 -0700 (PDT) Received: from localhost.bredbandsbolaget (c-79c8225c.014-348-6c756e10.bbcust.telenor.se. [92.34.200.121]) by smtp.gmail.com with ESMTPSA id c3sm2516749lfi.32.2019.11.01.06.02.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Nov 2019 06:02:34 -0700 (PDT) From: Linus Walleij To: netdev@vger.kernel.org, "David S . Miller" Cc: Arnd Bergmann , Jakub Kicinski , Linus Walleij Subject: [PATCH net-next 03/10 v2] ptp: ixp46x: move adjacent to ethernet driver Date: Fri, 1 Nov 2019 14:02:17 +0100 Message-Id: <20191101130224.7964-4-linus.walleij@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191101130224.7964-1-linus.walleij@linaro.org> References: <20191101130224.7964-1-linus.walleij@linaro.org> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Arnd Bergmann The ixp46x ptp driver has a somewhat unusual setup, where the ptp driver and the ethernet driver are in different directories but access the same registers that are defined a platform specific header file. Moving everything into drivers/net/ makes it look more like most other ptp drivers and allows compile-testing this driver on other targets. Signed-off-by: Arnd Bergmann Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Rename patch as "move ADJACENT" which makes more sense --- drivers/net/ethernet/xscale/Kconfig | 14 ++++++++++++++ drivers/net/ethernet/xscale/Makefile | 3 ++- drivers/net/ethernet/xscale/ixp4xx_eth.c | 3 ++- drivers/{ptp => net/ethernet/xscale}/ptp_ixp46x.c | 3 ++- .../net/ethernet/xscale/ptp_ixp46x.h | 0 drivers/ptp/Kconfig | 14 -------------- drivers/ptp/Makefile | 1 - 7 files changed, 20 insertions(+), 18 deletions(-) rename drivers/{ptp => net/ethernet/xscale}/ptp_ixp46x.c (99%) rename arch/arm/mach-ixp4xx/include/mach/ixp46x_ts.h => drivers/net/ethernet/xscale/ptp_ixp46x.h (100%) -- 2.21.0 diff --git a/drivers/net/ethernet/xscale/Kconfig b/drivers/net/ethernet/xscale/Kconfig index cd0a8f46e7c6..98aa7b8ddb06 100644 --- a/drivers/net/ethernet/xscale/Kconfig +++ b/drivers/net/ethernet/xscale/Kconfig @@ -27,4 +27,18 @@ config IXP4XX_ETH Say Y here if you want to use built-in Ethernet ports on IXP4xx processor. +config PTP_1588_CLOCK_IXP46X + tristate "Intel IXP46x as PTP clock" + depends on IXP4XX_ETH + depends on PTP_1588_CLOCK + default y + help + This driver adds support for using the IXP46X as a PTP + clock. This clock is only useful if your PTP programs are + getting hardware time stamps on the PTP Ethernet packets + using the SO_TIMESTAMPING API. + + To compile this driver as a module, choose M here: the module + will be called ptp_ixp46x. + endif # NET_VENDOR_XSCALE diff --git a/drivers/net/ethernet/xscale/Makefile b/drivers/net/ethernet/xscale/Makefile index 794a519d07b3..607f91b1e878 100644 --- a/drivers/net/ethernet/xscale/Makefile +++ b/drivers/net/ethernet/xscale/Makefile @@ -3,4 +3,5 @@ # Makefile for the Intel XScale IXP device drivers. # -obj-$(CONFIG_IXP4XX_ETH) += ixp4xx_eth.o +obj-$(CONFIG_IXP4XX_ETH) += ixp4xx_eth.o +obj-$(CONFIG_PTP_1588_CLOCK_IXP46X) += ptp_ixp46x.o diff --git a/drivers/net/ethernet/xscale/ixp4xx_eth.c b/drivers/net/ethernet/xscale/ixp4xx_eth.c index 6fc04ffb22c2..0075ecdb21f4 100644 --- a/drivers/net/ethernet/xscale/ixp4xx_eth.c +++ b/drivers/net/ethernet/xscale/ixp4xx_eth.c @@ -33,10 +33,11 @@ #include #include #include -#include #include #include +#include "ixp46x_ts.h" + #define DEBUG_DESC 0 #define DEBUG_RX 0 #define DEBUG_TX 0 diff --git a/drivers/ptp/ptp_ixp46x.c b/drivers/net/ethernet/xscale/ptp_ixp46x.c similarity index 99% rename from drivers/ptp/ptp_ixp46x.c rename to drivers/net/ethernet/xscale/ptp_ixp46x.c index 67028484e9a0..9ecc395239e9 100644 --- a/drivers/ptp/ptp_ixp46x.c +++ b/drivers/net/ethernet/xscale/ptp_ixp46x.c @@ -15,7 +15,8 @@ #include #include -#include + +#include "ixp46x_ts.h" #define DRIVER "ptp_ixp46x" #define N_EXT_TS 2 diff --git a/arch/arm/mach-ixp4xx/include/mach/ixp46x_ts.h b/drivers/net/ethernet/xscale/ptp_ixp46x.h similarity index 100% rename from arch/arm/mach-ixp4xx/include/mach/ixp46x_ts.h rename to drivers/net/ethernet/xscale/ptp_ixp46x.h diff --git a/drivers/ptp/Kconfig b/drivers/ptp/Kconfig index 960961fb0d7c..0209e0ef082d 100644 --- a/drivers/ptp/Kconfig +++ b/drivers/ptp/Kconfig @@ -56,20 +56,6 @@ config PTP_1588_CLOCK_QORIQ To compile this driver as a module, choose M here: the module will be called ptp-qoriq. -config PTP_1588_CLOCK_IXP46X - tristate "Intel IXP46x as PTP clock" - depends on IXP4XX_ETH - depends on PTP_1588_CLOCK - default y - help - This driver adds support for using the IXP46X as a PTP - clock. This clock is only useful if your PTP programs are - getting hardware time stamps on the PTP Ethernet packets - using the SO_TIMESTAMPING API. - - To compile this driver as a module, choose M here: the module - will be called ptp_ixp46x. - comment "Enable PHYLIB and NETWORK_PHY_TIMESTAMPING to see the additional clocks." depends on PHYLIB=n || NETWORK_PHY_TIMESTAMPING=n diff --git a/drivers/ptp/Makefile b/drivers/ptp/Makefile index 677d1d178a3e..8ac3513f61c9 100644 --- a/drivers/ptp/Makefile +++ b/drivers/ptp/Makefile @@ -6,7 +6,6 @@ ptp-y := ptp_clock.o ptp_chardev.o ptp_sysfs.o obj-$(CONFIG_PTP_1588_CLOCK) += ptp.o obj-$(CONFIG_PTP_1588_CLOCK_DTE) += ptp_dte.o -obj-$(CONFIG_PTP_1588_CLOCK_IXP46X) += ptp_ixp46x.o obj-$(CONFIG_PTP_1588_CLOCK_PCH) += ptp_pch.o obj-$(CONFIG_PTP_1588_CLOCK_KVM) += ptp_kvm.o obj-$(CONFIG_PTP_1588_CLOCK_QORIQ) += ptp-qoriq.o From patchwork Fri Nov 1 13:02:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 178308 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp456775ill; Fri, 1 Nov 2019 06:02:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqyvZumqiRwcSk+2OZPoIK1fJGYPYpavExm6m//VIrJoOJh9uOKJJxvaxWoVMiNaPph/5uMj X-Received: by 2002:a17:906:4f14:: with SMTP id t20mr9291132eju.239.1572613362574; Fri, 01 Nov 2019 06:02:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572613362; cv=none; d=google.com; s=arc-20160816; b=VYWqlSMazOKwkxx6rarrHoYrBKzrBr33NaLfR2T2YImXdLtikhexPstVIqpH4/k9eE f/LliviWtCxl1K2Z/33BrGAUtrw+qqpx4F6GnLtEv0YKM4Rfy2yPUNw19+mnLe6xYhJv ite08ZdO3lLwPSP5LKHt591mdwn5bP58pA3UGTOiIt/brh15ikKOYDUcgLV1XUcaEOi0 LMCYmn3+He/JJE2fM0yixr8pSG6oQxCShCiUOVDm+S1IbxvCnh8WK2f3ZWNilxpIJ/32 2ZyoXA1QYjccdU3bZMhu0Vk89AmShQr8cb3hdzOqlDeDqNlyD68Qs4tDeuTIHpwY3NjK byZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=fC3l+99+MK7bv8CZSBvWRePbspAxuFq+FAjKHtOpPDw=; b=cTZpGjlqeNQ7DAgS7wxzRDjR9ictqslI1ENlCuqOUvdpwsH5zUH0KzKCJ/3g7GWTiL 6S3/ilLPklm42RspD98BTS0DwXV14hRuP1Qgp4fAqE6xe+HICFZKciKxpcLzDTDTLrQ1 QzU+7ulUCrp1cgzdZAssmqrdT8BWkcuDyK93GMy0twCM3JRI84YwtGqj4A1o3G2s+VsA jfzc7lAl27NwLkYR4GqAIErdfY9ODY7uX0l1T/6Ax/Xk0JT60iNs8yqy3U5jhEmurUCg rntvNrJpG+I1vw77khQiRmqnUCQcjzJyKZv7Lxww0xvahu4PUowhGr5rBvmR1txt2OP2 3vjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RRahzDy9; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q8si281981edi.445.2019.11.01.06.02.42; Fri, 01 Nov 2019 06:02:42 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of netdev-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=@linaro.org header.s=google header.b=RRahzDy9; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727137AbfKANCl (ORCPT + 9 others); Fri, 1 Nov 2019 09:02:41 -0400 Received: from mail-lf1-f65.google.com ([209.85.167.65]:38204 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727085AbfKANCk (ORCPT ); Fri, 1 Nov 2019 09:02:40 -0400 Received: by mail-lf1-f65.google.com with SMTP id q28so7192901lfa.5 for ; Fri, 01 Nov 2019 06:02:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=fC3l+99+MK7bv8CZSBvWRePbspAxuFq+FAjKHtOpPDw=; b=RRahzDy9ZxtumMt3mGy7SDUZ5VKVa6x4XD491bg8aJEbfEGYep3o74FuPHXNOufrzh CpZ6Q3Sk+uYqTSSmjfs1iMSH+iIeODcjBImBDcd1ERrO7sNiXlhymoL1ZnZIMUnaq2Zm +aIW/ZMUYTEDwbRC0uRR1aV+lw7X5dRg1b1O8yk647csDrZIcza2oQkxL2KspxEx5C7t TR1u6Lc/PQyS0Ges2eFopfOhyl9mx+ycQeyw+c7PbaH/bvvmHzBm+DfjJlzQP3TB8Zhq GtHAyVjNPAE8wqP0FzfxeZNnjAs6D9GaVKmg7t80mwjzT2zf11+XIVACqBEd/vFsO1VY 4A4Q== 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:mime-version:content-transfer-encoding; bh=fC3l+99+MK7bv8CZSBvWRePbspAxuFq+FAjKHtOpPDw=; b=Wa953jfyspALcyT6UcoppUDQCBa9Dtp/CYNididC8y2YsEvTyQu3I+zKSIeucfuAjC UoOYG+wzyOnt4+cOdQ4prlqOFQIaFBffW7RamOcFfozROKEm3m8msLWl255m7KLSzbof y4W565+sN3JdvpfteQxawIOdPmR3U+Dk+0s86+29lVtVoiMOoVpAtqkLhCY6k0n8Px9x pgb1OBUbR2fCkB579V4E8MWkIdpeHBlNsd1BBw2hZuTnAUXZ3QgMRH5QIgs4erume3Fz tEXiCNee2rGbFPC4wgJvhv+iInOcTa9U1/n+aKvJjTKiveJ+L7jkg+nFqR8zzuYmc5aN mj9w== X-Gm-Message-State: APjAAAUfIDqbMvKf0ZXLHMXwbbFN41V3uVsLX7718OEv4cQ69sL9j2E5 92Pqmv6oPnHWN+NgYqp+ePc2i8fjh9zsDg== X-Received: by 2002:a19:41c8:: with SMTP id o191mr7276833lfa.101.1572613358142; Fri, 01 Nov 2019 06:02:38 -0700 (PDT) Received: from localhost.bredbandsbolaget (c-79c8225c.014-348-6c756e10.bbcust.telenor.se. [92.34.200.121]) by smtp.gmail.com with ESMTPSA id c3sm2516749lfi.32.2019.11.01.06.02.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Nov 2019 06:02:36 -0700 (PDT) From: Linus Walleij To: netdev@vger.kernel.org, "David S . Miller" Cc: Arnd Bergmann , Jakub Kicinski , Linus Walleij Subject: [PATCH net-next 04/10 v2] ixp4xx_eth: move platform_data definition Date: Fri, 1 Nov 2019 14:02:18 +0100 Message-Id: <20191101130224.7964-5-linus.walleij@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191101130224.7964-1-linus.walleij@linaro.org> References: <20191101130224.7964-1-linus.walleij@linaro.org> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Arnd Bergmann The platform data is needed to compile the driver as standalone, so move it to a global location along with similar files. Signed-off-by: Arnd Bergmann Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Rebased on the rest of the series. --- arch/arm/mach-ixp4xx/include/mach/platform.h | 13 +------------ .../xscale/{ptp_ixp46x.h => ixp46x_ts.h} | 0 drivers/net/ethernet/xscale/ixp4xx_eth.c | 1 + include/linux/platform_data/eth_ixp4xx.h | 19 +++++++++++++++++++ 4 files changed, 21 insertions(+), 12 deletions(-) rename drivers/net/ethernet/xscale/{ptp_ixp46x.h => ixp46x_ts.h} (100%) create mode 100644 include/linux/platform_data/eth_ixp4xx.h -- 2.21.0 diff --git a/arch/arm/mach-ixp4xx/include/mach/platform.h b/arch/arm/mach-ixp4xx/include/mach/platform.h index 04ef8025accc..6d403fe0bf52 100644 --- a/arch/arm/mach-ixp4xx/include/mach/platform.h +++ b/arch/arm/mach-ixp4xx/include/mach/platform.h @@ -15,6 +15,7 @@ #ifndef __ASSEMBLY__ #include +#include #include @@ -92,18 +93,6 @@ struct ixp4xx_pata_data { void __iomem *cs1; }; -#define IXP4XX_ETH_NPEA 0x00 -#define IXP4XX_ETH_NPEB 0x10 -#define IXP4XX_ETH_NPEC 0x20 - -/* Information about built-in Ethernet MAC interfaces */ -struct eth_plat_info { - u8 phy; /* MII PHY ID, 0 - 31 */ - u8 rxq; /* configurable, currently 0 - 31 only */ - u8 txreadyq; - u8 hwaddr[6]; -}; - /* * Frequency of clock used for primary clocksource */ diff --git a/drivers/net/ethernet/xscale/ptp_ixp46x.h b/drivers/net/ethernet/xscale/ixp46x_ts.h similarity index 100% rename from drivers/net/ethernet/xscale/ptp_ixp46x.h rename to drivers/net/ethernet/xscale/ixp46x_ts.h diff --git a/drivers/net/ethernet/xscale/ixp4xx_eth.c b/drivers/net/ethernet/xscale/ixp4xx_eth.c index 0075ecdb21f4..e811bf0d23cb 100644 --- a/drivers/net/ethernet/xscale/ixp4xx_eth.c +++ b/drivers/net/ethernet/xscale/ixp4xx_eth.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include diff --git a/include/linux/platform_data/eth_ixp4xx.h b/include/linux/platform_data/eth_ixp4xx.h new file mode 100644 index 000000000000..6f652ea0c6ae --- /dev/null +++ b/include/linux/platform_data/eth_ixp4xx.h @@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __PLATFORM_DATA_ETH_IXP4XX +#define __PLATFORM_DATA_ETH_IXP4XX + +#include + +#define IXP4XX_ETH_NPEA 0x00 +#define IXP4XX_ETH_NPEB 0x10 +#define IXP4XX_ETH_NPEC 0x20 + +/* Information about built-in Ethernet MAC interfaces */ +struct eth_plat_info { + u8 phy; /* MII PHY ID, 0 - 31 */ + u8 rxq; /* configurable, currently 0 - 31 only */ + u8 txreadyq; + u8 hwaddr[6]; +}; + +#endif From patchwork Fri Nov 1 13:02:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 178309 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp456855ill; Fri, 1 Nov 2019 06:02:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqzkhFVteyI9tpcu8VwOkB6VL6IdjKDXLg1Wz7kvOB9aSY7NH92ejdB5Quq2/bkSdZqLA7Sp X-Received: by 2002:a50:9136:: with SMTP id e51mr10751398eda.71.1572613365417; Fri, 01 Nov 2019 06:02:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572613365; cv=none; d=google.com; s=arc-20160816; b=wgCGWHAPeEmhnW6oTJucfq6hpt/Zl6/1V07lO13gIxQgiVbUtH9cL9YsSGjt/ILNVC 0lh+0JkpN/awyvwLcZbTXLQZjeIgqeISLksUvwotzcqNpBZYHeZi23vrOHyeDSREN3w+ LWq1gBuevs/3NSeSTUhmSUlmoaEmO1YwcBh35ys2ovNrpoBABNOJqf2DFi104eKdidIu IVg0rtFliAwyW675NIVCh4GiSgBzqQYyOiYunHQL5tRneyZan9luJ6pUmPRrC/8wPMk2 PrBpmWKvhp+O3ocomsD807qSs+CiJ0FuZu/JUpOjKvhplSYLgeP7+fb0r8UToxKEQG8a Z55Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=M+wZ1DyL0H/QBAW183PzIquK11Y7rCDGG1Vc3IWTh2g=; b=XOhswLOm0gP7EsUGFmfG1ZbGpJpqZS2X2qK44LJ6bAgtpfkVUIxVEKWv+a93ffyNZr io15MDXRpiawYXr+1cI0vVqKAXwJS1qln1luPngInqWh3P0g1AxCZpeyOJH52wWCTJ+g 2zJ08w4HNKmZiCZF1jK+3loOskW67N/8OmLEgUhDsGIVlOalD4YekM7GbSfWzKlYfv/8 Le2BwweS7PMQsaiYnO4AZKYGcTtfLWTnthPefpybYoO3oO6Cd5C7p9MUIXR4kXivdtMw 7RBDviwqd38WCt1IyRX5EhhnTI+/4hwCCSVZxxmukwF0RtvYkgus1ECI6mougJALsUxH XIIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xhKzWBnO; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q8si281981edi.445.2019.11.01.06.02.45; Fri, 01 Nov 2019 06:02:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of netdev-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=@linaro.org header.s=google header.b=xhKzWBnO; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727162AbfKANCo (ORCPT + 9 others); Fri, 1 Nov 2019 09:02:44 -0400 Received: from mail-lf1-f66.google.com ([209.85.167.66]:45251 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727085AbfKANCn (ORCPT ); Fri, 1 Nov 2019 09:02:43 -0400 Received: by mail-lf1-f66.google.com with SMTP id v8so7139886lfa.12 for ; Fri, 01 Nov 2019 06:02:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=M+wZ1DyL0H/QBAW183PzIquK11Y7rCDGG1Vc3IWTh2g=; b=xhKzWBnOHEwjI84xPPLk99ByUXWDj5j2mU8exuM2lXcgHhOENCGjmLyieEXRlmywWX qicMu+G9HRIVMOcUpuDf1m09lcggjkhYkXQiol0PLUMJwWtGTPRln+0wkASeerxo8TNw up8lR949ndoKA+NWZETvlZPHM2CrwjAGyZAncs/0rKvpbB3TSy1QD+0TbSnsksOha9hh Nbq6U0Kx/j7unELOqDxJGA9AUlymX/BofABI/R1drD4UEri9KwpSIsU65t4teugaUIum PcBS4BgDxxANrMzhuWXtEIyhG0K+bLILTC7B9QR1QO6XWm+pqJCwjUN52ASTzpsxXrDY XzJA== 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:mime-version:content-transfer-encoding; bh=M+wZ1DyL0H/QBAW183PzIquK11Y7rCDGG1Vc3IWTh2g=; b=Tj9ishAUh6WqQTEVFcfoTfltSRNsKoD6AWnViOwgps+mwHD1D7lnPADdoLXCI/XNAC VgWKWmXH9UJJy9UeRaVlaiSzfk8elJPW1sR07nk11RFaiFe3K9U3pNmG2zZrv7bjUfhI F84ZXn1zujlnrvUSyGGHTXU2SV/zQSwKlHUCjhB49yR8WNSKbOfTFLTFE7LvxFVkSAnf tVw9mDsgXocZJcMXwh94zuAdTnoZq2rsaSCilG0fkBd0H66E1c9ndqG7E5/XMTTw5BZy jmWkwzMHQzdoR4M1NUxJq1Comr+bwXyWGPM4E0xvQr3dMYHR9fsoPz3cq2SojdjU+3Lr WC8g== X-Gm-Message-State: APjAAAU+876iqvuczy/VKahphkQ5KW2zArbXWYXt9Ed7L53Ez4Bp7kho jnolbclBIuVLLNPUc14HuhuhGBKfnwj41w== X-Received: by 2002:a19:ac48:: with SMTP id r8mr7576880lfc.181.1572613360487; Fri, 01 Nov 2019 06:02:40 -0700 (PDT) Received: from localhost.bredbandsbolaget (c-79c8225c.014-348-6c756e10.bbcust.telenor.se. [92.34.200.121]) by smtp.gmail.com with ESMTPSA id c3sm2516749lfi.32.2019.11.01.06.02.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Nov 2019 06:02:39 -0700 (PDT) From: Linus Walleij To: netdev@vger.kernel.org, "David S . Miller" Cc: Arnd Bergmann , Jakub Kicinski , Linus Walleij Subject: [PATCH net-next 05/10 v2] net: ethernet: ixp4xx: Standard module init Date: Fri, 1 Nov 2019 14:02:19 +0100 Message-Id: <20191101130224.7964-6-linus.walleij@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191101130224.7964-1-linus.walleij@linaro.org> References: <20191101130224.7964-1-linus.walleij@linaro.org> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The IXP4xx driver was initializing the MDIO bus before even probing, in the callbacks supposed to be used for setting up the module itself, and with the side effect of trying to register the MDIO bus as soon as this module was loaded or compiled into the kernel whether the device was discovered or not. This does not work with multiplatform environments. To get rid of this: set up the MDIO bus from the probe() callback and remove it in the remove() callback. Rename the probe() and remove() calls to reflect the most common conventions. Since there is a bit of checking for the ethernet feature to be present in the MDIO registering function, making the whole module not even be registered if we can't find an MDIO bus, we need something similar: register the MDIO bus when the corresponding ethernet is probed, and return -EPROBE_DEFER on the other interfaces until this happens. If no MDIO bus is present on any of the registered interfaces we will eventually bail out. None of the platforms I've seen has e.g. MDIO on EthB and only uses EthC, there is always a Ethernet hardware on the NPE (B, C) that has the MDIO bus, we just might have to wait for it. Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Change the first alloc_etherdev() to devm_alloc_etherdev() and drop one leg of the errorpath so we can just return with error code in the first part of the code. --- drivers/net/ethernet/xscale/ixp4xx_eth.c | 96 +++++++++++------------- 1 file changed, 44 insertions(+), 52 deletions(-) -- 2.21.0 diff --git a/drivers/net/ethernet/xscale/ixp4xx_eth.c b/drivers/net/ethernet/xscale/ixp4xx_eth.c index e811bf0d23cb..799ffebba491 100644 --- a/drivers/net/ethernet/xscale/ixp4xx_eth.c +++ b/drivers/net/ethernet/xscale/ixp4xx_eth.c @@ -519,25 +519,14 @@ static int ixp4xx_mdio_write(struct mii_bus *bus, int phy_id, int location, return ret; } -static int ixp4xx_mdio_register(void) +static int ixp4xx_mdio_register(struct eth_regs __iomem *regs) { int err; if (!(mdio_bus = mdiobus_alloc())) return -ENOMEM; - if (cpu_is_ixp43x()) { - /* IXP43x lacks NPE-B and uses NPE-C for MII PHY access */ - if (!(ixp4xx_read_feature_bits() & IXP4XX_FEATURE_NPEC_ETH)) - return -ENODEV; - mdio_regs = (struct eth_regs __iomem *)IXP4XX_EthC_BASE_VIRT; - } else { - /* All MII PHY accesses use NPE-B Ethernet registers */ - if (!(ixp4xx_read_feature_bits() & IXP4XX_FEATURE_NPEB_ETH0)) - return -ENODEV; - mdio_regs = (struct eth_regs __iomem *)IXP4XX_EthB_BASE_VIRT; - } - + mdio_regs = regs; __raw_writel(DEFAULT_CORE_CNTRL, &mdio_regs->core_control); spin_lock_init(&mdio_lock); mdio_bus->name = "IXP4xx MII Bus"; @@ -1376,7 +1365,7 @@ static const struct net_device_ops ixp4xx_netdev_ops = { .ndo_validate_addr = eth_validate_addr, }; -static int eth_init_one(struct platform_device *pdev) +static int ixp4xx_eth_probe(struct platform_device *pdev) { struct port *port; struct net_device *dev; @@ -1386,7 +1375,7 @@ static int eth_init_one(struct platform_device *pdev) char phy_id[MII_BUS_ID_SIZE + 3]; int err; - if (!(dev = alloc_etherdev(sizeof(struct port)))) + if (!(dev = devm_alloc_etherdev(&pdev->dev, sizeof(struct port)))) return -ENOMEM; SET_NETDEV_DEV(dev, &pdev->dev); @@ -1396,20 +1385,51 @@ static int eth_init_one(struct platform_device *pdev) switch (port->id) { case IXP4XX_ETH_NPEA: + /* If the MDIO bus is not up yet, defer probe */ + if (!mdio_bus) + return -EPROBE_DEFER; port->regs = (struct eth_regs __iomem *)IXP4XX_EthA_BASE_VIRT; regs_phys = IXP4XX_EthA_BASE_PHYS; break; case IXP4XX_ETH_NPEB: + /* + * On all except IXP43x, NPE-B is used for the MDIO bus. + * If there is no NPE-B in the feature set, bail out, else + * register the MDIO bus. + */ + if (!cpu_is_ixp43x()) { + if (!(ixp4xx_read_feature_bits() & + IXP4XX_FEATURE_NPEB_ETH0)) + return -ENODEV; + /* Else register the MDIO bus on NPE-B */ + if ((err = ixp4xx_mdio_register(IXP4XX_EthC_BASE_VIRT))) + return err; + } + if (!mdio_bus) + return -EPROBE_DEFER; port->regs = (struct eth_regs __iomem *)IXP4XX_EthB_BASE_VIRT; regs_phys = IXP4XX_EthB_BASE_PHYS; break; case IXP4XX_ETH_NPEC: + /* + * IXP43x lacks NPE-B and uses NPE-C for the MDIO bus access, + * of there is no NPE-C, no bus, nothing works, so bail out. + */ + if (cpu_is_ixp43x()) { + if (!(ixp4xx_read_feature_bits() & + IXP4XX_FEATURE_NPEC_ETH)) + return -ENODEV; + /* Else register the MDIO bus on NPE-C */ + if ((err = ixp4xx_mdio_register(IXP4XX_EthC_BASE_VIRT))) + return err; + } + if (!mdio_bus) + return -EPROBE_DEFER; port->regs = (struct eth_regs __iomem *)IXP4XX_EthC_BASE_VIRT; regs_phys = IXP4XX_EthC_BASE_PHYS; break; default: - err = -ENODEV; - goto err_free; + return -ENODEV; } dev->netdev_ops = &ixp4xx_netdev_ops; @@ -1418,10 +1438,8 @@ static int eth_init_one(struct platform_device *pdev) netif_napi_add(dev, &port->napi, eth_poll, NAPI_WEIGHT); - if (!(port->npe = npe_request(NPE_ID(port->id)))) { - err = -EIO; - goto err_free; - } + if (!(port->npe = npe_request(NPE_ID(port->id)))) + return -EIO; port->mem_res = request_mem_region(regs_phys, REGS_SIZE, dev->name); if (!port->mem_res) { @@ -1467,12 +1485,10 @@ static int eth_init_one(struct platform_device *pdev) release_resource(port->mem_res); err_npe_rel: npe_release(port->npe); -err_free: - free_netdev(dev); return err; } -static int eth_remove_one(struct platform_device *pdev) +static int ixp4xx_eth_remove(struct platform_device *pdev) { struct net_device *dev = platform_get_drvdata(pdev); struct phy_device *phydev = dev->phydev; @@ -1480,45 +1496,21 @@ static int eth_remove_one(struct platform_device *pdev) unregister_netdev(dev); phy_disconnect(phydev); + ixp4xx_mdio_remove(); npe_port_tab[NPE_ID(port->id)] = NULL; npe_release(port->npe); release_resource(port->mem_res); - free_netdev(dev); return 0; } static struct platform_driver ixp4xx_eth_driver = { .driver.name = DRV_NAME, - .probe = eth_init_one, - .remove = eth_remove_one, + .probe = ixp4xx_eth_probe, + .remove = ixp4xx_eth_remove, }; - -static int __init eth_init_module(void) -{ - int err; - - /* - * FIXME: we bail out on device tree boot but this really needs - * to be fixed in a nicer way: this registers the MDIO bus before - * even matching the driver infrastructure, we should only probe - * detected hardware. - */ - if (of_have_populated_dt()) - return -ENODEV; - if ((err = ixp4xx_mdio_register())) - return err; - return platform_driver_register(&ixp4xx_eth_driver); -} - -static void __exit eth_cleanup_module(void) -{ - platform_driver_unregister(&ixp4xx_eth_driver); - ixp4xx_mdio_remove(); -} +module_platform_driver(ixp4xx_eth_driver); MODULE_AUTHOR("Krzysztof Halasa"); MODULE_DESCRIPTION("Intel IXP4xx Ethernet driver"); MODULE_LICENSE("GPL v2"); MODULE_ALIAS("platform:ixp4xx_eth"); -module_init(eth_init_module); -module_exit(eth_cleanup_module); From patchwork Fri Nov 1 13:02:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 178310 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp456937ill; Fri, 1 Nov 2019 06:02:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqwZWOksNd/VINvrao+h+3zfr+C1XcDq6qoo5R5o4YP+GYu0ISIXnqGw39X91vusbWsLxSLB X-Received: by 2002:a17:906:6848:: with SMTP id a8mr9609979ejs.306.1572613367987; Fri, 01 Nov 2019 06:02:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572613367; cv=none; d=google.com; s=arc-20160816; b=Ueoa2ZPALNTI5HG/NGlI7iDajfR7+LLdRsugzby3fMRi3r4RvDrEUVZO4xrdgG5s+y F3eu0RshrIP60LwQKWZmq/yN4p83jUBigf7sBU6U6YistoeuR0OqE95pQr2vFmW5D1Tr rZccsggcaagaNBBiv2jik3X7b/aI0TwfYQT7J/PGJence2kFGqf1C2CTrWcaXWyZP/Sz W+hGiE/5ucxS6KfpyW2SNdYuUbdewOkh7al29wEm1ZB3E3B6ST3/xKqd2WDY62M745DE 8H3kFlTpEohdYVLsK62Z5domVsC/ca1BsroCklB+S2nkdA/l5ADNiq9ctKWEzeRkmcdE Qr0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=JLmKxYWPrGxN637WEJSw5Q6s5tphPYjobAlnKmtB1EE=; b=pqmJ275leLamilwtPkVzNfum419+r3J6U6Avg75ROc5y3YudnbInHsELnUXeK81lnb nlQOzRWWg2mhELCSuS4E6mqEK6BNH7FKsAsUXg5SUJMv7gYvTfwKcsi4P4O/+jxqwsJr lJFfQHmfkCT57XlYkfXgSD7GhigoMCCAx62SdXiUn3KY7t5ObxvNyR+TbDw/yh/z0fUQ Hm8cVNJSKIyhDmopYMewdvTUaj0VAxIOwqwH/Q/my0TB1mXTiGNodB03rtYOTE40me37 aDYOHPPGvceWTSZrG7rgYzkJ134+k5EGMvDJJG+Fr0eAQG5p8T55+xT5yZKPupv5GMGT tXdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AJ2gW2DL; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q8si281981edi.445.2019.11.01.06.02.47; Fri, 01 Nov 2019 06:02:47 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of netdev-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=@linaro.org header.s=google header.b=AJ2gW2DL; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727170AbfKANCr (ORCPT + 9 others); Fri, 1 Nov 2019 09:02:47 -0400 Received: from mail-lj1-f193.google.com ([209.85.208.193]:40564 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727144AbfKANCp (ORCPT ); Fri, 1 Nov 2019 09:02:45 -0400 Received: by mail-lj1-f193.google.com with SMTP id q2so3623194ljg.7 for ; Fri, 01 Nov 2019 06:02:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=JLmKxYWPrGxN637WEJSw5Q6s5tphPYjobAlnKmtB1EE=; b=AJ2gW2DLuEWNtFFrZBqEV4EOsZi1lHJD4/920NS3IboOCROY5dZvhCFXxBgwx0/5XK kKZmfFtDqeyxY5zZhxAS1a4dv7ZqBPnaIsXolXu5ohOrtzRpyQs6Va0ig9H5742m03my V1s+4D+xLoEtXIZqjzJc0jCt9qiQIZx7ovaUNHdnMufqqUkWZcdx1rjzKJx0xtvZx9po iQO3vPrRjHe0bi0dXuAuxanm/96gBetg1bE4T2I9bHilWY9vQJ4ss2ShNEdlez3mw8lS OaR9KJfRV6AlrfImAd3sHBqhj6dpJRd/eUUtu8YAzXf55oSsRF30G1an/m77FJDLIR1n zWAA== 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:mime-version:content-transfer-encoding; bh=JLmKxYWPrGxN637WEJSw5Q6s5tphPYjobAlnKmtB1EE=; b=H4kEwiQ35z27if5fS+6exwWUIAxZQCAh2eTj7oqh9u7jrkPmfi+G41C2DV7pKF7QPa uEjWNy4HbcxZ9ci/XWCm/ri9tU/bJpHJjaggutQgHg2pPJCFejDnXiFWHSmxSQELAzbA R1CDFDQ2jl3koWdmm8yJ3gvCkeiC7khb36cFdE6aIiKrSXbXm7VOqW1PJsrtVvulq47Y mefCMdSWUAxlZG+trBJyC1UVCzdP86AvzTQbl9KVYf+v3FupLg0saxU0a7PUkllgxlV5 e45QqaIYKPX/rROZWTwdArKrdbEwOpUeZPLZKWUXGquq+7O0Y48nt9ScNy4gswvIbhtH iteA== X-Gm-Message-State: APjAAAVQfZkj84QSAOQaxwFxIqbJMSvgDryoMehsLPBCqqearDqWySuB u/5NKbK8DyxZeUjmVOR04CmWptCi+cCeEQ== X-Received: by 2002:a2e:3505:: with SMTP id z5mr7608237ljz.126.1572613362420; Fri, 01 Nov 2019 06:02:42 -0700 (PDT) Received: from localhost.bredbandsbolaget (c-79c8225c.014-348-6c756e10.bbcust.telenor.se. [92.34.200.121]) by smtp.gmail.com with ESMTPSA id c3sm2516749lfi.32.2019.11.01.06.02.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Nov 2019 06:02:41 -0700 (PDT) From: Linus Walleij To: netdev@vger.kernel.org, "David S . Miller" Cc: Arnd Bergmann , Jakub Kicinski , Linus Walleij Subject: [PATCH net-next 06/10 v2] net: ethernet: ixp4xx: Use distinct local variable Date: Fri, 1 Nov 2019 14:02:20 +0100 Message-Id: <20191101130224.7964-7-linus.walleij@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191101130224.7964-1-linus.walleij@linaro.org> References: <20191101130224.7964-1-linus.walleij@linaro.org> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Use "ndev" for the struct net_device and "dev" for the struct device in probe() and remove(). Add the local "dev" pointer for later use in refactoring. Take this opportunity to fix inverse christmas tree coding style. Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Rebase on the other changes. --- drivers/net/ethernet/xscale/ixp4xx_eth.c | 47 +++++++++++++----------- 1 file changed, 25 insertions(+), 22 deletions(-) -- 2.21.0 diff --git a/drivers/net/ethernet/xscale/ixp4xx_eth.c b/drivers/net/ethernet/xscale/ixp4xx_eth.c index 799ffebba491..05ab8426bb8d 100644 --- a/drivers/net/ethernet/xscale/ixp4xx_eth.c +++ b/drivers/net/ethernet/xscale/ixp4xx_eth.c @@ -1367,20 +1367,23 @@ static const struct net_device_ops ixp4xx_netdev_ops = { static int ixp4xx_eth_probe(struct platform_device *pdev) { - struct port *port; - struct net_device *dev; - struct eth_plat_info *plat = dev_get_platdata(&pdev->dev); + char phy_id[MII_BUS_ID_SIZE + 3]; struct phy_device *phydev = NULL; + struct device *dev = &pdev->dev; + struct eth_plat_info *plat; + struct net_device *ndev; + struct port *port; u32 regs_phys; - char phy_id[MII_BUS_ID_SIZE + 3]; int err; - if (!(dev = devm_alloc_etherdev(&pdev->dev, sizeof(struct port)))) + plat = dev_get_platdata(dev); + + if (!(ndev = devm_alloc_etherdev(dev, sizeof(struct port)))) return -ENOMEM; - SET_NETDEV_DEV(dev, &pdev->dev); - port = netdev_priv(dev); - port->netdev = dev; + SET_NETDEV_DEV(ndev, dev); + port = netdev_priv(ndev); + port->netdev = ndev; port->id = pdev->id; switch (port->id) { @@ -1432,16 +1435,16 @@ static int ixp4xx_eth_probe(struct platform_device *pdev) return -ENODEV; } - dev->netdev_ops = &ixp4xx_netdev_ops; - dev->ethtool_ops = &ixp4xx_ethtool_ops; - dev->tx_queue_len = 100; + ndev->netdev_ops = &ixp4xx_netdev_ops; + ndev->ethtool_ops = &ixp4xx_ethtool_ops; + ndev->tx_queue_len = 100; - netif_napi_add(dev, &port->napi, eth_poll, NAPI_WEIGHT); + netif_napi_add(ndev, &port->napi, eth_poll, NAPI_WEIGHT); if (!(port->npe = npe_request(NPE_ID(port->id)))) return -EIO; - port->mem_res = request_mem_region(regs_phys, REGS_SIZE, dev->name); + port->mem_res = request_mem_region(regs_phys, REGS_SIZE, ndev->name); if (!port->mem_res) { err = -EBUSY; goto err_npe_rel; @@ -1449,9 +1452,9 @@ static int ixp4xx_eth_probe(struct platform_device *pdev) port->plat = plat; npe_port_tab[NPE_ID(port->id)] = port; - memcpy(dev->dev_addr, plat->hwaddr, ETH_ALEN); + memcpy(ndev->dev_addr, plat->hwaddr, ETH_ALEN); - platform_set_drvdata(pdev, dev); + platform_set_drvdata(pdev, ndev); __raw_writel(DEFAULT_CORE_CNTRL | CORE_RESET, &port->regs->core_control); @@ -1461,7 +1464,7 @@ static int ixp4xx_eth_probe(struct platform_device *pdev) snprintf(phy_id, MII_BUS_ID_SIZE + 3, PHY_ID_FMT, mdio_bus->id, plat->phy); - phydev = phy_connect(dev, phy_id, &ixp4xx_adjust_link, + phydev = phy_connect(ndev, phy_id, &ixp4xx_adjust_link, PHY_INTERFACE_MODE_MII); if (IS_ERR(phydev)) { err = PTR_ERR(phydev); @@ -1470,10 +1473,10 @@ static int ixp4xx_eth_probe(struct platform_device *pdev) phydev->irq = PHY_POLL; - if ((err = register_netdev(dev))) + if ((err = register_netdev(ndev))) goto err_phy_dis; - printk(KERN_INFO "%s: MII PHY %i on %s\n", dev->name, plat->phy, + printk(KERN_INFO "%s: MII PHY %i on %s\n", ndev->name, plat->phy, npe_name(port->npe)); return 0; @@ -1490,11 +1493,11 @@ static int ixp4xx_eth_probe(struct platform_device *pdev) static int ixp4xx_eth_remove(struct platform_device *pdev) { - struct net_device *dev = platform_get_drvdata(pdev); - struct phy_device *phydev = dev->phydev; - struct port *port = netdev_priv(dev); + struct net_device *ndev = platform_get_drvdata(pdev); + struct phy_device *phydev = ndev->phydev; + struct port *port = netdev_priv(ndev); - unregister_netdev(dev); + unregister_netdev(ndev); phy_disconnect(phydev); ixp4xx_mdio_remove(); npe_port_tab[NPE_ID(port->id)] = NULL; From patchwork Fri Nov 1 13:02:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 178311 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp456938ill; Fri, 1 Nov 2019 06:02:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqyLQIXwiQIG5bW42eK5spDHN7sZzJqagP0GlLNgme7ANsXmHCyQQ4ldx97UghY9kUpfrFrU X-Received: by 2002:a17:906:f181:: with SMTP id gs1mr9547858ejb.13.1572613368415; Fri, 01 Nov 2019 06:02:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572613368; cv=none; d=google.com; s=arc-20160816; b=hYUq3Ef9kYZgZ4AYiMP43G+Ov/iWGcuCNvwkdnX2u5j+tuOEC00n0wVIj5fza2aNjQ 6AHIKHXONdiOziiX8l9xCnEaey6yHk9MCukuFYJg8Y1Z0pGxcwox47bf423KvYURCNOU BiUwex4vNn6SZMPPDeuT3GI6fIu0rxOtw/IVKs/FmvEK3dDfwjQoRo1ttI4x1EHyXWSr kHNUdGjsJt3FgJhojdeABEqFqPfEIcElNqBevV2bYBsSpGDCNuCVGrGQNmY4eaJoxDKa PZS1J9dXayJj6b6z1885kkYquxpsxUOh+SUjq8UAu+gNptIHEHFg7/j1pOLqMRb1Zzvu Rieg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=c2veLINbeE0nh+fIZp2oidgy1rZnvBgY8wYeIm0MsXI=; b=op/FOiFCBw8RebeVGbduRRYvSVYr1IUDn9eRTUEg7sWJm8jzmTKm/b/RDCkEgC7RGj QRtVti3Wf3PGRZoM1jj1D4r0tmsE42PrZpiAC8yxA8EVzBXCSiHeHQodZoHgq30+lROk WYtSU67tsaB1R+BjAlJSELF6g8MVbLORkn+QqGU4dqfD0D1ofsnNNHtvmM6FYjLcV/Jd VcoUehZAgU8lrXw4x0P6hYrX2paodDHc/I2l/FOg9aYpBiOrg5ON6zPbqvf6plricXQk QwyKAur4hS2SwCafWmtnA3rXcKl2TW8txkdo6H+gbMgVOIbDsjdX6IGbZgKXSqpMG6b5 husg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ELcAlnwi; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q8si281981edi.445.2019.11.01.06.02.48; Fri, 01 Nov 2019 06:02:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of netdev-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=@linaro.org header.s=google header.b=ELcAlnwi; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727180AbfKANCr (ORCPT + 9 others); Fri, 1 Nov 2019 09:02:47 -0400 Received: from mail-lj1-f196.google.com ([209.85.208.196]:43130 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727085AbfKANCq (ORCPT ); Fri, 1 Nov 2019 09:02:46 -0400 Received: by mail-lj1-f196.google.com with SMTP id s4so10152827ljj.10 for ; Fri, 01 Nov 2019 06:02:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=c2veLINbeE0nh+fIZp2oidgy1rZnvBgY8wYeIm0MsXI=; b=ELcAlnwiqa4nr26NqNF5pgF76Qk6LlEyZXYvZtqQKnzEF+S2V5csciTbnKWD8eDMBB 7DuWkGVxUK6AV76wqh/p25WC75YW33KXanfuxdhQVPcIoBU9MTXOM3JBtqCac7VZ+6Wb t296Oui3Xk3LvbhR2RS5xTSJhJV7C0ZyZwmO/58F5Jy+MNMgBuy4fGUhdUL1j9X6uOwn Jq3hZWjBoC1qaxpKaeUpLsU8eYfOPo4PbKBF9wgPOlnNioE8kl5gsUgAM3V9sL5IcfUb 58ILUujtKg+UxELg/AqR9jbjVpbpPu7IN++1FV4EQ5E4CxLQtz1gnGdKJ5oEInmtpOFV jvuw== 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:mime-version:content-transfer-encoding; bh=c2veLINbeE0nh+fIZp2oidgy1rZnvBgY8wYeIm0MsXI=; b=NH/yVmKq6V+BVKEAqoPsWk66o6iw7IH6qy8Fgvz5/2+rWhrFwS3bJlN+X0hPRI4BG2 X16BAHpwSlS++PkAxTId4XHVM329vZ9xk2V+YlQCzSBnHmt4mkB59FTQiw4RyIM2XEjO nULVfJrLdOFVQWCHoXQxUrCzbtSmmvGR7ifRfMoaOaCpyfPt3VcpthKR2X9ovjB1alLJ NQoObF0sHADvOrshjgSSrPK2F+m4QUUGB+Iz4IM3FpcHxvk5sfrq3JMpQFp686BZ31yu 8BfqV7Pi406FQFoe07T3bqpSzs+rd9ZrvXguOaZiALseLUI2fXxvPGgfwzjNbkq5iSRQ OnaQ== X-Gm-Message-State: APjAAAWEv2cA6RHCHuBgm+7btDeL90rgz2SDwssEzEFcxLmlSzFybcKx wbDlCVz1Nx1x74uSjKrl+7WbNEuHG7IVAQ== X-Received: by 2002:a2e:7204:: with SMTP id n4mr642848ljc.139.1572613364432; Fri, 01 Nov 2019 06:02:44 -0700 (PDT) Received: from localhost.bredbandsbolaget (c-79c8225c.014-348-6c756e10.bbcust.telenor.se. [92.34.200.121]) by smtp.gmail.com with ESMTPSA id c3sm2516749lfi.32.2019.11.01.06.02.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Nov 2019 06:02:43 -0700 (PDT) From: Linus Walleij To: netdev@vger.kernel.org, "David S . Miller" Cc: Arnd Bergmann , Jakub Kicinski , Linus Walleij Subject: [PATCH net-next 07/10 v2] net: ehernet: ixp4xx: Use netdev_* messages Date: Fri, 1 Nov 2019 14:02:21 +0100 Message-Id: <20191101130224.7964-8-linus.walleij@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191101130224.7964-1-linus.walleij@linaro.org> References: <20191101130224.7964-1-linus.walleij@linaro.org> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Simplify and correct a bunch of messages using printk directly to use the netdev_* macros. I have not changed all of them, just the low-hanging fruit. Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Squashed the previous devm_* changes into the patch where the simplified errorpath is needed and renamed this patch to just be about the message. - Fixed a bunch more prints. --- drivers/net/ethernet/xscale/ixp4xx_eth.c | 52 +++++++++++------------- 1 file changed, 23 insertions(+), 29 deletions(-) -- 2.21.0 diff --git a/drivers/net/ethernet/xscale/ixp4xx_eth.c b/drivers/net/ethernet/xscale/ixp4xx_eth.c index 05ab8426bb8d..f7edf8b38dea 100644 --- a/drivers/net/ethernet/xscale/ixp4xx_eth.c +++ b/drivers/net/ethernet/xscale/ixp4xx_eth.c @@ -572,8 +572,8 @@ static void ixp4xx_adjust_link(struct net_device *dev) __raw_writel(DEFAULT_TX_CNTRL0 | TX_CNTRL0_HALFDUPLEX, &port->regs->tx_control[0]); - printk(KERN_INFO "%s: link up, speed %u Mb/s, %s duplex\n", - dev->name, port->speed, port->duplex ? "full" : "half"); + netdev_info(dev, "%s: link up, speed %u Mb/s, %s duplex\n", + dev->name, port->speed, port->duplex ? "full" : "half"); } @@ -583,7 +583,7 @@ static inline void debug_pkt(struct net_device *dev, const char *func, #if DEBUG_PKT_BYTES int i; - printk(KERN_DEBUG "%s: %s(%i) ", dev->name, func, len); + netdev_debug(dev, "%s(%i) ", func, len); for (i = 0; i < len; i++) { if (i >= DEBUG_PKT_BYTES) break; @@ -674,7 +674,7 @@ static int eth_poll(struct napi_struct *napi, int budget) int received = 0; #if DEBUG_RX - printk(KERN_DEBUG "%s: eth_poll\n", dev->name); + netdev_debug(dev, "eth_poll\n"); #endif while (received < budget) { @@ -688,23 +688,20 @@ static int eth_poll(struct napi_struct *napi, int budget) if ((n = queue_get_desc(rxq, port, 0)) < 0) { #if DEBUG_RX - printk(KERN_DEBUG "%s: eth_poll napi_complete\n", - dev->name); + netdev_debug(dev, "eth_poll napi_complete\n"); #endif napi_complete(napi); qmgr_enable_irq(rxq); if (!qmgr_stat_below_low_watermark(rxq) && napi_reschedule(napi)) { /* not empty again */ #if DEBUG_RX - printk(KERN_DEBUG "%s: eth_poll napi_reschedule succeeded\n", - dev->name); + netdev_debug(dev, "eth_poll napi_reschedule succeeded\n"); #endif qmgr_disable_irq(rxq); continue; } #if DEBUG_RX - printk(KERN_DEBUG "%s: eth_poll all done\n", - dev->name); + netdev_debug(dev, "eth_poll all done\n"); #endif return received; /* all work done */ } @@ -769,7 +766,7 @@ static int eth_poll(struct napi_struct *napi, int budget) } #if DEBUG_RX - printk(KERN_DEBUG "eth_poll(): end, not all work done\n"); + netdev_debug(dev, "eth_poll(): end, not all work done\n"); #endif return received; /* not all work done */ } @@ -833,7 +830,7 @@ static int eth_xmit(struct sk_buff *skb, struct net_device *dev) struct desc *desc; #if DEBUG_TX - printk(KERN_DEBUG "%s: eth_xmit\n", dev->name); + netdev_debug(dev, "eth_xmit\n"); #endif if (unlikely(skb->len > MAX_MRU)) { @@ -888,22 +885,21 @@ static int eth_xmit(struct sk_buff *skb, struct net_device *dev) if (qmgr_stat_below_low_watermark(txreadyq)) { /* empty */ #if DEBUG_TX - printk(KERN_DEBUG "%s: eth_xmit queue full\n", dev->name); + netdev_debug(dev, "eth_xmit queue full\n"); #endif netif_stop_queue(dev); /* we could miss TX ready interrupt */ /* really empty in fact */ if (!qmgr_stat_below_low_watermark(txreadyq)) { #if DEBUG_TX - printk(KERN_DEBUG "%s: eth_xmit ready again\n", - dev->name); + netdev_debug(dev, "eth_xmit ready again\n"); #endif netif_wake_queue(dev); } } #if DEBUG_TX - printk(KERN_DEBUG "%s: eth_xmit end\n", dev->name); + netdev_debug(dev, "eth_xmit end\n"); #endif ixp_tx_timestamp(port, skb); @@ -1177,8 +1173,7 @@ static int eth_open(struct net_device *dev) return err; if (npe_recv_message(npe, &msg, "ETH_GET_STATUS")) { - printk(KERN_ERR "%s: %s not responding\n", dev->name, - npe_name(npe)); + netdev_err(dev, "%s not responding\n", npe_name(npe)); return -EIO; } port->firmware[0] = msg.byte4; @@ -1290,7 +1285,7 @@ static int eth_close(struct net_device *dev) msg.eth_id = port->id; msg.byte3 = 1; if (npe_send_recv_message(port->npe, &msg, "ETH_ENABLE_LOOPBACK")) - printk(KERN_CRIT "%s: unable to enable loopback\n", dev->name); + netdev_crit(dev, "unable to enable loopback\n"); i = 0; do { /* drain RX buffers */ @@ -1314,11 +1309,11 @@ static int eth_close(struct net_device *dev) } while (++i < MAX_CLOSE_WAIT); if (buffs) - printk(KERN_CRIT "%s: unable to drain RX queue, %i buffer(s)" - " left in NPE\n", dev->name, buffs); + netdev_crit(dev, "unable to drain RX queue, %i buffer(s)" + " left in NPE\n", buffs); #if DEBUG_CLOSE if (!buffs) - printk(KERN_DEBUG "Draining RX queue took %i cycles\n", i); + netdev_debug(dev, "draining RX queue took %i cycles\n", i); #endif buffs = TX_DESCS; @@ -1334,17 +1329,16 @@ static int eth_close(struct net_device *dev) } while (++i < MAX_CLOSE_WAIT); if (buffs) - printk(KERN_CRIT "%s: unable to drain TX queue, %i buffer(s) " - "left in NPE\n", dev->name, buffs); + netdev_crit(dev, "unable to drain TX queue, %i buffer(s) " + "left in NPE\n", buffs); #if DEBUG_CLOSE if (!buffs) - printk(KERN_DEBUG "Draining TX queues took %i cycles\n", i); + netdev_debug(dev, "draining TX queues took %i cycles\n", i); #endif msg.byte3 = 0; if (npe_send_recv_message(port->npe, &msg, "ETH_DISABLE_LOOPBACK")) - printk(KERN_CRIT "%s: unable to disable loopback\n", - dev->name); + netdev_crit(dev, "unable to disable loopback\n"); phy_stop(dev->phydev); @@ -1476,8 +1470,8 @@ static int ixp4xx_eth_probe(struct platform_device *pdev) if ((err = register_netdev(ndev))) goto err_phy_dis; - printk(KERN_INFO "%s: MII PHY %i on %s\n", ndev->name, plat->phy, - npe_name(port->npe)); + netdev_info(ndev, "%s: MII PHY %i on %s\n", ndev->name, plat->phy, + npe_name(port->npe)); return 0; From patchwork Fri Nov 1 13:02:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 178312 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp457041ill; Fri, 1 Nov 2019 06:02:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqx0sgdRcTsUvejIcd9In2D3COKWNY+u8q8hd5u9mL8OcQDVBlEKp5+JUWFul3SZl5q7s0bX X-Received: by 2002:a50:ace1:: with SMTP id x88mr12419520edc.132.1572613371627; Fri, 01 Nov 2019 06:02:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572613371; cv=none; d=google.com; s=arc-20160816; b=QDy6UeM/gfOlyCiUQ9PfLidO+VLbx+RjTqO6dhJWDc2XpnjlG6BwwPe0DG3/7vr/hs RK1kGtpcJRMXLNAbdUSX00ss5NXTm7Jy/HEXJH0CACU5BQnAYOrEc1mTQYPMoPPoqXpF 6nggcM/ZeN3zlye1VtavVFWQxOPylnFhR4weJFBWEMf6NB4Onw/BUQCgmB+LBaDoPTAk /iuOVcnewy5VYES5lomvGcjB0Wcx+ayAfAIAXQxvYVBJcJj0FsTj2Wk2cIrsljaxNaHb BtO41h10SaR9T4f7n3si6RhPlTSsdnjt8QTbS2dOYw0L2UzKitQprR9ajZXDOoGEeDFB +vnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=5qSCY0hy3sMC48rHBt8kAyy5w94n60kfo77Hgg2J0rk=; b=DY+hXBLik47jYP6QZ4m+YL1NvNevXQmaeNz37RUpjzrbjdD0306icwT/lKPJ1pchzn J9vzRJsx6kOIEVd1VIRmQkZ79fQIKv8+iJYUnCw4CFMi1Szr7aqpqVaN/CWh3M15LrXl tvomy4HUGIkPTnz98KPe4UeIO2C6uw4B1VJ/wDuySnLlX8HARb7/yhq/M5YmgvsiQrhe 9xZNupGBY5sGOhi+bX2nBlGke/Uk4fvc2lgK6nELuiXFhlpTLWsDKvz27GuU2Ma79Uyu 2lRJqgvXMxWQTJYWYnYOL6oVL7n9uXoK9FgJAkSYH3RaKSFfVQ1OIXsRwuUMS5ott0qO 5WTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YqdYTCYF; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q8si281981edi.445.2019.11.01.06.02.51; Fri, 01 Nov 2019 06:02:51 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of netdev-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=@linaro.org header.s=google header.b=YqdYTCYF; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727196AbfKANCu (ORCPT + 9 others); Fri, 1 Nov 2019 09:02:50 -0400 Received: from mail-lf1-f65.google.com ([209.85.167.65]:36253 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727085AbfKANCu (ORCPT ); Fri, 1 Nov 2019 09:02:50 -0400 Received: by mail-lf1-f65.google.com with SMTP id a6so3776064lfo.3 for ; Fri, 01 Nov 2019 06:02:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=5qSCY0hy3sMC48rHBt8kAyy5w94n60kfo77Hgg2J0rk=; b=YqdYTCYFlmov3myb26ioiRB9KTJ39sNs84l1K5oejeFawLSxRqhdX/CR9zLhZqri+v /hfqMWDUs5n+JBuNCulgySlxCzGAPopfk3G2/1gJXhDGcqyRXf7NpRPhtgzRzJBgcGEJ 4OHTI3FVedfJZLrYawGH39BcfVW1wm/vQoNTabHItq6M+y2+NWhjqvmYs1ceg1ymawUk trNDdSio6A+cEssXN3Ikwbs6aZ6qdFJ3imE//YFcBK8pgaiA4aVTGyFtlRp5K5z6osak RCEICM0gRmeExis28eQfoj7yuZFlx4hsEOFhPWTnpPi9KLbUxNRj4hozrs/ExWSvI9KY t0iA== 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:mime-version:content-transfer-encoding; bh=5qSCY0hy3sMC48rHBt8kAyy5w94n60kfo77Hgg2J0rk=; b=FzJU5DVWY86Z6RaaRK3sHBa2A/TWyelnUVr3r8uJwQ6ROxb9C13M3gWV7fjGTj+tAs gRE/sw3p7gQam6VEjUvA3kU06CEuotjtWN7GCHuIh/ZfvXmoZI/1pPO5H1wVGgmuJxEW /gJzULayRGkI7aGZlAEEYFMypgh3F9aD2FGtGpFvA311+Sw1LAZjsIfJK/MeQlFTvFDV JF2UYM7nWXGG/Xw8hufOl1/mMFcACC7966GAUD31Hc3L72UuSe6Gqh6zMX+7zvaiayYs LWlIO+I3PQ01O8YtWuyORNzrxWfJ3K07zH2PX4UN/XsMXUR6JYxNZr9MaICLRy33+4eo Siww== X-Gm-Message-State: APjAAAV/t8ol7LEbzpF3J6yvaS4VfMsx6zzhvV844WWfrbFOiZ2kypjS wRThG47s/uj15pYcRXMAe3jgkidakjq+HQ== X-Received: by 2002:a19:c790:: with SMTP id x138mr7352814lff.61.1572613366471; Fri, 01 Nov 2019 06:02:46 -0700 (PDT) Received: from localhost.bredbandsbolaget (c-79c8225c.014-348-6c756e10.bbcust.telenor.se. [92.34.200.121]) by smtp.gmail.com with ESMTPSA id c3sm2516749lfi.32.2019.11.01.06.02.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Nov 2019 06:02:45 -0700 (PDT) From: Linus Walleij To: netdev@vger.kernel.org, "David S . Miller" Cc: Arnd Bergmann , Jakub Kicinski , Linus Walleij Subject: [PATCH net-next 08/10 v2] ARM/net: ixp4xx: Pass ethernet physical base as resource Date: Fri, 1 Nov 2019 14:02:22 +0100 Message-Id: <20191101130224.7964-9-linus.walleij@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191101130224.7964-1-linus.walleij@linaro.org> References: <20191101130224.7964-1-linus.walleij@linaro.org> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org In order to probe this ethernet interface from the device tree all physical MMIO regions must be passed as resources. Begin this rewrite by first passing the port base address as a resource for all platforms using this driver, remap it in the driver and avoid using any reference of the statically mapped virtual address in the driver. Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Rebased on the rest of the series. --- arch/arm/mach-ixp4xx/fsg-setup.c | 20 ++++++++++++++++++++ arch/arm/mach-ixp4xx/goramo_mlr.c | 20 ++++++++++++++++++++ arch/arm/mach-ixp4xx/ixdp425-setup.c | 20 ++++++++++++++++++++ arch/arm/mach-ixp4xx/nas100d-setup.c | 10 ++++++++++ arch/arm/mach-ixp4xx/nslu2-setup.c | 10 ++++++++++ arch/arm/mach-ixp4xx/omixp-setup.c | 20 ++++++++++++++++++++ arch/arm/mach-ixp4xx/vulcan-setup.c | 20 ++++++++++++++++++++ drivers/net/ethernet/xscale/ixp4xx_eth.c | 20 +++++++++++--------- 8 files changed, 131 insertions(+), 9 deletions(-) -- 2.21.0 diff --git a/arch/arm/mach-ixp4xx/fsg-setup.c b/arch/arm/mach-ixp4xx/fsg-setup.c index 648932d8d7a8..507ee3878769 100644 --- a/arch/arm/mach-ixp4xx/fsg-setup.c +++ b/arch/arm/mach-ixp4xx/fsg-setup.c @@ -132,6 +132,22 @@ static struct platform_device fsg_leds = { }; /* Built-in 10/100 Ethernet MAC interfaces */ +static struct resource fsg_eth_npeb_resources[] = { + { + .start = IXP4XX_EthB_BASE_PHYS, + .end = IXP4XX_EthB_BASE_PHYS + 0x0fff, + .flags = IORESOURCE_MEM, + }, +}; + +static struct resource fsg_eth_npec_resources[] = { + { + .start = IXP4XX_EthC_BASE_PHYS, + .end = IXP4XX_EthC_BASE_PHYS + 0x0fff, + .flags = IORESOURCE_MEM, + }, +}; + static struct eth_plat_info fsg_plat_eth[] = { { .phy = 5, @@ -151,12 +167,16 @@ static struct platform_device fsg_eth[] = { .dev = { .platform_data = fsg_plat_eth, }, + .num_resources = ARRAY_SIZE(fsg_eth_npeb_resources), + .resource = fsg_eth_npeb_resources, }, { .name = "ixp4xx_eth", .id = IXP4XX_ETH_NPEC, .dev = { .platform_data = fsg_plat_eth + 1, }, + .num_resources = ARRAY_SIZE(fsg_eth_npec_resources), + .resource = fsg_eth_npec_resources, } }; diff --git a/arch/arm/mach-ixp4xx/goramo_mlr.c b/arch/arm/mach-ixp4xx/goramo_mlr.c index 93b7afeee142..07b50dfcc489 100644 --- a/arch/arm/mach-ixp4xx/goramo_mlr.c +++ b/arch/arm/mach-ixp4xx/goramo_mlr.c @@ -273,6 +273,22 @@ static struct platform_device device_uarts = { /* Built-in 10/100 Ethernet MAC interfaces */ +static struct resource eth_npeb_resources[] = { + { + .start = IXP4XX_EthB_BASE_PHYS, + .end = IXP4XX_EthB_BASE_PHYS + 0x0fff, + .flags = IORESOURCE_MEM, + }, +}; + +static struct resource eth_npec_resources[] = { + { + .start = IXP4XX_EthC_BASE_PHYS, + .end = IXP4XX_EthC_BASE_PHYS + 0x0fff, + .flags = IORESOURCE_MEM, + }, +}; + static struct eth_plat_info eth_plat[] = { { .phy = 0, @@ -290,10 +306,14 @@ static struct platform_device device_eth_tab[] = { .name = "ixp4xx_eth", .id = IXP4XX_ETH_NPEB, .dev.platform_data = eth_plat, + .num_resources = ARRAY_SIZE(eth_npeb_resources), + .resource = eth_npeb_resources, }, { .name = "ixp4xx_eth", .id = IXP4XX_ETH_NPEC, .dev.platform_data = eth_plat + 1, + .num_resources = ARRAY_SIZE(eth_npec_resources), + .resource = eth_npec_resources, } }; diff --git a/arch/arm/mach-ixp4xx/ixdp425-setup.c b/arch/arm/mach-ixp4xx/ixdp425-setup.c index 6f0f7ed18ea8..45d5b720ded6 100644 --- a/arch/arm/mach-ixp4xx/ixdp425-setup.c +++ b/arch/arm/mach-ixp4xx/ixdp425-setup.c @@ -187,6 +187,22 @@ static struct platform_device ixdp425_uart = { }; /* Built-in 10/100 Ethernet MAC interfaces */ +static struct resource ixp425_npeb_resources[] = { + { + .start = IXP4XX_EthB_BASE_PHYS, + .end = IXP4XX_EthB_BASE_PHYS + 0x0fff, + .flags = IORESOURCE_MEM, + }, +}; + +static struct resource ixp425_npec_resources[] = { + { + .start = IXP4XX_EthC_BASE_PHYS, + .end = IXP4XX_EthC_BASE_PHYS + 0x0fff, + .flags = IORESOURCE_MEM, + }, +}; + static struct eth_plat_info ixdp425_plat_eth[] = { { .phy = 0, @@ -204,10 +220,14 @@ static struct platform_device ixdp425_eth[] = { .name = "ixp4xx_eth", .id = IXP4XX_ETH_NPEB, .dev.platform_data = ixdp425_plat_eth, + .num_resources = ARRAY_SIZE(ixp425_npeb_resources), + .resource = ixp425_npeb_resources, }, { .name = "ixp4xx_eth", .id = IXP4XX_ETH_NPEC, .dev.platform_data = ixdp425_plat_eth + 1, + .num_resources = ARRAY_SIZE(ixp425_npec_resources), + .resource = ixp425_npec_resources, } }; diff --git a/arch/arm/mach-ixp4xx/nas100d-setup.c b/arch/arm/mach-ixp4xx/nas100d-setup.c index c142cfa8c5d6..6959ad2e3aec 100644 --- a/arch/arm/mach-ixp4xx/nas100d-setup.c +++ b/arch/arm/mach-ixp4xx/nas100d-setup.c @@ -165,6 +165,14 @@ static struct platform_device nas100d_uart = { }; /* Built-in 10/100 Ethernet MAC interfaces */ +static struct resource nas100d_eth_resources[] = { + { + .start = IXP4XX_EthB_BASE_PHYS, + .end = IXP4XX_EthB_BASE_PHYS + 0x0fff, + .flags = IORESOURCE_MEM, + }, +}; + static struct eth_plat_info nas100d_plat_eth[] = { { .phy = 0, @@ -178,6 +186,8 @@ static struct platform_device nas100d_eth[] = { .name = "ixp4xx_eth", .id = IXP4XX_ETH_NPEB, .dev.platform_data = nas100d_plat_eth, + .num_resources = ARRAY_SIZE(nas100d_eth_resources), + .resource = nas100d_eth_resources, } }; diff --git a/arch/arm/mach-ixp4xx/nslu2-setup.c b/arch/arm/mach-ixp4xx/nslu2-setup.c index ee1877fcfafe..a428bb918703 100644 --- a/arch/arm/mach-ixp4xx/nslu2-setup.c +++ b/arch/arm/mach-ixp4xx/nslu2-setup.c @@ -185,6 +185,14 @@ static struct platform_device nslu2_uart = { }; /* Built-in 10/100 Ethernet MAC interfaces */ +static struct resource nslu2_eth_resources[] = { + { + .start = IXP4XX_EthB_BASE_PHYS, + .end = IXP4XX_EthB_BASE_PHYS + 0x0fff, + .flags = IORESOURCE_MEM, + }, +}; + static struct eth_plat_info nslu2_plat_eth[] = { { .phy = 1, @@ -198,6 +206,8 @@ static struct platform_device nslu2_eth[] = { .name = "ixp4xx_eth", .id = IXP4XX_ETH_NPEB, .dev.platform_data = nslu2_plat_eth, + .num_resources = ARRAY_SIZE(nslu2_eth_resources), + .resource = nslu2_eth_resources, } }; diff --git a/arch/arm/mach-ixp4xx/omixp-setup.c b/arch/arm/mach-ixp4xx/omixp-setup.c index 6ed5a9aed600..8f2b8c473d7a 100644 --- a/arch/arm/mach-ixp4xx/omixp-setup.c +++ b/arch/arm/mach-ixp4xx/omixp-setup.c @@ -170,6 +170,22 @@ static struct platform_device mic256_leds = { }; /* Built-in 10/100 Ethernet MAC interfaces */ +static struct resource ixp425_npeb_resources[] = { + { + .start = IXP4XX_EthB_BASE_PHYS, + .end = IXP4XX_EthB_BASE_PHYS + 0x0fff, + .flags = IORESOURCE_MEM, + }, +}; + +static struct resource ixp425_npec_resources[] = { + { + .start = IXP4XX_EthC_BASE_PHYS, + .end = IXP4XX_EthC_BASE_PHYS + 0x0fff, + .flags = IORESOURCE_MEM, + }, +}; + static struct eth_plat_info ixdp425_plat_eth[] = { { .phy = 0, @@ -187,10 +203,14 @@ static struct platform_device ixdp425_eth[] = { .name = "ixp4xx_eth", .id = IXP4XX_ETH_NPEB, .dev.platform_data = ixdp425_plat_eth, + .num_resources = ARRAY_SIZE(ixp425_npeb_resources), + .resource = ixp425_npeb_resources, }, { .name = "ixp4xx_eth", .id = IXP4XX_ETH_NPEC, .dev.platform_data = ixdp425_plat_eth + 1, + .num_resources = ARRAY_SIZE(ixp425_npec_resources), + .resource = ixp425_npec_resources, }, }; diff --git a/arch/arm/mach-ixp4xx/vulcan-setup.c b/arch/arm/mach-ixp4xx/vulcan-setup.c index d2ebb7c675a8..e506d2af98ad 100644 --- a/arch/arm/mach-ixp4xx/vulcan-setup.c +++ b/arch/arm/mach-ixp4xx/vulcan-setup.c @@ -124,6 +124,22 @@ static struct platform_device vulcan_uart = { .num_resources = ARRAY_SIZE(vulcan_uart_resources), }; +static struct resource vulcan_npeb_resources[] = { + { + .start = IXP4XX_EthB_BASE_PHYS, + .end = IXP4XX_EthB_BASE_PHYS + 0x0fff, + .flags = IORESOURCE_MEM, + }, +}; + +static struct resource vulcan_npec_resources[] = { + { + .start = IXP4XX_EthC_BASE_PHYS, + .end = IXP4XX_EthC_BASE_PHYS + 0x0fff, + .flags = IORESOURCE_MEM, + }, +}; + static struct eth_plat_info vulcan_plat_eth[] = { [0] = { .phy = 0, @@ -144,6 +160,8 @@ static struct platform_device vulcan_eth[] = { .dev = { .platform_data = &vulcan_plat_eth[0], }, + .num_resources = ARRAY_SIZE(vulcan_npeb_resources), + .resource = vulcan_npeb_resources, }, [1] = { .name = "ixp4xx_eth", @@ -151,6 +169,8 @@ static struct platform_device vulcan_eth[] = { .dev = { .platform_data = &vulcan_plat_eth[1], }, + .num_resources = ARRAY_SIZE(vulcan_npec_resources), + .resource = vulcan_npec_resources, }, }; diff --git a/drivers/net/ethernet/xscale/ixp4xx_eth.c b/drivers/net/ethernet/xscale/ixp4xx_eth.c index f7edf8b38dea..ee45215c4ba4 100644 --- a/drivers/net/ethernet/xscale/ixp4xx_eth.c +++ b/drivers/net/ethernet/xscale/ixp4xx_eth.c @@ -1365,9 +1365,10 @@ static int ixp4xx_eth_probe(struct platform_device *pdev) struct phy_device *phydev = NULL; struct device *dev = &pdev->dev; struct eth_plat_info *plat; + resource_size_t regs_phys; struct net_device *ndev; + struct resource *res; struct port *port; - u32 regs_phys; int err; plat = dev_get_platdata(dev); @@ -1380,13 +1381,18 @@ static int ixp4xx_eth_probe(struct platform_device *pdev) port->netdev = ndev; port->id = pdev->id; + /* Get the port resource and remap */ + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!res) + return -ENODEV; + regs_phys = res->start; + port->regs = devm_ioremap_resource(dev, res); + switch (port->id) { case IXP4XX_ETH_NPEA: /* If the MDIO bus is not up yet, defer probe */ if (!mdio_bus) return -EPROBE_DEFER; - port->regs = (struct eth_regs __iomem *)IXP4XX_EthA_BASE_VIRT; - regs_phys = IXP4XX_EthA_BASE_PHYS; break; case IXP4XX_ETH_NPEB: /* @@ -1399,13 +1405,11 @@ static int ixp4xx_eth_probe(struct platform_device *pdev) IXP4XX_FEATURE_NPEB_ETH0)) return -ENODEV; /* Else register the MDIO bus on NPE-B */ - if ((err = ixp4xx_mdio_register(IXP4XX_EthC_BASE_VIRT))) + if ((err = ixp4xx_mdio_register(port->regs))) return err; } if (!mdio_bus) return -EPROBE_DEFER; - port->regs = (struct eth_regs __iomem *)IXP4XX_EthB_BASE_VIRT; - regs_phys = IXP4XX_EthB_BASE_PHYS; break; case IXP4XX_ETH_NPEC: /* @@ -1417,13 +1421,11 @@ static int ixp4xx_eth_probe(struct platform_device *pdev) IXP4XX_FEATURE_NPEC_ETH)) return -ENODEV; /* Else register the MDIO bus on NPE-C */ - if ((err = ixp4xx_mdio_register(IXP4XX_EthC_BASE_VIRT))) + if ((err = ixp4xx_mdio_register(port->regs))) return err; } if (!mdio_bus) return -EPROBE_DEFER; - port->regs = (struct eth_regs __iomem *)IXP4XX_EthC_BASE_VIRT; - regs_phys = IXP4XX_EthC_BASE_PHYS; break; default: return -ENODEV; From patchwork Fri Nov 1 13:02:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 178313 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp457085ill; Fri, 1 Nov 2019 06:02:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqzZtCXbbDMKOt68FLPSaoHDHszoZ6wV3oT7nvmz5myEj5DcYE+qawe10hyTWEGYNcCCCwMO X-Received: by 2002:a1c:2846:: with SMTP id o67mr10226533wmo.7.1572613373424; Fri, 01 Nov 2019 06:02:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572613373; cv=none; d=google.com; s=arc-20160816; b=sSzDTn1673i9l9BggRZhlSCk8nuVODnG48ZPLWeMFiXmisH6BUxvCoMrqIOW9wjUPj sjAxnlgv5XYL69vmdw0F78I+u1/8hDkYyM74rrfd74MF4cIvW7pguWbc0udzu+UDFS0N 2L/NYbTNab/nuJ8Z1YhxJcMZw4Pu8OuoyozqAkqW26uew5kUMKSLmFjlela7MxXgjUS4 nKTdlLU+nQR7hxS9n9q2xSzdA06GvwimV35TeFcv5x0bR81Yo1wuEFEH4CH3YHGvz2sw dOU025iw0lqmjqfDKx1vAbAH8Z+YGGRnwSoqLPorDouQ8bWLl4ovGQgrjdtf8pTPK0FU LYdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=hvMD1aC6WUHR6xu8BtikZIRx397yHG2yQak6VMqUJdU=; b=BoJQTUsIzsp2L2yBXPDyiio00X/jEO3cB8MpAVksobiOyaMtX90Ty2Ld1gR94fUbdY t4l/fvpuMLdDz5W5u9RXsaoTEs1cwRwZ/TEgTjr+5+hesMxF/fwqj90c5qZ323BOAAq0 ZS8I3FwQf5kpZQimYtWsnIo4brkaGj1aPb5UiI7olBfJo+y4Sob73RcIvyzuNyz7hOI+ EC0Jcoqhux2afh0kKB7sWCGGTsCGhOQSgFxQ8CXxs+b6MhPn8cicAvk8XI7LKlFVRLFL lTFagZjFTCxfbiFpkk6jMc/E2SCaYTPKYxvJ8BKBp8mvRJPpnofn1J6OA/Zz62QhHimR Xfvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HJrCydh0; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q8si281981edi.445.2019.11.01.06.02.53; Fri, 01 Nov 2019 06:02:53 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of netdev-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=@linaro.org header.s=google header.b=HJrCydh0; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727206AbfKANCw (ORCPT + 9 others); Fri, 1 Nov 2019 09:02:52 -0400 Received: from mail-lf1-f65.google.com ([209.85.167.65]:37540 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727181AbfKANCu (ORCPT ); Fri, 1 Nov 2019 09:02:50 -0400 Received: by mail-lf1-f65.google.com with SMTP id b20so7186125lfp.4 for ; Fri, 01 Nov 2019 06:02:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=hvMD1aC6WUHR6xu8BtikZIRx397yHG2yQak6VMqUJdU=; b=HJrCydh0EjgsJXa5y1pTpO14wSUxZUifGBHgoKl1vkt0PfKTzZd6uveD34Bgo895+z 4YCFmwXwihewpZqh/HggHXRL/uW1Oz8+1zWtFLbDxJREGvUhISaKTRNHH/+2xgzgA8H3 dgrYbpWWoZsiVL7G3G4iXy+vSURsHi9ztPckgGbULaASfEOqSsfnzNayqcCgsW8QFJH+ BbnXpHe6NIoqtFbR5ji/hOj3HSZXikYvflpUXtyvzkVcaf2NoSrX8b3mLCIuCwegQEph CSdoiXpGkeXDW1QNcod3jMglK9NWmCrS2+v5FtxdWG9po1oLtXbWNj52q7wYLjIQ5FQc ZAQQ== 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:mime-version:content-transfer-encoding; bh=hvMD1aC6WUHR6xu8BtikZIRx397yHG2yQak6VMqUJdU=; b=EOargR0DOvPaH57vT4FZsVNFJPhH1PB2lmXyKqdiaBaNsRdrEp6S5pmVRrR6xjk/w1 iigBH/o1gZh76E7TAfmWDRf01o4snxRgRq0ledfkIDvyipGyexQMbaD1EguPTb8PF/mv eWEvxoqqYbrN63F4Nl2sVGvpf5TVgmfXOw+deqiPedtbLWKLYXpctqDJxzgVxmx7wbFC bk8bFEb/wNLdGpsNq6wVVVWGPKwzyDUKs8UiRSJyk3SulXmvGTTr25MiUVtWRHtNQao7 4+9Z45IT07p2ByXLLBlL7La4C1HwFw4LnIHswizV3fSMmCKcd5I+FjxTr+2wZ2X4HxaN wcdQ== X-Gm-Message-State: APjAAAU1S9aQ+zSEG3qvAgmA//uyQB3Y4h4Ky21aKprMc7UYk1X7CxAe K3Zv4DcSLOrXqDxguxGxvnajK0P2iDc19g== X-Received: by 2002:a19:7b16:: with SMTP id w22mr7535433lfc.114.1572613368556; Fri, 01 Nov 2019 06:02:48 -0700 (PDT) Received: from localhost.bredbandsbolaget (c-79c8225c.014-348-6c756e10.bbcust.telenor.se. [92.34.200.121]) by smtp.gmail.com with ESMTPSA id c3sm2516749lfi.32.2019.11.01.06.02.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Nov 2019 06:02:47 -0700 (PDT) From: Linus Walleij To: netdev@vger.kernel.org, "David S . Miller" Cc: Arnd Bergmann , Jakub Kicinski , Linus Walleij Subject: [PATCH net-next 09/10 v2] net: ethernet: ixp4xx: Get port ID from base address Date: Fri, 1 Nov 2019 14:02:23 +0100 Message-Id: <20191101130224.7964-10-linus.walleij@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191101130224.7964-1-linus.walleij@linaro.org> References: <20191101130224.7964-1-linus.walleij@linaro.org> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The port->id was picked from the platform device .id field, but this is not supposed to be used for passing around random numbers in hardware. Identify the port ID number from the base address instead. This is necessary for Device Tree conversion: to DT these are just three networking engines (NPEs) that the OS can choose to use however it likes. When we move to DT we cannot get these port numbers from the device tree. That they behave differently and that the driver has to cope with that is due to different firmware being loaded into the different NPE:s. DT doesn't care about that. The firmware can theoretically be changed, but the DT bindings can not. Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Rebased on the rest of the series. --- drivers/net/ethernet/xscale/ixp4xx_eth.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) -- 2.21.0 diff --git a/drivers/net/ethernet/xscale/ixp4xx_eth.c b/drivers/net/ethernet/xscale/ixp4xx_eth.c index ee45215c4ba4..c5835a2fb965 100644 --- a/drivers/net/ethernet/xscale/ixp4xx_eth.c +++ b/drivers/net/ethernet/xscale/ixp4xx_eth.c @@ -1379,7 +1379,6 @@ static int ixp4xx_eth_probe(struct platform_device *pdev) SET_NETDEV_DEV(ndev, dev); port = netdev_priv(ndev); port->netdev = ndev; - port->id = pdev->id; /* Get the port resource and remap */ res = platform_get_resource(pdev, IORESOURCE_MEM, 0); @@ -1388,13 +1387,15 @@ static int ixp4xx_eth_probe(struct platform_device *pdev) regs_phys = res->start; port->regs = devm_ioremap_resource(dev, res); - switch (port->id) { - case IXP4XX_ETH_NPEA: + switch (res->start) { + case 0xc800c000: + port->id = IXP4XX_ETH_NPEA; /* If the MDIO bus is not up yet, defer probe */ if (!mdio_bus) return -EPROBE_DEFER; break; - case IXP4XX_ETH_NPEB: + case 0xc8009000: + port->id = IXP4XX_ETH_NPEB; /* * On all except IXP43x, NPE-B is used for the MDIO bus. * If there is no NPE-B in the feature set, bail out, else @@ -1411,7 +1412,8 @@ static int ixp4xx_eth_probe(struct platform_device *pdev) if (!mdio_bus) return -EPROBE_DEFER; break; - case IXP4XX_ETH_NPEC: + case 0xc800a000: + port->id = IXP4XX_ETH_NPEC; /* * IXP43x lacks NPE-B and uses NPE-C for the MDIO bus access, * of there is no NPE-C, no bus, nothing works, so bail out.