dsa: mv88e6352/mv88e6xxx: Move temperature sensor code to mv88e6xxx.c
Subsystems (3)
PATCH 1/1 dsa: mv88e6352/mv88e6xxx: Move temperature sensor code to mv88e6xxx.c
Move the temperature sensing code for mv88e6352 and mv88e6320 families into mv88e6xxx.c to simplify adding support for additional chips.
With this change, mv88e6xxx_6320_family() no longer needs to be a global function and is made static.
--- drivers/net/dsa/mv88e6352.c | 72 +----------------- drivers/net/dsa/mv88e6xxx.c | 176 ++++++++++++++++++++++++++++++++------------ drivers/net/dsa/mv88e6xxx.h | 7 +- 3 files changed, 136 insertions(+), 119 deletions(-)
drivers/net/dsa/mv88e6352.c +4 -68
@@ -92,70 +92,6 @@ static int mv88e6352_setup_global(struct dsa_switch *ds)return 0 ; } -#ifdef CONFIG_NET_DSA_HWMON - -static int mv88e6352_get_temp (struct dsa_switch *ds,int *temp) -{ -int phy =mv88e6xxx_6320_family (ds) ?3 :0 ; -int ret; - - *temp =0 ; - - ret =mv88e6xxx_phy_page_read (ds, phy,6 ,27 ); -if (ret <0 ) -return ret; - - *temp = (ret &0xff ) -25 ; - -return 0 ; -} - -static int mv88e6352_get_temp_limit (struct dsa_switch *ds,int *temp) -{ -int phy =mv88e6xxx_6320_family (ds) ?3 :0 ; -int ret; - - *temp =0 ; - - ret =mv88e6xxx_phy_page_read (ds, phy,6 ,26 ); -if (ret <0 ) -return ret; - - *temp = (((ret >>8 ) &0x1f ) *5 ) -25 ; - -return 0 ; -} - -static int mv88e6352_set_temp_limit (struct dsa_switch *ds,int temp) -{ -int phy =mv88e6xxx_6320_family (ds) ?3 :0 ; -int ret; - - ret =mv88e6xxx_phy_page_read (ds, phy,6 ,26 ); -if (ret <0 ) -return ret; - temp =clamp_val (DIV_ROUND_CLOSEST (temp,5 ) +5 ,0 ,0x1f ); -return mv88e6xxx_phy_page_write (ds, phy,6 ,26 , - (ret &0xe0ff ) | (temp <<8 )); -} - -static int mv88e6352_get_temp_alarm (struct dsa_switch *ds,bool *alarm) -{ -int phy =mv88e6xxx_6320_family (ds) ?3 :0 ; -int ret; - - *alarm = false; - - ret =mv88e6xxx_phy_page_read (ds, phy,6 ,26 ); -if (ret <0 ) -return ret; - - *alarm = !!(ret &0x40 ); - -return 0 ; -} -#endif /* CONFIG_NET_DSA_HWMON */ -static int mv88e6352_setup (struct dsa_switch *ds) {struct mv88e6xxx_priv_state *ps =ds_to_priv (ds);
@@ -393,10 +329,10 @@ struct dsa_switch_driver mv88e6352_switch_driver = { .set_eee = mv88e6xxx_set_eee, .get_eee = mv88e6xxx_get_eee, #ifdef CONFIG_NET_DSA_HWMON - .get_temp = mv88e6352_get_temp, - .get_temp_limit = mv88e6352_get_temp_limit, - .set_temp_limit = mv88e6352_set_temp_limit, - .get_temp_alarm = mv88e6352_get_temp_alarm, + .get_temp = mv88e6xxx_get_temp, + .get_temp_limit = mv88e6xxx_get_temp_limit, + .set_temp_limit = mv88e6xxx_set_temp_limit, + .get_temp_alarm = mv88e6xxx_get_temp_alarm, #endif .get_eeprom = mv88e6352_get_eeprom, .set_eeprom = mv88e6352_set_eeprom,
drivers/net/dsa/mv88e6xxx.c +127 -49
194 lines not on this page · raw message
drivers/net/dsa/mv88e6xxx.h +5 -2
@@ -394,7 +394,10 @@ int mv88e6xxx_get_sset_count_basic(struct dsa_switch *ds);int mv88e6xxx_get_regs_len (struct dsa_switch *ds,int port);void mv88e6xxx_get_regs (struct dsa_switch *ds,int port,struct ethtool_regs *regs,void *_p); -int mv88e6xxx_get_temp (struct dsa_switch *ds,int *temp); +int mv88e6xxx_get_temp (struct dsa_switch *ds,int *temp); +int mv88e6xxx_get_temp_limit (struct dsa_switch *ds,int *temp); +int mv88e6xxx_set_temp_limit (struct dsa_switch *ds,int temp); +int mv88e6xxx_get_temp_alarm (struct dsa_switch *ds,bool *alarm);int mv88e6xxx_eeprom_load_wait (struct dsa_switch *ds);int mv88e6xxx_eeprom_busy_wait (struct dsa_switch *ds);int mv88e6xxx_phy_read_indirect (struct dsa_switch *ds,int addr,int regnum);
@@ -415,7 +418,7 @@ int mv88e6xxx_port_fdb_getnext(struct dsa_switch *ds, int port,int mv88e6xxx_phy_page_read (struct dsa_switch *ds,int port,int page,int reg);int mv88e6xxx_phy_page_write (struct dsa_switch *ds,int port,int page,int reg,int val); -bool mv88e6xxx_6320_family (struct dsa_switch *ds); +extern struct dsa_switch_driver mv88e6131_switch_driver;extern struct dsa_switch_driver mv88e6123_61_65_switch_driver;extern struct dsa_switch_driver mv88e6352_switch_driver;
Signature · 1 line
2.1.0
Quoted 8 lines · Guenter Roeck
Move the temperature sensing code for mv88e6352 and mv88e6320 families into
mv88e6xxx.cto simplify adding support for additional chips.With this change,
mv88e6xxx_6320_family()no longer needs to be a global function and is made static.Cc Andrew Lunn <[email protected]>Signed-off-by Guenter Roeck <[email protected]>
Thanks for doing this Guenter
Andrew
Quoted 7 lines · Andrew Lunn
Quoted 6 lines · Guenter Roeck
Move the temperature sensing code for mv88e6352 and mv88e6320 families into
mv88e6xxx.cto simplify adding support for additional chips.With this change,
mv88e6xxx_6320_family()no longer needs to be a global function and is made static.
Quoted 7 lines
Quoted 2 lines
Cc Andrew Lunn <[email protected]>Signed-off-by Guenter Roeck <[email protected]>Acked-by Andrew Lunn <[email protected]>Thanks for doing this Guenter
My pleasure. Thanks a lot for the review!
Guenter
Quoted 8 lines · On Jul 25, 2015, at 12:42 PM, Guenter Roeck [email protected] wrote:
Move the temperature sensing code for mv88e6352 and mv88e6320 families into
mv88e6xxx.cto simplify adding support for additional chips.With this change,
mv88e6xxx_6320_family()no longer needs to be a global function and is made static.Cc Andrew Lunn <[email protected]>Signed-off-by Guenter Roeck <[email protected]>
On a Marvell 88E6352.
Thanks,
-v
Quoted 8 lines · Vivien Didelot
Quoted 6 lines · On Jul 25, 2015, at 12:42 PM, Guenter Roeck [email protected] wrote:
Move the temperature sensing code for mv88e6352 and mv88e6320 families into
mv88e6xxx.cto simplify adding support for additional chips.With this change,
mv88e6xxx_6320_family()no longer needs to be a global function and is made static.
Quoted 6 lines
Quoted 2 lines
Cc Andrew Lunn <[email protected]>Signed-off-by Guenter Roeck <[email protected]>Tested-by Vivien Didelot <[email protected]>On a Marvell 88E6352.
Thanks a lot for testing!
Guenter
From: Guenter Roeck <[email protected]>
Date: Sat, 25 Jul 2015 09:42:28 -0700
Quoted 8 lines
Move the temperature sensing code for mv88e6352 and mv88e6320 families into
mv88e6xxx.cto simplify adding support for additional chips.With this change,
mv88e6xxx_6320_family()no longer needs to be a global function and is made static.Cc Andrew Lunn <[email protected]>Signed-off-by Guenter Roeck <[email protected]>
Applied, thanks.