pch_phub: re-use native MAC address parser
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Tue, 28 May 2013 15:54:58 +0000 (18:54 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 3 Jun 2013 21:23:32 +0000 (14:23 -0700)
We have mac_pton() helper to parse MAC addresses.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/misc/pch_phub.c

index 931e635..8b4d4fb 100644 (file)
@@ -633,17 +633,13 @@ static ssize_t show_pch_mac(struct device *dev, struct device_attribute *attr,
 static ssize_t store_pch_mac(struct device *dev, struct device_attribute *attr,
                             const char *buf, size_t count)
 {
-       u8 mac[6];
+       u8 mac[ETH_ALEN];
        ssize_t rom_size;
        struct pch_phub_reg *chip = dev_get_drvdata(dev);
 
-       if (count != 18)
+       if (!mac_pton(buf, mac))
                return -EINVAL;
 
-       sscanf(buf, "%02x:%02x:%02x:%02x:%02x:%02x",
-               (u32 *)&mac[0], (u32 *)&mac[1], (u32 *)&mac[2], (u32 *)&mac[3],
-               (u32 *)&mac[4], (u32 *)&mac[5]);
-
        chip->pch_phub_extrom_base_address = pci_map_rom(chip->pdev, &rom_size);
        if (!chip->pch_phub_extrom_base_address)
                return -ENOMEM;