return val;
}
-static int mv88e6xxx_reg_read(struct mv88e6xxx_chip *chip, int addr, int reg)
-{
- int ret;
-
- mutex_lock(&chip->reg_lock);
- ret = _mv88e6xxx_reg_read(chip, addr, reg);
- mutex_unlock(&chip->reg_lock);
-
- return ret;
-}
-
static int _mv88e6xxx_reg_write(struct mv88e6xxx_chip *chip, int addr,
int reg, u16 val)
{
return ret;
}
+static int mv88e6xxx_port_read(struct mv88e6xxx_chip *chip, int port,
+ int reg, u16 *val)
+{
+ int addr = chip->info->port_base_addr + port;
+
+ if (port >= chip->info->num_ports)
+ return -EINVAL;
+
+ return mv88e6xxx_read(chip, addr, reg, val);
+}
+
static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port)
{
struct dsa_switch *ds = chip->ds;
static int mv88e6xxx_detect(struct mv88e6xxx_chip *chip)
{
const struct mv88e6xxx_info *info;
- int id, prod_num, rev;
+ unsigned int prod_num, rev;
+ u16 id;
+ int err;
- id = mv88e6xxx_reg_read(chip, chip->info->port_base_addr,
- PORT_SWITCH_ID);
- if (id < 0)
- return id;
+ mutex_lock(&chip->reg_lock);
+ err = mv88e6xxx_port_read(chip, 0, PORT_SWITCH_ID, &id);
+ mutex_unlock(&chip->reg_lock);
+ if (err)
+ return err;
prod_num = (id & 0xfff0) >> 4;
rev = id & 0x000f;