[][openwrt][common][app][Fix switch cmd netlink issue on mt7988]
[Description]
Fix switch cmd netlink issue on mt7988.
Fixes: ("[openwrt][common][app][Refactor switch command to support switches
with different design]") which does not consider mt7988 internal switch
support properly.
[Release-log]
N/A
Change-Id: Idbacd48d4422426e2df5cf15c13926b80481efc6
Reviewed-on: https://gerrit.mediatek.inc/c/openwrt/feeds/mtk_openwrt_feeds/+/8781435
diff --git a/feed/app/switch/src/switch_753x.c b/feed/app/switch/src/switch_753x.c
index 79bc298..6936f6a 100644
--- a/feed/app/switch/src/switch_753x.c
+++ b/feed/app/switch/src/switch_753x.c
@@ -464,33 +464,35 @@
FILE *fp = NULL;
char buff[255];
+ /*judge jaguar embedded switch */
+ fp = fopen("/proc/device-tree/compatible", "r");
+ if (fp != NULL) {
+ temp = -1;
+ if (fgets(buff, 255, (FILE *) fp) && strstr(buff, "mt7988"))
+ temp = 0x7988;
+
+ rc = fclose(fp);
+ if (rc == 0 && temp == 0x7988)
+ return temp;
+ }
+
/*judge 7530 */
reg_read((0x7ffc), &temp);
temp = temp >> 16;
if (temp == 0x7530)
return temp;
+
/*judge 7531 */
reg_read(0x781c, &temp);
temp = temp >> 16;
if (temp == 0x7531)
return temp;
+
/*judge an8855 */
reg_read(0x10005000, &temp);
if (temp == 0x8855)
return temp;
- /*judge jaguar embedded switch */
- fp = fopen("/proc/device-tree/compatible", "r");
- if (fp != NULL) {
- temp = -1;
- if (fgets(buff, 255, (FILE *) fp) && strstr(buff, "mt7988"))
- temp = 0x7988;
-
- rc = fclose(fp);
- if (rc == 0)
- return temp;
- }
-
return -1;
}
@@ -643,9 +645,11 @@
chip_name = get_chip_name();
}
- err = mt753x_netlink_init(AN8855_DSA_GENL_NAME);
- if (!err)
- chip_name = get_chip_name();
+ if (err < 0) {
+ err = mt753x_netlink_init(AN8855_DSA_GENL_NAME);
+ if (!err)
+ chip_name = get_chip_name();
+ }
if (err < 0) {
err = mt753x_netlink_init(AN8855_GENL_NAME);