hardware/libhardware_legacy
修订版 | 0f04d645eecf6a9c81214fa2b66870d433ae4650 (tree) |
---|---|
时间 | 2010-04-16 19:47:44 |
作者 | Yi Sun <beyounn@gmai...> |
Commiter | 黃志偉 |
changes based on review feedback
@@ -54,10 +54,9 @@ static char iface[PROPERTY_VALUE_MAX]; | ||
54 | 54 | #endif |
55 | 55 | #define WIFI_TEST_INTERFACE "sta" |
56 | 56 | #define SYSFS_PATH_MAX 256 |
57 | -#define SYSFS_CLASS_NET "/sys/class/net" | |
58 | -#define MODULE_DEFAULT_DIR "/lib/modules" | |
59 | 57 | #define PARSE_BUF_SIZE 4096 /* Should be long enough */ |
60 | -static const char SYS_FS_NET_DIR[] = "/sys/class/net"; | |
58 | +static const char SYSFS_CLASS_NET[] = "/sys/class/net"; | |
59 | +static const char MODULE_DEFAULT_DIR[] = "/lib/modules"; | |
61 | 60 | static const char SYS_MOD_NAME_DIR[] = "device/driver/module"; |
62 | 61 | static const char IFACE_DIR[] = "/data/system/wpa_supplicant"; |
63 | 62 | static const char FIRMWARE_LOADER[] = WIFI_FIRMWARE_LOADER; |
@@ -126,7 +125,7 @@ const char *get_dhcp_error_string() { | ||
126 | 125 | return dhcp_lasterror(); |
127 | 126 | } |
128 | 127 | |
129 | -static int get_driver_path( char *path, char *mname,int len) { | |
128 | +static int get_driver_path( const char *mname,char *path, unsigned int len) { | |
130 | 129 | struct utsname un; |
131 | 130 | FILE *fd; |
132 | 131 | int ret = 0, cnt; |
@@ -176,21 +175,21 @@ static int get_driver_info() { | ||
176 | 175 | char link[SYSFS_PATH_MAX]; |
177 | 176 | int ret = 0; |
178 | 177 | |
179 | - if ((netdir = opendir(SYS_FS_NET_DIR)) != NULL) { | |
178 | + if ((netdir = opendir(SYSFS_CLASS_NET)) != NULL) { | |
180 | 179 | while((de = readdir(netdir))!=NULL) { |
181 | 180 | struct dirent **namelist = NULL; |
182 | 181 | int cnt; |
183 | 182 | if ((!strcmp(de->d_name,".")) || (!strcmp(de->d_name,".."))) |
184 | 183 | continue; |
185 | - snprintf(path, SYSFS_PATH_MAX,SYSFS_CLASS_NET"/%s/wireless", de->d_name); | |
184 | + snprintf(path, SYSFS_PATH_MAX, "%s/%s/wireless", SYSFS_CLASS_NET, de->d_name); | |
186 | 185 | if (access(path, F_OK)) { |
187 | - snprintf(path, SYSFS_PATH_MAX,SYSFS_CLASS_NET"/%s/phy80211", de->d_name); | |
186 | + snprintf(path, SYSFS_PATH_MAX, "%s/%s/phy80211", SYSFS_CLASS_NET, de->d_name); | |
188 | 187 | if (access(path, F_OK)) |
189 | 188 | continue; |
190 | 189 | } |
191 | - snprintf(path,SYSFS_PATH_MAX,SYSFS_CLASS_NET"/%s/%s",de->d_name,SYS_MOD_NAME_DIR); | |
192 | - cnt = readlink(path, link,SYSFS_PATH_MAX-1); | |
193 | - if (cnt > 0 ) { | |
190 | + snprintf(path,SYSFS_PATH_MAX, "%s/%s/%s", SYSFS_CLASS_NET, de->d_name, SYS_MOD_NAME_DIR); | |
191 | + cnt = readlink(path, link, SYSFS_PATH_MAX-1); | |
192 | + if (cnt > 0) { | |
194 | 193 | char *mod = NULL, *mod1 = NULL; |
195 | 194 | link[cnt] = '\0'; |
196 | 195 | strtok(link,"/"); |
@@ -202,8 +201,7 @@ static int get_driver_info() { | ||
202 | 201 | property_set(DRIVER_PROP_NAME,"ok"); |
203 | 202 | property_set("wlan.modname",mod1); |
204 | 203 | snprintf(link,SYSFS_PATH_MAX,"%s.ko",mod1); |
205 | - if ( (cnt = get_driver_path(path, link, SYSFS_PATH_MAX)) > 0) | |
206 | - { | |
204 | + if ((cnt = get_driver_path(link, path, SYSFS_PATH_MAX)) > 0) { | |
207 | 205 | property_set("wlan.modpath",path); |
208 | 206 | } else { |
209 | 207 | LOGE("%s can not locate wifi driver, you will not be able to reinstall driver", |