mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-03 01:36:52 +09:00
Merge branch 'dev_addr-helpers'
Jakub Kicinski says: ==================== net: add a helpers for loading netdev->dev_addr from platform Similarly to recently added device_get_ethdev_address() and of_get_ethdev_address() create a helper for drivers loading mac addr from platform data. nvmem_get_mac_address() does not have driver callers so instead of adding a helper there unexport it. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
@@ -1385,7 +1385,7 @@ static void owl_emac_get_mac_addr(struct net_device *netdev)
|
||||
struct device *dev = netdev->dev.parent;
|
||||
int ret;
|
||||
|
||||
ret = eth_platform_get_mac_address(dev, netdev->dev_addr);
|
||||
ret = platform_get_ethdev_address(dev, netdev);
|
||||
if (!ret && is_valid_ether_addr(netdev->dev_addr))
|
||||
return;
|
||||
|
||||
|
||||
@@ -1544,7 +1544,7 @@ static int mtk_star_probe(struct platform_device *pdev)
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = eth_platform_get_mac_address(dev, ndev->dev_addr);
|
||||
ret = platform_get_ethdev_address(dev, ndev);
|
||||
if (ret || !is_valid_ether_addr(ndev->dev_addr))
|
||||
eth_hw_addr_random(ndev);
|
||||
|
||||
|
||||
@@ -758,8 +758,7 @@ static int smsc75xx_ioctl(struct net_device *netdev, struct ifreq *rq, int cmd)
|
||||
static void smsc75xx_init_mac_address(struct usbnet *dev)
|
||||
{
|
||||
/* maybe the boot loader passed the MAC address in devicetree */
|
||||
if (!eth_platform_get_mac_address(&dev->udev->dev,
|
||||
dev->net->dev_addr)) {
|
||||
if (!platform_get_ethdev_address(&dev->udev->dev, dev->net)) {
|
||||
if (is_valid_ether_addr(dev->net->dev_addr)) {
|
||||
/* device tree values are valid so use them */
|
||||
netif_dbg(dev, ifup, dev->net, "MAC address read from the device tree\n");
|
||||
|
||||
@@ -756,8 +756,7 @@ static int smsc95xx_ioctl(struct net_device *netdev, struct ifreq *rq, int cmd)
|
||||
static void smsc95xx_init_mac_address(struct usbnet *dev)
|
||||
{
|
||||
/* maybe the boot loader passed the MAC address in devicetree */
|
||||
if (!eth_platform_get_mac_address(&dev->udev->dev,
|
||||
dev->net->dev_addr)) {
|
||||
if (!platform_get_ethdev_address(&dev->udev->dev, dev->net)) {
|
||||
if (is_valid_ether_addr(dev->net->dev_addr)) {
|
||||
/* device tree values are valid so use them */
|
||||
netif_dbg(dev, ifup, dev->net, "MAC address read from the device tree\n");
|
||||
|
||||
@@ -29,6 +29,7 @@ struct device;
|
||||
struct fwnode_handle;
|
||||
|
||||
int eth_platform_get_mac_address(struct device *dev, u8 *mac_addr);
|
||||
int platform_get_ethdev_address(struct device *dev, struct net_device *netdev);
|
||||
unsigned char *arch_get_platform_mac_address(void);
|
||||
int nvmem_get_mac_address(struct device *dev, void *addrbuf);
|
||||
int device_get_mac_address(struct device *dev, char *addr);
|
||||
|
||||
@@ -523,6 +523,26 @@ int eth_platform_get_mac_address(struct device *dev, u8 *mac_addr)
|
||||
}
|
||||
EXPORT_SYMBOL(eth_platform_get_mac_address);
|
||||
|
||||
/**
|
||||
* platform_get_ethdev_address - Set netdev's MAC address from a given device
|
||||
* @dev: Pointer to the device
|
||||
* @netdev: Pointer to netdev to write the address to
|
||||
*
|
||||
* Wrapper around eth_platform_get_mac_address() which writes the address
|
||||
* directly to netdev->dev_addr.
|
||||
*/
|
||||
int platform_get_ethdev_address(struct device *dev, struct net_device *netdev)
|
||||
{
|
||||
u8 addr[ETH_ALEN] __aligned(2);
|
||||
int ret;
|
||||
|
||||
ret = eth_platform_get_mac_address(dev, addr);
|
||||
if (!ret)
|
||||
eth_hw_addr_set(netdev, addr);
|
||||
return ret;
|
||||
}
|
||||
EXPORT_SYMBOL(platform_get_ethdev_address);
|
||||
|
||||
/**
|
||||
* nvmem_get_mac_address - Obtain the MAC address from an nvmem cell named
|
||||
* 'mac-address' associated with given device.
|
||||
@@ -558,7 +578,6 @@ int nvmem_get_mac_address(struct device *dev, void *addrbuf)
|
||||
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL(nvmem_get_mac_address);
|
||||
|
||||
static int fwnode_get_mac_addr(struct fwnode_handle *fwnode,
|
||||
const char *name, char *addr)
|
||||
|
||||
Reference in New Issue
Block a user