u32 val, newval;
struct mii_bus *bus;
- val = priv->read(priv, 0x8);
+ val = priv->read(priv, AR8316_REG_POSTRIP);
if (priv->phy->interface == PHY_INTERFACE_MODE_RGMII) {
if (priv->port4_phy) {
if (val == newval)
goto out;
- priv->write(priv, 0x8, newval);
+ priv->write(priv, AR8316_REG_POSTRIP, newval);
/* Initialize the ports */
bus = priv->mii_bus;
if (!priv->mib_stats)
return -ENOMEM;
- mutex_init(&priv->mib_lock);
- INIT_DELAYED_WORK(&priv->mib_work, ar8xxx_mib_work_func);
-
return 0;
}
kfree(priv->mib_stats);
}
+static struct ar8216_priv *
+ar8xxx_create(void)
+{
+ struct ar8216_priv *priv;
+
+ priv = kzalloc(sizeof(struct ar8216_priv), GFP_KERNEL);
+ if (priv == NULL)
+ return NULL;
+
+ mutex_init(&priv->reg_mutex);
+ mutex_init(&priv->mib_lock);
+ INIT_DELAYED_WORK(&priv->mib_work, ar8xxx_mib_work_func);
+
+ return priv;
+}
+
+static struct ar8216_priv *
+ar8xxx_create_mii(struct mii_bus *bus)
+{
+ struct ar8216_priv *priv;
+
+ priv = ar8xxx_create();
+ if (priv) {
+ priv->mii_bus = bus;
+ priv->read = ar8216_mii_read;
+ priv->write = ar8216_mii_write;
+ }
+
+ return priv;
+}
+
static int
ar8216_config_init(struct phy_device *pdev)
{
int ret;
if (!priv) {
- priv = kzalloc(sizeof(struct ar8216_priv), GFP_KERNEL);
+ priv = ar8xxx_create_mii(pdev->bus);
if (priv == NULL)
return -ENOMEM;
- }
- priv->mii_bus = pdev->bus;
- priv->read = ar8216_mii_read;
- priv->write = ar8216_mii_write;
+ ret = ar8216_id_chip(priv);
+ if (ret)
+ goto err_free_priv;
+ }
priv->phy = pdev;
- ret = ar8216_id_chip(priv);
- if (ret)
- goto err_free_priv;
-
if (ar8xxx_has_gige(priv))
pdev->supported = SUPPORTED_1000baseT_Full;
else
return 0;
}
- mutex_init(&priv->reg_mutex);
-
pdev->priv = priv;
swdev = &priv->dev;
if (ret)
goto err_unregister_switch;
- dev->phy_ptr = priv;
-
/* VID fixup only needed on ar8216 */
- if (chip_is_ar8216(priv) && pdev->addr == 0) {
+ if (chip_is_ar8216(priv)) {
+ dev->phy_ptr = priv;
dev->priv_flags |= IFF_NO_IP_ALIGN;
dev->eth_mangle_rx = ar8216_mangle_rx;
dev->eth_mangle_tx = ar8216_mangle_tx;
if (!ar8xxx_is_possible(pdev->bus))
return -ENODEV;
- priv = kzalloc(sizeof(struct ar8216_priv), GFP_KERNEL);
+ priv = ar8xxx_create_mii(pdev->bus);
if (priv == NULL)
return -ENOMEM;
- priv->mii_bus = pdev->bus;
- priv->read = ar8216_mii_read;
- priv->write = ar8216_mii_write;
priv->phy = pdev;
ret = ar8216_id_chip(priv);