Re: [PATCH] sky2: Add module parameter for passing the MAC address

From: Liviu Dudau
Date: Wed Aug 05 2015 - 13:18:22 EST


On Wed, Aug 05, 2015 at 06:15:37PM +0100, Ryan Harkin wrote:
> On 5 August 2015 at 16:50, Liviu Dudau <[1]Liviu.Dudau@xxxxxxx> wrote:
>
> For designs where EEPROMs are not connected to PCI Yukon2
> chips we need to get the MAC address from the firmware.
> Add a module parameter called 'mac_address' for this. It
> will be used if no DT node can be found and the B2_MAC
> register holds an invalid value.
>
> Signed-off-by: Liviu Dudau <[2]Liviu.Dudau@xxxxxxx>
>
> Looks good to me. FWIW, you can have a tested or reviewed-by at your preference:
> Tested-by: Ryan Harkin <[3]ryan.harkin@xxxxxxxxxx>
> Reviewed-by: Ryan Harkin <[4]ryan.harkin@xxxxxxxxxx>
>

Thanks Ryan, I think one can provide both tags, so I will use them together.

Best regards,
Liviu

> Â
>
> ---
> Âdrivers/net/ethernet/marvell/sky2.c | 14 +++++++++++++-
> Â1 file changed, 13 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/marvell/sky2.c b/drivers/net/ethernet/marvell/sky2.c
> index d9f4498..a977d95 100644
> --- a/drivers/net/ethernet/marvell/sky2.c
> +++ b/drivers/net/ethernet/marvell/sky2.c
> @@ -101,6 +101,10 @@ static int legacy_pme = 0;
> Âmodule_param(legacy_pme, int, 0);
> ÂMODULE_PARM_DESC(legacy_pme, "Legacy power management");
>
> +/* Ugh! Let the firmware tell us the hardware address */
> +static int mac_address[ETH_ALEN] = { 0, };
> +module_param_array(mac_address, int, NULL, 0);
> +
> Âstatic const struct pci_device_id sky2_id_table[] = {
> Â Â Â Â { PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, 0x9000) }, /* SK-9Sxx */
> Â Â Â Â { PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, 0x9E00) }, /* SK-9Exx */
> @@ -4811,13 +4815,21 @@ static struct net_device *sky2_init_netdev(struct sky2_hw *hw, unsigned port,
> Â Â Â Â /* try to get mac address in the following order:
> Â Â Â Â Â* 1) from device tree data
> Â Â Â Â Â* 2) from internal registers set by bootloader
> +Â Â Â Â * 3) from the command line parameter
> Â Â Â Â Â*/
> Â Â Â Â iap = of_get_mac_address(hw->pdev->dev.of_node);
> Â Â Â Â if (iap)
> Â Â Â Â Â Â Â Â memcpy(dev->dev_addr, iap, ETH_ALEN);
> -Â Â Â Âelse
> +Â Â Â Âelse {
> Â Â Â Â Â Â Â Â memcpy_fromio(dev->dev_addr, hw->regs + B2_MAC_1 + port * 8,
> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ETH_ALEN);
> +Â Â Â Â Â Â Â Âif (!is_valid_ether_addr(&dev->dev_addr[0])) {
> +Â Â Â Â Â Â Â Â Â Â Â Âint i;
> +
> +Â Â Â Â Â Â Â Â Â Â Â Âfor (i = 0; i < ETH_ALEN; i++)
> +Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Âdev->dev_addr[i] = mac_address[i];
> +Â Â Â Â Â Â Â Â}
> +Â Â Â Â}
>
> Â Â Â Â return dev;
> Â}
> --
> 2.4.6
>
> References
>
> Visible links
> 1. mailto:Liviu.Dudau@xxxxxxx
> 2. mailto:Liviu.Dudau@xxxxxxx
> 3. mailto:ryan.harkin@xxxxxxxxxx
> 4. mailto:ryan.harkin@xxxxxxxxxx

--
====================
| I would like to |
| fix the world, |
| but they're not |
| giving me the |
\ source code! /
---------------
Â\_(ã)_/Â

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/