From 8553655c5f5f21e19f8ad7c0d45ce48186468826 Mon Sep 17 00:00:00 2001 From: AmadeusGhost <42570690+AmadeusGhost@users.noreply.github.com> Date: Fri, 23 Jul 2021 12:20:01 +0800 Subject: [PATCH] kernel/pending: refresh some patches Fix: #421 --- ...address-support-to-of_get_mac_addres.patch | 97 ++++------------- .../pending-5.4/655-increase_skb_pad.patch | 2 +- ...address-support-to-of_get_mac_addres.patch | 102 ++++-------------- 3 files changed, 45 insertions(+), 156 deletions(-) diff --git a/target/linux/generic/pending-5.10/681-NET-add-mtd-mac-address-support-to-of_get_mac_addres.patch b/target/linux/generic/pending-5.10/681-NET-add-mtd-mac-address-support-to-of_get_mac_addres.patch index 82a0a2c311..9e16564953 100644 --- a/target/linux/generic/pending-5.10/681-NET-add-mtd-mac-address-support-to-of_get_mac_addres.patch +++ b/target/linux/generic/pending-5.10/681-NET-add-mtd-mac-address-support-to-of_get_mac_addres.patch @@ -38,58 +38,13 @@ Signed-off-by: Ansuel Smith return mac; } -+typedef int(*mtd_mac_address_read)(struct mtd_info *mtd, loff_t from, u_char *buf); -+ -+static int read_mtd_mac_address(struct mtd_info *mtd, loff_t from, u_char *mac) -+{ -+ size_t retlen; -+ -+ return mtd_read(mtd, from, 6, &retlen, mac); -+} -+ -+static int read_mtd_mac_address_ascii(struct mtd_info *mtd, loff_t from, u_char *mac) -+{ -+ size_t retlen; -+ char buf[17]; -+ -+ if (mtd_read(mtd, from, 12, &retlen, buf)) { -+ return -1; -+ } -+ if (sscanf(buf, "%2hhx%2hhx%2hhx%2hhx%2hhx%2hhx", -+ &mac[0], &mac[1], &mac[2], &mac[3], -+ &mac[4], &mac[5]) == 6) { -+ return 0; -+ } -+ if (mtd_read(mtd, from+12, 5, &retlen, buf+12)) { -+ return -1; -+ } -+ if (sscanf(buf, "%2hhx:%2hhx:%2hhx:%2hhx:%2hhx:%2hhx", -+ &mac[0], &mac[1], &mac[2], &mac[3], -+ &mac[4], &mac[5]) == 6) { -+ return 0; -+ } -+ return -1; -+} -+ -+static struct mtd_mac_address_property { -+ char *name; -+ mtd_mac_address_read read; -+} mtd_mac_address_properties[] = { -+ { -+ .name = "mtd-mac-address", -+ .read = read_mtd_mac_address, -+ }, { -+ .name = "mtd-mac-address-ascii", -+ .read = read_mtd_mac_address_ascii, -+ }, -+}; -+ +static const void *of_get_mac_address_mtd(struct device_node *np) +{ +#ifdef CONFIG_MTD + struct device_node *mtd_np = NULL; + struct property *prop; -+ int size, ret = -1; ++ size_t retlen; ++ int size, ret; + struct mtd_info *mtd; + const char *part; + const __be32 *list; @@ -97,35 +52,27 @@ Signed-off-by: Ansuel Smith + u8 mac[ETH_ALEN]; + void *addr; + -+ for (i = 0; i < ARRAY_SIZE(mtd_mac_address_properties); i++) { -+ list = of_get_property(np, mtd_mac_address_properties[i].name, &size); -+ if (!list || (size != (2 * sizeof(*list)))) -+ continue; -+ -+ phandle = be32_to_cpup(list++); -+ if (phandle) -+ mtd_np = of_find_node_by_phandle(phandle); -+ -+ if (!mtd_np) -+ continue; -+ -+ part = of_get_property(mtd_np, "label", NULL); -+ if (!part) -+ part = mtd_np->name; -+ -+ mtd = get_mtd_device_nm(part); -+ if (IS_ERR(mtd)) -+ continue; -+ -+ ret = mtd_mac_address_properties[i].read(mtd, be32_to_cpup(list), mac); -+ put_mtd_device(mtd); -+ if (!ret) { -+ break; -+ } -+ } -+ if (ret) { ++ list = of_get_property(np, "mtd-mac-address", &size); ++ if (!list || (size != (2 * sizeof(*list)))) + return NULL; -+ } ++ ++ phandle = be32_to_cpup(list++); ++ if (phandle) ++ mtd_np = of_find_node_by_phandle(phandle); ++ ++ if (!mtd_np) ++ return NULL; ++ ++ part = of_get_property(mtd_np, "label", NULL); ++ if (!part) ++ part = mtd_np->name; ++ ++ mtd = get_mtd_device_nm(part); ++ if (IS_ERR(mtd)) ++ return NULL; ++ ++ ret = mtd_read(mtd, be32_to_cpup(list), 6, &retlen, mac); ++ put_mtd_device(mtd); + + if (!is_valid_ether_addr(mac)) + return NULL; diff --git a/target/linux/generic/pending-5.4/655-increase_skb_pad.patch b/target/linux/generic/pending-5.4/655-increase_skb_pad.patch index 3ca190f0aa..e325301d3c 100644 --- a/target/linux/generic/pending-5.4/655-increase_skb_pad.patch +++ b/target/linux/generic/pending-5.4/655-increase_skb_pad.patch @@ -9,7 +9,7 @@ Signed-off-by: Felix Fietkau --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h -@@ -2661,7 +2661,7 @@ static inline int pskb_network_may_pull( +@@ -2650,7 +2650,7 @@ static inline int pskb_network_may_pull( * NET_IP_ALIGN(2) + ethernet_header(14) + IP_header(20/40) + ports(8) */ #ifndef NET_SKB_PAD diff --git a/target/linux/generic/pending-5.4/681-NET-add-mtd-mac-address-support-to-of_get_mac_addres.patch b/target/linux/generic/pending-5.4/681-NET-add-mtd-mac-address-support-to-of_get_mac_addres.patch index 506f324f79..44a6b6a047 100644 --- a/target/linux/generic/pending-5.4/681-NET-add-mtd-mac-address-support-to-of_get_mac_addres.patch +++ b/target/linux/generic/pending-5.4/681-NET-add-mtd-mac-address-support-to-of_get_mac_addres.patch @@ -40,63 +40,13 @@ index 6e411821583e..f072e2509cc9 100644 return mac; } -+typedef int(*mtd_mac_address_read)(struct mtd_info *mtd, loff_t from, u_char *buf); -+ -+static int read_mtd_mac_address(struct mtd_info *mtd, loff_t from, u_char *mac) -+{ -+ size_t retlen; -+ -+ return mtd_read(mtd, from, 6, &retlen, mac); -+} -+ -+static int read_mtd_mac_address_ascii(struct mtd_info *mtd, loff_t from, u_char *mac) -+{ -+ size_t retlen; -+ char buf[17]; -+ -+ if (mtd_read(mtd, from, 12, &retlen, buf)) { -+ return -1; -+ } -+ if (sscanf(buf, "%2hhx%2hhx%2hhx%2hhx%2hhx%2hhx", -+ &mac[0], &mac[1], &mac[2], &mac[3], -+ &mac[4], &mac[5]) == 6) { -+ if (mac[0] == '\0' && mac[1] == '\0') { /* First 2 bytes are zero, probably a bug. Trying to re-read */ -+ buf[4] = '\0'; /* Make it null-terminated */ -+ if (sscanf(buf, "%4hx", mac) == 1) -+ *(uint16_t*)mac = htons(*(uint16_t*)mac); -+ } -+ return 0; -+ } -+ if (mtd_read(mtd, from+12, 5, &retlen, buf+12)) { -+ return -1; -+ } -+ if (sscanf(buf, "%2hhx:%2hhx:%2hhx:%2hhx:%2hhx:%2hhx", -+ &mac[0], &mac[1], &mac[2], &mac[3], -+ &mac[4], &mac[5]) == 6) { -+ return 0; -+ } -+ return -1; -+} -+ -+static struct mtd_mac_address_property { -+ char *name; -+ mtd_mac_address_read read; -+} mtd_mac_address_properties[] = { -+ { -+ .name = "mtd-mac-address", -+ .read = read_mtd_mac_address, -+ }, { -+ .name = "mtd-mac-address-ascii", -+ .read = read_mtd_mac_address_ascii, -+ }, -+}; -+ +static const void *of_get_mac_address_mtd(struct device_node *np) +{ +#ifdef CONFIG_MTD + struct device_node *mtd_np = NULL; + struct property *prop; -+ int size, ret = -1; ++ size_t retlen; ++ int size, ret; + struct mtd_info *mtd; + const char *part; + const __be32 *list; @@ -104,35 +54,27 @@ index 6e411821583e..f072e2509cc9 100644 + u8 mac[ETH_ALEN]; + void *addr; + -+ for (i = 0; i < ARRAY_SIZE(mtd_mac_address_properties); i++) { -+ list = of_get_property(np, mtd_mac_address_properties[i].name, &size); -+ if (!list || (size != (2 * sizeof(*list)))) -+ continue; -+ -+ phandle = be32_to_cpup(list++); -+ if (phandle) -+ mtd_np = of_find_node_by_phandle(phandle); -+ -+ if (!mtd_np) -+ continue; -+ -+ part = of_get_property(mtd_np, "label", NULL); -+ if (!part) -+ part = mtd_np->name; -+ -+ mtd = get_mtd_device_nm(part); -+ if (IS_ERR(mtd)) -+ continue; -+ -+ ret = mtd_mac_address_properties[i].read(mtd, be32_to_cpup(list), mac); -+ put_mtd_device(mtd); -+ if (!ret) { -+ break; -+ } -+ } -+ if (ret) { ++ list = of_get_property(np, "mtd-mac-address", &size); ++ if (!list || (size != (2 * sizeof(*list)))) + return NULL; -+ } ++ ++ phandle = be32_to_cpup(list++); ++ if (phandle) ++ mtd_np = of_find_node_by_phandle(phandle); ++ ++ if (!mtd_np) ++ return NULL; ++ ++ part = of_get_property(mtd_np, "label", NULL); ++ if (!part) ++ part = mtd_np->name; ++ ++ mtd = get_mtd_device_nm(part); ++ if (IS_ERR(mtd)) ++ return NULL; ++ ++ ret = mtd_read(mtd, be32_to_cpup(list), 6, &retlen, mac); ++ put_mtd_device(mtd); + + if (!is_valid_ether_addr(mac)) + return NULL;