RT-WiFi/compat/compat-3.9.c
2017-08-31 12:00:57 +02:00

59 lines
1.5 KiB
C

/*
* Copyright (c) 2013 Luis R. Rodriguez <mcgrof@do-not-panic.com>
*
* Backport functionality introduced in Linux 3.9.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#include <linux/module.h>
#include <linux/device.h>
#include <linux/err.h>
#include <linux/netdevice.h>
#include <linux/if.h>
#include <linux/if_ether.h>
#include <linux/etherdevice.h>
void __iomem *devm_ioremap_resource(struct device *dev, struct resource *res)
{
void __iomem *dest_ptr;
dest_ptr = devm_ioremap_resource(dev, res);
if (!dest_ptr)
return (void __iomem *)ERR_PTR(-ENOMEM);
return dest_ptr;
}
EXPORT_SYMBOL_GPL(devm_ioremap_resource);
/**
* eth_prepare_mac_addr_change - prepare for mac change
* @dev: network device
* @p: socket address
*/
int eth_prepare_mac_addr_change(struct net_device *dev, void *p)
{
struct sockaddr *addr = p;
if (!(dev->priv_flags & IFF_LIVE_ADDR_CHANGE) && netif_running(dev))
return -EBUSY;
if (!is_valid_ether_addr(addr->sa_data))
return -EADDRNOTAVAIL;
return 0;
}
EXPORT_SYMBOL_GPL(eth_prepare_mac_addr_change);
/**
* eth_commit_mac_addr_change - commit mac change
* @dev: network device
* @p: socket address
*/
void eth_commit_mac_addr_change(struct net_device *dev, void *p)
{
struct sockaddr *addr = p;
memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN);
}
EXPORT_SYMBOL_GPL(eth_commit_mac_addr_change);