Skip to contentSkip to conversation

net: pasemi: Replace mac address parsing

PATCH Applied Andy Shevchenko 3 participants 5 messages Dec 19, 2017 – Dec 20, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: pasemi: Replace mac address parsing

Replace sscanf() with mac_pton().

---
 drivers/net/ethernet/pasemi/pasemi_mac.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/net/ethernet/pasemi/pasemi_mac.c +1 -3
index c9a55b774935..07a2eb3781b1 100644
@@ -212,9 +212,7 @@ static int pasemi_get_mac_addr(struct pasemi_mac *mac)
 		return -ENOENT;
 	}
 
-	if (sscanf(maddr, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx",
-		   &addr[0], &addr[1], &addr[2], &addr[3], &addr[4], &addr[5])
-	    != ETH_ALEN) {
+	if (!mac_pton(maddr, addr)) {
 		dev_warn(&pdev->dev,
 			 "can't parse mac address, not configuring\n");
 		return -EINVAL;
Signature · 1 line
2.15.1
#1 lore raw
Quoted 3 lines · Andy Shevchenko

Replace sscanf() with mac_pton().

You don't need to select GENERIC_NET_UTILS for that?

Quoted 20 lines
---
 drivers/net/ethernet/pasemi/pasemi_mac.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/net/ethernet/pasemi/pasemi_mac.c +1 -3
index c9a55b774935..07a2eb3781b1 100644
@@ -212,9 +212,7 @@ static int pasemi_get_mac_addr(struct pasemi_mac *mac)
 		return -ENOENT;
 	}
 
-	if (sscanf(maddr, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx",
-		   &addr[0], &addr[1], &addr[2], &addr[3], &addr[4], &addr[5])
-	    != ETH_ALEN) {
+	if (!mac_pton(maddr, addr)) {
 		dev_warn(&pdev->dev,
 			 "can't parse mac address, not configuring\n");
 		return -EINVAL;
Signature · 1 line
~Randy
#2 lore raw
Quoted 6 lines · Randy Dunlap
Quoted 3 lines · Andy Shevchenko

Replace sscanf() with mac_pton().

You don't need to select GENERIC_NET_UTILS for that?

It's done by CONFIG_NET.

Quoted 27 lines
Quoted 25 lines
---
 drivers/net/ethernet/pasemi/pasemi_mac.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/net/ethernet/pasemi/pasemi_mac.c +1 -3
index c9a55b774935..07a2eb3781b1 100644
@@ -212,9 +212,7 @@ static int pasemi_get_mac_addr(struct pasemi_mac
 *mac)
 		return -ENOENT;
 	}
 
-	if (sscanf(maddr, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx",
-		   &addr[0], &addr[1], &addr[2], &addr[3],
 &addr[4], &addr[5])
-	    != ETH_ALEN) {
+	if (!mac_pton(maddr, addr)) {
 		dev_warn(&pdev->dev,

"can't parse mac address, not
configuring\n");
return -EINVAL;

Signature · 2 lines
Andy Shevchenko <[email protected]>
Intel Finland Oy
#3 lore raw
Quoted 10 lines · Andy Shevchenko
Quoted 6 lines · Randy Dunlap
Quoted 3 lines · Andy Shevchenko

Replace sscanf() with mac_pton().

You don't need to select GENERIC_NET_UTILS for that?

It's done by CONFIG_NET.

Ah, thanks.

Signature · 1 line
~Randy