From patchwork Mon Oct 21 00:08: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: 176996 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp2664893ill; Sun, 20 Oct 2019 17:10:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqz4fUT0mlkwsGthsLrME+fNVgQHaRIwZv64YuMKNtG/oTV0gPvSZKuHSixV7U/v8e4zCNlG X-Received: by 2002:a50:b6cb:: with SMTP id f11mr305424ede.299.1571616608027; Sun, 20 Oct 2019 17:10:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571616608; cv=none; d=google.com; s=arc-20160816; b=aDe26RfJsh6pMm3f1RTBvFT/8H1uyJReAwji/eRvqvwvNx2KiZkh3moFtnrFzArudr WWVCYVxURfsfwi6/YRsVovEqPGwCIwPZWcnk3YNUXmemi8R78YOUQ/r5RZCadwsIm/0A OXP7P4lybjtdZc77O/G1aBGhfxd8HpXX3Kq6o4ijfyyfNXuURSQ2SDMbXb3TzZwi3B9l x7ADKlSqbiFmd6d/KilZBCpGYj42HZoWtoellHQFiYx6vQWJBQzr3GFB0FAaV9GO0U+P NrymDoZEfozdnFgdg6dhpxiwv64vWYYsI5Wkw2bycPqJErvgeuxWNxVaZMYWbZaLrMhu 2v2g== 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=hqHu8s6QOiWYaaMGUw3zthI3ATM9j5J6bRTqf/L3OEI=; b=WgUvAYY1yyQ45FNhxMP3R17MxngWjr1BoeuHopj4C7JoiUNNyUhw51uSINKJLyMMgN P+gtayhZfhWAS5Iwg8kiS0EMRL5UnjSjfuy7clG3mqvwQqVG6GiJz87La+HOG+6cpuLH 13Fw0LaB/4IYT7umzCe2adcx3pI5lPDiNc0wKxvCMY6TXdqudzjy22+Tn36IH5umw17q 9IQwhHTvNMoKvIay11vGAH6iAC3PIb2yJ76viZYuLvaLs2irBk/68zuwiJ3Fo/3qksLT /6oMuh870UtQWSmiA8QXS49J2HxfXO3vfm3Yiv9ATeyF/2tOH/knifcDhV4ts8P2SN7/ jIog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hdofXcDz; 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 p3si8007457ejj.347.2019.10.20.17.10.07; Sun, 20 Oct 2019 17:10:08 -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=hdofXcDz; 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 S1726796AbfJUAKC (ORCPT + 8 others); Sun, 20 Oct 2019 20:10:02 -0400 Received: from mail-lf1-f68.google.com ([209.85.167.68]:40513 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726576AbfJUAKC (ORCPT ); Sun, 20 Oct 2019 20:10:02 -0400 Received: by mail-lf1-f68.google.com with SMTP id i15so1128614lfo.7 for ; Sun, 20 Oct 2019 17:10:01 -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=hqHu8s6QOiWYaaMGUw3zthI3ATM9j5J6bRTqf/L3OEI=; b=hdofXcDzV9c8/JVe9WftNKsBEY6LkDmAQNJT/1p4gbRDFU+akneahydrCfADj8Es/e lVLhXdvqDvBvDiX8kc/oKeQ5aX6Rp8C7JB0cHiyp4Xc58rztjUedgdFU13RPvUzvZ8uZ ts06KN1/FeNJD1PTTnoHoovWx0EDziysM13WaUxQ+TRcM+whYLQrInjXdjTv3sApPMi+ 0CgwRU3nO1n4TNFRmOaY44gYMtHGGjeKZ0Ve5cGxkNl/fg6JQVNbwfx4wcEV+DFxXzHB 9ZZsfF8sT2GeOMfW4lePZFK/L/A5SkX7RKph0M6BA4XVJ8jckL5+YTbH7f7TFWp9JFEZ kDgA== 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=hqHu8s6QOiWYaaMGUw3zthI3ATM9j5J6bRTqf/L3OEI=; b=i2+Ig7as3VBB6ma31zDfzm9Zm/4NUEokht72Uf62dBBhPc5JC2OFz3TwCl+iHdeLvN bE0KKfSQqO6o1RtsIfx0Ja6ttBbbVmSE5plWdvVprOnZr1NIVum985dwti/Tfe21XBKh 3zFSfuLf2oqAzVTCxGlQ8jUhEcvWRlBDPeSWlGceKaaSeuQ1ndY62tQeO3G+CKfkrnAu kJnVZU55GoOncha5G6OcL74CshiirXde0XsML4UhAI2lFRHX/AuACJ9IamXmc876RWVt oeLyJySN0eZZMNeSAh6OorDMAAanLJtcSGn5+COxJBC+la4c2GnI9IN4tGMhY1Sn2/69 SJzg== X-Gm-Message-State: APjAAAW8rhRfzy2vQ/b+SmIbLZmTrEI75W5uLOJt4kyvdpV4ggHXFy0M VK4r2bXijlL51wk3msgSoDlwqWmqvww= X-Received: by 2002:a19:4f0b:: with SMTP id d11mr2288071lfb.51.1571616600131; Sun, 20 Oct 2019 17:10:00 -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 a18sm2723081lfi.15.2019.10.20.17.09.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Oct 2019 17:09:55 -0700 (PDT) From: Linus Walleij To: netdev@vger.kernel.org, "David S . Miller" Cc: Arnd Bergmann , Linus Walleij Subject: [PATCH 01/10] wan: ixp4xx_hss: fix compile-testing on 64-bit Date: Mon, 21 Oct 2019 02:08:15 +0200 Message-Id: <20191021000824.531-2-linus.walleij@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191021000824.531-1-linus.walleij@linaro.org> References: <20191021000824.531-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 --- 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 Mon Oct 21 00:08: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: 176997 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp2665005ill; Sun, 20 Oct 2019 17:10:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqwIkwuFPENioPOzq/Nc+KjfJ1eRZd4NaGm3W0D0bAykCkrvpNJgJlz+WowfGtOBvlsG0Ih2 X-Received: by 2002:a05:6402:1511:: with SMTP id f17mr22073812edw.232.1571616616301; Sun, 20 Oct 2019 17:10:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571616616; cv=none; d=google.com; s=arc-20160816; b=wcToTXGdKPJ8qqLzSoyvUX1OrN4u9sRDRo94XMg2dMUnHZKq8F4IwqrOuOuSd/+N8R AW1GBDDpwEEX0VU90Xb5xsX2yDyWbb/a0VgW/26upYhLlVQGFEGZ5kGqPvZxZGDaHpye NHWlQXY5FUnJP3D+uCATgky4fmGfQFnfh9XYqTdeNzJzWYnBP9ncf5UeDQQ+453kop4l V/jLz4RkFilgrgRl6PRIYCNBxLgEnCsoQjaCj6PdVntjdJkbJ577LhQyXPQ7CbVYbpTS IXFq7cONVWdAoDroFMS7xINyMOEcuYWVbGPL3gYFsDyoa4RYRkkqh1dhhfUw/teW0t77 2VAw== 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=9/FLpztDlNWbBg/JuYp1tFoVp95L3E5/Cpe4B2PPpq8=; b=GHa4S+OKZliHKMPTBZyuTPORwxzyvbPKkMo735kiBAeaLQOaFyiZDfn40b1LKhM83U PShtwqFeBSNAxxR9FtcJahxwsT2eEW91ehpMDsMEdLjYbh0U7erZOzOKhd0L9FWNgv6O Kr5y91y2l67UFr5qBpEQBbAv8Cq5KesOC0PwZ0egdipiA1VEqoLTIxiwHYMAUkcav/NS EmhcDekzO7Qzkbpy/tAqs99mCkkZHRaXwcw3LW5H9rHA4k0jaAsRAs6U4HKvfr+IypnW 7dzbMfULzXYF/YO1bscZVzsn5PIKAHyN03RlI5zGZlPN2cgYUQlORBtTWEl+Ei32uMND dZqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ceSY77Z2; 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 k13si1900533eds.194.2019.10.20.17.10.15; Sun, 20 Oct 2019 17:10:16 -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=ceSY77Z2; 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 S1726814AbfJUAKK (ORCPT + 8 others); Sun, 20 Oct 2019 20:10:10 -0400 Received: from mail-lj1-f193.google.com ([209.85.208.193]:35941 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726576AbfJUAKK (ORCPT ); Sun, 20 Oct 2019 20:10:10 -0400 Received: by mail-lj1-f193.google.com with SMTP id v24so11363583ljj.3 for ; Sun, 20 Oct 2019 17:10:07 -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=9/FLpztDlNWbBg/JuYp1tFoVp95L3E5/Cpe4B2PPpq8=; b=ceSY77Z2ACB2CbaTnA8NInoDHEl53XTFKp3dOKq7jxdtrLK/BrwPJPMqwFdL9Xff+H uQIkavYNUrgvdxKrIaeZa0YRjqmlWX8M4CGIE7t8R1TUWjOzUXjnBYTWh0a2uiMQQOuN df80IsAkfnE6AylzUx/u+qPnA4iPQ25M4B0LU2qQXCtT5c3I8SfmyE1WaWbc0EtCRCiW 7hsLrGMag1qn7CVktlh9Z3nuY1bIprl4zGlnk/ZmZRC9cy811WWkMPSN3BAxscdQnAqO VVl0uvUrAvEHwlEoHoK5hkfOlxA0sQD3lCONhd1vgHNRi5mk/B5mkN13C2UuuVmkCILL e/IQ== 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=9/FLpztDlNWbBg/JuYp1tFoVp95L3E5/Cpe4B2PPpq8=; b=GB8zoW6JRdG+L5W4yA8kmfTNnd2354EgBGNU+pMFmvpfVFBqsfgnB+4A2tFVSDEL71 nh57d5XaMJbsSwyb+8TIe3ltGw4rdNbthaDdW9eU9TyOOokPpn4rrZc6rl+NGFQi9vr6 uLA+4Fit4WXC3k3DJXaFGuSHYD78w0ofvRMPZ3YZ64b740ZRp2bLNMSn7pawbjyCcMe0 u4dOzmhs/rb3NYqsPcKYyOAjGYTRyYLm/6gmKNoDtDAG/2KSHauljOqyc+mUwbNaQGeZ 74wDE9ntQ3CJTtI0J6qjU3lO7gHmCMmhMYhlrFGeYMBZW9QqHluisZxLMhUjlJ1g6xqk MNeA== X-Gm-Message-State: APjAAAW+xNeCQxSzOxzHr/QC6GGz9cxkI6ZVgs+4u+Pt4qWoIaJJDYvu nWpd1CIHQsFSbunob6a58nQ0zPpUKGI= X-Received: by 2002:a2e:a415:: with SMTP id p21mr12601906ljn.59.1571616606515; Sun, 20 Oct 2019 17:10:06 -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 a18sm2723081lfi.15.2019.10.20.17.10.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Oct 2019 17:10:01 -0700 (PDT) From: Linus Walleij To: netdev@vger.kernel.org, "David S . Miller" Cc: Arnd Bergmann , Linus Walleij Subject: [PATCH 02/10] wan: ixp4xx_hss: enable compile testing Date: Mon, 21 Oct 2019 02:08:16 +0200 Message-Id: <20191021000824.531-3-linus.walleij@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191021000824.531-1-linus.walleij@linaro.org> References: <20191021000824.531-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 and enable compile testing. Signed-off-by: Arnd Bergmann Signed-off-by: Linus Walleij --- 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..bf2fe1d602ea 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 || COMPILE_TEST 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 Mon Oct 21 00:08: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: 176998 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp2665009ill; Sun, 20 Oct 2019 17:10:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqwqUquK/z+KFrIDFzfJjEkTAjg5eKu2zBZCCm8MfXi8XCLK5be5CPiBPw0Y4EdZhsta/LHP X-Received: by 2002:a17:906:f15:: with SMTP id z21mr19730596eji.119.1571616616638; Sun, 20 Oct 2019 17:10:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571616616; cv=none; d=google.com; s=arc-20160816; b=uVWoZExEYgJr8/UXaJUV3ld8sjzWdb6GIlY8monRBEiUnKSobsaK35rim4adBlG9U5 AnJrFJB9U98YIEseER/vkZvrUrjeH850VSPOjWDwtk0duZOWNPcU+pB8fdSmQKVhqSw6 v4LrULdkv5BMszV7BccVopfRGQNzuhoYOCQ0h8oaBlMe0romxAeaHtQew/XacswWO7MW HCnQzVzHjIFo4tNMaEBAvyqIcOmK/Brknz9rFvuO+PXmqQvlxpCnoaOasbCZV4JY+l1/ 5cxq4ZUV7x6wpQUZN5+O06FiNouOiUEFwTk4PofpkeqJBglLS2TYTfEUTD99Y5m59d6+ 1UhA== 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=4IX5+POITfEW/GgAGOAhpjC4hfqZle1GS39hd34tABc=; b=Ya9av5fFbrrT8UE+5pqT3/bTglHc2HoUCxC25YR+wHlh50j0nD76mwkKzpgDTrZniJ eO8DVoyR6QoIFs763mS87fiq0QpZ3n/g2EdYHzNzF0kioZz0mygoSRpoJ41gUVNzBZYV +R5H6i7/z7JtFkeNb9kJGoAkxKRnqQnqxhXSlKFfgbGD31/Q2UeKrvJjNvXA/RrUVYUv 7+zlNY2mQN7E0jIaEJbHIV7kAQReWGJeiblR60uCobyS2FVxxpXP+ay9AS+E7CjsF9/b rD7gIqDqOtfDeFKpel/BUH3px54sK1L+74TJm/vcTn3Y8PcnSenc9tJStV+E6am6cc5m QJUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=c5DF7HgK; 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 k13si1900533eds.194.2019.10.20.17.10.16; Sun, 20 Oct 2019 17:10:16 -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=c5DF7HgK; 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 S1726824AbfJUAKP (ORCPT + 8 others); Sun, 20 Oct 2019 20:10:15 -0400 Received: from mail-lf1-f66.google.com ([209.85.167.66]:37562 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726576AbfJUAKO (ORCPT ); Sun, 20 Oct 2019 20:10:14 -0400 Received: by mail-lf1-f66.google.com with SMTP id g21so7462609lfh.4 for ; Sun, 20 Oct 2019 17:10:12 -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=4IX5+POITfEW/GgAGOAhpjC4hfqZle1GS39hd34tABc=; b=c5DF7HgKK0qIVF5rMuCnstNYrUQyFDJudBcyRBvVxl/OVavercO78axLTa1y5E7PY9 isDPTp7kArMWMMBYhe8CTWf2krU7hyabVdxzoFqaJLHxrT9CkqWNLB0zHnlRSaspxFtr hwWSEbd/UCBehQVJC4Z2taD1Ge3gBKGq2+QjiqvPWw73jRtgqA95n41bXU8KiS+1njfZ Rxubls2yDJAK07c3eZP8HnqSnuFvaUBVvFkE1l9cpddF7e7dtR+GPZxNb7S9WNj+eLqQ PfkH6ooG2nCzk8PUHBf0dI+NrzvcJ5cppY1PvtylUn9mhARuHLVXGAQeIAtFn53bin1L p3Dw== 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=4IX5+POITfEW/GgAGOAhpjC4hfqZle1GS39hd34tABc=; b=QRH92UmIPsIu60HBv30aSGuSX/BEdXbvfmrXeOOiJM/sPqZ91vdg42KlOBdM86VXy7 VOGktgxaEPmN5xu/2vrwyaQQBYIIJH9KV9u04O0r4DY0LZCyn/lpqMysYTblnNTsHwYG cgfcwPWeaHVDJzsYcC61jrUjkSUzfmlBluDBaUnc5ZnmpWUe0HGDN6/bDsgpnsL/pl// JUQqSb7+o6NVjcBZPlp287qVftGdeGGA9Z8o9JiiDhrDBdZsBTB5Xh5+/GvwxSjI0luu N34RIDS9s8ypZwLlSyVrXGaPZhuJJPtnmZ9eO6e0V2Tc7GUCRz8GoekPJ9iKRd3rl+1H 2CiA== X-Gm-Message-State: APjAAAUN0TksI2CUNfP+e09T+nD7kunXfh4jJUTfl0nmEGtuWCkf9dkl a0R0UyoQQAeGLcgrPxPxgfz/uqqTWgE= X-Received: by 2002:a19:cc07:: with SMTP id c7mr13155282lfg.107.1571616611546; Sun, 20 Oct 2019 17:10:11 -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 a18sm2723081lfi.15.2019.10.20.17.10.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Oct 2019 17:10:08 -0700 (PDT) From: Linus Walleij To: netdev@vger.kernel.org, "David S . Miller" Cc: Arnd Bergmann , Linus Walleij Subject: [PATCH 03/10] ptp: ixp46x: move next to ethernet driver Date: Mon, 21 Oct 2019 02:08:17 +0200 Message-Id: <20191021000824.531-4-linus.walleij@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191021000824.531-1-linus.walleij@linaro.org> References: <20191021000824.531-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 --- 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 Mon Oct 21 00:08: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: 176999 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp2665136ill; Sun, 20 Oct 2019 17:10:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqzAZx8xFOMzcoZwbkiPssJwrkpi8gcJqnKFsfZwO6spFk3T18tYuco3hBpsmol5FexWuFmV X-Received: by 2002:a17:906:fcce:: with SMTP id qx14mr19953502ejb.186.1571616623094; Sun, 20 Oct 2019 17:10:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571616623; cv=none; d=google.com; s=arc-20160816; b=ja5S9saj+CTQ1H5GUCP59dvMuK7Hn9RbTFVkPZRGeur7pAN1/SOBi2a+Z89/bWULvx jxaZLrvdpEy8w+BRGCFdDiiwo6PKRFYsUlr1FMXWSA/OqiUufrRLXTrYtNwKwhOnnMv8 8AoOes+QbB3fIINPrmxRMmYdsX0hL/jo5xz+UEUylN0cEUFYdein0YbbPFfIT9VXtsh2 Knav2rJI7oHItcRLzO2mF5+zpAfJ/cqZyTyhroYIGEyKnJ/PwPqeDsCCHxZ+NsNBKY9Z iod92YYdj8rK5lKOW0IE7PUg8FVBJXbNCjTCewwDKQhrUBT8076y1qIfujBAjJIuHmb2 AgGQ== 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=lJsmXghA9bj4MW9coGQv2iHXFYhIB7erLdehvCkiBm8=; b=YuzTzDYYvZsgeXDCnXGqDG2nXVtzu3+0w79dLTAXG+aUvtz72AYxalih++3Jl7URMg H3K45aRaC60oCEUKliXNQr6ydhhrmaaJ//gfKCUkV/zid9axSfQp0VdMyycSvgsa3CAl y3dK2+IDVK3K7UgUidK8evgNJrBWgI1jJKGzS4L7moLLd/FGBxwRRJqpijAuFAfJyK53 GC/OlSN3H6i8bx+JbppLSdCs3HGEXUq50ZKiAVIdlJkDxE8nOJ6ijAjlQF/ipiTkAoi4 rEyjh1mhmu8FVg7ofBJWkO7X2wKCyQluMbgvUcyy2mhtxj1vhI+3vboslwzBuvlEVmfx a6FA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fv9KRJjR; 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 p15si7653658ejx.56.2019.10.20.17.10.22; Sun, 20 Oct 2019 17:10:23 -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=fv9KRJjR; 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 S1726831AbfJUAKT (ORCPT + 8 others); Sun, 20 Oct 2019 20:10:19 -0400 Received: from mail-lj1-f193.google.com ([209.85.208.193]:43969 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726576AbfJUAKT (ORCPT ); Sun, 20 Oct 2019 20:10:19 -0400 Received: by mail-lj1-f193.google.com with SMTP id n14so11330150ljj.10 for ; Sun, 20 Oct 2019 17:10:17 -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=lJsmXghA9bj4MW9coGQv2iHXFYhIB7erLdehvCkiBm8=; b=fv9KRJjRBRF0GU7K38jgnfXAroHAYkJuBFwSWdswzpQgO4SsCA7fAHNjGITclSNNnZ NdrjV+i/pQ6fVJVmGq3wVdB+cjt5GRiFIx1yfcMVqCtd9BIYCJpF/p5ja6zNajiafDIt ek07xeKet0pO/3ozckCG3d0e9mZ/QyvhWbWIDGalS7dUZRgaNkvdUreubp5/dWnm2EQs fJpo+q6VtFnFhFL2kWM249uPYksD7oReFcoj27Z6nnE3dPZT7ZgoOvKaHI2QCbl2+NIb SfffzoKWjq7w7lmW/vQly0u5PnecveAX3Tg3qqVWhjP113svTU8Q1ctlnVX9dDV6McGM I4gw== 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=lJsmXghA9bj4MW9coGQv2iHXFYhIB7erLdehvCkiBm8=; b=lg6Dr9XvXVxNt2R1WW7tjrwKAnf+IjFUzJh/U08nobNqU6eKjbjHhYTJ/nd6GWu83k NjlvZtSMYMch9Q1ehO5gf2x5KVlF2hDsG2StaCYqk1IU7WXt3zO7CrullOKr0rn1HmvV WrBUoKZgnzeVAM5h6ke1/OdMD6neB2C0LgBh0b3gk5xUJNLvt/o4FYbemFifPNYcJmbE oQ4/8JNX9JgxZ/ssIYylz7aHObgTIUUE6HHGyk6fHR1Weodp9yyYrQLejkXriJMSfHgw qtNNcxH+c8UAKER8Lntp/9pC4k85SPz0y5km5ollCoeGe5RLVcV7E1lXo6oNo48D3yAv 2XfQ== X-Gm-Message-State: APjAAAXqE37j221ZtekS6lqRYgIzTK0poqU2m+aKAkZ7NJEwqXW7PGxS AZ7q2luVagCkr0zPywHrTRGg2Bool+c= X-Received: by 2002:a2e:b0d8:: with SMTP id g24mr10114035ljl.159.1571616616233; Sun, 20 Oct 2019 17:10:16 -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 a18sm2723081lfi.15.2019.10.20.17.10.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Oct 2019 17:10:13 -0700 (PDT) From: Linus Walleij To: netdev@vger.kernel.org, "David S . Miller" Cc: Arnd Bergmann , Linus Walleij Subject: [PATCH 04/10] ixp4xx_eth: move platform_data definition Date: Mon, 21 Oct 2019 02:08:18 +0200 Message-Id: <20191021000824.531-5-linus.walleij@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191021000824.531-1-linus.walleij@linaro.org> References: <20191021000824.531-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 --- 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 Mon Oct 21 00:08: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: 177000 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp2665266ill; Sun, 20 Oct 2019 17:10:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqyxzvmcn+mblQEVg/Ec+TPWE7WGNOWm0FHJ4LqACbTvuYZcHNaptaNaUvKXjWXN2gBiH532 X-Received: by 2002:a17:906:4d50:: with SMTP id b16mr19185264ejv.245.1571616629253; Sun, 20 Oct 2019 17:10:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571616629; cv=none; d=google.com; s=arc-20160816; b=ODi8cDk9T/GEJTSUrf6ZpV0QWXHZR46Eyqm40ff5sFQjO/qTXx75hY9kjzrJxBNo+m 2/3b3obOtewSZihOYJRJxnV9gHJfBGEb8ccy9zdg47xbCQvc/l0UAUEQuy4xzG6WPyC6 BRX9DrRN3qE9xpym+omFLjMUlbZ/D4go0i8sd5uUnwGn3crm04YTrCEUmQecMH3hkz26 pNfMjuSghaPGNlsWB07fA5cS4KKVGINjS9ZMTUXo8/iwLk/K3HhGTKRueLTbhWM3d4xl P3pmBcqYHha2+bHyIuK9Zt16c62y6htmZAKD/h4u1inv9r+Vnu9ekHKcC1E6xnwpWJHV LRLg== 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=0NB+9F8QdSssG4LeN9+6VVsx224hqSgKkrEemXRqU3Q=; b=DjhcpI6p6ZuU5ClmJFvkHDU+vjYJ6LG7PXXp5mLsSiJM4vXs+oqrm3flpU5kzv/iun vqPCwFthjfI54k4TjcrVDjP/Ox/b1m58pXVj9jxYq89YG0YiWuVUCcMNNmkEHtPtE2Bw kgvLF85CJQrETWF+X9qOpScXeBjQgpMQC725CfbKZkMux0hAlFgT2zNj9kxTDzrBH/dM 9SaiCdluCUy0FqXT8WzTNDdU+6HuKslkmp9wVf0NbTUO3QDUJHGibvbgIDBlV7O5MXJ6 RnDe0isewI+m73w/upfZVdtmym0vVJ8LMe88u03LAjcN6sHh7bsTvsxRqex3U0ag4alv zHow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KqNaHzqn; 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 d22si8677346ede.131.2019.10.20.17.10.29; Sun, 20 Oct 2019 17:10:29 -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=KqNaHzqn; 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 S1726837AbfJUAKZ (ORCPT + 8 others); Sun, 20 Oct 2019 20:10:25 -0400 Received: from mail-lj1-f196.google.com ([209.85.208.196]:46828 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726576AbfJUAKY (ORCPT ); Sun, 20 Oct 2019 20:10:24 -0400 Received: by mail-lj1-f196.google.com with SMTP id d1so11305165ljl.13 for ; Sun, 20 Oct 2019 17:10:23 -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=0NB+9F8QdSssG4LeN9+6VVsx224hqSgKkrEemXRqU3Q=; b=KqNaHzqn3Yoib521F4irfIlA+iesFszNicGLllELH2cojXjQhLZtwqwTlzYsNl7JZ4 B65CbADm6RfCi86/pADnMIPgK3xWerKzdJCUbEttJnnCRbYiVgFNBXImLJmlV6pQW1Ht YPWwsmhT0O0Noakvi+XTfH/QjIHy33xgNexKvTZuRNsAnlN8ZD4Ooi9HcAXevUKWXUra 8KXs8xD8AVOpDKE8UfWOAWWmkiNmRq/Q86qv7nbHk2/wjTqOvYKH2R0b5zo5EHPZOm2N M4nRK+OIw34/BwaW783eqVLtrxkTuRbWcEjUXJGUzA92v2nnW3kqcwP1Z+Tc9s7js93F ZSSg== 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=0NB+9F8QdSssG4LeN9+6VVsx224hqSgKkrEemXRqU3Q=; b=jwWRn4HtHCOGtA8vQhQv7ROl3diRyDv+8FvkACmbHN61hmITyCd1/rwIZTZTRWZ7k7 ybyrpw3OFGayDwgArPC+7bqB2+BkiccRtEgJYgXg+YamoKrxPTshLLIZpKKt2jl3mwlh RHhhEifA0tICAI2GC1sBr37guhMcG20kdspk9aCXZX3bQgQ0wC3szB4hNd5CCTBLg2j8 12VXTBXWOkVWd8PEQlX5KqZF1CS4jCqWBjNB4hDXrM/EF6dhcXL3thEPBUvD9zRm2xpx CR5ozFEbF5Njbb5qk32IxULKQSy1Zj9DwNeyiZLs20sh28KMdtLr8OV9Fz47njHu4Sw9 uiyw== X-Gm-Message-State: APjAAAVGPr+WtCiaCCa9fJEOjZ99scbJRk1lsb6AYO4MndC1JRfxK2bI UKibjDHESspkkfgM37F0bLSrjJbKaiw= X-Received: by 2002:a05:651c:209:: with SMTP id y9mr12533276ljn.134.1571616621663; Sun, 20 Oct 2019 17:10:21 -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 a18sm2723081lfi.15.2019.10.20.17.10.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Oct 2019 17:10:18 -0700 (PDT) From: Linus Walleij To: netdev@vger.kernel.org, "David S . Miller" Cc: Arnd Bergmann , Linus Walleij Subject: [PATCH 05/10] net: ethernet: ixp4xx: Standard module init Date: Mon, 21 Oct 2019 02:08:19 +0200 Message-Id: <20191021000824.531-6-linus.walleij@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191021000824.531-1-linus.walleij@linaro.org> References: <20191021000824.531-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 --- drivers/net/ethernet/xscale/ixp4xx_eth.c | 82 ++++++++++++------------ 1 file changed, 40 insertions(+), 42 deletions(-) -- 2.21.0 diff --git a/drivers/net/ethernet/xscale/ixp4xx_eth.c b/drivers/net/ethernet/xscale/ixp4xx_eth.c index e811bf0d23cb..26da84402cfd 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; @@ -1396,14 +1385,46 @@ 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; @@ -1472,7 +1493,7 @@ static int eth_init_one(struct platform_device *pdev) 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,6 +1501,7 @@ 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); @@ -1489,36 +1511,12 @@ static int eth_remove_one(struct platform_device *pdev) 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 Mon Oct 21 00:08: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: 177001 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp2665342ill; Sun, 20 Oct 2019 17:10:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqxPiTIVzLqh6K6N1e6V7XHP2s1MxA6KHhEG6kO8NdueM+UaAWT7VHEcoNSL4OCmz03VJ3eH X-Received: by 2002:a17:906:a442:: with SMTP id cb2mr19470640ejb.163.1571616634176; Sun, 20 Oct 2019 17:10:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571616634; cv=none; d=google.com; s=arc-20160816; b=M0G6yBFoJzEQ75aOzoHIV3ACyJyfrMYqZUmx0rz81T47MOwO/lnsDfRhaO97+gIN+G gVenLH0lWstXJYRdhetdplwcTB1aqzBo4wnWCseOCZQ8KmrUb43xyk0eH70eWwnuqbWg qtHw9ByQGz4XBqpKc5snKo3djZR1745eJ4im88tMoQSTk8L9gOAyl3c8sXPoPraFwXao sYYaiE4/NjzcEHmfmhxBW4FG6ekDnHzyKklOiilq1ZCl69Gz9T/6QQSARUdm2igqPkqG mYRY5ajzkNePUolJx+J06jmrrBVgABHkThW9Mg8W7rJ0iSOzpMiU4h7C+QGAFGc1fNKA FM3w== 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=37DVlI7CMW6o++Ct+3WzRl3YFsvzn5oKwtoZ1rtvgU0=; b=vpG0OMCtlv3pNcxStHg/pBLRwZXro6mxFaj1Cp58xJbUTkY3SFNmjx7iupykXV832I 9RMGrS7L/OJ6TyltWPxT2iDe5gesG/OnqFDlsn5sW1krpspLmAflfP1bq4yhMYopIvpJ d/sZo2FFLUULEtsGoEj9lFY2CUDjJ9gao4fiWiAio5nGaVCwhg4fv10XVpTCmptadK6P Fh1iXh79DVP+hkcCsbBiVByAyGmdo2ZA39CMpY3qJq+ox2k+LHWYCEPlGMGAG7VEsA/b ff2Qw5+7RtfRwfh7iUnjKwpzoyEpH985O7FF2V56u4m2wKUihYOpBNn+BzwPXfaG7P3l rm3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Mpu1XSua; 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 h49si574683edh.2.2019.10.20.17.10.34; Sun, 20 Oct 2019 17:10:34 -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=Mpu1XSua; 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 S1726851AbfJUAKa (ORCPT + 8 others); Sun, 20 Oct 2019 20:10:30 -0400 Received: from mail-lf1-f67.google.com ([209.85.167.67]:34573 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726576AbfJUAK3 (ORCPT ); Sun, 20 Oct 2019 20:10:29 -0400 Received: by mail-lf1-f67.google.com with SMTP id f5so850459lfp.1 for ; Sun, 20 Oct 2019 17:10:27 -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=37DVlI7CMW6o++Ct+3WzRl3YFsvzn5oKwtoZ1rtvgU0=; b=Mpu1XSuaKgG9v5Z1dHNnDg8YsH3kOi6WahFWov+vQM6VE37kqPnBOThHvnlTXK13B6 q2GaZAcb+7bQDu32nPuopkGD514yfxxusbY8D+pPXmmD3ECdTiU8OGPLYMHVx73/j7+A jvVqmwsl4gepDkvAxY0f3BHBWEJ6zAb5K0DFrxfZ33OH7OKEieJcP8lJkA0ERJY0q7lD s75gNZx06VdIEQID0lVYhxkCRs3TFdH0+ZXwxMgaiv9oUkkOCdBrJDjtWCtA4OMyuSlc GzeLRemVnAtxSh7pUr1o+u2UqxCQ5h+a47EGeATkVxZLkA5VbkkrxZ+D+IZ7+y3O03eB kcXA== 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=37DVlI7CMW6o++Ct+3WzRl3YFsvzn5oKwtoZ1rtvgU0=; b=r3nsppCamO8V5zo8Jwr9nTMk2Ll5qJ4WFNB1kKrBfUFWHcnK1quQamqOv0QLqdJ6ud u43eQm/XiTnUY8vnDV1JBBnk6UnvPMVUG/t4QAzwSy1eotiUM4S5wj2e2cRYPBPBt82E 1sDs7v7Z0UjCDBqsbLckqeoyK2oKS+s+UnOdEv6C7HuWVLtaFm3tVRb77SUaih3fktVQ vPjk2khX77qVrlermySkG0AzlYlz6xld3GIFcvkSx0L7fD5qBtBJLbbgx7K2I8qRefUk p77C/7U0IHTIlN3FXMgD/HYWmegTpwB+0rEQW0QRZUpfOE3+pipQaXxHoHTRPRBOrM9V AQRg== X-Gm-Message-State: APjAAAXFwAWXkPXON3WSzXseerXlxyUazQX1Bawp/2/XSTLB6Bwrjzi/ VDsoMceTaLvaoPURxQx5DmedZByms0A= X-Received: by 2002:a19:f013:: with SMTP id p19mr12301116lfc.98.1571616626295; Sun, 20 Oct 2019 17:10:26 -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 a18sm2723081lfi.15.2019.10.20.17.10.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Oct 2019 17:10:23 -0700 (PDT) From: Linus Walleij To: netdev@vger.kernel.org, "David S . Miller" Cc: Arnd Bergmann , Linus Walleij Subject: [PATCH 06/10] net: ethernet: ixp4xx: Use distinct local variable Date: Mon, 21 Oct 2019 02:08:20 +0200 Message-Id: <20191021000824.531-7-linus.walleij@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191021000824.531-1-linus.walleij@linaro.org> References: <20191021000824.531-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 --- drivers/net/ethernet/xscale/ixp4xx_eth.c | 51 +++++++++++++----------- 1 file changed, 27 insertions(+), 24 deletions(-) -- 2.21.0 diff --git a/drivers/net/ethernet/xscale/ixp4xx_eth.c b/drivers/net/ethernet/xscale/ixp4xx_eth.c index 26da84402cfd..fbe328693de5 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 = alloc_etherdev(sizeof(struct port)))) + plat = dev_get_platdata(dev); + + if (!(ndev = alloc_etherdev(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) { @@ -1433,18 +1436,18 @@ static int ixp4xx_eth_probe(struct platform_device *pdev) goto err_free; } - 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)))) { err = -EIO; goto err_free; } - 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; @@ -1452,9 +1455,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); @@ -1464,7 +1467,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); @@ -1473,10 +1476,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; @@ -1489,23 +1492,23 @@ static int ixp4xx_eth_probe(struct platform_device *pdev) err_npe_rel: npe_release(port->npe); err_free: - free_netdev(dev); + free_netdev(ndev); return err; } 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; npe_release(port->npe); release_resource(port->mem_res); - free_netdev(dev); + free_netdev(ndev); return 0; } From patchwork Mon Oct 21 00:08: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: 177002 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp2665376ill; Sun, 20 Oct 2019 17:10:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqzhBzYmepdZM/3sn1s8rXbLgtZE0IzmqSjP7e67vFC8wBmqXu8qjYkPvXnXVB4n90nody8m X-Received: by 2002:a17:906:f258:: with SMTP id gy24mr19936533ejb.25.1571616636297; Sun, 20 Oct 2019 17:10:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571616636; cv=none; d=google.com; s=arc-20160816; b=BDmTiNQgBt8mV+1+qXi+GDfjCZ/TmV/aNkV7T9CHVVfRpzd2i7ojZYs3YgbWFiligB ngYdLKdy1ZJMP+2krXlOUymPrLuE4eYE71vebPNoOrFo6N1RC2P80sRrq3IGEUNscJ8C YBGGQlmLkz8yTq/wgFyKR9EVG8ax5LhaIB5rMMPm4elUcVk3DOWnCnOU2keKA7vpokyL RfCLtbo21TLx4+q1nzclNWIvDRvKgNTvucQtZf44oSajgRR6JXYnaxFdfQj7NzAf/mME a1EpsQF0Icp8Rb/6VZRkNdZMFZUhc5WA9r0+krBwnZVniM0IQRN7JYKZ7ojsegFzwHYO gwwQ== 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=kkHVPrwW+udBDpjAVf93ePr4kr7CnBbxsMjmX8osV5o=; b=zJZkForwquwVXPWmS5by6cpTREodt8//9B7ToRZUHKhpUOiA2Mz+QNqB4dccCl0QgY AcYiLiouQQLKZZuHkhk7XJ00ZTvDwhwwB5GuqBiMENdwEsU0QIbVo9jpiIq+kcz+H8hw IIPv8mZhlUEtm5wdh4Hx2WTtUZzaA1H6QKhcHZg2UiHzNP9vGDgjffsq9Zs29CGxFP/g h6cYuS0aQx6x39kZQOstpMyLMdWfymxj9oc6YQxtZm8qPRp/l4ZrXAW2DPetIQv/khbc qzg+Dv9/IgyngLFIju7wkVIIIxLxVnbSEpVv268cA9aoKxoFpcpAwaUvaLWn71q1RR1t RSqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VQit91pF; 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 h49si574683edh.2.2019.10.20.17.10.36; Sun, 20 Oct 2019 17:10:36 -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=VQit91pF; 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 S1726859AbfJUAKf (ORCPT + 8 others); Sun, 20 Oct 2019 20:10:35 -0400 Received: from mail-lf1-f65.google.com ([209.85.167.65]:35199 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726576AbfJUAKe (ORCPT ); Sun, 20 Oct 2019 20:10:34 -0400 Received: by mail-lf1-f65.google.com with SMTP id y6so2296530lfj.2 for ; Sun, 20 Oct 2019 17:10:33 -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=kkHVPrwW+udBDpjAVf93ePr4kr7CnBbxsMjmX8osV5o=; b=VQit91pF8e5h0je2IrXBZjvqhweZKHs/fnKtt4b1yfmIyboo7b6zrjHF3srL8BPXIk gvdWDNH0BuAy7iKpY26ZeqlahiRcU3cWChG8eox2o7tqK/sgWiEhN+I5r5UaQMIoagnU qGKzPTRohi+ZDVeVA8R3AV49WJ3ILlMyLzWcSfXtNRwz0oDMgLhEIIzbOopUkZLH/oGb FNqCbGxfm/f32fxB5Bus8e0kEuvj3PVN+TUO81mVn1sDoyQsNrDy8UY9qTiXAjWZctx6 peD3F5SoSQDnSoU79Jr1oF97ZkvZ+gIh5KyarUsqi1lKpvt5/1L59SBDAPID2TCS6zgN 88bQ== 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=kkHVPrwW+udBDpjAVf93ePr4kr7CnBbxsMjmX8osV5o=; b=ShvlV1aJtWXwCaDQ3xIUWCyJGlcJuhM3vaoZ+FZVcCKCjoajt9K6k/3q8EtByesz4K BOKBUjqvbo1VkgJRa/WCd8Bg2Gy7kUX5xk98NWbzb48Q9Gopu3DwFSCeHwzKgZoxCSXx xZdvxH6zWgLLTmCq3EPncGcFljBFDJZaqS7eNdw1a1Eb3jh1MQqcgCpwgNP1Wq+CorK0 SuxHyprWGjsknj5fDcNPCnxEcYrVPxbJaDtBsj630yojIMNKIB7pDic1d3XR3sI/bfSX fuCS7+RFzITldUtjZ623f70JJ7sMxZr4xmUU3CE1sgiQnDA0C1pPknGhGCGwNyZWGqUv TuIQ== X-Gm-Message-State: APjAAAX9vjMDVeDQ9HgfCx1RWgXxygGqysjHtCdtvYdADA1vNCEYpeuJ evlP60fSIycE/4SQjfaX3LLdfRpsLGg= X-Received: by 2002:a19:ed16:: with SMTP id y22mr2359217lfy.166.1571616632149; Sun, 20 Oct 2019 17:10:32 -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 a18sm2723081lfi.15.2019.10.20.17.10.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Oct 2019 17:10:27 -0700 (PDT) From: Linus Walleij To: netdev@vger.kernel.org, "David S . Miller" Cc: Arnd Bergmann , Linus Walleij Subject: [PATCH 07/10] net: ehernet: ixp4xx: Use devm_alloc_etherdev() Date: Mon, 21 Oct 2019 02:08:21 +0200 Message-Id: <20191021000824.531-8-linus.walleij@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191021000824.531-1-linus.walleij@linaro.org> References: <20191021000824.531-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 Using the devm_alloc_etherdev() function simplifies the error path. I also patch the message to use dev_info(). Signed-off-by: Linus Walleij --- drivers/net/ethernet/xscale/ixp4xx_eth.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) -- 2.21.0 diff --git a/drivers/net/ethernet/xscale/ixp4xx_eth.c b/drivers/net/ethernet/xscale/ixp4xx_eth.c index fbe328693de5..df18d8ebb170 100644 --- a/drivers/net/ethernet/xscale/ixp4xx_eth.c +++ b/drivers/net/ethernet/xscale/ixp4xx_eth.c @@ -1378,7 +1378,7 @@ static int ixp4xx_eth_probe(struct platform_device *pdev) plat = dev_get_platdata(dev); - if (!(ndev = alloc_etherdev(sizeof(struct port)))) + if (!(ndev = devm_alloc_etherdev(dev, sizeof(struct port)))) return -ENOMEM; SET_NETDEV_DEV(ndev, dev); @@ -1432,8 +1432,7 @@ static int ixp4xx_eth_probe(struct platform_device *pdev) regs_phys = IXP4XX_EthC_BASE_PHYS; break; default: - err = -ENODEV; - goto err_free; + return -ENODEV; } ndev->netdev_ops = &ixp4xx_netdev_ops; @@ -1442,10 +1441,8 @@ static int ixp4xx_eth_probe(struct platform_device *pdev) netif_napi_add(ndev, &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, ndev->name); if (!port->mem_res) { @@ -1479,8 +1476,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)); + dev_info(dev, "%s: MII PHY %i on %s\n", ndev->name, plat->phy, + npe_name(port->npe)); return 0; @@ -1491,8 +1488,6 @@ static int ixp4xx_eth_probe(struct platform_device *pdev) release_resource(port->mem_res); err_npe_rel: npe_release(port->npe); -err_free: - free_netdev(ndev); return err; } @@ -1508,7 +1503,6 @@ static int ixp4xx_eth_remove(struct platform_device *pdev) npe_port_tab[NPE_ID(port->id)] = NULL; npe_release(port->npe); release_resource(port->mem_res); - free_netdev(ndev); return 0; } From patchwork Mon Oct 21 00:08: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: 177003 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp2665453ill; Sun, 20 Oct 2019 17:10:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqw5pMDVctcxt6/Q7thrGR4vR3Fv8nLBSqzw1m9PpWCHYSGjxx0TWrKuk4gkVsheZlSu/2hc X-Received: by 2002:a17:906:95d6:: with SMTP id n22mr148373ejy.295.1571616641902; Sun, 20 Oct 2019 17:10:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571616641; cv=none; d=google.com; s=arc-20160816; b=i151Ijy2jfbMNwsfsbLcig6aD64TRO5tmhYrHTQXbOHuJp2/FXoly0Z7LdmgWCRxaA rKAxQvD00+LFVvOPca5IIVHgq9TJx/zJUXWDzudIODz4xAUp4RcjFkg7z2YMvpG4W+Wj vX/RDME6HpbZx+1APJoyKtAmSBq7Zl8R1cRha4sQooQEm4u58YYSrzKyd8+Cp7vaXnaR McpdYvWg56WDaAyB1+c17nCX7zy9SGVeX8qnMQBM+HhAyCSUcNWtvOYcjR4tBtjJX4A+ 596hf/nzYCrd/VmV/yRC+He+gQBJv9iFmJXcut8t4T39dNKDqFdqswci806HwuRCju1h aodQ== 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=NQA3AJm3F7kktm2Jt5b0JWKorpvHRxsQoUBzWLUiICs=; b=lv0AMR+36UUgA22yJRXkaAORwfXT7RB/m8l+9y54qK1bdkwLWVqYzGSjU6oWj3ra1a qr/5qd4S6Aa8AIEwytg7uvDrKTNEZ7tkGrlvOp19oEbgM9fkPwkzjCtw/lmIaeK3v6+P ZvKNv4qnTUPnnHjzptpnI0ZATajnJcYYcxbl8nRLr3iA3iWUmqyHMWnZYVIDwy5girwC A+Por/i16a0etX3TkMjHzEEd4bsubxUSQIwCFrQGXSd2/ou0lKxB3RmYmvXrZHceGTtG +BIKOVIfcVfI4Zab806n/Lrzv8erMEFy4CphGD4PpMTyTiSAAaB/lJt++bNn8RLGULpu MnRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SpnDSw3G; 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 h49si574683edh.2.2019.10.20.17.10.40; Sun, 20 Oct 2019 17:10:41 -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=SpnDSw3G; 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 S1726867AbfJUAKk (ORCPT + 8 others); Sun, 20 Oct 2019 20:10:40 -0400 Received: from mail-lj1-f195.google.com ([209.85.208.195]:41904 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726576AbfJUAKj (ORCPT ); Sun, 20 Oct 2019 20:10:39 -0400 Received: by mail-lj1-f195.google.com with SMTP id f5so11345796ljg.8 for ; Sun, 20 Oct 2019 17:10: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=NQA3AJm3F7kktm2Jt5b0JWKorpvHRxsQoUBzWLUiICs=; b=SpnDSw3G82h9koRO2lHsmsdwuXll7vzv5TWQ/nGDMiGr7Ou6wbbZuTDum6uUMlq01K Wd/8t06AH9Xwe4D8f3Hpok3qq0rUwKz64CxL8osfDGLsxR01ApV3rLoVRKtSBewpJ3JJ QcPSzUQDvFb8dWfCGkB+t2LTLb5HWLrinx1Oe1Wo/KvdJco3X0FYVK5rQ1SDs+4Zb/xO zkCu1nGXBHEqB6aBm9CJUjFMHruzouewcMurAefAlE27sns26cZH/rs3Cq2W9BCkzWql kjIOGt6TWOHiMBov+FyaIba21JLxilX+TrSEMnT0rp3EA/tBVrdM1pU0IRgrn1Eie+kp 6ECg== 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=NQA3AJm3F7kktm2Jt5b0JWKorpvHRxsQoUBzWLUiICs=; b=U/musXY2uAMK1E1V6D+xH20/mQ1l2bLK0DB+yz2bxXY1mZJMe3FZh+GzXFIpwvY0Vx EWEiNJ+eUQx11BS/PYuJDkwA4aQL7s3YUmxKtKwmpHNiuLBq6HmTO88PC+AZgVp8YiVw LQy7BDWjKmHj9ynUL7oYEP3rc7w4UBWDkDOi2cJt+TF9uPtNzLMLJMtk97R70F5eVOLB 16Vv9yGspc74xysKdOItLKHEckZ57u448YAMJlX7L1CMnHkk2dCyK2e7t9sL49lj62+D ywftDPHOswRB3jnnyaMEAoTpL5PeivGjvWq3NfmhP1ZZjatVqo32lGbaszjKOrZxbO+1 3ymQ== X-Gm-Message-State: APjAAAWYgXtXn/mKi4LXnormoA2IYwLExp3/hC0aU81L84HxU/7ImEb9 v5zjXb7ydPhcn6RWHHqRkznyq2kWT7M= X-Received: by 2002:a2e:b4a8:: with SMTP id q8mr12850183ljm.106.1571616636261; Sun, 20 Oct 2019 17:10:36 -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 a18sm2723081lfi.15.2019.10.20.17.10.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Oct 2019 17:10:33 -0700 (PDT) From: Linus Walleij To: netdev@vger.kernel.org, "David S . Miller" Cc: Arnd Bergmann , Linus Walleij Subject: [PATCH 08/10] ARM/net: ixp4xx: Pass ethernet physical base as resource Date: Mon, 21 Oct 2019 02:08:22 +0200 Message-Id: <20191021000824.531-9-linus.walleij@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191021000824.531-1-linus.walleij@linaro.org> References: <20191021000824.531-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 --- 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 df18d8ebb170..60cff1bce113 100644 --- a/drivers/net/ethernet/xscale/ixp4xx_eth.c +++ b/drivers/net/ethernet/xscale/ixp4xx_eth.c @@ -1371,9 +1371,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); @@ -1386,13 +1387,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: /* @@ -1405,13 +1411,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: /* @@ -1423,13 +1427,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 Mon Oct 21 00:08: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: 177004 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp2665511ill; Sun, 20 Oct 2019 17:10:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqzz2tPfvHZMS52jNboJF5Se7IStaw2Jd9wyqvwfr/vBsRgdKguysGfBgvR7NFTc/PDlu8iz X-Received: by 2002:a17:906:edb7:: with SMTP id sa23mr19696571ejb.263.1571616646506; Sun, 20 Oct 2019 17:10:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571616646; cv=none; d=google.com; s=arc-20160816; b=PeiaEBDnBz0EUUlvAaLldiUbAR2181pr0lw3UNIDx3y6RehQC+fkF/wR0/hHL/ABOx e7cctLB+LKPuj4PiSbGw4lnCYBRIlejjq/rkwLCsX9SsMc9pBJC4J0qiiF2C+ndZcu+8 IPe06j9cY4MagqzY1sD9sdtfHblQbn4UfwY1+miRDze12JAIUDeO2StImXxPY0X+IfTj +4wIftRC/o6EVn6qK2sy8mg0dsc50aYgRXoplRn32RJx1sW7EGGZNenXKQwkINnthagU HsWHdRUzItALJhBhHAvv2knWKnYlEfgUE14n1FyAauu0lfJGSw6iOgmPUM6hvDXFA1WN PyXQ== 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=q+ctxv8RRYH9UHhPygjo4LsS0z8/6tCihoymd1vpL+Y=; b=BCmggL0YB4z04HNZ7UapMR3ex6wO+eUv7OsXWN/CM08SUKBnx5eH7DJ/iOS/3wama/ l3+U1pQAb0z3tI5mkwlTosLA9U9A5QIGqlFmKXnIS8cgw8twE5D5IfN9/7DfiMiHa8Eo r8Cdzgv88JB7UQHcfKlQOk4YIcfqHtwBRnG4p6MbwnSTP+ga9rcNYrVWNfk7+Gm4jdti mrSj4yFWucaxbEmgm3iW01YGIm0tefIyFTb/gRUO2JuqGJAOyaa4x2nIbX8Gx8OQukqF AxmdUf7jwpqrA+HazEqK/2gUxuOuLelGIl/fmRnkDygZJrMLd9e796aW7Vr60zEKgL5b fAGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dpl+avsM; 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 h49si574683edh.2.2019.10.20.17.10.45; Sun, 20 Oct 2019 17:10:46 -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=dpl+avsM; 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 S1726875AbfJUAKp (ORCPT + 8 others); Sun, 20 Oct 2019 20:10:45 -0400 Received: from mail-lj1-f195.google.com ([209.85.208.195]:44914 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726576AbfJUAKo (ORCPT ); Sun, 20 Oct 2019 20:10:44 -0400 Received: by mail-lj1-f195.google.com with SMTP id m13so11318407ljj.11 for ; Sun, 20 Oct 2019 17:10: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=q+ctxv8RRYH9UHhPygjo4LsS0z8/6tCihoymd1vpL+Y=; b=dpl+avsMBk2oF+F75HFzsHb+4ohPfWZKw4xzpnz2r0q+0K87kvkG0vHZ4XO6X118tj qsvuUDXzHIW5opt31kjQ0sbujyzdc32SMzjyv8GBHQb6v0eQnKCWlcVefPFUnni/Lf2B R6BVKCa/g6OnnZRQU3CSQijSxUMPVe/8Hakc2MiWUBlTeeykEJtlpnzgejSWKh/Mxu/w 1GtpVHwmTyUi5gM3+XdKwyw6uAbMh5VThtzPVl8BjLrRAFwdngvNzXmMZsNoZCh0Q4BO fz018bf+HNQnlUH3pgilKnRAeFWm1xroMGu10FDTvZHcha8QuvcUuQe3XSuBbpmd9iqR 2YCw== 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=q+ctxv8RRYH9UHhPygjo4LsS0z8/6tCihoymd1vpL+Y=; b=rrPNvFe5oV+tvwLwCXolp3mEpQ7fF6Ja93arD2+iv92we+U6n9w+hQlDX+NifGJCPG vOav51XEwnFGWDh7K/2Y2ER/8w9u3hzJJkjhevqTNcfYc14gaognKzlYZuvkqqb2VtUa 2A9x8EIp9n44Ndlx8yalPEgQYfw7wGnf9HeAtPnH8VNj//Vd8xurwfoI+lk20x6XNQvV R/43gBA3cuPY0YPCQ1EczStSuVegpcOmrGnUk/6DI4zkq6WQAY/Vkj6FNHOjUuLNEUE/ h4RPUy9VzjvrWP5GvzYCcrTdPzZo49MApHChBFMXDh+P41yCvJ8+4/dfA5kB1iyp98EO 5jNA== X-Gm-Message-State: APjAAAVUjYtI4pShRBksq2uN0Fscs48pdkIkNQAmIPaPtW26YkaD5MA4 Ub4raCDzM2AU8P6NJ4ZwRQLvC8wwRDc= X-Received: by 2002:a2e:2901:: with SMTP id u1mr12964731lje.78.1571616640059; Sun, 20 Oct 2019 17:10: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 a18sm2723081lfi.15.2019.10.20.17.10.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Oct 2019 17:10:38 -0700 (PDT) From: Linus Walleij To: netdev@vger.kernel.org, "David S . Miller" Cc: Arnd Bergmann , Linus Walleij Subject: [PATCH 09/10] net: ethernet: ixp4xx: Get port ID from base address Date: Mon, 21 Oct 2019 02:08:23 +0200 Message-Id: <20191021000824.531-10-linus.walleij@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191021000824.531-1-linus.walleij@linaro.org> References: <20191021000824.531-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. Signed-off-by: Linus Walleij --- 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 60cff1bce113..0996046bd046 100644 --- a/drivers/net/ethernet/xscale/ixp4xx_eth.c +++ b/drivers/net/ethernet/xscale/ixp4xx_eth.c @@ -1385,7 +1385,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); @@ -1394,13 +1393,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 @@ -1417,7 +1418,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 Mon Oct 21 00:08: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: 177005 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp2665537ill; Sun, 20 Oct 2019 17:10:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqw82zgP2wdSdEbIxL2hELkq3q4ZJScnqjQSy7s3CjPhKuORl908U2j/ZSvNf0/mlVREEIqc X-Received: by 2002:a17:906:f181:: with SMTP id gs1mr19269256ejb.13.1571616648158; Sun, 20 Oct 2019 17:10:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571616648; cv=none; d=google.com; s=arc-20160816; b=lVtK86Sn5nQTAFU7/h//WfnFMG2I0Ig8FdUi8LPgvUUM7JEP3wNRrn1LbSaasGhGPv gYSLaTHV3zaPjzAhf5XkLXAcvQpCqGf85KnPdZmAjp85C8lyAtlWWv7C/2JNqV5Ry3Dv VGlL69GMMZC+X7Q8O00cqEuYsdUOTog7akybAWU/wVSFT9C5qlAvxoof5GyLz+Hs7tFl vLytQtaGhHzcEtVVcYdtiIT8r3kxZq/yJLdSBHWC1MJWyA7zkpENGlpkVniK5Nzl7fZM t35dL8oW1XvXIsNIhfrUxTDYERTegVw0Ecj4YeYzBtJCVU792IR/561sQCpTDjoLj/OS lSiA== 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=w29PBjLwWeAIRWp3fgOMUnbQQY3WjjWLD5FB+tSHMf0=; b=UNdEAxivpNt0AT50LKjUhWTBvfen8A0/zqUK9opHmJhxcNkqY+bwz99AB7bw6XQRfT GwcPfXg6HRktjdAlkc+tcS9DtZUCaP0acBJGOC1blK+c5MLd3sw2iaj88jbeCLT/qqzj E1xvBi2AKgJpBPT28QZJSU1nK5uZ75FZkSCVmuebrpMhpqawwYKyIiqgZZq6s6bXJK7B ZMHpn9DXpYS4olZrcBGBtkFaod3pjodkE1WCCE5JBhAdR/5N/BwM0dRmqXiEFpGfgfBf Bq2CXMMMGzHl92ein/1xAmLfsxmWLVFnDNozYuGlg7AonBy6PuOmKMoRDddqbeQPyPoJ HoSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GvcMVtUc; 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 h49si574683edh.2.2019.10.20.17.10.48; Sun, 20 Oct 2019 17:10: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=GvcMVtUc; 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 S1726882AbfJUAKr (ORCPT + 8 others); Sun, 20 Oct 2019 20:10:47 -0400 Received: from mail-lj1-f195.google.com ([209.85.208.195]:44920 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726576AbfJUAKq (ORCPT ); Sun, 20 Oct 2019 20:10:46 -0400 Received: by mail-lj1-f195.google.com with SMTP id m13so11318480ljj.11 for ; Sun, 20 Oct 2019 17:10: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=w29PBjLwWeAIRWp3fgOMUnbQQY3WjjWLD5FB+tSHMf0=; b=GvcMVtUcZdvDkFibuxGMO+5YFlu5kmAb7d85Q15wzNDdhVu020W5tdZnndUsBeC7MV 4bF7C3ndevxvEOFzZ1K/SwB8Vr+XBtoibBlNK3aj10dDZG27XRz1BF+WUqdVIAJNxioq 7LeQeDpVcyqGWxggLxkVSEarsLduUPsXX2ENWdiq//5GLc4D4BIHACyPK0OorjRIIUjj XmBMq7ez9230Q2jWieWcv0eF4j8EDE9TIKM5CE0MmtQyTJJA1CxtxYoEJEoXprKQLkLd rYxgSZ9RF48D3iS5PA7H8pQeDiUiIGlShikQtJAYO5MNUM7lJ01T5HXy2khyIChy0fsL EuCg== 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=w29PBjLwWeAIRWp3fgOMUnbQQY3WjjWLD5FB+tSHMf0=; b=JLY883T0Jd4jro993zjxXjyjK1EWhlyh+Eav5SE1RFksVb2rH9Yt33pHH9FX/xP/jC dx0hMuKmfo9L4jJvjx89nfHc8xWeIhCLk83n8mpnTy25HWTzYsWw7SG26gZX8Vb9+x+t /UrUXfGtIvwq0uw3D41aaMGC6kv/JFj0/9p00vgDR0Hy8b5O91A8E4gD3832Flwn/ZzS zrAw1LBsR71TXnkOvlVXRcpDdrox8Hr9H7MqWLizUGIswaiEYHQ5fFpr4ahpCiPQlZGe tJAF/w5NqlKcmUP5HAhfS13t90Jt6cNsaDeQDzKVfoB1NMyYHvcLg2Aq6+KRpzYA0rny GFsQ== X-Gm-Message-State: APjAAAUBvPczGy6FPQIBdSBWVhol2FoB+eX6twiujItvG+fdr8mooFAt PZTjK2NNhUD3JBr/YjqEzx3xypdtX3A= X-Received: by 2002:a2e:8694:: with SMTP id l20mr12693736lji.64.1571616643771; Sun, 20 Oct 2019 17:10:43 -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 a18sm2723081lfi.15.2019.10.20.17.10.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Oct 2019 17:10:42 -0700 (PDT) From: Linus Walleij To: netdev@vger.kernel.org, "David S . Miller" Cc: Arnd Bergmann , Linus Walleij Subject: [PATCH 10/10] net: ethernet: ixp4xx: Use parent dev for DMA pool Date: Mon, 21 Oct 2019 02:08:24 +0200 Message-Id: <20191021000824.531-11-linus.walleij@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191021000824.531-1-linus.walleij@linaro.org> References: <20191021000824.531-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. Signed-off-by: Linus Walleij --- drivers/net/ethernet/xscale/ixp4xx_eth.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.21.0 diff --git a/drivers/net/ethernet/xscale/ixp4xx_eth.c b/drivers/net/ethernet/xscale/ixp4xx_eth.c index 0996046bd046..3ee6d7232eb9 100644 --- a/drivers/net/ethernet/xscale/ixp4xx_eth.c +++ b/drivers/net/ethernet/xscale/ixp4xx_eth.c @@ -1090,7 +1090,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;