From patchwork Tue Aug 2 20:25:59 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathias Kresin X-Patchwork-Id: 655137 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2001:1868:205::9]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3s3npt5tMXz9t2W for ; Wed, 3 Aug 2016 06:28:54 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=kresin-me.20150623.gappssmtp.com header.i=@kresin-me.20150623.gappssmtp.com header.b=gj3FUxAw; dkim-atps=neutral Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bUgH5-0006eR-5N; Tue, 02 Aug 2016 20:26:51 +0000 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bUgGn-0006Ry-LF for lede-dev@lists.infradead.org; Tue, 02 Aug 2016 20:26:36 +0000 Received: by mail-wm0-x241.google.com with SMTP id i5so32809209wmg.2 for ; Tue, 02 Aug 2016 13:26:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kresin-me.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references; bh=0YvLigQO8f1JIOHE+Tq83EO1QEDW4aVfMs9sq0W1fPg=; b=gj3FUxAwLyqID/+tn0zhCKzZ+8itYgKw0hHu5nSHetVhGb3NU+k29c6mACJqwajDl9 qVnSg+BTdoGHqXOsGg/FvJT5kG/QPWgFqGzjXkaYrRhaRUWMP7OmR0EXXf53BaGs7Cdt Jbmxv/LaMuG2W7wblJU7ULchlzsqMzVAR5CvRYgGNkiWX7MLaloBX2LuKpQCTz426hbZ Wb/UfoSiWXcd5BKLSHjVKSqmMbcIuFmBSHIPr8PcZxrYtDd0JGQpClYADhX33q1WP6PD AcHbMPEFYoG6vKgN6QNuErs3YnHYBF02Il64I6XeqmhqiSuZWOFet9VBxepz1UArsEvm 6vJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=0YvLigQO8f1JIOHE+Tq83EO1QEDW4aVfMs9sq0W1fPg=; b=JlNjPc3CBy+Vn+rO1+LiwQKBydRD9U++RjHAjxWGv01mATendfPeDYGGDzT83TgC31 s7d9AGOrUJzGgJsk9oJRhLNJ70A2MbK/2ycEwlUFj2XyjEl2J294zPpjpnLFEj+MX48k 3lHlu7Z/u8d96oteUlnLrjRBElOcZtsnhZDtTTfsp3B3vqkXm57ZERn268ko+x2xampl qR04wHo58XNc0e1otc061QWZdoUOVfLrPz/v62NCayll8aKIB/pLW1Pmeg+0cN0F19Pi tJzVY8pjZKBYNibjvlGA7WqmBS5TVNZWnRJxHtvli4jirW1PkPU+8AMOd100yRfuQKBK 8ydQ== X-Gm-Message-State: AEkooutytyJ3kqLC8eUOS1sMy6wk/aFYaWGfDu8EPqzOV5Dj4gxfcdhpAHcPe8hqBxnA8w== X-Received: by 10.194.110.42 with SMTP id hx10mr57441568wjb.116.1470169571660; Tue, 02 Aug 2016 13:26:11 -0700 (PDT) Received: from desktop.wvd.kresin.me (p200300454B096D00631C7FC25CD5DED3.dip0.t-ipconnect.de. [2003:45:4b09:6d00:631c:7fc2:5cd5:ded3]) by smtp.gmail.com with ESMTPSA id r13sm4622129wmf.12.2016.08.02.13.26.10 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 02 Aug 2016 13:26:11 -0700 (PDT) From: Mathias Kresin To: lede-dev@lists.infradead.org Date: Tue, 2 Aug 2016 22:25:59 +0200 Message-Id: <1470169562-26594-2-git-send-email-dev@kresin.me> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1470169562-26594-1-git-send-email-dev@kresin.me> References: <1470169562-26594-1-git-send-email-dev@kresin.me> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160802_132634_116075_C6C15384 X-CRM114-Status: GOOD ( 13.01 ) X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2a00:1450:400c:c09:0:0:0:241 listed in] [list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid Subject: [LEDE-DEV] [PATCH 2/5] lantiq: drop orphaned eeprom-handling code branches X-BeenThere: lede-dev@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "Lede-dev" Errors-To: lede-dev-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org All device tree nodes are using the named properties now and the code path handling the reg property isn't required any more. The code related to the ath,eep-flash property has been reformatted to be better readable. Signed-off-by: Mathias Kresin --- ...-lantiq-wifi-and-ethernet-eeprom-handling.patch | 168 +++++++++------------ 1 file changed, 71 insertions(+), 97 deletions(-) diff --git a/target/linux/lantiq/patches-4.4/0035-owrt-lantiq-wifi-and-ethernet-eeprom-handling.patch b/target/linux/lantiq/patches-4.4/0035-owrt-lantiq-wifi-and-ethernet-eeprom-handling.patch index 7116b89..6cf1b7c 100644 --- a/target/linux/lantiq/patches-4.4/0035-owrt-lantiq-wifi-and-ethernet-eeprom-handling.patch +++ b/target/linux/lantiq/patches-4.4/0035-owrt-lantiq-wifi-and-ethernet-eeprom-handling.patch @@ -51,7 +51,7 @@ Signed-off-by: John Crispin obj-$(CONFIG_XRX200_PHY_FW) += xrx200_phy_fw.o --- /dev/null +++ b/arch/mips/lantiq/xway/ath_eep.c -@@ -0,0 +1,307 @@ +@@ -0,0 +1,281 @@ +/* + * Copyright (C) 2011 Luca Olivetti + * Copyright (C) 2011 John Crispin @@ -93,9 +93,7 @@ Signed-off-by: John Crispin +static int ath9k_eep_load; +int __init of_ath9k_eeprom_probe(struct platform_device *pdev) +{ -+ struct device_node *np = pdev->dev.of_node, *mtd_np; -+ struct resource *eep_res, *mac_res = NULL; -+ void __iomem *eep, *mac; ++ struct device_node *np = pdev->dev.of_node, *mtd_np = NULL; + int mac_offset, led_pin; + u32 mac_inc = 0, pci_slot = 0; + int i; @@ -106,41 +104,38 @@ Signed-off-by: John Crispin + phandle phandle; + u16 dev_ids[2] = { 0 }; + -+ if ((list = of_get_property(np, "ath,eep-flash", &i)) && i == 2 * -+ sizeof(*list) && (phandle = be32_to_cpup(list++)) && -+ (mtd_np = of_find_node_by_phandle(phandle)) && ((part = -+ of_get_property(mtd_np, "label", NULL)) || (part = -+ mtd_np->name)) && (the_mtd = get_mtd_device_nm(part)) -+ != ERR_PTR(-ENODEV)) { -+ i = mtd_read(the_mtd, be32_to_cpup(list), -+ ATH9K_PLAT_EEP_MAX_WORDS << 1, &flash_readlen, -+ (void *) ath9k_pdata.eeprom_data); -+ if (!of_property_read_u32(np, "ath,mac-offset", &mac_offset)) { -+ size_t mac_readlen; -+ mtd_read(the_mtd, mac_offset, 6, &mac_readlen, -+ (void *) athxk_eeprom_mac); -+ } -+ put_mtd_device(the_mtd); -+ if ((sizeof(ath9k_pdata.eeprom_data) != flash_readlen) || i) { -+ dev_err(&pdev->dev, "failed to load eeprom from mtd\n"); -+ return -ENODEV; -+ } -+ } else { -+ eep_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); -+ mac_res = platform_get_resource(pdev, IORESOURCE_MEM, 1); -+ -+ if (!eep_res) { -+ dev_err(&pdev->dev, "failed to load eeprom address\n"); -+ return -ENODEV; -+ } -+ if (resource_size(eep_res) != ATH9K_PLAT_EEP_MAX_WORDS << 1) { -+ dev_err(&pdev->dev, "eeprom has an invalid size\n"); -+ return -EINVAL; -+ } -+ -+ eep = ioremap(eep_res->start, resource_size(eep_res)); -+ memcpy_fromio(ath9k_pdata.eeprom_data, eep, -+ ATH9K_PLAT_EEP_MAX_WORDS << 1); ++ list = of_get_property(np, "ath,eep-flash", &i); ++ if (!list || (i != (2 * sizeof(*list)))) ++ return -ENODEV; ++ ++ phandle = be32_to_cpup(list++); ++ if (phandle) ++ mtd_np = of_find_node_by_phandle(phandle); ++ ++ if (!mtd_np) ++ return -ENODEV; ++ ++ part = of_get_property(mtd_np, "label", NULL); ++ if (!part) ++ part = mtd_np->name; ++ ++ the_mtd = get_mtd_device_nm(part); ++ if (IS_ERR(the_mtd)) ++ return -ENODEV; ++ ++ i = mtd_read(the_mtd, be32_to_cpup(list), ATH9K_PLAT_EEP_MAX_WORDS << 1, ++ &flash_readlen, (void *) ath9k_pdata.eeprom_data); ++ ++ if (!of_property_read_u32(np, "ath,mac-offset", &mac_offset)) { ++ size_t mac_readlen; ++ mtd_read(the_mtd, mac_offset, 6, &mac_readlen, ++ (void *) athxk_eeprom_mac); ++ } ++ put_mtd_device(the_mtd); ++ ++ if ((sizeof(ath9k_pdata.eeprom_data) != flash_readlen) || i) { ++ dev_err(&pdev->dev, "failed to load eeprom from mtd\n"); ++ return -ENODEV; + } + + if (of_find_property(np, "ath,eep-swap", NULL)) @@ -153,18 +148,9 @@ Signed-off-by: John Crispin + dev_info(&pdev->dev, "endian check enabled.\n"); + } + -+ if (!is_valid_ether_addr(athxk_eeprom_mac)) { -+ if (mac_res) { -+ if (resource_size(mac_res) != 6) { -+ dev_err(&pdev->dev, "mac has an invalid size\n"); -+ return -EINVAL; -+ } -+ mac = ioremap(mac_res->start, resource_size(mac_res)); -+ memcpy_fromio(athxk_eeprom_mac, mac, 6); -+ } else if (ltq_get_eth_mac()) { -+ memcpy(athxk_eeprom_mac, ltq_get_eth_mac(), 6); -+ } -+ } ++ if (!is_valid_ether_addr(athxk_eeprom_mac) && ltq_get_eth_mac()) ++ memcpy(athxk_eeprom_mac, ltq_get_eth_mac(), 6); ++ + if (!is_valid_ether_addr(athxk_eeprom_mac)) { + dev_warn(&pdev->dev, "using random mac\n"); + random_ether_addr(athxk_eeprom_mac); @@ -263,9 +249,7 @@ Signed-off-by: John Crispin + +int __init of_ath5k_eeprom_probe(struct platform_device *pdev) +{ -+ struct device_node *np = pdev->dev.of_node, *mtd_np; -+ struct resource *eep_res, *mac_res = NULL; -+ void __iomem *eep, *mac; ++ struct device_node *np = pdev->dev.of_node, *mtd_np = NULL; + int mac_offset; + u32 mac_inc = 0; + int i; @@ -275,57 +259,47 @@ Signed-off-by: John Crispin + const char *part; + phandle phandle; + -+ if ((list = of_get_property(np, "ath,eep-flash", &i)) && i == 2 * -+ sizeof(*list) && (phandle = be32_to_cpup(list++)) && -+ (mtd_np = of_find_node_by_phandle(phandle)) && ((part = -+ of_get_property(mtd_np, "label", NULL)) || (part = -+ mtd_np->name)) && (the_mtd = get_mtd_device_nm(part)) -+ != ERR_PTR(-ENODEV)) { -+ i = mtd_read(the_mtd, be32_to_cpup(list), -+ ATH5K_PLAT_EEP_MAX_WORDS << 1, &flash_readlen, -+ (void *) ath5k_pdata.eeprom_data); -+ put_mtd_device(the_mtd); -+ if ((sizeof(ATH5K_PLAT_EEP_MAX_WORDS << 1) != flash_readlen) -+ || i) { -+ dev_err(&pdev->dev, "failed to load eeprom from mtd\n"); -+ return -ENODEV; -+ } -+ } else { -+ eep_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); -+ mac_res = platform_get_resource(pdev, IORESOURCE_MEM, 1); -+ -+ if (!eep_res) { -+ dev_err(&pdev->dev, "failed to load eeprom address\n"); -+ return -ENODEV; -+ } -+ if (resource_size(eep_res) != ATH5K_PLAT_EEP_MAX_WORDS << 1) { -+ dev_err(&pdev->dev, "eeprom has an invalid size\n"); -+ return -EINVAL; -+ } -+ -+ eep = ioremap(eep_res->start, resource_size(eep_res)); -+ ath5k_pdata.eeprom_data = kmalloc(ATH5K_PLAT_EEP_MAX_WORDS<<1, -+ GFP_KERNEL); -+ memcpy_fromio(ath5k_pdata.eeprom_data, eep, -+ ATH5K_PLAT_EEP_MAX_WORDS << 1); ++ list = of_get_property(np, "ath,eep-flash", &i); ++ if (!list || (i != (2 * sizeof(*list)))) ++ return -ENODEV; ++ ++ phandle = be32_to_cpup(list++); ++ if (phandle) ++ mtd_np = of_find_node_by_phandle(phandle); ++ ++ if (!mtd_np) ++ return -ENODEV; ++ ++ part = of_get_property(mtd_np, "label", NULL); ++ if (!part) ++ part = mtd_np->name; ++ ++ the_mtd = get_mtd_device_nm(part); ++ if (IS_ERR(the_mtd)) ++ return -ENODEV; ++ ++ i = mtd_read(the_mtd, be32_to_cpup(list), ATH5K_PLAT_EEP_MAX_WORDS << 1, ++ &flash_readlen, (void *) ath5k_pdata.eeprom_data); ++ ++ put_mtd_device(the_mtd); ++ ++ if ((sizeof(ATH5K_PLAT_EEP_MAX_WORDS << 1) != flash_readlen) ++ || i) { ++ dev_err(&pdev->dev, "failed to load eeprom from mtd\n"); ++ return -ENODEV; + } + + if (of_find_property(np, "ath,eep-swap", NULL)) + for (i = 0; i < ATH5K_PLAT_EEP_MAX_WORDS; i++) + ath5k_pdata.eeprom_data[i] = swab16(ath5k_pdata.eeprom_data[i]); + -+ if (!of_property_read_u32(np, "ath,mac-offset", &mac_offset)) { ++ if (!of_property_read_u32(np, "ath,mac-offset", &mac_offset)) + memcpy_fromio(athxk_eeprom_mac, (void*) ath5k_pdata.eeprom_data + mac_offset, 6); -+ } else if (mac_res) { -+ if (resource_size(mac_res) != 6) { -+ dev_err(&pdev->dev, "mac has an invalid size\n"); -+ return -EINVAL; -+ } -+ mac = ioremap(mac_res->start, resource_size(mac_res)); -+ memcpy_fromio(athxk_eeprom_mac, mac, 6); -+ } else if (ltq_get_eth_mac()) ++ ++ if (!is_valid_ether_addr(athxk_eeprom_mac) && ltq_get_eth_mac()) + memcpy(athxk_eeprom_mac, ltq_get_eth_mac(), 6); -+ else { ++ ++ if (!is_valid_ether_addr(athxk_eeprom_mac)) { + dev_warn(&pdev->dev, "using random mac\n"); + random_ether_addr(athxk_eeprom_mac); + }