Skip adding the unused network interface.

PFE has fixed configuration for three GEMACs. For spacecast, only
one interface is used. With the existing chip design, it is risky to
completely remove two interfaces due to the following two reasons:

- id and gem_id is used interchangeably in the pfe control logic.
- Even fix the id with gem_id, there is a gotcha, the mdio bus setting
  is only associated with the first gem register. The logic can be
  found in gemac_set_mdc_div. The lan port is hooked to the second
  gemac for spacecast.

Therefore, to minimize the code change and interface change, the
device name is used to identify the unused interface. For the unused
device, skip adding the network device.

Change-Id: I76434a2250614d212640aea0a9be14f11c3d2823
diff --git a/pfe_ctrl/pfe_eth.c b/pfe_ctrl/pfe_eth.c
index a8891d9..aad7741 100644
--- a/pfe_ctrl/pfe_eth.c
+++ b/pfe_ctrl/pfe_eth.c
@@ -2665,6 +2665,25 @@
 	priv->cpu_id = -1;
 
 	pfe_eth_fast_tx_timeout_init(priv);
+	/* Initialize mdio */
+	if (minfo[id].enabled) {
+
+		if ((err = pfe_eth_mdio_init(priv, &minfo[id]))) {
+			netdev_err(dev, "%s: pfe_eth_mdio_init() failed\n", __func__);
+			goto err2;
+		}
+	}
+	/* For unused interface, skip adding the network device. The code is
+	 * added here instead of configuring einfo because:
+	 * - id and gem_id is used interchangeably in the pfe control logic.
+	 * - Even fix the id with gem_id, there is a gotcha, the mdio bus
+	 *   setting is only associated with the first gem register. The logic
+	 *   can be found in gemac_set_mdc_div.
+	 */
+	if (!strcmp(einfo[id].name, "unused")) {
+		netif_info(priv, probe, dev, "%s: Skip unused interface: %d\n", __func__, id);
+		return 0;
+	}
 
 	/* Copy the station address into the dev structure, */
 	memcpy(dev->dev_addr, einfo[id].mac_addr, ETH_ALEN);
@@ -2674,16 +2693,7 @@
 	if (err < 0) {
 		netdev_err(dev, "%s: dev_alloc_name(%s) failed\n", __func__, einfo[id].name);
 		err = -EINVAL;
-		goto err2;
-	}
-
-	/* Initialize mdio */
-	if (minfo[id].enabled) {
-
-		if ((err = pfe_eth_mdio_init(priv, &minfo[id]))) {
-			netdev_err(dev, "%s: pfe_eth_mdio_init() failed\n", __func__);
-			goto err2;
-		}
+		goto err3;
 	}
 
 	dev->mtu = 1500;