mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-27 12:57:53 +00:00
eth: fwnode: remove the addr len from mac helpers
All callers pass in ETH_ALEN and the function itself will return -EINVAL for any other address length. Just assume it's ETH_ALEN like all other mac address helpers (nvm, of, platform). Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
8017c4d817
commit
0a14501ed8
14 changed files with 22 additions and 27 deletions
|
@ -36,7 +36,7 @@ static int xge_get_resources(struct xge_pdata *pdata)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (device_get_mac_address(dev, ndev->dev_addr, ETH_ALEN))
|
if (device_get_mac_address(dev, ndev->dev_addr))
|
||||||
eth_hw_addr_random(ndev);
|
eth_hw_addr_random(ndev);
|
||||||
|
|
||||||
memcpy(ndev->perm_addr, ndev->dev_addr, ndev->addr_len);
|
memcpy(ndev->perm_addr, ndev->dev_addr, ndev->addr_len);
|
||||||
|
|
|
@ -1731,7 +1731,7 @@ static int xgene_enet_get_resources(struct xgene_enet_pdata *pdata)
|
||||||
xgene_get_port_id_acpi(dev, pdata);
|
xgene_get_port_id_acpi(dev, pdata);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (device_get_mac_address(dev, ndev->dev_addr, ETH_ALEN))
|
if (device_get_mac_address(dev, ndev->dev_addr))
|
||||||
eth_hw_addr_random(ndev);
|
eth_hw_addr_random(ndev);
|
||||||
|
|
||||||
memcpy(ndev->perm_addr, ndev->dev_addr, ndev->addr_len);
|
memcpy(ndev->perm_addr, ndev->dev_addr, ndev->addr_len);
|
||||||
|
|
|
@ -4084,7 +4084,7 @@ static int bcmgenet_probe(struct platform_device *pdev)
|
||||||
if (pd && !IS_ERR_OR_NULL(pd->mac_address))
|
if (pd && !IS_ERR_OR_NULL(pd->mac_address))
|
||||||
eth_hw_addr_set(dev, pd->mac_address);
|
eth_hw_addr_set(dev, pd->mac_address);
|
||||||
else
|
else
|
||||||
if (device_get_mac_address(&pdev->dev, dev->dev_addr, ETH_ALEN))
|
if (device_get_mac_address(&pdev->dev, dev->dev_addr))
|
||||||
if (has_acpi_companion(&pdev->dev))
|
if (has_acpi_companion(&pdev->dev))
|
||||||
bcmgenet_get_hw_addr(priv, dev->dev_addr);
|
bcmgenet_get_hw_addr(priv, dev->dev_addr);
|
||||||
|
|
||||||
|
|
|
@ -1389,7 +1389,7 @@ static int acpi_get_mac_address(struct device *dev, struct acpi_device *adev,
|
||||||
u8 mac[ETH_ALEN];
|
u8 mac[ETH_ALEN];
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = fwnode_get_mac_address(acpi_fwnode_handle(adev), mac, ETH_ALEN);
|
ret = fwnode_get_mac_address(acpi_fwnode_handle(adev), mac);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dev_err(dev, "MAC address invalid: %pM\n", mac);
|
dev_err(dev, "MAC address invalid: %pM\n", mac);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
|
@ -183,7 +183,7 @@ static void ftgmac100_initial_mac(struct ftgmac100 *priv)
|
||||||
unsigned int m;
|
unsigned int m;
|
||||||
unsigned int l;
|
unsigned int l;
|
||||||
|
|
||||||
if (!device_get_mac_address(priv->dev, mac, ETH_ALEN)) {
|
if (!device_get_mac_address(priv->dev, mac)) {
|
||||||
eth_hw_addr_set(priv->netdev, mac);
|
eth_hw_addr_set(priv->netdev, mac);
|
||||||
dev_info(priv->dev, "Read MAC address %pM from device tree\n",
|
dev_info(priv->dev, "Read MAC address %pM from device tree\n",
|
||||||
mac);
|
mac);
|
||||||
|
|
|
@ -1212,7 +1212,7 @@ static void hns_init_mac_addr(struct net_device *ndev)
|
||||||
{
|
{
|
||||||
struct hns_nic_priv *priv = netdev_priv(ndev);
|
struct hns_nic_priv *priv = netdev_priv(ndev);
|
||||||
|
|
||||||
if (device_get_mac_address(priv->dev, ndev->dev_addr, ETH_ALEN)) {
|
if (device_get_mac_address(priv->dev, ndev->dev_addr)) {
|
||||||
eth_hw_addr_random(ndev);
|
eth_hw_addr_random(ndev);
|
||||||
dev_warn(priv->dev, "No valid mac, use random mac %pM",
|
dev_warn(priv->dev, "No valid mac, use random mac %pM",
|
||||||
ndev->dev_addr);
|
ndev->dev_addr);
|
||||||
|
|
|
@ -6081,7 +6081,7 @@ static void mvpp2_port_copy_mac_addr(struct net_device *dev, struct mvpp2 *priv,
|
||||||
char hw_mac_addr[ETH_ALEN] = {0};
|
char hw_mac_addr[ETH_ALEN] = {0};
|
||||||
char fw_mac_addr[ETH_ALEN];
|
char fw_mac_addr[ETH_ALEN];
|
||||||
|
|
||||||
if (!fwnode_get_mac_address(fwnode, fw_mac_addr, ETH_ALEN)) {
|
if (!fwnode_get_mac_address(fwnode, fw_mac_addr)) {
|
||||||
*mac_from = "firmware node";
|
*mac_from = "firmware node";
|
||||||
eth_hw_addr_set(dev, fw_mac_addr);
|
eth_hw_addr_set(dev, fw_mac_addr);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -1572,7 +1572,7 @@ static int enc28j60_probe(struct spi_device *spi)
|
||||||
goto error_irq;
|
goto error_irq;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!device_get_mac_address(&spi->dev, macaddr, sizeof(macaddr)))
|
if (!device_get_mac_address(&spi->dev, macaddr))
|
||||||
eth_hw_addr_set(dev, macaddr);
|
eth_hw_addr_set(dev, macaddr);
|
||||||
else
|
else
|
||||||
eth_hw_addr_random(dev);
|
eth_hw_addr_random(dev);
|
||||||
|
|
|
@ -549,7 +549,7 @@ static int emac_probe_resources(struct platform_device *pdev,
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
/* get mac address */
|
/* get mac address */
|
||||||
if (!device_get_mac_address(&pdev->dev, maddr, ETH_ALEN))
|
if (!device_get_mac_address(&pdev->dev, maddr))
|
||||||
eth_hw_addr_set(netdev, maddr);
|
eth_hw_addr_set(netdev, maddr);
|
||||||
else
|
else
|
||||||
eth_hw_addr_random(netdev);
|
eth_hw_addr_random(netdev);
|
||||||
|
|
|
@ -2375,7 +2375,7 @@ static int smsc911x_probe_config(struct smsc911x_platform_config *config,
|
||||||
phy_interface = PHY_INTERFACE_MODE_NA;
|
phy_interface = PHY_INTERFACE_MODE_NA;
|
||||||
config->phy_interface = phy_interface;
|
config->phy_interface = phy_interface;
|
||||||
|
|
||||||
device_get_mac_address(dev, config->mac, ETH_ALEN);
|
device_get_mac_address(dev, config->mac);
|
||||||
|
|
||||||
err = device_property_read_u32(dev, "reg-io-width", &width);
|
err = device_property_read_u32(dev, "reg-io-width", &width);
|
||||||
if (err == -ENXIO)
|
if (err == -ENXIO)
|
||||||
|
|
|
@ -2034,7 +2034,7 @@ static int netsec_probe(struct platform_device *pdev)
|
||||||
goto free_ndev;
|
goto free_ndev;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = device_get_mac_address(&pdev->dev, macbuf, sizeof(macbuf));
|
ret = device_get_mac_address(&pdev->dev, macbuf);
|
||||||
if (!ret)
|
if (!ret)
|
||||||
eth_hw_addr_set(ndev, macbuf);
|
eth_hw_addr_set(ndev, macbuf);
|
||||||
|
|
||||||
|
|
|
@ -3224,7 +3224,7 @@ static int ath10k_core_probe_fw(struct ath10k *ar)
|
||||||
ath10k_debug_print_board_info(ar);
|
ath10k_debug_print_board_info(ar);
|
||||||
}
|
}
|
||||||
|
|
||||||
device_get_mac_address(ar->dev, ar->mac_addr, sizeof(ar->mac_addr));
|
device_get_mac_address(ar->dev, ar->mac_addr);
|
||||||
|
|
||||||
ret = ath10k_core_init_firmware_features(ar);
|
ret = ath10k_core_init_firmware_features(ar);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
|
|
|
@ -31,8 +31,8 @@ struct fwnode_handle;
|
||||||
int eth_platform_get_mac_address(struct device *dev, u8 *mac_addr);
|
int eth_platform_get_mac_address(struct device *dev, u8 *mac_addr);
|
||||||
unsigned char *arch_get_platform_mac_address(void);
|
unsigned char *arch_get_platform_mac_address(void);
|
||||||
int nvmem_get_mac_address(struct device *dev, void *addrbuf);
|
int nvmem_get_mac_address(struct device *dev, void *addrbuf);
|
||||||
int device_get_mac_address(struct device *dev, char *addr, int alen);
|
int device_get_mac_address(struct device *dev, char *addr);
|
||||||
int fwnode_get_mac_address(struct fwnode_handle *fwnode, char *addr, int alen);
|
int fwnode_get_mac_address(struct fwnode_handle *fwnode, char *addr);
|
||||||
|
|
||||||
u32 eth_get_headlen(const struct net_device *dev, const void *data, u32 len);
|
u32 eth_get_headlen(const struct net_device *dev, const void *data, u32 len);
|
||||||
__be16 eth_type_trans(struct sk_buff *skb, struct net_device *dev);
|
__be16 eth_type_trans(struct sk_buff *skb, struct net_device *dev);
|
||||||
|
|
|
@ -561,14 +561,11 @@ int nvmem_get_mac_address(struct device *dev, void *addrbuf)
|
||||||
EXPORT_SYMBOL(nvmem_get_mac_address);
|
EXPORT_SYMBOL(nvmem_get_mac_address);
|
||||||
|
|
||||||
static int fwnode_get_mac_addr(struct fwnode_handle *fwnode,
|
static int fwnode_get_mac_addr(struct fwnode_handle *fwnode,
|
||||||
const char *name, char *addr, int alen)
|
const char *name, char *addr)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (alen != ETH_ALEN)
|
ret = fwnode_property_read_u8_array(fwnode, name, addr, ETH_ALEN);
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
ret = fwnode_property_read_u8_array(fwnode, name, addr, alen);
|
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
@ -581,7 +578,6 @@ static int fwnode_get_mac_addr(struct fwnode_handle *fwnode,
|
||||||
* fwnode_get_mac_address - Get the MAC from the firmware node
|
* fwnode_get_mac_address - Get the MAC from the firmware node
|
||||||
* @fwnode: Pointer to the firmware node
|
* @fwnode: Pointer to the firmware node
|
||||||
* @addr: Address of buffer to store the MAC in
|
* @addr: Address of buffer to store the MAC in
|
||||||
* @alen: Length of the buffer pointed to by addr, should be ETH_ALEN
|
|
||||||
*
|
*
|
||||||
* Search the firmware node for the best MAC address to use. 'mac-address' is
|
* Search the firmware node for the best MAC address to use. 'mac-address' is
|
||||||
* checked first, because that is supposed to contain to "most recent" MAC
|
* checked first, because that is supposed to contain to "most recent" MAC
|
||||||
|
@ -600,11 +596,11 @@ static int fwnode_get_mac_addr(struct fwnode_handle *fwnode,
|
||||||
* In this case, the real MAC is in 'local-mac-address', and 'mac-address'
|
* In this case, the real MAC is in 'local-mac-address', and 'mac-address'
|
||||||
* exists but is all zeros.
|
* exists but is all zeros.
|
||||||
*/
|
*/
|
||||||
int fwnode_get_mac_address(struct fwnode_handle *fwnode, char *addr, int alen)
|
int fwnode_get_mac_address(struct fwnode_handle *fwnode, char *addr)
|
||||||
{
|
{
|
||||||
if (!fwnode_get_mac_addr(fwnode, "mac-address", addr, alen) ||
|
if (!fwnode_get_mac_addr(fwnode, "mac-address", addr) ||
|
||||||
!fwnode_get_mac_addr(fwnode, "local-mac-address", addr, alen) ||
|
!fwnode_get_mac_addr(fwnode, "local-mac-address", addr) ||
|
||||||
!fwnode_get_mac_addr(fwnode, "address", addr, alen))
|
!fwnode_get_mac_addr(fwnode, "address", addr))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return -ENOENT;
|
return -ENOENT;
|
||||||
|
@ -615,10 +611,9 @@ EXPORT_SYMBOL(fwnode_get_mac_address);
|
||||||
* device_get_mac_address - Get the MAC for a given device
|
* device_get_mac_address - Get the MAC for a given device
|
||||||
* @dev: Pointer to the device
|
* @dev: Pointer to the device
|
||||||
* @addr: Address of buffer to store the MAC in
|
* @addr: Address of buffer to store the MAC in
|
||||||
* @alen: Length of the buffer pointed to by addr, should be ETH_ALEN
|
|
||||||
*/
|
*/
|
||||||
int device_get_mac_address(struct device *dev, char *addr, int alen)
|
int device_get_mac_address(struct device *dev, char *addr)
|
||||||
{
|
{
|
||||||
return fwnode_get_mac_address(dev_fwnode(dev), addr, alen);
|
return fwnode_get_mac_address(dev_fwnode(dev), addr);
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(device_get_mac_address);
|
EXPORT_SYMBOL(device_get_mac_address);
|
||||||
|
|
Loading…
Reference in a new issue