[U-Boot] [PATCH 3/6] net: sunxi-emac: Add write_hwaddr net_op hook
Joe Hershberger
joe.hershberger at gmail.com
Wed Nov 30 22:32:26 CET 2016
On Fri, Nov 25, 2016 at 9:38 AM, Olliver Schinagl <oliver at schinagl.nl> wrote:
> Expose enetaddr writing via net_ops so that it can be hooked into.
>
> Signed-off-by: Olliver Schinagl <oliver at schinagl.nl>
> ---
> drivers/net/sunxi_emac.c | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/drivers/net/sunxi_emac.c b/drivers/net/sunxi_emac.c
> index 99339db..bba8630 100644
> --- a/drivers/net/sunxi_emac.c
> +++ b/drivers/net/sunxi_emac.c
> @@ -554,6 +554,17 @@ static void sunxi_emac_eth_stop(struct udevice *dev)
> /* Nothing to do here */
> }
>
> +static int sunxi_emac_eth_write_hwaddr(struct udevice *dev)
> +{
> + struct eth_pdata *pdata = dev_get_platdata(dev);
> + struct emac_eth_dev *priv = dev_get_priv(dev);
> +
> + if (!dev)
> + return -ENOSYS;
> +
> + return _sunxi_write_hwaddr(priv, pdata->enetaddr);
You should check the pdata ptr value before dereferencing it.
> +}
> +
> static int sunxi_emac_eth_probe(struct udevice *dev)
> {
> struct eth_pdata *pdata = dev_get_platdata(dev);
> @@ -570,6 +581,7 @@ static const struct eth_ops sunxi_emac_eth_ops = {
> .send = sunxi_emac_eth_send,
> .recv = sunxi_emac_eth_recv,
> .stop = sunxi_emac_eth_stop,
> + .write_hwaddr = sunxi_emac_eth_write_hwaddr,
> };
>
> static int sunxi_emac_eth_ofdata_to_platdata(struct udevice *dev)
> --
> 2.10.2
>
> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot
More information about the U-Boot
mailing list