2012-02-22 12:37:05

by Danny Kukawka

[permalink] [raw]
Subject: [PATCH 0/2] reuse eth_mac_addr()

Two patches to remove custom .ndo_set_mac_address methodes
and use eth_mac_addr() instead since these functions to the
same as eth_mac_addr().

An advantage of this change: eth_mac_addr() already
checks if the given mac address is valid.

Danny Kukawka (2):
3com/typhoon: reuse eth_mac_addr()
net/ieee802154/6lowpan.c: reuse eth_mac_addr()

drivers/net/ethernet/3com/typhoon.c | 14 +-------------
net/ieee802154/6lowpan.c | 16 ++--------------
2 files changed, 3 insertions(+), 27 deletions(-)

--
1.7.8.3


2012-02-22 12:37:03

by Danny Kukawka

[permalink] [raw]
Subject: [PATCH 2/2] net/ieee802154/6lowpan.c: reuse eth_mac_addr()

Use eth_mac_addr() for .ndo_set_mac_address, remove
lowpan_set_address since it do currently the same as
eth_mac_addr(). Additional advantage: eth_mac_addr() already
checks if the given address is valid

Signed-off-by: Danny Kukawka <[email protected]>
---
net/ieee802154/6lowpan.c | 16 ++--------------
1 files changed, 2 insertions(+), 14 deletions(-)

diff --git a/net/ieee802154/6lowpan.c b/net/ieee802154/6lowpan.c
index e4ecc1e..3685158 100644
--- a/net/ieee802154/6lowpan.c
+++ b/net/ieee802154/6lowpan.c
@@ -55,6 +55,7 @@
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/netdevice.h>
+#include <linux/etherdevice.h>
#include <net/af_ieee802154.h>
#include <net/ieee802154.h>
#include <net/ieee802154_netdev.h>
@@ -924,19 +925,6 @@ drop:
return -EINVAL;
}

-static int lowpan_set_address(struct net_device *dev, void *p)
-{
- struct sockaddr *sa = p;
-
- if (netif_running(dev))
- return -EBUSY;
-
- /* TODO: validate addr */
- memcpy(dev->dev_addr, sa->sa_data, dev->addr_len);
-
- return 0;
-}
-
static int lowpan_get_mac_header_length(struct sk_buff *skb)
{
/*
@@ -1062,7 +1050,7 @@ static struct header_ops lowpan_header_ops = {

static const struct net_device_ops lowpan_netdev_ops = {
.ndo_start_xmit = lowpan_xmit,
- .ndo_set_mac_address = lowpan_set_address,
+ .ndo_set_mac_address = eth_mac_addr,
};

static void lowpan_setup(struct net_device *dev)
--
1.7.8.3

2012-02-22 12:36:59

by Danny Kukawka

[permalink] [raw]
Subject: [PATCH 1/2] 3com/typhoon: reuse eth_mac_addr()

Use eth_mac_addr() for .ndo_set_mac_address, remove
typhoon_set_mac_address() since it do currently the same as
eth_mac_addr(). Additional advantage: eth_mac_addr() already
checks if the given address is valid.

Signed-off-by: Danny Kukawka <[email protected]>
---
drivers/net/ethernet/3com/typhoon.c | 14 +-------------
1 files changed, 1 insertions(+), 13 deletions(-)

diff --git a/drivers/net/ethernet/3com/typhoon.c b/drivers/net/ethernet/3com/typhoon.c
index f7d622e..1234a14 100644
--- a/drivers/net/ethernet/3com/typhoon.c
+++ b/drivers/net/ethernet/3com/typhoon.c
@@ -966,18 +966,6 @@ typhoon_get_stats(struct net_device *dev)
return stats;
}

-static int
-typhoon_set_mac_address(struct net_device *dev, void *addr)
-{
- struct sockaddr *saddr = (struct sockaddr *) addr;
-
- if(netif_running(dev))
- return -EBUSY;
-
- memcpy(dev->dev_addr, saddr->sa_data, dev->addr_len);
- return 0;
-}
-
static void
typhoon_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
{
@@ -2266,7 +2254,7 @@ static const struct net_device_ops typhoon_netdev_ops = {
.ndo_tx_timeout = typhoon_tx_timeout,
.ndo_get_stats = typhoon_get_stats,
.ndo_validate_addr = eth_validate_addr,
- .ndo_set_mac_address = typhoon_set_mac_address,
+ .ndo_set_mac_address = eth_mac_addr,
.ndo_change_mtu = eth_change_mtu,
};

--
1.7.8.3

2012-02-22 13:30:15

by Dmitry Baryshkov

[permalink] [raw]
Subject: Re: [PATCH 2/2] net/ieee802154/6lowpan.c: reuse eth_mac_addr()

On Wed, Feb 22, 2012 at 4:36 PM, Danny Kukawka <[email protected]> wrote:
> Use eth_mac_addr() for .ndo_set_mac_address, remove
> lowpan_set_address since it do currently the same as
> eth_mac_addr(). Additional advantage: eth_mac_addr() already
> checks if the given address is valid
>
> Signed-off-by: Danny Kukawka <[email protected]>

Acked-by: Dmitry Eremin-Solenikov <[email protected]>

--
With best wishes
Dmitry

2012-02-22 13:55:26

by David Dillow

[permalink] [raw]
Subject: Re: [PATCH 1/2] 3com/typhoon: reuse eth_mac_addr()

On Wed, 2012-02-22 at 13:36 +0100, Danny Kukawka wrote:
> Use eth_mac_addr() for .ndo_set_mac_address, remove
> typhoon_set_mac_address() since it do currently the same as
> eth_mac_addr(). Additional advantage: eth_mac_addr() already
> checks if the given address is valid.
>
> Signed-off-by: Danny Kukawka <[email protected]>

Acked-by: Dave Dillow <[email protected]>

2012-02-22 19:56:58

by David Miller

[permalink] [raw]
Subject: Re: [PATCH 2/2] net/ieee802154/6lowpan.c: reuse eth_mac_addr()

From: Danny Kukawka <[email protected]>
Date: Wed, 22 Feb 2012 13:36:39 +0100

> Use eth_mac_addr() for .ndo_set_mac_address, remove
> lowpan_set_address since it do currently the same as
> eth_mac_addr(). Additional advantage: eth_mac_addr() already
> checks if the given address is valid
>
> Signed-off-by: Danny Kukawka <[email protected]>

Applied.

2012-02-22 19:57:42

by David Miller

[permalink] [raw]
Subject: Re: [PATCH 1/2] 3com/typhoon: reuse eth_mac_addr()

From: Danny Kukawka <[email protected]>
Date: Wed, 22 Feb 2012 13:36:38 +0100

> Use eth_mac_addr() for .ndo_set_mac_address, remove
> typhoon_set_mac_address() since it do currently the same as
> eth_mac_addr(). Additional advantage: eth_mac_addr() already
> checks if the given address is valid.
>
> Signed-off-by: Danny Kukawka <[email protected]>

Applied.