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: 1188005 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="zPuFRVJF"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 474MmW4WNHz9sRX for ; Sat, 2 Nov 2019 00:02:35 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727083AbfKANCe (ORCPT ); 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-Google-Smtp-Source: APXvYqyx9xCsIqhZGzBB+hiusl/KzyGGof21JXoBcuFzjOGWBuiLu94lAfVtAluBBvQMsdqp/JPCqA== 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(-) 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: 1188006 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="P59WIHG4"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 474MmZ34Ryz9sRc for ; Sat, 2 Nov 2019 00:02:38 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727108AbfKANCh (ORCPT ); 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-Google-Smtp-Source: APXvYqycVX/g1nunIVpjox4XDWyxochtMsk5XFaGwIXUphjYFVRh9SfeHukIPoNhq2SI1FYpfvM7bg== 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 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: 1188007 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="gU7SZg+h"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 474Mmg4xwSz9sRX for ; Sat, 2 Nov 2019 00:02:43 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727128AbfKANCj (ORCPT ); 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-Google-Smtp-Source: APXvYqxaGVF6BmEaTCwBgV9A7GYcew4WIPagyIg6GfmMkFAQTdtgpHrWNBZWAi675hxJOtMIy9nl1A== 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%) 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: 1188008 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="RRahzDy9"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 474Mmh4SfHz9sRp for ; Sat, 2 Nov 2019 00:02:44 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727137AbfKANCl (ORCPT ); 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-Google-Smtp-Source: APXvYqyEpgx3CfeqNxcpzpnpjbyiU4JA3zju8wAI8MrViFlS4wI927Emju2ZEGe93sE0nBNvKU9bag== 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 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: 1188009 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="xhKzWBnO"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 474Mmj4Cg2z9sRs for ; Sat, 2 Nov 2019 00:02:45 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727162AbfKANCo (ORCPT ); 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-Google-Smtp-Source: APXvYqyZk6oPK/KSgYiG1/DHUJE8sJXM3An2QDOCnGsRc4+foTmu0Vv3JOo/uW9jSZqDnGGBCe9SIg== 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(-) 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: 1188010 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="AJ2gW2DL"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 474Mml67KKz9sRX for ; Sat, 2 Nov 2019 00:02:47 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727170AbfKANCr (ORCPT ); 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-Google-Smtp-Source: APXvYqxIBv3yNJQwIfSTM20qT6MMLmdsVnywYA2F763OOvO0GX9bXldSGbV3l/88Tix/xw5S5dXLiw== 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(-) 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: 1188011 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="ELcAlnwi"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 474Mmn29v2z9sP3 for ; Sat, 2 Nov 2019 00:02:49 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727180AbfKANCr (ORCPT ); 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-Google-Smtp-Source: APXvYqzc1bDk3Tyd9FoVYzS2YNOHoHmrcK/CVTlY4XVQmyHBy1BI7Cu+UoW39huXrQcJpYKF8Rh3HA== 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(-) 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: 1188012 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="YqdYTCYF"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 474Mmq2VCdz9sRm for ; Sat, 2 Nov 2019 00:02:51 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727196AbfKANCu (ORCPT ); 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-Google-Smtp-Source: APXvYqwaxtKUNbiVKoe9UrW/Eu/bXCNQa2pdKadGKnPGzgBuEADTulTvKC/p5fsyEUjvY0YatVD1ew== 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(-) 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: 1188013 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="HJrCydh0"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 474Mms24xXz9sP3 for ; Sat, 2 Nov 2019 00:02:53 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727206AbfKANCw (ORCPT ); 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-Google-Smtp-Source: APXvYqxFQjZutksgwIOgJVR6VAvD9jVOz4pNGfcxN9SvnZ/G/bAZNiCaHsxV+sKyI71/E1CJZi8SCw== 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(-) 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. From patchwork Fri Nov 1 13:02:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 1188014 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="lqtN08Hq"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 474Mmz1zMWz9sRm for ; Sat, 2 Nov 2019 00:02:59 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727216AbfKANCy (ORCPT ); Fri, 1 Nov 2019 09:02:54 -0400 Received: from mail-lj1-f195.google.com ([209.85.208.195]:41559 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727200AbfKANCx (ORCPT ); Fri, 1 Nov 2019 09:02:53 -0400 Received: by mail-lj1-f195.google.com with SMTP id m9so10151626ljh.8 for ; Fri, 01 Nov 2019 06:02:51 -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=c9W010bePpb3OOGnKRElBxkQbvyqmresES6SORuIRPg=; b=lqtN08HqXra8vS2ZQwN34VQ3mbUzilaONUN/1vaug++BgQlN2uzi4XefvguK4Beb4a DqnNyDqSXJg/8DaX6dZZhF9GhnUB4JIuoYMtWXYg5VGGW3UQPm0EAflzrFazZwtdhHzZ Q77h/ppit2TQRHzVO3MnEPk9kwjb+Ox65brMWJ4tmm0mLryD/9d3kiEHj+3LU7CjYP/l A53j+5UUf9aUp20CPR7935ZJGeKJZPV52HHN4bafhlmJpYLmehtdsIkU3eQgRz6wOUip l5QOhCa/YGtzs1J+i8RqerTfEiZODoR44olNVbovOAcQLHOrI2WC0M92IysVQIBX/2jB Lgpw== 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=c9W010bePpb3OOGnKRElBxkQbvyqmresES6SORuIRPg=; b=qIKNWygL252lgi/NmsiDi3nutqS4KgDmSgxqM9kyjBKl7m4m9hojxszW2sh/F8I5l4 goytNwVw79gdsSrpMPOX1MoHTs1KQMXlOZ5dux2tXlY+MDMHR4E3JN5Dl/6BlIH+8JBi W669/jFBe6BXBNAEwWiMC6/5iO8wN+V5t9Vhqvd7gXqjYRMf9N59AsTXjfQVtXsiZYeN 8poyHvwLU+/H1rR1jwOQZG7Fv4xAJuZsSeiV51o7rN6A/i1YKVeyZq1DtDo+V/JCBrun cgZnKZ4O8Qk3LE6H3vavFTpGBvT3/GT73MGrRChQvKFY3DfjAR/VWiTB5nzExsuC6Xpy TuXA== X-Gm-Message-State: APjAAAVeVK8yJQ7/6oCWMq/pJfeiS2V7hirdZDGlmBwPFn4U8Uvf09cI xzQPvUzK1foPdOrrzQ/ZUlmUmbgr/lC1zA== X-Google-Smtp-Source: APXvYqym6LEoQ+L0bWEEkIZdGK/5n+fclcT4T6pMm7IxZq0DR1lLBzU3h1EiEJgYSghkF8lAhNGjJg== X-Received: by 2002:a2e:85ce:: with SMTP id h14mr4861703ljj.92.1572613370415; Fri, 01 Nov 2019 06:02:50 -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.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Nov 2019 06:02:49 -0700 (PDT) From: Linus Walleij To: netdev@vger.kernel.org, "David S . Miller" Cc: Arnd Bergmann , Jakub Kicinski , Linus Walleij , stable@vger.kernel.org Subject: [PATCH net-next 10/10 v2] net: ethernet: ixp4xx: Use parent dev for DMA pool Date: Fri, 1 Nov 2019 14:02:24 +0100 Message-Id: <20191101130224.7964-11-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 the netdevice struct device .parent field when calling dma_pool_create(): the .dma_coherent_mask and .dma_mask pertains to the bus device on the hardware (platform) bus in this case, not the struct device inside the network device. This makes the pool allocation work. Cc: stable@vger.kernel.org Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Rebase with the rest of the series. - Tag for stable, this is pretty serious. - I have no real idea when this stopped working. --- drivers/net/ethernet/xscale/ixp4xx_eth.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/xscale/ixp4xx_eth.c b/drivers/net/ethernet/xscale/ixp4xx_eth.c index c5835a2fb965..4baceae50490 100644 --- a/drivers/net/ethernet/xscale/ixp4xx_eth.c +++ b/drivers/net/ethernet/xscale/ixp4xx_eth.c @@ -1086,7 +1086,7 @@ static int init_queues(struct port *port) int i; if (!ports_open) { - dma_pool = dma_pool_create(DRV_NAME, &port->netdev->dev, + dma_pool = dma_pool_create(DRV_NAME, port->netdev->dev.parent, POOL_ALLOC_SIZE, 32, 0); if (!dma_pool) return -ENOMEM;