diff options
author | Andrew Lunn <andrew@lunn.ch> | 2014-11-15 16:24:52 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-11-16 15:47:26 -0500 |
commit | 4dd38cdb42c31a4ba69fbccf826fd4cd5e488edb (patch) | |
tree | 31e5bfed4b6d152fd212a33bca7c56dc89588264 /drivers/net/dsa | |
parent | eaa237657b97068db0eb49bae86714e9324cff9a (diff) |
net: dsa: mv88e6171: Add support for reading the temperature
This chip also has a temperature sensor which can be read using the
common code. In order to use it, add the needed mutex protection for
accessing registers via the shared code.
Signed-off-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/mv88e6171.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/drivers/net/dsa/mv88e6171.c b/drivers/net/dsa/mv88e6171.c index 537eeedece21..ed4c79778823 100644 --- a/drivers/net/dsa/mv88e6171.c +++ b/drivers/net/dsa/mv88e6171.c | |||
@@ -316,6 +316,8 @@ static int mv88e6171_setup(struct dsa_switch *ds) | |||
316 | return ret; | 316 | return ret; |
317 | } | 317 | } |
318 | 318 | ||
319 | mutex_init(&ps->phy_mutex); | ||
320 | |||
319 | return 0; | 321 | return 0; |
320 | } | 322 | } |
321 | 323 | ||
@@ -329,18 +331,28 @@ static int mv88e6171_port_to_phy_addr(int port) | |||
329 | static int | 331 | static int |
330 | mv88e6171_phy_read(struct dsa_switch *ds, int port, int regnum) | 332 | mv88e6171_phy_read(struct dsa_switch *ds, int port, int regnum) |
331 | { | 333 | { |
334 | struct mv88e6xxx_priv_state *ps = ds_to_priv(ds); | ||
332 | int addr = mv88e6171_port_to_phy_addr(port); | 335 | int addr = mv88e6171_port_to_phy_addr(port); |
336 | int ret; | ||
333 | 337 | ||
334 | return mv88e6xxx_phy_read(ds, addr, regnum); | 338 | mutex_lock(&ps->phy_mutex); |
339 | ret = mv88e6xxx_phy_read(ds, addr, regnum); | ||
340 | mutex_unlock(&ps->phy_mutex); | ||
341 | return ret; | ||
335 | } | 342 | } |
336 | 343 | ||
337 | static int | 344 | static int |
338 | mv88e6171_phy_write(struct dsa_switch *ds, | 345 | mv88e6171_phy_write(struct dsa_switch *ds, |
339 | int port, int regnum, u16 val) | 346 | int port, int regnum, u16 val) |
340 | { | 347 | { |
348 | struct mv88e6xxx_priv_state *ps = ds_to_priv(ds); | ||
341 | int addr = mv88e6171_port_to_phy_addr(port); | 349 | int addr = mv88e6171_port_to_phy_addr(port); |
350 | int ret; | ||
342 | 351 | ||
343 | return mv88e6xxx_phy_write(ds, addr, regnum, val); | 352 | mutex_lock(&ps->phy_mutex); |
353 | ret = mv88e6xxx_phy_write(ds, addr, regnum, val); | ||
354 | mutex_unlock(&ps->phy_mutex); | ||
355 | return ret; | ||
344 | } | 356 | } |
345 | 357 | ||
346 | static struct mv88e6xxx_hw_stat mv88e6171_hw_stats[] = { | 358 | static struct mv88e6xxx_hw_stat mv88e6171_hw_stats[] = { |
@@ -408,6 +420,9 @@ struct dsa_switch_driver mv88e6171_switch_driver = { | |||
408 | .get_strings = mv88e6171_get_strings, | 420 | .get_strings = mv88e6171_get_strings, |
409 | .get_ethtool_stats = mv88e6171_get_ethtool_stats, | 421 | .get_ethtool_stats = mv88e6171_get_ethtool_stats, |
410 | .get_sset_count = mv88e6171_get_sset_count, | 422 | .get_sset_count = mv88e6171_get_sset_count, |
423 | #ifdef CONFIG_NET_DSA_HWMON | ||
424 | .get_temp = mv88e6xxx_get_temp, | ||
425 | #endif | ||
411 | }; | 426 | }; |
412 | 427 | ||
413 | MODULE_ALIAS("platform:mv88e6171"); | 428 | MODULE_ALIAS("platform:mv88e6171"); |