aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/bcm53xx/files
diff options
context:
space:
mode:
authorRafał Miłecki <zajec5@gmail.com>2015-03-14 16:35:56 +0000
committerRafał Miłecki <zajec5@gmail.com>2015-03-14 16:35:56 +0000
commit5cf9746b1d5908c896fb684a0353adaf6e6f4957 (patch)
treedb1e85b2f6a74a1f14cb0484d733c09fc4bc4c66 /target/linux/bcm53xx/files
parent6175f4168bc96472d1e0e4c42ea69789a8580564 (diff)
downloadmaster-187ad058-5cf9746b1d5908c896fb684a0353adaf6e6f4957.tar.gz
master-187ad058-5cf9746b1d5908c896fb684a0353adaf6e6f4957.tar.bz2
master-187ad058-5cf9746b1d5908c896fb684a0353adaf6e6f4957.zip
bcm53xx: support NVRAM prefixes with extra / in devpath
Signed-off-by: Rafał Miłecki <zajec5@gmail.com> git-svn-id: svn://svn.openwrt.org/openwrt/trunk@44755 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'target/linux/bcm53xx/files')
-rw-r--r--target/linux/bcm53xx/files/drivers/misc/bcm47xx-sprom.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/target/linux/bcm53xx/files/drivers/misc/bcm47xx-sprom.c b/target/linux/bcm53xx/files/drivers/misc/bcm47xx-sprom.c
index 3c5d58ff38..e9bca9fbaf 100644
--- a/target/linux/bcm53xx/files/drivers/misc/bcm47xx-sprom.c
+++ b/target/linux/bcm53xx/files/drivers/misc/bcm47xx-sprom.c
@@ -646,23 +646,27 @@ static struct platform_device *sprom_pdev = NULL;
static char prefix[20];
-static void bcm47xx_sprom_apply_prefix_alias(char *prefix, size_t prefix_len)
+static void bcm47xx_sprom_apply_prefix_alias(char *prefix, size_t prefix_size)
{
- size_t needle_len = strlen(prefix) - 1;
+ size_t prefix_len = strlen(prefix);
+ size_t short_len = prefix_len - 1;
char nvram_var[10];
char buf[20];
int i;
- if (needle_len <= 0 || prefix[needle_len] != '/')
+ if (prefix_len <= 0 || prefix[prefix_len - 1] != '/') {
+ pr_warn("Invalid prefix: \"%s\"\n", prefix);
return;
+ }
for (i = 0; i < 3; i++) {
if (snprintf(nvram_var, sizeof(nvram_var), "devpath%d", i) <= 0)
continue;
if (bcm47xx_nvram_getenv(nvram_var, buf, sizeof(buf)) < 0)
continue;
- if (strlen(buf) == needle_len && !strncmp(buf, prefix, needle_len)) {
- snprintf(prefix, prefix_len, "%d:", i);
+ if (!strcmp(buf, prefix) ||
+ (short_len && strlen(buf) == short_len && !strncmp(buf, prefix, short_len))) {
+ snprintf(prefix, prefix_size, "%d:", i);
return;
}
}