From e74b6010eca026625ba4e39c80620320ca777deb Mon Sep 17 00:00:00 2001
From: Ioana Radulescu <ruxandra.radulescu@nxp.com>
Date: Tue, 5 Apr 2016 13:35:14 +0300
Subject: [PATCH 210/226] staging: fsl-dpaa2/mac: Fix unregister_netdev issue

We only register the netdevice associated with a mac object if
ONFIG_FSL_DPAA2_MAC_NETDEV is set, but we always unregister it
during device remove(). Fix this by ifdef-ing the unregister
operation.

Also ifdef the change in netdevice name as it only makes sense
under this option.

Signed-off-by: Ioana Radulescu <ruxandra.radulescu@nxp.com>
(cherry picked from commit dd6a5313e194168d46fef495a6e3bc5207801473)
---
 drivers/staging/fsl-dpaa2/mac/mac.c |    5 +++++
 1 file changed, 5 insertions(+)

--- a/drivers/staging/fsl-dpaa2/mac/mac.c
+++ b/drivers/staging/fsl-dpaa2/mac/mac.c
@@ -534,7 +534,10 @@ static int dpaa2_mac_probe(struct fsl_mc
 	priv->netdev = netdev;
 
 	SET_NETDEV_DEV(netdev, dev);
+
+#ifdef CONFIG_FSL_DPAA2_MAC_NETDEVS
 	snprintf(netdev->name, IFNAMSIZ, "mac%d", mc_dev->obj_desc.id);
+#endif
 
 	dev_set_drvdata(dev, priv);
 
@@ -684,7 +687,9 @@ static int dpaa2_mac_remove(struct fsl_m
 	struct device		*dev = &mc_dev->dev;
 	struct dpaa2_mac_priv	*priv = dev_get_drvdata(dev);
 
+#ifdef CONFIG_FSL_DPAA2_MAC_NETDEVS
 	unregister_netdev(priv->netdev);
+#endif
 	teardown_irqs(priv->mc_dev);
 	dpmac_close(priv->mc_dev->mc_io, 0, priv->mc_dev->mc_handle);
 	fsl_mc_portal_free(priv->mc_dev->mc_io);
