diff options
author | Vivien Didelot <vivien.didelot@savoirfairelinux.com> | 2016-07-20 18:18:36 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2016-07-21 00:10:54 -0400 |
commit | 8f6345b2483be3eec9faac39d173b98790724011 (patch) | |
tree | 7479fb5f7ca42aaa2c421887de598b9570b902d4 /drivers/net/dsa | |
parent | 855b193290e6a07b343ee3c059ea6b4bd6cdc2bf (diff) |
net: dsa: mv88e6xxx: kill last locked reg_read
Get rid of the last usage of the locked mv88e6xxx_reg_read function with
a new mv88e6xxx_port_read helper, useful later for chips with different
port registers base address.
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>
Diffstat (limited to 'drivers/net/dsa')
-rw-r--r-- | drivers/net/dsa/mv88e6xxx/chip.c | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c index f95f1d49fdba..d36aedde8cb9 100644 --- a/drivers/net/dsa/mv88e6xxx/chip.c +++ b/drivers/net/dsa/mv88e6xxx/chip.c | |||
@@ -254,17 +254,6 @@ static int _mv88e6xxx_reg_read(struct mv88e6xxx_chip *chip, int addr, int reg) | |||
254 | return val; | 254 | return val; |
255 | } | 255 | } |
256 | 256 | ||
257 | static int mv88e6xxx_reg_read(struct mv88e6xxx_chip *chip, int addr, int reg) | ||
258 | { | ||
259 | int ret; | ||
260 | |||
261 | mutex_lock(&chip->reg_lock); | ||
262 | ret = _mv88e6xxx_reg_read(chip, addr, reg); | ||
263 | mutex_unlock(&chip->reg_lock); | ||
264 | |||
265 | return ret; | ||
266 | } | ||
267 | |||
268 | static int _mv88e6xxx_reg_write(struct mv88e6xxx_chip *chip, int addr, | 257 | static int _mv88e6xxx_reg_write(struct mv88e6xxx_chip *chip, int addr, |
269 | int reg, u16 val) | 258 | int reg, u16 val) |
270 | { | 259 | { |
@@ -2426,6 +2415,17 @@ static int mv88e6xxx_power_on_serdes(struct mv88e6xxx_chip *chip) | |||
2426 | return ret; | 2415 | return ret; |
2427 | } | 2416 | } |
2428 | 2417 | ||
2418 | static int mv88e6xxx_port_read(struct mv88e6xxx_chip *chip, int port, | ||
2419 | int reg, u16 *val) | ||
2420 | { | ||
2421 | int addr = chip->info->port_base_addr + port; | ||
2422 | |||
2423 | if (port >= chip->info->num_ports) | ||
2424 | return -EINVAL; | ||
2425 | |||
2426 | return mv88e6xxx_read(chip, addr, reg, val); | ||
2427 | } | ||
2428 | |||
2429 | static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port) | 2429 | static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port) |
2430 | { | 2430 | { |
2431 | struct dsa_switch *ds = chip->ds; | 2431 | struct dsa_switch *ds = chip->ds; |
@@ -3830,12 +3830,15 @@ static const struct mv88e6xxx_info *mv88e6xxx_lookup_info(unsigned int prod_num) | |||
3830 | static int mv88e6xxx_detect(struct mv88e6xxx_chip *chip) | 3830 | static int mv88e6xxx_detect(struct mv88e6xxx_chip *chip) |
3831 | { | 3831 | { |
3832 | const struct mv88e6xxx_info *info; | 3832 | const struct mv88e6xxx_info *info; |
3833 | int id, prod_num, rev; | 3833 | unsigned int prod_num, rev; |
3834 | u16 id; | ||
3835 | int err; | ||
3834 | 3836 | ||
3835 | id = mv88e6xxx_reg_read(chip, chip->info->port_base_addr, | 3837 | mutex_lock(&chip->reg_lock); |
3836 | PORT_SWITCH_ID); | 3838 | err = mv88e6xxx_port_read(chip, 0, PORT_SWITCH_ID, &id); |
3837 | if (id < 0) | 3839 | mutex_unlock(&chip->reg_lock); |
3838 | return id; | 3840 | if (err) |
3841 | return err; | ||
3839 | 3842 | ||
3840 | prod_num = (id & 0xfff0) >> 4; | 3843 | prod_num = (id & 0xfff0) >> 4; |
3841 | rev = id & 0x000f; | 3844 | rev = id & 0x000f; |