[PATCH 3/5] of: net: introduce a of_set_mac_address() helper function
Andrew Lunn
andrew at lunn.ch
Wed Jun 5 03:13:54 EDT 2013
On Wed, Jun 05, 2013 at 08:40:07AM +0200, Thomas Petazzoni wrote:
> The ARM MXS code already has some code to allocate and setup a
> property that contains the MAC address, and the Marvell Armada 370/XP
> code is going to gain a similar copy of this code. Therefore, let's
> add a small helper function that does that, in drivers/of/of_net.c.
>
> Signed-off-by: Thomas Petazzoni <thomas.petazzoni at free-electrons.com>
> ---
> drivers/of/of_net.c | 36 ++++++++++++++++++++++++++++++++++++
> include/linux/of_net.h | 6 ++++++
> 2 files changed, 42 insertions(+)
>
> diff --git a/drivers/of/of_net.c b/drivers/of/of_net.c
> index ffab033..02af898 100644
> --- a/drivers/of/of_net.c
> +++ b/drivers/of/of_net.c
> @@ -92,3 +92,39 @@ const void *of_get_mac_address(struct device_node *np)
> return NULL;
> }
> EXPORT_SYMBOL(of_get_mac_address);
> +
> +/**
> + * Set a MAC address of a given network interface device tree node, if
> + * none was already defined.
> + */
> +int of_set_mac_address(struct device_node *np, const void *mac)
> +{
> + struct property *pp;
> + int ret;
> +
> + if (of_get_mac_address(np))
> + return 0;
Hi Thomas
The semantics is a bit odd here for a set function. Only set if not
already set. From the function name, its not clear it has this extra
semantics. of_set_if_not_set_mac_address() seems a bit long, but makes
it clearer. Or maybe of_set_default_mac_address()?
I've no strong preference here, i just see the potential for bugs.
Andrew
More information about the linux-arm-kernel
mailing list