fs = get_fs();
set_fs(get_ds());
+
+ /* Special case if file length is reported as zero - try to read until it fails.
+ * This allows us to read /proc
+ */
+ if (whats_left == 0) {
+ do {
+ r = vfs_read(f, p, max_read_size, &f->f_pos);
+ if (r < 0) {
+ SCSC_TAG_INFO(MX_FILE, "No more data %s\n", path);
+ break;
+ }
+ p += r;
+ if (r < max_read_size) {
+ SCSC_TAG_INFO(MX_FILE, "Read %zd from %s\n", (ptrdiff_t)(p - buf), path);
+ break;
+ }
+ } while (r > 0);
+
+ goto done;
+ }
+
/* Read at most max_read_size in each read. Loop until the whole file has
* been copied to the local buffer.
*/
whats_left -= r;
p += r;
}
+done:
set_fs(fs);
filp_close(f, NULL);
u32 u[ETH_ALEN];
char path_name[MX_WLAN_FILE_PATH_LEN_MAX];
int r;
+ bool valid = false;
/* read maddr_file */
if (sdev->maddr_file_name) {
}
r = sscanf(e->data, "%02X:%02X:%02X:%02X:%02X:%02X", &u[0], &u[1], &u[2], &u[3], &u[4], &u[5]);
if (r != ETH_ALEN) {
- SLSI_ERR(sdev, "%s exists, but format is incorrect (should be e.g. xx:xx:xx:xx:xx:xx)\n", path_name);
+ SLSI_ERR(sdev, "%s exists, but format is incorrect (%d) [%20s] (should be e.g. xx:xx:xx:xx:xx:xx)\n",
+ CONFIG_SCSC_WLAN_MAC_ADDRESS_FILENAME, r, e->data);
goto mac_default;
}
- for (i = 0; i < ETH_ALEN; i++)
+ for (i = 0; i < ETH_ALEN; i++) {
+ if (u[i] != 0xff)
+ valid = true;
addr[i] = u[i] & 0xff;
- SLSI_INFO(sdev, "MAC address loaded from %s: %02X:%02X:%02X:%02X:%02X:%02X\n", CONFIG_SCSC_WLAN_MAC_ADDRESS_FILENAME, u[0], u[1], u[2], u[3], u[4], u[5]);
- mx140_release_file(sdev->maxwell_core, e);
- return;
+ }
+
+ /* If MAC address seems valid, finished */
+ if (valid) {
+ SLSI_INFO(sdev, "MAC address loaded from %s: %02X:%02X:%02X:%02X:%02X:%02X\n",
+ CONFIG_SCSC_WLAN_MAC_ADDRESS_FILENAME, u[0], u[1], u[2], u[3], u[4], u[5]);
+
+ /* MAC address read could hold invalid values, try to fix it to normal address */
+ if (addr[0] & 0x01) {
+ addr[0] = addr[0] & 0xfe;
+ SLSI_INFO(sdev, "MAC address invalid, fixed address: %pM\n", addr);
+ }
+ mx140_release_file(sdev->maxwell_core, e);
+ return;
+ }
#endif
mac_default: