Skip to content

Commit

Permalink
net: dsa: mv88e6xxx: abstract VTU/STU data access
Browse files Browse the repository at this point in the history
Both VTU and STU operations use the same routine to access their
(common) data registers, with a different offset.

Add VTU and STU specific read and write functions to the data registers
to abstract the required offset.

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 May 11, 2016
1 parent c3f1010 commit 15d7d7d
Showing 1 changed file with 28 additions and 4 deletions.
32 changes: 28 additions & 4 deletions drivers/net/dsa/mv88e6xxx.c
Original file line number Diff line number Diff line change
Expand Up @@ -1498,6 +1498,18 @@ static int _mv88e6xxx_vtu_stu_data_read(struct mv88e6xxx_priv_state *ps,
return 0;
}

static int mv88e6xxx_vtu_data_read(struct mv88e6xxx_priv_state *ps,
struct mv88e6xxx_vtu_stu_entry *entry)
{
return _mv88e6xxx_vtu_stu_data_read(ps, entry, 0);
}

static int mv88e6xxx_stu_data_read(struct mv88e6xxx_priv_state *ps,
struct mv88e6xxx_vtu_stu_entry *entry)
{
return _mv88e6xxx_vtu_stu_data_read(ps, entry, 2);
}

static int _mv88e6xxx_vtu_stu_data_write(struct mv88e6xxx_priv_state *ps,
struct mv88e6xxx_vtu_stu_entry *entry,
unsigned int nibble_offset)
Expand All @@ -1523,6 +1535,18 @@ static int _mv88e6xxx_vtu_stu_data_write(struct mv88e6xxx_priv_state *ps,
return 0;
}

static int mv88e6xxx_vtu_data_write(struct mv88e6xxx_priv_state *ps,
struct mv88e6xxx_vtu_stu_entry *entry)
{
return _mv88e6xxx_vtu_stu_data_write(ps, entry, 0);
}

static int mv88e6xxx_stu_data_write(struct mv88e6xxx_priv_state *ps,
struct mv88e6xxx_vtu_stu_entry *entry)
{
return _mv88e6xxx_vtu_stu_data_write(ps, entry, 2);
}

static int _mv88e6xxx_vtu_vid_write(struct mv88e6xxx_priv_state *ps, u16 vid)
{
return _mv88e6xxx_reg_write(ps, REG_GLOBAL, GLOBAL_VTU_VID,
Expand Down Expand Up @@ -1551,7 +1575,7 @@ static int _mv88e6xxx_vtu_getnext(struct mv88e6xxx_priv_state *ps,
next.valid = !!(ret & GLOBAL_VTU_VID_VALID);

if (next.valid) {
ret = _mv88e6xxx_vtu_stu_data_read(ps, &next, 0);
ret = mv88e6xxx_vtu_data_read(ps, &next);
if (ret < 0)
return ret;

Expand Down Expand Up @@ -1658,7 +1682,7 @@ static int _mv88e6xxx_vtu_loadpurge(struct mv88e6xxx_priv_state *ps,
goto loadpurge;

/* Write port member tags */
ret = _mv88e6xxx_vtu_stu_data_write(ps, entry, 0);
ret = mv88e6xxx_vtu_data_write(ps, entry);
if (ret < 0)
return ret;

Expand Down Expand Up @@ -1724,7 +1748,7 @@ static int _mv88e6xxx_stu_getnext(struct mv88e6xxx_priv_state *ps, u8 sid,
next.valid = !!(ret & GLOBAL_VTU_VID_VALID);

if (next.valid) {
ret = _mv88e6xxx_vtu_stu_data_read(ps, &next, 2);
ret = mv88e6xxx_stu_data_read(ps, &next);
if (ret < 0)
return ret;
}
Expand All @@ -1747,7 +1771,7 @@ static int _mv88e6xxx_stu_loadpurge(struct mv88e6xxx_priv_state *ps,
goto loadpurge;

/* Write port states */
ret = _mv88e6xxx_vtu_stu_data_write(ps, entry, 2);
ret = mv88e6xxx_stu_data_write(ps, entry);
if (ret < 0)
return ret;

Expand Down

0 comments on commit 15d7d7d

Please sign in to comment.