summaryrefslogtreecommitdiff
path: root/package/iwinfo/src/iwinfo_madwifi.c
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2012-02-17 00:36:25 +0000
committerJo-Philipp Wich <jow@openwrt.org>2012-02-17 00:36:25 +0000
commit018d69c3b3421ff86be0004a25943068cd54aace (patch)
tree25f3ffdfbd017853efe69fecf8793dca16212075 /package/iwinfo/src/iwinfo_madwifi.c
parente17a3ffbbde8622189a4514f864f8241fb1ed485 (diff)
downloadmtk-20170518-018d69c3b3421ff86be0004a25943068cd54aace.zip
mtk-20170518-018d69c3b3421ff86be0004a25943068cd54aace.tar.gz
mtk-20170518-018d69c3b3421ff86be0004a25943068cd54aace.tar.bz2
iwinfo: implement proper hardware detection for ar23xx SoC devices like the NanoStation 2
SVN-Revision: 30605
Diffstat (limited to 'package/iwinfo/src/iwinfo_madwifi.c')
-rw-r--r--package/iwinfo/src/iwinfo_madwifi.c75
1 files changed, 2 insertions, 73 deletions
diff --git a/package/iwinfo/src/iwinfo_madwifi.c b/package/iwinfo/src/iwinfo_madwifi.c
index 732cfe5..fcd6c8c 100644
--- a/package/iwinfo/src/iwinfo_madwifi.c
+++ b/package/iwinfo/src/iwinfo_madwifi.c
@@ -988,40 +988,6 @@ int madwifi_get_mbssid_support(const char *ifname, int *buf)
return -1;
}
-static void madwifi_proc_file(const char *ifname, const char *file,
- char *buf, int blen)
-{
- int fd;
- const char *wifi = madwifi_isvap(ifname, NULL);
-
- if (!wifi && madwifi_iswifi(ifname))
- wifi = ifname;
-
- snprintf(buf, blen, "/proc/sys/dev/%s/%s", wifi, file);
-
- if ((fd = open(buf, O_RDONLY)) > 0)
- {
- if (read(fd, buf, blen) > 1)
- buf[strlen(buf)-1] = 0;
- else
- buf[0] = 0;
-
- close(fd);
- }
- else
- {
- buf[0] = 0;
- }
-}
-
-static int madwifi_startswith(const char *a, const char *b)
-{
- int l1 = strlen(a);
- int l2 = strlen(b);
- int ln = (l1 < l2) ? l1 : l2;
- return !strncmp(a, b, ln);
-}
-
int madwifi_get_hardware_id(const char *ifname, char *buf)
{
char vendor[64];
@@ -1030,32 +996,7 @@ int madwifi_get_hardware_id(const char *ifname, char *buf)
struct iwinfo_hardware_entry *e;
if (wext_get_hardware_id(ifname, buf))
- {
- ids = (struct iwinfo_hardware_id *)buf;
- madwifi_proc_file(ifname, "dev_vendor", vendor, sizeof(vendor));
- madwifi_proc_file(ifname, "dev_name", device, sizeof(device));
-
- if (vendor[0] && device[0])
- {
- for (e = IWINFO_HARDWARE_ENTRIES; e->vendor_name; e++)
- {
- if (!madwifi_startswith(vendor, e->vendor_name))
- continue;
-
- if (!madwifi_startswith(device, e->device_name))
- continue;
-
- ids->vendor_id = e->vendor_id;
- ids->device_id = e->device_id;
- ids->subsystem_vendor_id = e->subsystem_vendor_id;
- ids->subsystem_device_id = e->subsystem_device_id;
-
- return 0;
- }
- }
-
- return -1;
- }
+ return iwinfo_hardware_id_from_mtd((struct iwinfo_hardware_id *)buf);
return 0;
}
@@ -1073,24 +1014,12 @@ madwifi_get_hardware_entry(const char *ifname)
int madwifi_get_hardware_name(const char *ifname, char *buf)
{
- char vendor[64];
- char device[64];
const struct iwinfo_hardware_entry *hw;
if (!(hw = madwifi_get_hardware_entry(ifname)))
- {
- madwifi_proc_file(ifname, "dev_vendor", vendor, sizeof(vendor));
- madwifi_proc_file(ifname, "dev_name", device, sizeof(device));
-
- if (vendor[0] && device[0])
- sprintf(buf, "%s %s", vendor, device);
- else
- sprintf(buf, "Generic Atheros");
- }
+ sprintf(buf, "Generic Atheros");
else
- {
sprintf(buf, "%s %s", hw->vendor_name, hw->device_name);
- }
return 0;
}