Skip to content

Commit

Permalink
net: dsa: mv88e6xxx: add SMI init helper
Browse files Browse the repository at this point in the history
Add an helper function to isolate SMI specific assignments and checks.

This function will later help choosing the different SMI accesses based
of the compatible info.

Since the chip structure is already allocated in the legacy probe, use
the mv88e6xxx_reg_read access routine instead of __mv88e6xxx_reg_read.

Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Vivien Didelot authored and David S. Miller committed Jun 21, 2016
1 parent 469d729 commit 4a70c4a
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions drivers/net/dsa/mv88e6xxx.c
Original file line number Diff line number Diff line change
Expand Up @@ -3616,6 +3616,19 @@ static struct mv88e6xxx_priv_state *mv88e6xxx_alloc_chip(struct device *dev)
return ps;
}

static int mv88e6xxx_smi_init(struct mv88e6xxx_priv_state *ps,
struct mii_bus *bus, int sw_addr)
{
/* ADDR[0] pin is unavailable externally and considered zero */
if (sw_addr & 0x1)
return -EINVAL;

ps->bus = bus;
ps->sw_addr = sw_addr;

return 0;
}

static const char *mv88e6xxx_drv_probe(struct device *dsa_dev,
struct device *host_dev, int sw_addr,
void **priv)
Expand All @@ -3635,7 +3648,11 @@ static const char *mv88e6xxx_drv_probe(struct device *dsa_dev,
if (!ps)
return NULL;

id = __mv88e6xxx_reg_read(bus, sw_addr, REG_PORT(0), PORT_SWITCH_ID);
err = mv88e6xxx_smi_init(ps, bus, sw_addr);
if (err)
goto free;

id = mv88e6xxx_reg_read(ps, REG_PORT(0), PORT_SWITCH_ID);
if (id < 0)
goto free;

Expand All @@ -3648,8 +3665,6 @@ static const char *mv88e6xxx_drv_probe(struct device *dsa_dev,

name = info->name;

ps->bus = bus;
ps->sw_addr = sw_addr;
ps->info = info;

err = mv88e6xxx_mdio_register(ps, NULL);
Expand Down Expand Up @@ -3741,8 +3756,9 @@ static int mv88e6xxx_probe(struct mdio_device *mdiodev)
if (!ps)
return -ENOMEM;

ps->bus = mdiodev->bus;
ps->sw_addr = mdiodev->addr;
err = mv88e6xxx_smi_init(ps, mdiodev->bus, mdiodev->addr);
if (err)
return err;

id = mv88e6xxx_reg_read(ps, REG_PORT(0), PORT_SWITCH_ID);
if (id < 0)
Expand Down

0 comments on commit 4a70c4a

Please sign in to comment.