- if (!priv) {
- priv = ar8xxx_create_mii(pdev->bus);
- if (priv == NULL)
- return -ENOMEM;
-
- ret = ar8216_id_chip(priv);
- if (ret)
- goto err_free_priv;
- }
-
- priv->phy = pdev;
-
- if (ar8xxx_has_gige(priv))
- pdev->supported = SUPPORTED_1000baseT_Full;
- else
- pdev->supported = SUPPORTED_100baseT_Full;
- pdev->advertising = pdev->supported;
-
- if (pdev->addr != 0) {
- if (chip_is_ar8316(priv)) {
- /* check if we're attaching to the switch twice */
- pdev = pdev->bus->phy_map[0];
- if (!pdev) {
- ar8xxx_free(priv);
- return 0;
- }
-
- /* switch device has not been initialized, reuse priv */
- if (!pdev->priv) {
- priv->port4_phy = true;
- pdev->priv = priv;
- return 0;
- }
-
- ar8xxx_free(priv);
-
- /* switch device has been initialized, reinit */
- priv = pdev->priv;
- priv->dev.ports = (AR8216_NUM_PORTS - 1);
- priv->initialized = false;
- priv->port4_phy = true;
- ar8316_hw_init(priv);
- return 0;
- }
-
- ar8xxx_free(priv);
- return 0;
- }
-
- pdev->priv = priv;