From 796ce30bdd8c584f9279ade534989088cca565e7 Mon Sep 17 00:00:00 2001 From: jostar-yang Date: Wed, 1 Nov 2023 03:08:58 +0800 Subject: [PATCH] [Edgecore][sonic-platform-modules-accton]Support kernel 6.1 and bookworm (#16982) * [Edgecore][sonic-platform-modules-accton]Support kernel 6.1 and bookworm * Modify pddf drv code for i2c_remove_callback function fail --- platform/broadcom/rules.dep | 3 +- platform/broadcom/rules.mk | 3 +- .../modules/x86-64-accton-as4630-54pe-cpld.c | 3 +- .../modules/x86-64-accton-as4630-54pe-psu.c | 3 +- .../modules/x86-64-accton-as4630-54te-cpld.c | 3 +- .../modules/x86-64-accton-as4630-54te-psu.c | 3 +- .../as5712-54x/classes/fanutil.py | 15 +- .../as5712-54x/classes/thermalutil.py | 12 +- .../modules/accton_as5712_54x_psu.c | 3 +- .../modules/accton_as5712_54x_sfp.c | 3 +- .../modules/i2c-mux-accton_as5712_54x_cpld.c | 3 +- .../as5812-54t/classes/fanutil.py | 15 +- .../as5812-54t/classes/thermalutil.py | 33 ++- .../modules/x86-64-accton-as5812-54t-cpld.c | 3 +- .../modules/x86-64-accton-as5812-54t-psu.c | 3 +- .../as5812-54x/classes/fanutil.py | 15 +- .../as5812-54x/classes/thermalutil.py | 32 ++- .../modules/accton_as5812_54x_psu.c | 3 +- .../modules/accton_as5812_54x_sfp.c | 3 +- .../as5812-54x/modules/cpr_4011_4mxx.c | 3 +- .../modules/i2c-mux-accton_as5812_54x_cpld.c | 3 +- .../as5812-54x/modules/ym2651y.c | 3 +- .../as5835-54t/classes/fanutil.py | 26 +-- .../as5835-54t/classes/thermalutil.py | 19 +- .../modules/accton_as5835_54t_cpld.c | 3 +- .../modules/accton_as5835_54t_fan.c | 3 +- .../modules/accton_as5835_54t_psu.c | 3 +- .../as5835-54x/classes/fanutil.py | 10 - .../modules/accton_as5835_54x_cpld.c | 3 +- .../modules/accton_as5835_54x_fan.c | 3 +- .../modules/accton_as5835_54x_psu.c | 3 +- .../as6712-32x/classes/fanutil.py | 43 +--- .../as6712-32x/classes/thermalutil.py | 32 ++- .../modules/accton-as6712-32x-cpld.c | 3 +- .../modules/accton_as6712_32x_psu.c | 3 +- .../as6712-32x/modules/cpr_4011_4mxx.c | 3 +- .../modules/accton_as7312_54x_fan.c | 3 +- .../modules/accton_as7312_54x_psu.c | 3 +- .../modules/accton_as7312_54x_sfp.c | 3 +- .../as7312-54x/modules/accton_i2c_cpld.c | 3 +- .../as7312-54xs/classes/fanutil.py | 33 +-- .../as7312-54xs/classes/thermalutil.py | 29 +-- .../modules/accton_as7312_54x_fan.c | 3 +- .../modules/accton_as7312_54x_psu.c | 3 +- .../modules/accton_as7312_54x_sfp.c | 3 +- .../as7312-54xs/modules/accton_i2c_cpld.c | 3 +- .../modules/accton_as7315_27xb_fan.c | 3 +- .../modules/x86-64-accton-as7315-27xb-cpld.c | 3 +- .../modules/x86-64-accton-as7315-27xb-psu.c | 3 +- .../modules/accton_as7326_56x_fan.c | 3 +- .../modules/accton_as7326_56x_psu.c | 3 +- .../as7326-56x/modules/accton_i2c_cpld.c | 3 +- .../modules/accton_as7712_32x_fan.c | 3 +- .../modules/accton_as7712_32x_psu.c | 3 +- .../modules/accton_as7712_32x_sfp.c | 9 +- .../as7716-32x/classes/fanutil.py | 40 +--- .../as7716-32x/classes/thermalutil.py | 32 +-- .../modules/accton_as7716_32x_cpld1.c | 3 +- .../modules/accton_as7716_32x_fan.c | 3 +- .../modules/accton_as7716_32x_psu.c | 3 +- .../modules/accton_as7716_32x_sfp.c | 3 +- .../as7716-32x/modules/accton_i2c_cpld.c | 3 +- .../as7716-32x/modules/cpr_4011_4mxx.c | 3 +- .../as7716-32x/modules/ym2651y.c | 3 +- .../as7716-32xb/classes/fanutil.py | 52 +---- .../as7716-32xb/classes/thermalutil.py | 32 +-- .../modules/accton_as7716_32xb_cpld1.c | 12 +- .../modules/accton_as7716_32xb_fan.c | 7 +- .../modules/accton_as7716_32xb_oom.c | 21 +- .../modules/accton_as7716_32xb_pmbus.c | 10 +- .../modules/accton_as7716_32xb_psu.c | 13 +- .../modules/accton_as7716_32xb_sfp.c | 10 +- .../modules/accton_as7716_32xb_sys.c | 45 +--- .../modules/accton_as7716_32xb_thermal.c | 3 +- .../as7716-32xb/modules/accton_i2c_cpld.c | 19 +- .../as7726-32x/classes/fanutil.py | 4 +- .../as7726-32x/classes/thermalutil.py | 11 +- .../modules/accton_as7726_32x_cpld.c | 3 +- .../modules/accton_as7726_32x_fan.c | 3 +- .../modules/accton_as7726_32x_psu.c | 3 +- .../as7726-32x/modules/ym2651y.c | 3 +- .../modules/x86-64-accton-as7816-64x-fan.c | 3 +- .../modules/x86-64-accton-as7816-64x-psu.c | 3 +- .../modules/x86-64-accton-as7816-64x-sfp.c | 3 +- .../as9716-32d/classes/fanutil.py | 4 +- .../as9716-32d/classes/thermalutil.py | 8 +- .../modules/accton_as9716_32d_cpld.c | 3 +- .../modules/accton_as9716_32d_fan.c | 3 +- .../modules/accton_as9716_32d_psu.c | 3 +- .../as9716-32d/modules/accton_i2c_psu.c | 3 +- .../as9726-32d/classes/fanutil.py | 8 +- .../as9726-32d/classes/thermalutil.py | 7 +- .../modules/x86-64-accton-as9726-32d-cpld.c | 5 +- .../modules/x86-64-accton-as9726-32d-fan.c | 3 +- .../modules/x86-64-accton-as9726-32d-psu.c | 4 +- .../as9726-32d/modules/ym2651y.c | 3 +- .../common/modules/accton_i2c_cpld.c | 3 +- .../common/modules/accton_pmbus_3y.c | 3 +- .../common/modules/cpr_4011_4mxx.c | 3 +- .../common/modules/ym2651y.c | 3 +- .../minipack/lib/fbfpgaiomodule.c | 22 +- .../minipack/modules/minipack_psensor.c | 199 +++++++++++++++--- .../modules/cpld/driver/pddf_cpld_driver.c | 1 + .../i2c/modules/fan/driver/pddf_fan_driver.c | 1 + .../fpgai2c/driver/pddf_fpgai2c_driver.c | 2 +- 105 files changed, 373 insertions(+), 717 deletions(-) diff --git a/platform/broadcom/rules.dep b/platform/broadcom/rules.dep index 40e69471872b..aa8547fcac98 100644 --- a/platform/broadcom/rules.dep +++ b/platform/broadcom/rules.dep @@ -4,14 +4,13 @@ include $(PLATFORM_PATH)/sai.dep # TODO: re-enable once the following have been updated for bookworm: # * Nokia # * Dell -# * Accton # * Juniper # * Ragile include $(PLATFORM_PATH)/platform-modules-s6000.dep #include $(PLATFORM_PATH)/platform-modules-dell.dep include $(PLATFORM_PATH)/platform-modules-arista.dep include $(PLATFORM_PATH)/platform-modules-ingrasys.dep -#include $(PLATFORM_PATH)/platform-modules-accton.dep +include $(PLATFORM_PATH)/platform-modules-accton.dep include $(PLATFORM_PATH)/platform-modules-alphanetworks.dep include $(PLATFORM_PATH)/platform-modules-inventec.dep include $(PLATFORM_PATH)/platform-modules-cel.dep diff --git a/platform/broadcom/rules.mk b/platform/broadcom/rules.mk index a877fe27a89c..438d9b0ce2cb 100755 --- a/platform/broadcom/rules.mk +++ b/platform/broadcom/rules.mk @@ -3,7 +3,6 @@ include $(PLATFORM_PATH)/sai.mk # TODO: re-enable once the following have been updated for bookworm: # * Nokia # * Dell -# * Accton # * Juniper # * Ragile # * Ufispace @@ -11,7 +10,7 @@ include $(PLATFORM_PATH)/sai.mk #include $(PLATFORM_PATH)/platform-modules-dell.mk include $(PLATFORM_PATH)/platform-modules-arista.mk #include $(PLATFORM_PATH)/platform-modules-ingrasys.mk -#include $(PLATFORM_PATH)/platform-modules-accton.mk +include $(PLATFORM_PATH)/platform-modules-accton.mk include $(PLATFORM_PATH)/platform-modules-alphanetworks.mk #include $(PLATFORM_PATH)/platform-modules-inventec.mk include $(PLATFORM_PATH)/platform-modules-cel.mk diff --git a/platform/broadcom/sonic-platform-modules-accton/as4630-54pe/modules/x86-64-accton-as4630-54pe-cpld.c b/platform/broadcom/sonic-platform-modules-accton/as4630-54pe/modules/x86-64-accton-as4630-54pe-cpld.c index 0e9fc11aca81..8450b1f73bb0 100644 --- a/platform/broadcom/sonic-platform-modules-accton/as4630-54pe/modules/x86-64-accton-as4630-54pe-cpld.c +++ b/platform/broadcom/sonic-platform-modules-accton/as4630-54pe/modules/x86-64-accton-as4630-54pe-cpld.c @@ -769,7 +769,7 @@ static int as4630_54pe_cpld_probe(struct i2c_client *client, return ret; } -static int as4630_54pe_cpld_remove(struct i2c_client *client) +static void as4630_54pe_cpld_remove(struct i2c_client *client) { struct as4630_54pe_cpld_data *data = i2c_get_clientdata(client); const struct attribute_group *group = NULL; @@ -794,7 +794,6 @@ static int as4630_54pe_cpld_remove(struct i2c_client *client) kfree(data); - return 0; } static int as4630_54pe_cpld_read_internal(struct i2c_client *client, u8 reg) diff --git a/platform/broadcom/sonic-platform-modules-accton/as4630-54pe/modules/x86-64-accton-as4630-54pe-psu.c b/platform/broadcom/sonic-platform-modules-accton/as4630-54pe/modules/x86-64-accton-as4630-54pe-psu.c index 3d197210e35f..20a00abb8d7c 100644 --- a/platform/broadcom/sonic-platform-modules-accton/as4630-54pe/modules/x86-64-accton-as4630-54pe-psu.c +++ b/platform/broadcom/sonic-platform-modules-accton/as4630-54pe/modules/x86-64-accton-as4630-54pe-psu.c @@ -186,7 +186,7 @@ static int as4630_54pe_psu_probe(struct i2c_client *client, return status; } -static int as4630_54pe_psu_remove(struct i2c_client *client) +static void as4630_54pe_psu_remove(struct i2c_client *client) { struct as4630_54pe_psu_data *data = i2c_get_clientdata(client); @@ -194,7 +194,6 @@ static int as4630_54pe_psu_remove(struct i2c_client *client) sysfs_remove_group(&client->dev.kobj, &as4630_54pe_psu_group); kfree(data); - return 0; } enum psu_index diff --git a/platform/broadcom/sonic-platform-modules-accton/as4630-54te/modules/x86-64-accton-as4630-54te-cpld.c b/platform/broadcom/sonic-platform-modules-accton/as4630-54te/modules/x86-64-accton-as4630-54te-cpld.c index 317eac3a4cbb..ce733cdf74cf 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as4630-54te/modules/x86-64-accton-as4630-54te-cpld.c +++ b/platform/broadcom/sonic-platform-modules-accton/as4630-54te/modules/x86-64-accton-as4630-54te-cpld.c @@ -772,7 +772,7 @@ static int as4630_54te_cpld_probe(struct i2c_client *client, return ret; } -static int as4630_54te_cpld_remove(struct i2c_client *client) +static void as4630_54te_cpld_remove(struct i2c_client *client) { struct as4630_54te_cpld_data *data = i2c_get_clientdata(client); const struct attribute_group *group = NULL; @@ -797,7 +797,6 @@ static int as4630_54te_cpld_remove(struct i2c_client *client) kfree(data); - return 0; } static int as4630_54te_cpld_read_internal(struct i2c_client *client, u8 reg) diff --git a/platform/broadcom/sonic-platform-modules-accton/as4630-54te/modules/x86-64-accton-as4630-54te-psu.c b/platform/broadcom/sonic-platform-modules-accton/as4630-54te/modules/x86-64-accton-as4630-54te-psu.c index 3a99f19a9cd2..cfd96377028a 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as4630-54te/modules/x86-64-accton-as4630-54te-psu.c +++ b/platform/broadcom/sonic-platform-modules-accton/as4630-54te/modules/x86-64-accton-as4630-54te-psu.c @@ -187,7 +187,7 @@ static int as4630_54te_psu_probe(struct i2c_client *client, return status; } -static int as4630_54te_psu_remove(struct i2c_client *client) +static void as4630_54te_psu_remove(struct i2c_client *client) { struct as4630_54te_psu_data *data = i2c_get_clientdata(client); @@ -195,7 +195,6 @@ static int as4630_54te_psu_remove(struct i2c_client *client) sysfs_remove_group(&client->dev.kobj, &as4630_54te_psu_group); kfree(data); - return 0; } enum psu_index diff --git a/platform/broadcom/sonic-platform-modules-accton/as5712-54x/classes/fanutil.py b/platform/broadcom/sonic-platform-modules-accton/as5712-54x/classes/fanutil.py index c16771e214e4..4ee42e84a3e2 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as5712-54x/classes/fanutil.py +++ b/platform/broadcom/sonic-platform-modules-accton/as5712-54x/classes/fanutil.py @@ -122,7 +122,7 @@ def _get_fan_node_val(self, fan_num, node_num): return None try: - val_file.close() + val_file.close() except: logging.debug('GET. unable to close file. device_path:%s', device_path) return None @@ -153,7 +153,7 @@ def _set_fan_node_val(self, fan_num, node_num, val): val_file.write(content) try: - val_file.close() + val_file.close() except: logging.debug('GET. unable to close file. device_path:%s', device_path) return None @@ -225,14 +225,3 @@ def get_fan_status(self, fan_num): return True -#def main(): -# fan = FanUtil() -# -# print 'get_size_node_map : %d' % fan.get_size_node_map() -# print 'get_size_path_map : %d' % fan.get_size_path_map() -# for x in range(fan.get_idx_fan_start(), fan.get_num_fans()+1): -# for y in range(fan.get_idx_node_start(), fan.get_num_nodes()+1): -# print fan.get_fan_to_device_path(x, y) -# -#if __name__ == '__main__': -# main() diff --git a/platform/broadcom/sonic-platform-modules-accton/as5712-54x/classes/thermalutil.py b/platform/broadcom/sonic-platform-modules-accton/as5712-54x/classes/thermalutil.py index 5b8f890e8819..d571cf0af73a 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as5712-54x/classes/thermalutil.py +++ b/platform/broadcom/sonic-platform-modules-accton/as5712-54x/classes/thermalutil.py @@ -80,7 +80,7 @@ def _get_thermal_node_val(self, thermal_num): return None try: - val_file.close() + val_file.close() except: logging.debug('GET. unable to close file. device_path:%s', device_path) return None @@ -109,13 +109,3 @@ def get_thermal_1_val(self): def get_thermal_2_val(self): return self._get_thermal_node_val(self.THERMAL_NUM_2_IDX) -#def main(): -# thermal = ThermalUtil() -# -# print 'get_size_node_map : %d' % thermal.get_size_node_map() -# print 'get_size_path_map : %d' % thermal.get_size_path_map() -# for x in range(thermal.get_idx_thermal_start(), thermal.get_num_thermals()+1): -# print thermal.get_thermal_to_device_path(x) -# -#if __name__ == '__main__': -# main() diff --git a/platform/broadcom/sonic-platform-modules-accton/as5712-54x/modules/accton_as5712_54x_psu.c b/platform/broadcom/sonic-platform-modules-accton/as5712-54x/modules/accton_as5712_54x_psu.c index 9a0d1dae58ba..453484e40c62 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as5712-54x/modules/accton_as5712_54x_psu.c +++ b/platform/broadcom/sonic-platform-modules-accton/as5712-54x/modules/accton_as5712_54x_psu.c @@ -193,7 +193,7 @@ static int as5712_54x_psu_probe(struct i2c_client *client, return status; } -static int as5712_54x_psu_remove(struct i2c_client *client) +static void as5712_54x_psu_remove(struct i2c_client *client) { struct as5712_54x_psu_data *data = i2c_get_clientdata(client); @@ -201,7 +201,6 @@ static int as5712_54x_psu_remove(struct i2c_client *client) sysfs_remove_group(&client->dev.kobj, &as5712_54x_psu_group); kfree(data); - return 0; } enum psu_index diff --git a/platform/broadcom/sonic-platform-modules-accton/as5712-54x/modules/accton_as5712_54x_sfp.c b/platform/broadcom/sonic-platform-modules-accton/as5712-54x/modules/accton_as5712_54x_sfp.c index d236057c4e59..ec97be4755d4 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as5712-54x/modules/accton_as5712_54x_sfp.c +++ b/platform/broadcom/sonic-platform-modules-accton/as5712-54x/modules/accton_as5712_54x_sfp.c @@ -498,7 +498,7 @@ static int as5712_54x_sfp_probe(struct i2c_client *client, return status; } -static int as5712_54x_sfp_remove(struct i2c_client *client) +static void as5712_54x_sfp_remove(struct i2c_client *client) { struct as5712_54x_sfp_data *data = i2c_get_clientdata(client); @@ -506,7 +506,6 @@ static int as5712_54x_sfp_remove(struct i2c_client *client) sysfs_remove_group(&client->dev.kobj, &as5712_54x_sfp_group); kfree(data); - return 0; } enum port_numbers { diff --git a/platform/broadcom/sonic-platform-modules-accton/as5712-54x/modules/i2c-mux-accton_as5712_54x_cpld.c b/platform/broadcom/sonic-platform-modules-accton/as5712-54x/modules/i2c-mux-accton_as5712_54x_cpld.c index 9dbac9ca337e..2eb4dc44ed8d 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as5712-54x/modules/i2c-mux-accton_as5712_54x_cpld.c +++ b/platform/broadcom/sonic-platform-modules-accton/as5712-54x/modules/i2c-mux-accton_as5712_54x_cpld.c @@ -1277,7 +1277,7 @@ static int as5712_54x_cpld_mux_probe(struct i2c_client *client, return ret; } -static int as5712_54x_cpld_mux_remove(struct i2c_client *client) +static void as5712_54x_cpld_mux_remove(struct i2c_client *client) { struct i2c_mux_core *muxc = i2c_get_clientdata(client); struct as5712_54x_cpld_data *data = i2c_mux_priv(muxc); @@ -1306,7 +1306,6 @@ static int as5712_54x_cpld_mux_remove(struct i2c_client *client) i2c_mux_del_adapters(muxc); - return 0; } static int as5712_54x_cpld_read_internal(struct i2c_client *client, u8 reg) diff --git a/platform/broadcom/sonic-platform-modules-accton/as5812-54t/classes/fanutil.py b/platform/broadcom/sonic-platform-modules-accton/as5812-54t/classes/fanutil.py index 223408fb962c..494e6df3c214 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as5812-54t/classes/fanutil.py +++ b/platform/broadcom/sonic-platform-modules-accton/as5812-54t/classes/fanutil.py @@ -135,7 +135,7 @@ def _get_fan_node_val(self, fan_num, node_num): return None try: - val_file.close() + val_file.close() except: self.logger.debug('GET. unable to close file. device_path:%s', device_path) return None @@ -166,7 +166,7 @@ def _set_fan_node_val(self, fan_num, node_num, val): val_file.write(content) try: - val_file.close() + val_file.close() except: self.logger.debug('GET. unable to close file. device_path:%s', device_path) return None @@ -230,14 +230,3 @@ def get_fan_status(self, fan_num): return True -#def main(): -# fan = FanUtil() -# -# print 'get_size_node_map : %d' % fan.get_size_node_map() -# print 'get_size_path_map : %d' % fan.get_size_path_map() -# for x in range(fan.get_idx_fan_start(), fan.get_num_fans()+1): -# for y in range(fan.get_idx_node_start(), fan.get_num_nodes()+1): -# print fan.get_fan_to_device_path(x, y) -# -#if __name__ == '__main__': -# main() diff --git a/platform/broadcom/sonic-platform-modules-accton/as5812-54t/classes/thermalutil.py b/platform/broadcom/sonic-platform-modules-accton/as5812-54t/classes/thermalutil.py index 0095a7871029..4c1707d3f162 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as5812-54t/classes/thermalutil.py +++ b/platform/broadcom/sonic-platform-modules-accton/as5812-54t/classes/thermalutil.py @@ -77,19 +77,21 @@ def _get_thermal_node_val(self, thermal_num): self.logger.error('GET. unable to open file: %s', str(e)) return None - content = val_file.readline().rstrip() + content = val_file.readline().rstrip() - if content == '': - self.logger.debug('GET. content is NULL. device_path:%s', device_path) - return None + if content == '': + self.logger.debug('GET. content is NULL. device_path:%s', device_path) + return None - try: - val_file.close() - except: - self.logger.debug('GET. unable to close file. device_path:%s', device_path) - return None + try: + val_file.close() + except: + self.logger.debug('GET. unable to close file. device_path:%s', device_path) + return None - return int(content) + return int(content) + + return 0 def get_num_thermals(self): @@ -112,14 +114,3 @@ def get_thermal_1_val(self): def get_thermal_2_val(self): return self._get_thermal_node_val(self.THERMAL_NUM_2_IDX) - -#def main(): -# thermal = ThermalUtil() -# -# print 'get_size_node_map : %d' % thermal.get_size_node_map() -# print 'get_size_path_map : %d' % thermal.get_size_path_map() -# for x in range(thermal.get_idx_thermal_start(), thermal.get_num_thermals()+1): -# print thermal.get_thermal_to_device_path(x) -# -#if __name__ == '__main__': -# main() diff --git a/platform/broadcom/sonic-platform-modules-accton/as5812-54t/modules/x86-64-accton-as5812-54t-cpld.c b/platform/broadcom/sonic-platform-modules-accton/as5812-54t/modules/x86-64-accton-as5812-54t-cpld.c index 2d44d5355ca0..f7dc82f71930 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as5812-54t/modules/x86-64-accton-as5812-54t-cpld.c +++ b/platform/broadcom/sonic-platform-modules-accton/as5812-54t/modules/x86-64-accton-as5812-54t-cpld.c @@ -447,7 +447,7 @@ static int as5812_54t_cpld_probe(struct i2c_client *client, return status; } -static int as5812_54t_cpld_remove(struct i2c_client *client) +static void as5812_54t_cpld_remove(struct i2c_client *client) { struct as5812_54t_cpld_data *data = i2c_get_clientdata(client); @@ -456,7 +456,6 @@ static int as5812_54t_cpld_remove(struct i2c_client *client) kfree(data); as5812_54t_cpld_remove_client(client); - return 0; } int as5812_54t_cpld_read(unsigned short cpld_addr, u8 reg) diff --git a/platform/broadcom/sonic-platform-modules-accton/as5812-54t/modules/x86-64-accton-as5812-54t-psu.c b/platform/broadcom/sonic-platform-modules-accton/as5812-54t/modules/x86-64-accton-as5812-54t-psu.c index c62998655bcd..96f6bfcd22af 100644 --- a/platform/broadcom/sonic-platform-modules-accton/as5812-54t/modules/x86-64-accton-as5812-54t-psu.c +++ b/platform/broadcom/sonic-platform-modules-accton/as5812-54t/modules/x86-64-accton-as5812-54t-psu.c @@ -191,7 +191,7 @@ static int as5812_54t_psu_probe(struct i2c_client *client, return status; } -static int as5812_54t_psu_remove(struct i2c_client *client) +static void as5812_54t_psu_remove(struct i2c_client *client) { struct as5812_54t_psu_data *data = i2c_get_clientdata(client); @@ -199,7 +199,6 @@ static int as5812_54t_psu_remove(struct i2c_client *client) sysfs_remove_group(&client->dev.kobj, &as5812_54t_psu_group); kfree(data); - return 0; } enum psu_index diff --git a/platform/broadcom/sonic-platform-modules-accton/as5812-54x/classes/fanutil.py b/platform/broadcom/sonic-platform-modules-accton/as5812-54x/classes/fanutil.py index 95a4558622e9..a68e34f89b6f 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as5812-54x/classes/fanutil.py +++ b/platform/broadcom/sonic-platform-modules-accton/as5812-54x/classes/fanutil.py @@ -135,7 +135,7 @@ def _get_fan_node_val(self, fan_num, node_num): return None try: - val_file.close() + val_file.close() except: self.logger.debug('GET. unable to close file. device_path:%s', device_path) return None @@ -166,7 +166,7 @@ def _set_fan_node_val(self, fan_num, node_num, val): val_file.write(content) try: - val_file.close() + val_file.close() except: self.logger.debug('GET. unable to close file. device_path:%s', device_path) return None @@ -230,14 +230,3 @@ def get_fan_status(self, fan_num): return True -#def main(): -# fan = FanUtil() -# -# print 'get_size_node_map : %d' % fan.get_size_node_map() -# print 'get_size_path_map : %d' % fan.get_size_path_map() -# for x in range(fan.get_idx_fan_start(), fan.get_num_fans()+1): -# for y in range(fan.get_idx_node_start(), fan.get_num_nodes()+1): -# print fan.get_fan_to_device_path(x, y) -# -#if __name__ == '__main__': -# main() diff --git a/platform/broadcom/sonic-platform-modules-accton/as5812-54x/classes/thermalutil.py b/platform/broadcom/sonic-platform-modules-accton/as5812-54x/classes/thermalutil.py index 7799bb3d53c4..1713e9a8d417 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as5812-54x/classes/thermalutil.py +++ b/platform/broadcom/sonic-platform-modules-accton/as5812-54x/classes/thermalutil.py @@ -77,21 +77,23 @@ def _get_thermal_node_val(self, thermal_num): self.logger.error('GET. unable to open file: %s', str(e)) return None - content = val_file.readline().rstrip() + content = val_file.readline().rstrip() - if content == '': - self.logger.debug('GET. content is NULL. device_path:%s', device_path) - return None + if content == '': + self.logger.debug('GET. content is NULL. device_path:%s', device_path) + return None - try: - val_file.close() - except: - self.logger.debug('GET. unable to close file. device_path:%s', device_path) - return None + try: + val_file.close() + except: + self.logger.debug('GET. unable to close file. device_path:%s', device_path) + return None - return int(content) + return int(content) + return 0 + def get_num_thermals(self): return self.THERMAL_NUM_ON_MAIN_BROAD @@ -113,13 +115,3 @@ def get_thermal_1_val(self): def get_thermal_2_val(self): return self._get_thermal_node_val(self.THERMAL_NUM_2_IDX) -#def main(): -# thermal = ThermalUtil() -# -# print 'get_size_node_map : %d' % thermal.get_size_node_map() -# print 'get_size_path_map : %d' % thermal.get_size_path_map() -# for x in range(thermal.get_idx_thermal_start(), thermal.get_num_thermals()+1): -# print thermal.get_thermal_to_device_path(x) -# -#if __name__ == '__main__': -# main() diff --git a/platform/broadcom/sonic-platform-modules-accton/as5812-54x/modules/accton_as5812_54x_psu.c b/platform/broadcom/sonic-platform-modules-accton/as5812-54x/modules/accton_as5812_54x_psu.c index 2c6b5f492a97..f339e0fc3bd8 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as5812-54x/modules/accton_as5812_54x_psu.c +++ b/platform/broadcom/sonic-platform-modules-accton/as5812-54x/modules/accton_as5812_54x_psu.c @@ -193,7 +193,7 @@ static int as5812_54x_psu_probe(struct i2c_client *client, return status; } -static int as5812_54x_psu_remove(struct i2c_client *client) +static void as5812_54x_psu_remove(struct i2c_client *client) { struct as5812_54x_psu_data *data = i2c_get_clientdata(client); @@ -201,7 +201,6 @@ static int as5812_54x_psu_remove(struct i2c_client *client) sysfs_remove_group(&client->dev.kobj, &as5812_54x_psu_group); kfree(data); - return 0; } enum psu_index diff --git a/platform/broadcom/sonic-platform-modules-accton/as5812-54x/modules/accton_as5812_54x_sfp.c b/platform/broadcom/sonic-platform-modules-accton/as5812-54x/modules/accton_as5812_54x_sfp.c index 10841c1d22e4..61cfed4eae14 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as5812-54x/modules/accton_as5812_54x_sfp.c +++ b/platform/broadcom/sonic-platform-modules-accton/as5812-54x/modules/accton_as5812_54x_sfp.c @@ -498,7 +498,7 @@ static int as5812_54x_sfp_probe(struct i2c_client *client, return status; } -static int as5812_54x_sfp_remove(struct i2c_client *client) +static void as5812_54x_sfp_remove(struct i2c_client *client) { struct as5812_54x_sfp_data *data = i2c_get_clientdata(client); @@ -506,7 +506,6 @@ static int as5812_54x_sfp_remove(struct i2c_client *client) sysfs_remove_group(&client->dev.kobj, &as5812_54x_sfp_group); kfree(data); - return 0; } enum port_numbers { diff --git a/platform/broadcom/sonic-platform-modules-accton/as5812-54x/modules/cpr_4011_4mxx.c b/platform/broadcom/sonic-platform-modules-accton/as5812-54x/modules/cpr_4011_4mxx.c index 30bea914d589..cdacf7d7e87b 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as5812-54x/modules/cpr_4011_4mxx.c +++ b/platform/broadcom/sonic-platform-modules-accton/as5812-54x/modules/cpr_4011_4mxx.c @@ -267,7 +267,7 @@ static int cpr_4011_4mxx_probe(struct i2c_client *client, return status; } -static int cpr_4011_4mxx_remove(struct i2c_client *client) +static void cpr_4011_4mxx_remove(struct i2c_client *client) { struct cpr_4011_4mxx_data *data = i2c_get_clientdata(client); @@ -275,7 +275,6 @@ static int cpr_4011_4mxx_remove(struct i2c_client *client) sysfs_remove_group(&client->dev.kobj, &cpr_4011_4mxx_group); kfree(data); - return 0; } static const struct i2c_device_id cpr_4011_4mxx_id[] = { diff --git a/platform/broadcom/sonic-platform-modules-accton/as5812-54x/modules/i2c-mux-accton_as5812_54x_cpld.c b/platform/broadcom/sonic-platform-modules-accton/as5812-54x/modules/i2c-mux-accton_as5812_54x_cpld.c index 1578d75bdd92..8d96352246c9 100644 --- a/platform/broadcom/sonic-platform-modules-accton/as5812-54x/modules/i2c-mux-accton_as5812_54x_cpld.c +++ b/platform/broadcom/sonic-platform-modules-accton/as5812-54x/modules/i2c-mux-accton_as5812_54x_cpld.c @@ -1277,7 +1277,7 @@ static int as5812_54x_cpld_mux_probe(struct i2c_client *client, return ret; } -static int as5812_54x_cpld_mux_remove(struct i2c_client *client) +static void as5812_54x_cpld_mux_remove(struct i2c_client *client) { struct i2c_mux_core *muxc = i2c_get_clientdata(client); struct as5812_54x_cpld_data *data = i2c_mux_priv(muxc); @@ -1306,7 +1306,6 @@ static int as5812_54x_cpld_mux_remove(struct i2c_client *client) i2c_mux_del_adapters(muxc); - return 0; } static int as5812_54x_cpld_read_internal(struct i2c_client *client, u8 reg) diff --git a/platform/broadcom/sonic-platform-modules-accton/as5812-54x/modules/ym2651y.c b/platform/broadcom/sonic-platform-modules-accton/as5812-54x/modules/ym2651y.c index 519530387e29..3a5a1e73a480 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as5812-54x/modules/ym2651y.c +++ b/platform/broadcom/sonic-platform-modules-accton/as5812-54x/modules/ym2651y.c @@ -466,7 +466,7 @@ static int ym2651y_probe(struct i2c_client *client, return status; } -static int ym2651y_remove(struct i2c_client *client) +static void ym2651y_remove(struct i2c_client *client) { struct ym2651y_data *data = i2c_get_clientdata(client); @@ -474,7 +474,6 @@ static int ym2651y_remove(struct i2c_client *client) sysfs_remove_group(&client->dev.kobj, &ym2651y_group); kfree(data); - return 0; } static const struct i2c_device_id ym2651y_id[] = { diff --git a/platform/broadcom/sonic-platform-modules-accton/as5835-54t/classes/fanutil.py b/platform/broadcom/sonic-platform-modules-accton/as5835-54t/classes/fanutil.py index e60236c9c781..a618f1f9df68 100644 --- a/platform/broadcom/sonic-platform-modules-accton/as5835-54t/classes/fanutil.py +++ b/platform/broadcom/sonic-platform-modules-accton/as5835-54t/classes/fanutil.py @@ -104,7 +104,7 @@ def _get_fan_node_val(self, fan_num, node_num): return None try: - val_file.close() + val_file.close() except: logging.debug('GET. unable to close file. device_path:%s', device_path) return None @@ -135,7 +135,7 @@ def _set_fan_node_val(self, fan_num, node_num, val): val_file.write(content) try: - val_file.close() + val_file.close() except: logging.debug('GET. unable to close file. device_path:%s', device_path) return None @@ -174,14 +174,11 @@ def get_fan_to_device_path(self, fan_num, node_num): def get_fan_fault(self, fan_num): return self._get_fan_node_val(fan_num, self.FAN_NODE_FAULT_IDX_OF_MAP) - #def get_fan_speed(self, fan_num): - # return self._get_fan_node_val(fan_num, self.FAN_NODE_SPEED_IDX_OF_MAP) - def get_fan_dir(self, fan_num): return self._get_fan_node_val(fan_num, self.FAN_NODE_DIR_IDX_OF_MAP) def get_fan_duty_cycle(self): - #duty_path = self.FAN_DUTY_PATH + try: val_file = open(self.FAN_DUTY_PATH) except IOError as e: @@ -203,9 +200,6 @@ def set_fan_duty_cycle(self, val): fan_file.close() return True - #def get_fanr_fault(self, fan_num): - # return self._get_fan_node_val(fan_num, self.FANR_NODE_FAULT_IDX_OF_MAP) - def get_fanr_speed(self, fan_num): return self._get_fan_node_val(fan_num, self.FANR_NODE_SPEED_IDX_OF_MAP) @@ -218,20 +212,6 @@ def get_fan_status(self, fan_num): logging.debug('GET. FAN fault. fan_num, %d', fan_num) return False - #if self.get_fanr_fault(fan_num) is not None and self.get_fanr_fault(fan_num) > 0: - # logging.debug('GET. FANR fault. fan_num, %d', fan_num) - # return False return True -#def main(): -# fan = FanUtil() -# -# print 'get_size_node_map : %d' % fan.get_size_node_map() -# print 'get_size_path_map : %d' % fan.get_size_path_map() -# for x in range(fan.get_idx_fan_start(), fan.get_num_fans()+1): -# for y in range(fan.get_idx_node_start(), fan.get_num_nodes()+1): -# print fan.get_fan_to_device_path(x, y) -# -#if __name__ == '__main__': -# main() diff --git a/platform/broadcom/sonic-platform-modules-accton/as5835-54t/classes/thermalutil.py b/platform/broadcom/sonic-platform-modules-accton/as5835-54t/classes/thermalutil.py index 00e5bfa25683..3569b95f8f69 100644 --- a/platform/broadcom/sonic-platform-modules-accton/as5835-54t/classes/thermalutil.py +++ b/platform/broadcom/sonic-platform-modules-accton/as5835-54t/classes/thermalutil.py @@ -76,10 +76,11 @@ def _get_thermal_val(self, thermal_num): logging.debug('GET. content is NULL. device_path:%s', device_path) return None try: - val_file.close() + val_file.close() except: logging.debug('GET. unable to close file. device_path:%s', device_path) - return None + return None + return int(content) else: @@ -113,17 +114,3 @@ def get_thermal_3_val(self): def get_thermal_temp(self): return (self._get_thermal_val(self.THERMAL_NUM_1_IDX) + self._get_thermal_val(self.THERMAL_NUM_2_IDX) +self._get_thermal_val(self.THERMAL_NUM_3_IDX)) -def main(): - thermal = ThermalUtil() - print("termal1=%d" %thermal._get_thermal_val(1)) - print("termal2=%d" %thermal._get_thermal_val(2)) - print("termal3=%d" %thermal._get_thermal_val(3)) - print("termal4=%d" %thermal._get_thermal_val(4)) -# -# print 'get_size_node_map : %d' % thermal.get_size_node_map() -# print 'get_size_path_map : %d' % thermal.get_size_path_map() -# for x in range(thermal.get_idx_thermal_start(), thermal.get_num_thermals()+1): -# print thermal.get_thermal_to_device_path(x) -# -if __name__ == '__main__': - main() \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-accton/as5835-54t/modules/accton_as5835_54t_cpld.c b/platform/broadcom/sonic-platform-modules-accton/as5835-54t/modules/accton_as5835_54t_cpld.c index 9765fd430432..7e9a3eb06b9b 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as5835-54t/modules/accton_as5835_54t_cpld.c +++ b/platform/broadcom/sonic-platform-modules-accton/as5835-54t/modules/accton_as5835_54t_cpld.c @@ -462,7 +462,7 @@ static int as5835_54t_cpld_probe(struct i2c_client *client, return ret; } -static int as5835_54t_cpld_remove(struct i2c_client *client) +static void as5835_54t_cpld_remove(struct i2c_client *client) { struct as5835_54t_cpld_data *data = i2c_get_clientdata(client); const struct attribute_group *group = NULL; @@ -490,7 +490,6 @@ static int as5835_54t_cpld_remove(struct i2c_client *client) kfree(data); - return 0; } static int as5835_54t_cpld_read_internal(struct i2c_client *client, u8 reg) diff --git a/platform/broadcom/sonic-platform-modules-accton/as5835-54t/modules/accton_as5835_54t_fan.c b/platform/broadcom/sonic-platform-modules-accton/as5835-54t/modules/accton_as5835_54t_fan.c index ea6fdb8296c9..7e52ab2b17b4 100644 --- a/platform/broadcom/sonic-platform-modules-accton/as5835-54t/modules/accton_as5835_54t_fan.c +++ b/platform/broadcom/sonic-platform-modules-accton/as5835-54t/modules/accton_as5835_54t_fan.c @@ -447,13 +447,12 @@ static int as5835_54t_fan_probe(struct i2c_client *client, return status; } -static int as5835_54t_fan_remove(struct i2c_client *client) +static void as5835_54t_fan_remove(struct i2c_client *client) { struct as5835_54t_fan_data *data = i2c_get_clientdata(client); hwmon_device_unregister(data->hwmon_dev); sysfs_remove_group(&client->dev.kobj, &as5835_54t_fan_group); - return 0; } /* Addresses to scan */ diff --git a/platform/broadcom/sonic-platform-modules-accton/as5835-54t/modules/accton_as5835_54t_psu.c b/platform/broadcom/sonic-platform-modules-accton/as5835-54t/modules/accton_as5835_54t_psu.c index 78f0b4298a58..a52f543f2357 100644 --- a/platform/broadcom/sonic-platform-modules-accton/as5835-54t/modules/accton_as5835_54t_psu.c +++ b/platform/broadcom/sonic-platform-modules-accton/as5835-54t/modules/accton_as5835_54t_psu.c @@ -189,7 +189,7 @@ static int as5835_54t_psu_probe(struct i2c_client *client, return status; } -static int as5835_54t_psu_remove(struct i2c_client *client) +static void as5835_54t_psu_remove(struct i2c_client *client) { struct as5835_54t_psu_data *data = i2c_get_clientdata(client); @@ -197,7 +197,6 @@ static int as5835_54t_psu_remove(struct i2c_client *client) sysfs_remove_group(&client->dev.kobj, &as5835_54t_psu_group); kfree(data); - return 0; } enum psu_index diff --git a/platform/broadcom/sonic-platform-modules-accton/as5835-54x/classes/fanutil.py b/platform/broadcom/sonic-platform-modules-accton/as5835-54x/classes/fanutil.py index b8b4820f9e4a..1869e5da40d5 100644 --- a/platform/broadcom/sonic-platform-modules-accton/as5835-54x/classes/fanutil.py +++ b/platform/broadcom/sonic-platform-modules-accton/as5835-54x/classes/fanutil.py @@ -174,14 +174,10 @@ def get_fan_to_device_path(self, fan_num, node_num): def get_fan_fault(self, fan_num): return self._get_fan_node_val(fan_num, self.FAN_NODE_FAULT_IDX_OF_MAP) - #def get_fan_speed(self, fan_num): - # return self._get_fan_node_val(fan_num, self.FAN_NODE_SPEED_IDX_OF_MAP) - def get_fan_dir(self, fan_num): return self._get_fan_node_val(fan_num, self.FAN_NODE_DIR_IDX_OF_MAP) def get_fan_duty_cycle(self): - #duty_path = self.FAN_DUTY_PATH try: val_file = open(self.FAN_DUTY_PATH) except IOError as e: @@ -203,8 +199,6 @@ def set_fan_duty_cycle(self, val): fan_file.close() return True - #def get_fanr_fault(self, fan_num): - # return self._get_fan_node_val(fan_num, self.FANR_NODE_FAULT_IDX_OF_MAP) def get_fanr_speed(self, fan_num): return self._get_fan_node_val(fan_num, self.FANR_NODE_SPEED_IDX_OF_MAP) @@ -218,9 +212,5 @@ def get_fan_status(self, fan_num): logging.debug('GET. FAN fault. fan_num, %d', fan_num) return False - #if self.get_fanr_fault(fan_num) is not None and self.get_fanr_fault(fan_num) > 0: - # logging.debug('GET. FANR fault. fan_num, %d', fan_num) - # return False - return True diff --git a/platform/broadcom/sonic-platform-modules-accton/as5835-54x/modules/accton_as5835_54x_cpld.c b/platform/broadcom/sonic-platform-modules-accton/as5835-54x/modules/accton_as5835_54x_cpld.c index 97b7d879f03a..f4da03ac1165 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as5835-54x/modules/accton_as5835_54x_cpld.c +++ b/platform/broadcom/sonic-platform-modules-accton/as5835-54x/modules/accton_as5835_54x_cpld.c @@ -1055,7 +1055,7 @@ static int as5835_54x_cpld_probe(struct i2c_client *client, return ret; } -static int as5835_54x_cpld_remove(struct i2c_client *client) +static void as5835_54x_cpld_remove(struct i2c_client *client) { struct as5835_54x_cpld_data *data = i2c_get_clientdata(client); const struct attribute_group *group = NULL; @@ -1083,7 +1083,6 @@ static int as5835_54x_cpld_remove(struct i2c_client *client) kfree(data); - return 0; } static int as5835_54x_cpld_read_internal(struct i2c_client *client, u8 reg) diff --git a/platform/broadcom/sonic-platform-modules-accton/as5835-54x/modules/accton_as5835_54x_fan.c b/platform/broadcom/sonic-platform-modules-accton/as5835-54x/modules/accton_as5835_54x_fan.c index 45b8d0d9840f..6d4ac73f651c 100644 --- a/platform/broadcom/sonic-platform-modules-accton/as5835-54x/modules/accton_as5835_54x_fan.c +++ b/platform/broadcom/sonic-platform-modules-accton/as5835-54x/modules/accton_as5835_54x_fan.c @@ -447,13 +447,12 @@ static int as5835_54x_fan_probe(struct i2c_client *client, return status; } -static int as5835_54x_fan_remove(struct i2c_client *client) +static void as5835_54x_fan_remove(struct i2c_client *client) { struct as5835_54x_fan_data *data = i2c_get_clientdata(client); hwmon_device_unregister(data->hwmon_dev); sysfs_remove_group(&client->dev.kobj, &as5835_54x_fan_group); - return 0; } /* Addresses to scan */ diff --git a/platform/broadcom/sonic-platform-modules-accton/as5835-54x/modules/accton_as5835_54x_psu.c b/platform/broadcom/sonic-platform-modules-accton/as5835-54x/modules/accton_as5835_54x_psu.c index 00b43829e32f..b07216c1c162 100644 --- a/platform/broadcom/sonic-platform-modules-accton/as5835-54x/modules/accton_as5835_54x_psu.c +++ b/platform/broadcom/sonic-platform-modules-accton/as5835-54x/modules/accton_as5835_54x_psu.c @@ -189,7 +189,7 @@ static int as5835_54x_psu_probe(struct i2c_client *client, return status; } -static int as5835_54x_psu_remove(struct i2c_client *client) +static void as5835_54x_psu_remove(struct i2c_client *client) { struct as5835_54x_psu_data *data = i2c_get_clientdata(client); @@ -197,7 +197,6 @@ static int as5835_54x_psu_remove(struct i2c_client *client) sysfs_remove_group(&client->dev.kobj, &as5835_54x_psu_group); kfree(data); - return 0; } enum psu_index diff --git a/platform/broadcom/sonic-platform-modules-accton/as6712-32x/classes/fanutil.py b/platform/broadcom/sonic-platform-modules-accton/as6712-32x/classes/fanutil.py index 20d604ab4a3a..ef87dc9961ea 100644 --- a/platform/broadcom/sonic-platform-modules-accton/as6712-32x/classes/fanutil.py +++ b/platform/broadcom/sonic-platform-modules-accton/as6712-32x/classes/fanutil.py @@ -43,13 +43,8 @@ class FanUtil(object): FAN_NODE_NUM_OF_MAP = 2 FAN_NODE_FAULT_IDX_OF_MAP = 1 - #FAN_NODE_SPEED_IDX_OF_MAP = 2 FAN_NODE_DIR_IDX_OF_MAP = 2 - #FAN_NODE_DUTY_IDX_OF_MAP = 4 - #FANR_NODE_FAULT_IDX_OF_MAP = 5 - #BASE_VAL_PATH = '/sys/bus/i2c/devices/11-0066/{0}' - #FAN_DUTY_PATH = '/sys/bus/i2c/devices/11-0066/fan_duty_cycle_percentage' BASE_VAL_PATH = '/sys/devices/platform/as6712_32x_fan/{0}' FAN_DUTY_PATH = '/sys/devices/platform/as6712_32x_fan/fan1_duty_cycle_percentage' @@ -66,7 +61,7 @@ class FanUtil(object): #fan1_fault #fan1_present - #(FAN_NUM_2_IDX, FAN_NODE_DUTY_IDX_OF_MAP): 'fan2_duty_cycle_percentage', + _fan_to_device_node_mapping = { (FAN_NUM_1_IDX, FAN_NODE_FAULT_IDX_OF_MAP): 'fan1_fault', (FAN_NUM_1_IDX, FAN_NODE_DIR_IDX_OF_MAP): 'fan1_direction', @@ -112,7 +107,7 @@ def _get_fan_node_val(self, fan_num, node_num): return None try: - val_file.close() + val_file.close() except: logging.debug('GET. unable to close file. device_path:%s', device_path) return None @@ -143,7 +138,7 @@ def _set_fan_node_val(self, fan_num, node_num, val): val_file.write(content) try: - val_file.close() + val_file.close() except: logging.debug('GET. unable to close file. device_path:%s', device_path) return None @@ -182,14 +177,11 @@ def get_fan_to_device_path(self, fan_num, node_num): def get_fan_fault(self, fan_num): return self._get_fan_node_val(fan_num, self.FAN_NODE_FAULT_IDX_OF_MAP) - #def get_fan_speed(self, fan_num): - # return self._get_fan_node_val(fan_num, self.FAN_NODE_SPEED_IDX_OF_MAP) - def get_fan_dir(self, fan_num): return self._get_fan_node_val(fan_num, self.FAN_NODE_DIR_IDX_OF_MAP) def get_fan_duty_cycle(self): - #duty_path = self.FAN_DUTY_PATH + try: val_file = open(self.FAN_DUTY_PATH) except IOError as e: @@ -200,13 +192,7 @@ def get_fan_duty_cycle(self): val_file.close() return int(content) - #self._get_fan_node_val(fan_num, self.FAN_NODE_DUTY_IDX_OF_MAP) -#static u32 reg_val_to_duty_cycle(u8 reg_val) -#{ -# reg_val &= FAN_DUTY_CYCLE_REG_MASK; -# return ((u32)(reg_val+1) * 625 + 75)/ 100; -#} -# + def set_fan_duty_cycle(self, val): try: @@ -214,13 +200,11 @@ def set_fan_duty_cycle(self, val): except IOError as e: print("Error: unable to open file: %s" % str(e)) return False - #val = ((val + 1 ) * 625 +75 ) / 100 + fan_file.write(str(val)) fan_file.close() return True - #def get_fanr_fault(self, fan_num): - # return self._get_fan_node_val(fan_num, self.FANR_NODE_FAULT_IDX_OF_MAP) def get_fanr_speed(self, fan_num): return self._get_fan_node_val(fan_num, self.FANR_NODE_SPEED_IDX_OF_MAP) @@ -234,20 +218,5 @@ def get_fan_status(self, fan_num): logging.debug('GET. FAN fault. fan_num, %d', fan_num) return False - #if self.get_fanr_fault(fan_num) is not None and self.get_fanr_fault(fan_num) > 0: - # logging.debug('GET. FANR fault. fan_num, %d', fan_num) - # return False - return True -#def main(): -# fan = FanUtil() -# -# print 'get_size_node_map : %d' % fan.get_size_node_map() -# print 'get_size_path_map : %d' % fan.get_size_path_map() -# for x in range(fan.get_idx_fan_start(), fan.get_num_fans()+1): -# for y in range(fan.get_idx_node_start(), fan.get_num_nodes()+1): -# print fan.get_fan_to_device_path(x, y) -# -#if __name__ == '__main__': -# main() diff --git a/platform/broadcom/sonic-platform-modules-accton/as6712-32x/classes/thermalutil.py b/platform/broadcom/sonic-platform-modules-accton/as6712-32x/classes/thermalutil.py index 8fdb01ecc564..1056332a12fe 100644 --- a/platform/broadcom/sonic-platform-modules-accton/as6712-32x/classes/thermalutil.py +++ b/platform/broadcom/sonic-platform-modules-accton/as6712-32x/classes/thermalutil.py @@ -74,19 +74,21 @@ def _get_thermal_node_val(self, thermal_num): logging.error('GET. unable to open file: %s', str(e)) return None - content = val_file.readline().rstrip() + content = val_file.readline().rstrip() - if content == '': - logging.debug('GET. content is NULL. device_path:%s', device_path) - return None + if content == '': + logging.debug('GET. content is NULL. device_path:%s', device_path) + return None - try: - val_file.close() - except: - logging.debug('GET. unable to close file. device_path:%s', device_path) - return None + try: + val_file.close() + except: + logging.debug('GET. unable to close file. device_path:%s', device_path) + return None - return int(content) + return int(content) + + return 0 def get_num_thermals(self): @@ -112,13 +114,3 @@ def get_thermal_2_val(self): def get_thermal_temp(self): return (self._get_thermal_node_val(self.THERMAL_NUM_1_IDX) + self._get_thermal_node_val(self.THERMAL_NUM_2_IDX) +self._get_thermal_node_val(self.THERMAL_NUM_3_IDX)) -#def main(): -# thermal = ThermalUtil() -# -# print 'get_size_node_map : %d' % thermal.get_size_node_map() -# print 'get_size_path_map : %d' % thermal.get_size_path_map() -# for x in range(thermal.get_idx_thermal_start(), thermal.get_num_thermals()+1): -# print thermal.get_thermal_to_device_path(x) -# -#if __name__ == '__main__': -# main() diff --git a/platform/broadcom/sonic-platform-modules-accton/as6712-32x/modules/accton-as6712-32x-cpld.c b/platform/broadcom/sonic-platform-modules-accton/as6712-32x/modules/accton-as6712-32x-cpld.c index 0c86cb94711c..33b57c939507 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as6712-32x/modules/accton-as6712-32x-cpld.c +++ b/platform/broadcom/sonic-platform-modules-accton/as6712-32x/modules/accton-as6712-32x-cpld.c @@ -721,7 +721,7 @@ static int as6712_32x_cpld_mux_probe(struct i2c_client *client, return ret; } -static int as6712_32x_cpld_mux_remove(struct i2c_client *client) +static void as6712_32x_cpld_mux_remove(struct i2c_client *client) { struct i2c_mux_core *muxc = i2c_get_clientdata(client); struct as6712_32x_cpld_data *data = i2c_mux_priv(muxc); @@ -750,7 +750,6 @@ static int as6712_32x_cpld_mux_remove(struct i2c_client *client) i2c_mux_del_adapters(muxc); - return 0; } static int as6712_32x_cpld_read_internal(struct i2c_client *client, u8 reg) diff --git a/platform/broadcom/sonic-platform-modules-accton/as6712-32x/modules/accton_as6712_32x_psu.c b/platform/broadcom/sonic-platform-modules-accton/as6712-32x/modules/accton_as6712_32x_psu.c index 5b9eda261489..9ae5755956f9 100644 --- a/platform/broadcom/sonic-platform-modules-accton/as6712-32x/modules/accton_as6712_32x_psu.c +++ b/platform/broadcom/sonic-platform-modules-accton/as6712-32x/modules/accton_as6712_32x_psu.c @@ -188,7 +188,7 @@ static int as6712_32x_psu_probe(struct i2c_client *client, return status; } -static int as6712_32x_psu_remove(struct i2c_client *client) +static void as6712_32x_psu_remove(struct i2c_client *client) { struct as6712_32x_psu_data *data = i2c_get_clientdata(client); @@ -196,7 +196,6 @@ static int as6712_32x_psu_remove(struct i2c_client *client) sysfs_remove_group(&client->dev.kobj, &as6712_32x_psu_group); kfree(data); - return 0; } enum psu_index diff --git a/platform/broadcom/sonic-platform-modules-accton/as6712-32x/modules/cpr_4011_4mxx.c b/platform/broadcom/sonic-platform-modules-accton/as6712-32x/modules/cpr_4011_4mxx.c index 15cef4ef50d7..b18cba8c9db8 100644 --- a/platform/broadcom/sonic-platform-modules-accton/as6712-32x/modules/cpr_4011_4mxx.c +++ b/platform/broadcom/sonic-platform-modules-accton/as6712-32x/modules/cpr_4011_4mxx.c @@ -300,7 +300,7 @@ static int cpr_4011_4mxx_probe(struct i2c_client *client, return status; } -static int cpr_4011_4mxx_remove(struct i2c_client *client) +static void cpr_4011_4mxx_remove(struct i2c_client *client) { struct cpr_4011_4mxx_data *data = i2c_get_clientdata(client); @@ -308,7 +308,6 @@ static int cpr_4011_4mxx_remove(struct i2c_client *client) sysfs_remove_group(&client->dev.kobj, &cpr_4011_4mxx_group); kfree(data); - return 0; } static const struct i2c_device_id cpr_4011_4mxx_id[] = { diff --git a/platform/broadcom/sonic-platform-modules-accton/as7312-54x/modules/accton_as7312_54x_fan.c b/platform/broadcom/sonic-platform-modules-accton/as7312-54x/modules/accton_as7312_54x_fan.c index 9e7be492b734..8eceeef0d2a9 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as7312-54x/modules/accton_as7312_54x_fan.c +++ b/platform/broadcom/sonic-platform-modules-accton/as7312-54x/modules/accton_as7312_54x_fan.c @@ -498,13 +498,12 @@ static int as7312_54x_fan_probe(struct i2c_client *client, return status; } -static int as7312_54x_fan_remove(struct i2c_client *client) +static void as7312_54x_fan_remove(struct i2c_client *client) { struct as7312_54x_fan_data *data = i2c_get_clientdata(client); hwmon_device_unregister(data->hwmon_dev); sysfs_remove_group(&client->dev.kobj, &as7312_54x_fan_group); - return 0; } /* Addresses to scan */ diff --git a/platform/broadcom/sonic-platform-modules-accton/as7312-54x/modules/accton_as7312_54x_psu.c b/platform/broadcom/sonic-platform-modules-accton/as7312-54x/modules/accton_as7312_54x_psu.c index 4646224ef903..049c3dfa3208 100644 --- a/platform/broadcom/sonic-platform-modules-accton/as7312-54x/modules/accton_as7312_54x_psu.c +++ b/platform/broadcom/sonic-platform-modules-accton/as7312-54x/modules/accton_as7312_54x_psu.c @@ -155,7 +155,7 @@ static int as7312_54x_psu_probe(struct i2c_client *client, return status; } -static int as7312_54x_psu_remove(struct i2c_client *client) +static void as7312_54x_psu_remove(struct i2c_client *client) { struct as7312_54x_psu_data *data = i2c_get_clientdata(client); @@ -163,7 +163,6 @@ static int as7312_54x_psu_remove(struct i2c_client *client) sysfs_remove_group(&client->dev.kobj, &as7312_54x_psu_group); kfree(data); - return 0; } enum psu_index diff --git a/platform/broadcom/sonic-platform-modules-accton/as7312-54x/modules/accton_as7312_54x_sfp.c b/platform/broadcom/sonic-platform-modules-accton/as7312-54x/modules/accton_as7312_54x_sfp.c index 921d9f892cac..5261686874d2 100644 --- a/platform/broadcom/sonic-platform-modules-accton/as7312-54x/modules/accton_as7312_54x_sfp.c +++ b/platform/broadcom/sonic-platform-modules-accton/as7312-54x/modules/accton_as7312_54x_sfp.c @@ -1919,7 +1919,7 @@ static int qfp_remove(struct i2c_client *client, struct qsfp_data *data) return 0; } -static int sfp_device_remove(struct i2c_client *client) +static void sfp_device_remove(struct i2c_client *client) { int ret = 0; struct sfp_port_data *data = i2c_get_clientdata(client); @@ -1936,7 +1936,6 @@ static int sfp_device_remove(struct i2c_client *client) kfree(data->writebuf); #endif kfree(data); - return ret; } /* Addresses scanned diff --git a/platform/broadcom/sonic-platform-modules-accton/as7312-54x/modules/accton_i2c_cpld.c b/platform/broadcom/sonic-platform-modules-accton/as7312-54x/modules/accton_i2c_cpld.c index 67ecd8e036a9..5900dfb10dec 100644 --- a/platform/broadcom/sonic-platform-modules-accton/as7312-54x/modules/accton_i2c_cpld.c +++ b/platform/broadcom/sonic-platform-modules-accton/as7312-54x/modules/accton_i2c_cpld.c @@ -1074,7 +1074,7 @@ static int as7312_54x_cpld_probe(struct i2c_client *client, return ret; } -static int as7312_54x_cpld_remove(struct i2c_client *client) +static void as7312_54x_cpld_remove(struct i2c_client *client) { struct as7312_54x_cpld_data *data = i2c_get_clientdata(client); const struct attribute_group *group = NULL; @@ -1102,7 +1102,6 @@ static int as7312_54x_cpld_remove(struct i2c_client *client) kfree(data); - return 0; } static int as7312_54x_cpld_read_internal(struct i2c_client *client, u8 reg) diff --git a/platform/broadcom/sonic-platform-modules-accton/as7312-54xs/classes/fanutil.py b/platform/broadcom/sonic-platform-modules-accton/as7312-54xs/classes/fanutil.py index 22424c74c5c6..2cab43928a70 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as7312-54xs/classes/fanutil.py +++ b/platform/broadcom/sonic-platform-modules-accton/as7312-54xs/classes/fanutil.py @@ -44,12 +44,8 @@ class FanUtil(object): FAN_NODE_NUM_OF_MAP = 2 FAN_NODE_FAULT_IDX_OF_MAP = 1 - #FAN_NODE_SPEED_IDX_OF_MAP = 2 FAN_NODE_DIR_IDX_OF_MAP = 2 - #FAN_NODE_DUTY_IDX_OF_MAP = 4 - #FANR_NODE_FAULT_IDX_OF_MAP = 5 - #BASE_VAL_PATH = '/sys/devices/platform/as5712_54x_fan/{0}' BASE_VAL_PATH = '/sys/bus/i2c/devices/2-0066/{0}' FAN_DUTY_PATH = '/sys/bus/i2c/devices/2-0066/fan_duty_cycle_percentage' @@ -68,7 +64,7 @@ class FanUtil(object): #fan1_fault #fan1_present - #(FAN_NUM_2_IDX, FAN_NODE_DUTY_IDX_OF_MAP): 'fan2_duty_cycle_percentage', + _fan_to_device_node_mapping = { (FAN_NUM_1_IDX, FAN_NODE_FAULT_IDX_OF_MAP): 'fan1_fault', (FAN_NUM_1_IDX, FAN_NODE_DIR_IDX_OF_MAP): 'fan1_direction', @@ -189,14 +185,10 @@ def get_fan_to_device_path(self, fan_num, node_num): def get_fan_fault(self, fan_num): return self._get_fan_node_val(fan_num, self.FAN_NODE_FAULT_IDX_OF_MAP) - #def get_fan_speed(self, fan_num): - # return self._get_fan_node_val(fan_num, self.FAN_NODE_SPEED_IDX_OF_MAP) - def get_fan_dir(self, fan_num): return self._get_fan_node_val(fan_num, self.FAN_NODE_DIR_IDX_OF_MAP) def get_fan_duty_cycle(self): - #duty_path = self.FAN_DUTY_PATH try: val_file = open(self.FAN_DUTY_PATH) except IOError as e: @@ -207,13 +199,7 @@ def get_fan_duty_cycle(self): val_file.close() return int(content) - #self._get_fan_node_val(fan_num, self.FAN_NODE_DUTY_IDX_OF_MAP) -#static u32 reg_val_to_duty_cycle(u8 reg_val) -#{ -# reg_val &= FAN_DUTY_CYCLE_REG_MASK; -# return ((u32)(reg_val+1) * 625 + 75)/ 100; -#} -# + def set_fan_duty_cycle(self, val): try: @@ -221,13 +207,11 @@ def set_fan_duty_cycle(self, val): except IOError as e: print("Error: unable to open file: %s" % str(e)) return False - #val = ((val + 1 ) * 625 +75 ) / 100 + fan_file.write(str(val)) fan_file.close() return True - #def get_fanr_fault(self, fan_num): - # return self._get_fan_node_val(fan_num, self.FANR_NODE_FAULT_IDX_OF_MAP) def get_fanr_speed(self, fan_num): return self._get_fan_node_val(fan_num, self.FANR_NODE_SPEED_IDX_OF_MAP) @@ -243,14 +227,3 @@ def get_fan_status(self, fan_num): return True -#def main(): -# fan = FanUtil() -# -# print 'get_size_node_map : %d' % fan.get_size_node_map() -# print 'get_size_path_map : %d' % fan.get_size_path_map() -# for x in range(fan.get_idx_fan_start(), fan.get_num_fans()+1): -# for y in range(fan.get_idx_node_start(), fan.get_num_nodes()+1): -# print fan.get_fan_to_device_path(x, y) -# -#if __name__ == '__main__': -# main() diff --git a/platform/broadcom/sonic-platform-modules-accton/as7312-54xs/classes/thermalutil.py b/platform/broadcom/sonic-platform-modules-accton/as7312-54xs/classes/thermalutil.py index ddc3521fafac..cbd5edcffca6 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as7312-54xs/classes/thermalutil.py +++ b/platform/broadcom/sonic-platform-modules-accton/as7312-54xs/classes/thermalutil.py @@ -78,20 +78,21 @@ def _get_thermal_node_val(self, thermal_num): self.logger.error('GET. unable to open file: %s', str(e)) return None - content = val_file.readline().rstrip() + content = val_file.readline().rstrip() - if content == '': - self.logger.debug('GET. content is NULL. device_path:%s', device_path) + if content == '': + self.logger.debug('GET. content is NULL. device_path:%s', device_path) return None - try: - val_file.close() - except: - self.logger.debug('GET. unable to close file. device_path:%s', device_path) - return None + try: + val_file.close() + except: + self.logger.debug('GET. unable to close file. device_path:%s', device_path) + return None - return int(content) + return int(content) + return 0 def get_num_thermals(self): return self.THERMAL_NUM_ON_MAIN_BROAD @@ -116,13 +117,3 @@ def get_thermal_2_val(self): def get_thermal_temp(self): return (self._get_thermal_node_val(self.THERMAL_NUM_1_IDX) + self._get_thermal_node_val(self.THERMAL_NUM_2_IDX) +self._get_thermal_node_val(self.THERMAL_NUM_3_IDX)) -#def main(): -# thermal = ThermalUtil() -# -# print 'get_size_node_map : %d' % thermal.get_size_node_map() -# print 'get_size_path_map : %d' % thermal.get_size_path_map() -# for x in range(thermal.get_idx_thermal_start(), thermal.get_num_thermals()+1): -# print thermal.get_thermal_to_device_path(x) -# -#if __name__ == '__main__': -# main() diff --git a/platform/broadcom/sonic-platform-modules-accton/as7312-54xs/modules/accton_as7312_54x_fan.c b/platform/broadcom/sonic-platform-modules-accton/as7312-54xs/modules/accton_as7312_54x_fan.c index 1a32c57f28e9..b0a6ad0630f4 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as7312-54xs/modules/accton_as7312_54x_fan.c +++ b/platform/broadcom/sonic-platform-modules-accton/as7312-54xs/modules/accton_as7312_54x_fan.c @@ -496,13 +496,12 @@ static int as7312_54x_fan_probe(struct i2c_client *client, return status; } -static int as7312_54x_fan_remove(struct i2c_client *client) +static void as7312_54x_fan_remove(struct i2c_client *client) { struct as7312_54x_fan_data *data = i2c_get_clientdata(client); hwmon_device_unregister(data->hwmon_dev); sysfs_remove_group(&client->dev.kobj, &as7312_54x_fan_group); - return 0; } /* Addresses to scan */ diff --git a/platform/broadcom/sonic-platform-modules-accton/as7312-54xs/modules/accton_as7312_54x_psu.c b/platform/broadcom/sonic-platform-modules-accton/as7312-54xs/modules/accton_as7312_54x_psu.c index 4646224ef903..049c3dfa3208 100644 --- a/platform/broadcom/sonic-platform-modules-accton/as7312-54xs/modules/accton_as7312_54x_psu.c +++ b/platform/broadcom/sonic-platform-modules-accton/as7312-54xs/modules/accton_as7312_54x_psu.c @@ -155,7 +155,7 @@ static int as7312_54x_psu_probe(struct i2c_client *client, return status; } -static int as7312_54x_psu_remove(struct i2c_client *client) +static void as7312_54x_psu_remove(struct i2c_client *client) { struct as7312_54x_psu_data *data = i2c_get_clientdata(client); @@ -163,7 +163,6 @@ static int as7312_54x_psu_remove(struct i2c_client *client) sysfs_remove_group(&client->dev.kobj, &as7312_54x_psu_group); kfree(data); - return 0; } enum psu_index diff --git a/platform/broadcom/sonic-platform-modules-accton/as7312-54xs/modules/accton_as7312_54x_sfp.c b/platform/broadcom/sonic-platform-modules-accton/as7312-54xs/modules/accton_as7312_54x_sfp.c index 921d9f892cac..5261686874d2 100644 --- a/platform/broadcom/sonic-platform-modules-accton/as7312-54xs/modules/accton_as7312_54x_sfp.c +++ b/platform/broadcom/sonic-platform-modules-accton/as7312-54xs/modules/accton_as7312_54x_sfp.c @@ -1919,7 +1919,7 @@ static int qfp_remove(struct i2c_client *client, struct qsfp_data *data) return 0; } -static int sfp_device_remove(struct i2c_client *client) +static void sfp_device_remove(struct i2c_client *client) { int ret = 0; struct sfp_port_data *data = i2c_get_clientdata(client); @@ -1936,7 +1936,6 @@ static int sfp_device_remove(struct i2c_client *client) kfree(data->writebuf); #endif kfree(data); - return ret; } /* Addresses scanned diff --git a/platform/broadcom/sonic-platform-modules-accton/as7312-54xs/modules/accton_i2c_cpld.c b/platform/broadcom/sonic-platform-modules-accton/as7312-54xs/modules/accton_i2c_cpld.c index 67ecd8e036a9..5900dfb10dec 100644 --- a/platform/broadcom/sonic-platform-modules-accton/as7312-54xs/modules/accton_i2c_cpld.c +++ b/platform/broadcom/sonic-platform-modules-accton/as7312-54xs/modules/accton_i2c_cpld.c @@ -1074,7 +1074,7 @@ static int as7312_54x_cpld_probe(struct i2c_client *client, return ret; } -static int as7312_54x_cpld_remove(struct i2c_client *client) +static void as7312_54x_cpld_remove(struct i2c_client *client) { struct as7312_54x_cpld_data *data = i2c_get_clientdata(client); const struct attribute_group *group = NULL; @@ -1102,7 +1102,6 @@ static int as7312_54x_cpld_remove(struct i2c_client *client) kfree(data); - return 0; } static int as7312_54x_cpld_read_internal(struct i2c_client *client, u8 reg) diff --git a/platform/broadcom/sonic-platform-modules-accton/as7315-27xb/modules/accton_as7315_27xb_fan.c b/platform/broadcom/sonic-platform-modules-accton/as7315-27xb/modules/accton_as7315_27xb_fan.c index adf8fc69ea35..f924b962f3db 100644 --- a/platform/broadcom/sonic-platform-modules-accton/as7315-27xb/modules/accton_as7315_27xb_fan.c +++ b/platform/broadcom/sonic-platform-modules-accton/as7315-27xb/modules/accton_as7315_27xb_fan.c @@ -630,14 +630,13 @@ static int fan_probe(struct i2c_client *client, } -static int fan_remove(struct i2c_client *client) +static void fan_remove(struct i2c_client *client) { struct fan_data_t *data = i2c_get_clientdata(client); hwmon_device_unregister(data->hwmon_dev); sysfs_remove_group(&client->dev.kobj, &data->group); kfree(data->group.attrs); - return 0; } diff --git a/platform/broadcom/sonic-platform-modules-accton/as7315-27xb/modules/x86-64-accton-as7315-27xb-cpld.c b/platform/broadcom/sonic-platform-modules-accton/as7315-27xb/modules/x86-64-accton-as7315-27xb-cpld.c index dcd604f1f61b..0ebeb637daf6 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as7315-27xb/modules/x86-64-accton-as7315-27xb-cpld.c +++ b/platform/broadcom/sonic-platform-modules-accton/as7315-27xb/modules/x86-64-accton-as7315-27xb-cpld.c @@ -914,7 +914,7 @@ static int as7315_i2c_cpld_probe(struct i2c_client *client, } -static int as7315_i2c_cpld_remove(struct i2c_client *client) +static void as7315_i2c_cpld_remove(struct i2c_client *client) { struct cpld_data *data = i2c_get_clientdata(client); struct i2c_mux_core *muxc = data->muxc; @@ -925,7 +925,6 @@ static int as7315_i2c_cpld_remove(struct i2c_client *client) i2c_mux_del_adapters(muxc); } accton_i2c_cpld_remove_client(client); - return 0; } int accton_i2c_cpld_read(u8 cpld_addr, u8 reg) diff --git a/platform/broadcom/sonic-platform-modules-accton/as7315-27xb/modules/x86-64-accton-as7315-27xb-psu.c b/platform/broadcom/sonic-platform-modules-accton/as7315-27xb/modules/x86-64-accton-as7315-27xb-psu.c index 1cf6313eab09..3fdbaca4376b 100644 --- a/platform/broadcom/sonic-platform-modules-accton/as7315-27xb/modules/x86-64-accton-as7315-27xb-psu.c +++ b/platform/broadcom/sonic-platform-modules-accton/as7315-27xb/modules/x86-64-accton-as7315-27xb-psu.c @@ -263,7 +263,7 @@ static int as7315_27xb_psu_probe(struct i2c_client *client, return status; } -static int as7315_27xb_psu_remove(struct i2c_client *client) +static void as7315_27xb_psu_remove(struct i2c_client *client) { struct as7315_27xb_psu_data *data = i2c_get_clientdata(client); @@ -271,7 +271,6 @@ static int as7315_27xb_psu_remove(struct i2c_client *client) sysfs_remove_group(&client->dev.kobj, &as7315_27xb_psu_group); kfree(data); - return 0; } enum psu_index diff --git a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/modules/accton_as7326_56x_fan.c b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/modules/accton_as7326_56x_fan.c index 6120760fa941..2637d485ce8f 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/modules/accton_as7326_56x_fan.c +++ b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/modules/accton_as7326_56x_fan.c @@ -497,13 +497,12 @@ static int as7326_56x_fan_probe(struct i2c_client *client, return status; } -static int as7326_56x_fan_remove(struct i2c_client *client) +static void as7326_56x_fan_remove(struct i2c_client *client) { struct as7326_56x_fan_data *data = i2c_get_clientdata(client); hwmon_device_unregister(data->hwmon_dev); sysfs_remove_group(&client->dev.kobj, &as7326_56x_fan_group); - return 0; } /* Addresses to scan */ diff --git a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/modules/accton_as7326_56x_psu.c b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/modules/accton_as7326_56x_psu.c index 8c2ece6200fe..4b7205122759 100644 --- a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/modules/accton_as7326_56x_psu.c +++ b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/modules/accton_as7326_56x_psu.c @@ -155,7 +155,7 @@ static int as7326_56x_psu_probe(struct i2c_client *client, return status; } -static int as7326_56x_psu_remove(struct i2c_client *client) +static void as7326_56x_psu_remove(struct i2c_client *client) { struct as7326_56x_psu_data *data = i2c_get_clientdata(client); @@ -163,7 +163,6 @@ static int as7326_56x_psu_remove(struct i2c_client *client) sysfs_remove_group(&client->dev.kobj, &as7326_56x_psu_group); kfree(data); - return 0; } enum psu_index diff --git a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/modules/accton_i2c_cpld.c b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/modules/accton_i2c_cpld.c index 70d9a66affdb..00467b12e147 100644 --- a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/modules/accton_i2c_cpld.c +++ b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/modules/accton_i2c_cpld.c @@ -1031,7 +1031,7 @@ static int as7326_56x_cpld_probe(struct i2c_client *client, return ret; } -static int as7326_56x_cpld_remove(struct i2c_client *client) +static void as7326_56x_cpld_remove(struct i2c_client *client) { struct as7326_56x_cpld_data *data = i2c_get_clientdata(client); const struct attribute_group *group = NULL; @@ -1059,7 +1059,6 @@ static int as7326_56x_cpld_remove(struct i2c_client *client) kfree(data); - return 0; } static int as7326_56x_cpld_read_internal(struct i2c_client *client, u8 reg) diff --git a/platform/broadcom/sonic-platform-modules-accton/as7712-32x/modules/accton_as7712_32x_fan.c b/platform/broadcom/sonic-platform-modules-accton/as7712-32x/modules/accton_as7712_32x_fan.c index 73dd36c2883e..9af08d95eeb2 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as7712-32x/modules/accton_as7712_32x_fan.c +++ b/platform/broadcom/sonic-platform-modules-accton/as7712-32x/modules/accton_as7712_32x_fan.c @@ -586,13 +586,12 @@ static int as7712_32x_fan_probe(struct i2c_client *client, return status; } -static int as7712_32x_fan_remove(struct i2c_client *client) +static void as7712_32x_fan_remove(struct i2c_client *client) { struct as7712_32x_fan_data *data = i2c_get_clientdata(client); hwmon_device_unregister(data->hwmon_dev); sysfs_remove_group(&client->dev.kobj, &as7712_32x_fan_group); - return 0; } /* Addresses to scan */ diff --git a/platform/broadcom/sonic-platform-modules-accton/as7712-32x/modules/accton_as7712_32x_psu.c b/platform/broadcom/sonic-platform-modules-accton/as7712-32x/modules/accton_as7712_32x_psu.c index 233aef78e09f..3944c87c85a0 100644 --- a/platform/broadcom/sonic-platform-modules-accton/as7712-32x/modules/accton_as7712_32x_psu.c +++ b/platform/broadcom/sonic-platform-modules-accton/as7712-32x/modules/accton_as7712_32x_psu.c @@ -155,7 +155,7 @@ static int as7712_32x_psu_probe(struct i2c_client *client, return status; } -static int as7712_32x_psu_remove(struct i2c_client *client) +static void as7712_32x_psu_remove(struct i2c_client *client) { struct as7712_32x_psu_data *data = i2c_get_clientdata(client); @@ -163,7 +163,6 @@ static int as7712_32x_psu_remove(struct i2c_client *client) sysfs_remove_group(&client->dev.kobj, &as7712_32x_psu_group); kfree(data); - return 0; } enum psu_index diff --git a/platform/broadcom/sonic-platform-modules-accton/as7712-32x/modules/accton_as7712_32x_sfp.c b/platform/broadcom/sonic-platform-modules-accton/as7712-32x/modules/accton_as7712_32x_sfp.c index 4668f5a7f050..ad35f6486e75 100644 --- a/platform/broadcom/sonic-platform-modules-accton/as7712-32x/modules/accton_as7712_32x_sfp.c +++ b/platform/broadcom/sonic-platform-modules-accton/as7712-32x/modules/accton_as7712_32x_sfp.c @@ -1126,20 +1126,19 @@ static int qfp_remove(struct i2c_client *client, struct qsfp_data *data) return 0; } -static int sfp_device_remove(struct i2c_client *client) +static void sfp_device_remove(struct i2c_client *client) { struct sfp_port_data *data = i2c_get_clientdata(client); switch (data->driver_type) { case DRIVER_TYPE_SFP_MSA: - return sfp_msa_remove(client, data->msa); + sfp_msa_remove(client, data->msa); case DRIVER_TYPE_SFP_DDM: - return sfp_ddm_remove(client, data->ddm); + sfp_ddm_remove(client, data->ddm); case DRIVER_TYPE_QSFP: - return qfp_remove(client, data->qsfp); + qfp_remove(client, data->qsfp); } - return 0; } static struct i2c_driver sfp_driver = { diff --git a/platform/broadcom/sonic-platform-modules-accton/as7716-32x/classes/fanutil.py b/platform/broadcom/sonic-platform-modules-accton/as7716-32x/classes/fanutil.py index 469b2fbfb4c3..1d2a569c001b 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as7716-32x/classes/fanutil.py +++ b/platform/broadcom/sonic-platform-modules-accton/as7716-32x/classes/fanutil.py @@ -43,12 +43,8 @@ class FanUtil(object): FAN_NODE_NUM_OF_MAP = 2 FAN_NODE_FAULT_IDX_OF_MAP = 1 - #FAN_NODE_SPEED_IDX_OF_MAP = 2 FAN_NODE_DIR_IDX_OF_MAP = 2 - #FAN_NODE_DUTY_IDX_OF_MAP = 4 - #FANR_NODE_FAULT_IDX_OF_MAP = 5 - #BASE_VAL_PATH = '/sys/devices/platform/as5712_54x_fan/{0}' BASE_VAL_PATH = '/sys/bus/i2c/devices/9-0066/{0}' FAN_DUTY_PATH = '/sys/bus/i2c/devices/9-0066/fan_duty_cycle_percentage' @@ -65,7 +61,7 @@ class FanUtil(object): #fan1_fault #fan1_present - #(FAN_NUM_2_IDX, FAN_NODE_DUTY_IDX_OF_MAP): 'fan2_duty_cycle_percentage', + _fan_to_device_node_mapping = { (FAN_NUM_1_IDX, FAN_NODE_FAULT_IDX_OF_MAP): 'fan1_fault', (FAN_NUM_1_IDX, FAN_NODE_DIR_IDX_OF_MAP): 'fan1_direction', @@ -113,7 +109,7 @@ def _get_fan_node_val(self, fan_num, node_num): return None try: - val_file.close() + val_file.close() except: logging.debug('GET. unable to close file. device_path:%s', device_path) return None @@ -144,7 +140,7 @@ def _set_fan_node_val(self, fan_num, node_num, val): val_file.write(content) try: - val_file.close() + val_file.close() except: logging.debug('GET. unable to close file. device_path:%s', device_path) return None @@ -183,14 +179,11 @@ def get_fan_to_device_path(self, fan_num, node_num): def get_fan_fault(self, fan_num): return self._get_fan_node_val(fan_num, self.FAN_NODE_FAULT_IDX_OF_MAP) - #def get_fan_speed(self, fan_num): - # return self._get_fan_node_val(fan_num, self.FAN_NODE_SPEED_IDX_OF_MAP) def get_fan_dir(self, fan_num): return self._get_fan_node_val(fan_num, self.FAN_NODE_DIR_IDX_OF_MAP) def get_fan_duty_cycle(self): - #duty_path = self.FAN_DUTY_PATH try: val_file = open(self.FAN_DUTY_PATH) except IOError as e: @@ -201,13 +194,7 @@ def get_fan_duty_cycle(self): val_file.close() return int(content) - #self._get_fan_node_val(fan_num, self.FAN_NODE_DUTY_IDX_OF_MAP) -#static u32 reg_val_to_duty_cycle(u8 reg_val) -#{ -# reg_val &= FAN_DUTY_CYCLE_REG_MASK; -# return ((u32)(reg_val+1) * 625 + 75)/ 100; -#} -# + def set_fan_duty_cycle(self, val): try: @@ -215,14 +202,11 @@ def set_fan_duty_cycle(self, val): except IOError as e: print("Error: unable to open file: %s" % str(e)) return False - #val = ((val + 1 ) * 625 +75 ) / 100 + fan_file.write(str(val)) fan_file.close() return True - #def get_fanr_fault(self, fan_num): - # return self._get_fan_node_val(fan_num, self.FANR_NODE_FAULT_IDX_OF_MAP) - def get_fanr_speed(self, fan_num): return self._get_fan_node_val(fan_num, self.FANR_NODE_SPEED_IDX_OF_MAP) @@ -235,20 +219,6 @@ def get_fan_status(self, fan_num): logging.debug('GET. FAN fault. fan_num, %d', fan_num) return False - #if self.get_fanr_fault(fan_num) is not None and self.get_fanr_fault(fan_num) > 0: - # logging.debug('GET. FANR fault. fan_num, %d', fan_num) - # return False return True -#def main(): -# fan = FanUtil() -# -# print 'get_size_node_map : %d' % fan.get_size_node_map() -# print 'get_size_path_map : %d' % fan.get_size_path_map() -# for x in range(fan.get_idx_fan_start(), fan.get_num_fans()+1): -# for y in range(fan.get_idx_node_start(), fan.get_num_nodes()+1): -# print fan.get_fan_to_device_path(x, y) -# -#if __name__ == '__main__': -# main() diff --git a/platform/broadcom/sonic-platform-modules-accton/as7716-32x/classes/thermalutil.py b/platform/broadcom/sonic-platform-modules-accton/as7716-32x/classes/thermalutil.py index 50d8c85d94ca..fa9fb0daeeca 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as7716-32x/classes/thermalutil.py +++ b/platform/broadcom/sonic-platform-modules-accton/as7716-32x/classes/thermalutil.py @@ -73,20 +73,21 @@ def _get_thermal_node_val(self, thermal_num): logging.error('GET. unable to open file: %s', str(e)) return None - content = val_file.readline().rstrip() + content = val_file.readline().rstrip() - if content == '': - logging.debug('GET. content is NULL. device_path:%s', device_path) - return None + if content == '': + logging.debug('GET. content is NULL. device_path:%s', device_path) + return None - try: - val_file.close() - except: - logging.debug('GET. unable to close file. device_path:%s', device_path) - return None + try: + val_file.close() + except: + logging.debug('GET. unable to close file. device_path:%s', device_path) + return None - return int(content) + return int(content) + return 0 def get_num_thermals(self): return self.THERMAL_NUM_ON_MAIN_BROAD @@ -110,14 +111,3 @@ def get_thermal_2_val(self): return self._get_thermal_node_val(self.THERMAL_NUM_2_IDX) def get_thermal_temp(self): return (self._get_thermal_node_val(self.THERMAL_NUM_1_IDX) + self._get_thermal_node_val(self.THERMAL_NUM_2_IDX) +self._get_thermal_node_val(self.THERMAL_NUM_3_IDX)) - -#def main(): -# thermal = ThermalUtil() -# -# print 'get_size_node_map : %d' % thermal.get_size_node_map() -# print 'get_size_path_map : %d' % thermal.get_size_path_map() -# for x in range(thermal.get_idx_thermal_start(), thermal.get_num_thermals()+1): -# print thermal.get_thermal_to_device_path(x) -# -#if __name__ == '__main__': -# main() diff --git a/platform/broadcom/sonic-platform-modules-accton/as7716-32x/modules/accton_as7716_32x_cpld1.c b/platform/broadcom/sonic-platform-modules-accton/as7716-32x/modules/accton_as7716_32x_cpld1.c index cbab013f5860..7d0117409a41 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as7716-32x/modules/accton_as7716_32x_cpld1.c +++ b/platform/broadcom/sonic-platform-modules-accton/as7716-32x/modules/accton_as7716_32x_cpld1.c @@ -571,7 +571,7 @@ static int as7716_32x_cpld_probe(struct i2c_client *client, return status; } -static int as7716_32x_cpld_remove(struct i2c_client *client) +static void as7716_32x_cpld_remove(struct i2c_client *client) { struct as7716_32x_cpld_data *data = i2c_get_clientdata(client); @@ -580,7 +580,6 @@ static int as7716_32x_cpld_remove(struct i2c_client *client) kfree(data); as7716_32x_cpld_remove_client(client); - return 0; } int as7716_32x_cpld_read(unsigned short cpld_addr, u8 reg) diff --git a/platform/broadcom/sonic-platform-modules-accton/as7716-32x/modules/accton_as7716_32x_fan.c b/platform/broadcom/sonic-platform-modules-accton/as7716-32x/modules/accton_as7716_32x_fan.c index 3a0610fe370d..f6aedcb2b800 100644 --- a/platform/broadcom/sonic-platform-modules-accton/as7716-32x/modules/accton_as7716_32x_fan.c +++ b/platform/broadcom/sonic-platform-modules-accton/as7716-32x/modules/accton_as7716_32x_fan.c @@ -487,13 +487,12 @@ static int as7716_32x_fan_probe(struct i2c_client *client, return status; } -static int as7716_32x_fan_remove(struct i2c_client *client) +static void as7716_32x_fan_remove(struct i2c_client *client) { struct as7716_32x_fan_data *data = i2c_get_clientdata(client); hwmon_device_unregister(data->hwmon_dev); sysfs_remove_group(&client->dev.kobj, &as7716_32x_fan_group); - return 0; } /* Addresses to scan */ diff --git a/platform/broadcom/sonic-platform-modules-accton/as7716-32x/modules/accton_as7716_32x_psu.c b/platform/broadcom/sonic-platform-modules-accton/as7716-32x/modules/accton_as7716_32x_psu.c index 78a58b820b2a..5e9b07b89464 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as7716-32x/modules/accton_as7716_32x_psu.c +++ b/platform/broadcom/sonic-platform-modules-accton/as7716-32x/modules/accton_as7716_32x_psu.c @@ -181,7 +181,7 @@ static int as7716_32x_psu_probe(struct i2c_client *client, return status; } -static int as7716_32x_psu_remove(struct i2c_client *client) +static void as7716_32x_psu_remove(struct i2c_client *client) { struct as7716_32x_psu_data *data = i2c_get_clientdata(client); @@ -189,7 +189,6 @@ static int as7716_32x_psu_remove(struct i2c_client *client) sysfs_remove_group(&client->dev.kobj, &as7716_32x_psu_group); kfree(data); - return 0; } enum psu_index diff --git a/platform/broadcom/sonic-platform-modules-accton/as7716-32x/modules/accton_as7716_32x_sfp.c b/platform/broadcom/sonic-platform-modules-accton/as7716-32x/modules/accton_as7716_32x_sfp.c index 9c7a05632154..40435d178898 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as7716-32x/modules/accton_as7716_32x_sfp.c +++ b/platform/broadcom/sonic-platform-modules-accton/as7716-32x/modules/accton_as7716_32x_sfp.c @@ -216,7 +216,7 @@ static int as7716_32x_sfp_probe(struct i2c_client *client, return status; } -static int as7716_32x_sfp_remove(struct i2c_client *client) +static void as7716_32x_sfp_remove(struct i2c_client *client) { struct as7716_32x_sfp_data *data = i2c_get_clientdata(client); @@ -224,7 +224,6 @@ static int as7716_32x_sfp_remove(struct i2c_client *client) sysfs_remove_group(&client->dev.kobj, &as7716_32x_sfp_group); kfree(data); - return 0; } enum port_numbers { diff --git a/platform/broadcom/sonic-platform-modules-accton/as7716-32x/modules/accton_i2c_cpld.c b/platform/broadcom/sonic-platform-modules-accton/as7716-32x/modules/accton_i2c_cpld.c index 46d1e2773287..6e5e20f00836 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as7716-32x/modules/accton_i2c_cpld.c +++ b/platform/broadcom/sonic-platform-modules-accton/as7716-32x/modules/accton_i2c_cpld.c @@ -151,12 +151,11 @@ static int accton_i2c_cpld_probe(struct i2c_client *client, return status; } -static int accton_i2c_cpld_remove(struct i2c_client *client) +static void accton_i2c_cpld_remove(struct i2c_client *client) { sysfs_remove_group(&client->dev.kobj, &as5712_54x_cpld_group); accton_i2c_cpld_remove_client(client); - return 0; } static const struct i2c_device_id accton_i2c_cpld_id[] = { diff --git a/platform/broadcom/sonic-platform-modules-accton/as7716-32x/modules/cpr_4011_4mxx.c b/platform/broadcom/sonic-platform-modules-accton/as7716-32x/modules/cpr_4011_4mxx.c index 30bea914d589..cdacf7d7e87b 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as7716-32x/modules/cpr_4011_4mxx.c +++ b/platform/broadcom/sonic-platform-modules-accton/as7716-32x/modules/cpr_4011_4mxx.c @@ -267,7 +267,7 @@ static int cpr_4011_4mxx_probe(struct i2c_client *client, return status; } -static int cpr_4011_4mxx_remove(struct i2c_client *client) +static void cpr_4011_4mxx_remove(struct i2c_client *client) { struct cpr_4011_4mxx_data *data = i2c_get_clientdata(client); @@ -275,7 +275,6 @@ static int cpr_4011_4mxx_remove(struct i2c_client *client) sysfs_remove_group(&client->dev.kobj, &cpr_4011_4mxx_group); kfree(data); - return 0; } static const struct i2c_device_id cpr_4011_4mxx_id[] = { diff --git a/platform/broadcom/sonic-platform-modules-accton/as7716-32x/modules/ym2651y.c b/platform/broadcom/sonic-platform-modules-accton/as7716-32x/modules/ym2651y.c index 8e76c56b54fc..2b6470a87dd1 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as7716-32x/modules/ym2651y.c +++ b/platform/broadcom/sonic-platform-modules-accton/as7716-32x/modules/ym2651y.c @@ -413,7 +413,7 @@ static int ym2651y_probe(struct i2c_client *client, return status; } -static int ym2651y_remove(struct i2c_client *client) +static void ym2651y_remove(struct i2c_client *client) { struct ym2651y_data *data = i2c_get_clientdata(client); @@ -421,7 +421,6 @@ static int ym2651y_remove(struct i2c_client *client) sysfs_remove_group(&client->dev.kobj, &ym2651y_group); kfree(data); - return 0; } static const struct i2c_device_id ym2651y_id[] = { diff --git a/platform/broadcom/sonic-platform-modules-accton/as7716-32xb/classes/fanutil.py b/platform/broadcom/sonic-platform-modules-accton/as7716-32xb/classes/fanutil.py index 381b787e0d80..c4a51a96a8cb 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as7716-32xb/classes/fanutil.py +++ b/platform/broadcom/sonic-platform-modules-accton/as7716-32xb/classes/fanutil.py @@ -43,12 +43,8 @@ class FanUtil(object): FAN_NODE_NUM_OF_MAP = 2 FAN_NODE_FAULT_IDX_OF_MAP = 1 - #FAN_NODE_SPEED_IDX_OF_MAP = 2 FAN_NODE_DIR_IDX_OF_MAP = 2 - #FAN_NODE_DUTY_IDX_OF_MAP = 4 - #FANR_NODE_FAULT_IDX_OF_MAP = 5 - #BASE_VAL_PATH = '/sys/devices/platform/as5712_54x_fan/{0}' BASE_VAL_PATH = '/sys/bus/i2c/devices/9-0066/{0}' FAN_DUTY_PATH = '/sys/bus/i2c/devices/9-0066/fan_duty_cycle_percentage' @@ -65,7 +61,7 @@ class FanUtil(object): #fan1_fault #fan1_present - #(FAN_NUM_2_IDX, FAN_NODE_DUTY_IDX_OF_MAP): 'fan2_duty_cycle_percentage', + _fan_to_device_node_mapping = { (FAN_NUM_1_IDX, FAN_NODE_FAULT_IDX_OF_MAP): 'fan1_fault', (FAN_NUM_1_IDX, FAN_NODE_DIR_IDX_OF_MAP): 'fan1_direction', @@ -107,17 +103,13 @@ def _get_fan_node_val(self, fan_num, node_num): return None content = val_file.readline().rstrip() - #print "fan_num=%d" %fan_num - #print "node_num=%d" %node_num - #print "device_path=%s" %device_path - #print "content=%s" %content if content == '': logging.debug('GET. content is NULL. device_path:%s', device_path) return None try: - val_file.close() + val_file.close() except: logging.debug('GET. unable to close file. device_path:%s', device_path) return None @@ -148,7 +140,7 @@ def _set_fan_node_val(self, fan_num, node_num, val): val_file.write(content) try: - val_file.close() + val_file.close() except: logging.debug('GET. unable to close file. device_path:%s', device_path) return None @@ -162,10 +154,6 @@ def __init__(self): for node_num in range(self.FAN_NODE_FAULT_IDX_OF_MAP, self.FAN_NODE_NUM_OF_MAP+1): self._fan_to_device_path_mapping[(fan_num, node_num)] = fan_path.format( self._fan_to_device_node_mapping[(fan_num, node_num)]) - #self._fan_to_device_path_mapping[(fan_num, node_num)] = fan_path + self._fan_to_device_node_mapping[(fan_num, node_num)]) - #print "fan_num=%d" %fan_num - #print "node_num=%d" %node_num - #print "self._fan_to_device_path_mapping[(fan_num, node_num)]=%s" %self._fan_to_device_path_mapping[(fan_num, node_num)] def get_num_fans(self): return self.FAN_NUM_ON_MAIN_BROAD @@ -191,14 +179,11 @@ def get_fan_to_device_path(self, fan_num, node_num): def get_fan_fault(self, fan_num): return self._get_fan_node_val(fan_num, self.FAN_NODE_FAULT_IDX_OF_MAP) - #def get_fan_speed(self, fan_num): - # return self._get_fan_node_val(fan_num, self.FAN_NODE_SPEED_IDX_OF_MAP) - def get_fan_dir(self, fan_num): return self._get_fan_node_val(fan_num, self.FAN_NODE_DIR_IDX_OF_MAP) def get_fan_duty_cycle(self): - #duty_path = self.FAN_DUTY_PATH + try: val_file = open(self.FAN_DUTY_PATH) except IOError as e: @@ -209,13 +194,7 @@ def get_fan_duty_cycle(self): val_file.close() return int(content) - #self._get_fan_node_val(fan_num, self.FAN_NODE_DUTY_IDX_OF_MAP) -#static u32 reg_val_to_duty_cycle(u8 reg_val) -#{ -# reg_val &= FAN_DUTY_CYCLE_REG_MASK; -# return ((u32)(reg_val+1) * 625 + 75)/ 100; -#} -# + def set_fan_duty_cycle(self, val): try: @@ -223,13 +202,11 @@ def set_fan_duty_cycle(self, val): except IOError as e: print("Error: unable to open file: %s" % str(e)) return False - #val = ((val + 1 ) * 625 +75 ) / 100 + fan_file.write(str(val)) fan_file.close() return True - #def get_fanr_fault(self, fan_num): - # return self._get_fan_node_val(fan_num, self.FANR_NODE_FAULT_IDX_OF_MAP) def get_fanr_speed(self, fan_num): return self._get_fan_node_val(fan_num, self.FANR_NODE_SPEED_IDX_OF_MAP) @@ -237,27 +214,12 @@ def get_fanr_speed(self, fan_num): def get_fan_status(self, fan_num): if fan_num < self.FAN_NUM_1_IDX or fan_num > self.FAN_NUM_ON_MAIN_BROAD: logging.debug('GET. Parameter error. fan_num, %d', fan_num) - print("fan %d return none" %fan_num) + return None if self.get_fan_fault(fan_num) is not None and self.get_fan_fault(fan_num) > 0: logging.debug('GET. FAN fault. fan_num, %d', fan_num) return False - #if self.get_fanr_fault(fan_num) is not None and self.get_fanr_fault(fan_num) > 0: - # logging.debug('GET. FANR fault. fan_num, %d', fan_num) - # return False - return True -#def main(): -# fan = FanUtil() -# -# print 'get_size_node_map : %d' % fan.get_size_node_map() -# print 'get_size_path_map : %d' % fan.get_size_path_map() -# for x in range(fan.get_idx_fan_start(), fan.get_num_fans()+1): -# for y in range(fan.get_idx_node_start(), fan.get_num_nodes()+1): -# print fan.get_fan_to_device_path(x, y) -# -#if __name__ == '__main__': -# main() diff --git a/platform/broadcom/sonic-platform-modules-accton/as7716-32xb/classes/thermalutil.py b/platform/broadcom/sonic-platform-modules-accton/as7716-32xb/classes/thermalutil.py index d3feda8faad9..fe6ac7050019 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as7716-32xb/classes/thermalutil.py +++ b/platform/broadcom/sonic-platform-modules-accton/as7716-32xb/classes/thermalutil.py @@ -59,7 +59,6 @@ def __init__(self): self._thermal_to_device_path_mapping[x] = thermal_path.format( self._thermal_to_device_node_mapping[x][0], self._thermal_to_device_node_mapping[x][1]) - #print "self._thermal_to_device_path_mapping[x]=%s" %self._thermal_to_device_path_mapping[x] def _get_thermal_node_val(self, thermal_num): if thermal_num < self.THERMAL_NUM_1_IDX or thermal_num > self.THERMAL_NUM_ON_MAIN_BROAD: @@ -74,20 +73,21 @@ def _get_thermal_node_val(self, thermal_num): logging.error('GET. unable to open file: %s', str(e)) return None - content = val_file.readline().rstrip() + content = val_file.readline().rstrip() - if content == '': - logging.debug('GET. content is NULL. device_path:%s', device_path) - return None + if content == '': + logging.debug('GET. content is NULL. device_path:%s', device_path) + return None - try: - val_file.close() - except: - logging.debug('GET. unable to close file. device_path:%s', device_path) - return None + try: + val_file.close() + except: + logging.debug('GET. unable to close file. device_path:%s', device_path) + return None - return int(content) + return int(content) + return 0 def get_num_thermals(self): return self.THERMAL_NUM_ON_MAIN_BROAD @@ -112,13 +112,3 @@ def get_thermal_2_val(self): def get_thermal_temp(self): return (self._get_thermal_node_val(self.THERMAL_NUM_1_IDX) + self._get_thermal_node_val(self.THERMAL_NUM_2_IDX) +self._get_thermal_node_val(self.THERMAL_NUM_3_IDX)) -#def main(): -# thermal = ThermalUtil() -# -# print 'get_size_node_map : %d' % thermal.get_size_node_map() -# print 'get_size_path_map : %d' % thermal.get_size_path_map() -# for x in range(thermal.get_idx_thermal_start(), thermal.get_num_thermals()+1): -# print thermal.get_thermal_to_device_path(x) -# -#if __name__ == '__main__': -# main() diff --git a/platform/broadcom/sonic-platform-modules-accton/as7716-32xb/modules/accton_as7716_32xb_cpld1.c b/platform/broadcom/sonic-platform-modules-accton/as7716-32xb/modules/accton_as7716_32xb_cpld1.c index c322972481ba..23c1e8c1d75b 100644 --- a/platform/broadcom/sonic-platform-modules-accton/as7716-32xb/modules/accton_as7716_32xb_cpld1.c +++ b/platform/broadcom/sonic-platform-modules-accton/as7716-32xb/modules/accton_as7716_32xb_cpld1.c @@ -505,8 +505,6 @@ static ssize_t sfp_value_store(struct device *dev, struct device_attribute *da, int index; long keyin = 0; - //printk("sfp_value_store\n"); - //printk("attr->index=%d\n", attr->index); mutex_lock(&data->update_lock); switch (attr->index) { @@ -550,8 +548,6 @@ static ssize_t sfp_value_show(struct device *dev, struct device_attribute *da, int index; int status = -EINVAL; - //printk("sfp_value_show, attr->index=%d\n", attr->index); - //printk("TRANSCEIVER_PRESENT_ATTR_ID(1)=%d, TRANSCEIVER_RESET_ATTR_ID(1)=%d\n", TRANSCEIVER_PRESENT_ATTR_ID(1), TRANSCEIVER_RESET_ATTR_ID(1)); mutex_lock(&data->update_lock); switch (attr->index) { @@ -569,7 +565,6 @@ static ssize_t sfp_value_show(struct device *dev, struct device_attribute *da, case MODULE_RESET_17 ... MODULE_RESET_24: case MODULE_RESET_25 ... MODULE_RESET_32: index=sfp_array_index_get(attr->index); - //printk("rst:attr->index=%d, index=%d\n",attr->index, index); if(index < 0 || index > PORT_NUM_MAX -1) break; status = sprintf(buf, "%u\n", data->reset[index]); @@ -809,7 +804,7 @@ static int as7716_32xb_cpld_probe(struct i2c_client *client, return status; } -static int as7716_32xb_cpld_remove(struct i2c_client *client) +static void as7716_32xb_cpld_remove(struct i2c_client *client) { struct as7716_32xb_cpld_data *data = i2c_get_clientdata(client); @@ -818,7 +813,6 @@ static int as7716_32xb_cpld_remove(struct i2c_client *client) kfree(data); as7716_32xb_cpld_remove_client(client); - return 0; } int as7716_32xb_cpld_read(unsigned short cpld_addr, u8 reg) @@ -930,7 +924,6 @@ static ssize_t set_mode_reset(struct device *dev, struct device_attribute *da, if (error) { return error; } - //printk("set_mode_reset:attr->index=%d\n",attr->index); switch (attr->index) { case MODULE_RESET_1 ... MODULE_RESET_8: reg = 0x04; @@ -957,17 +950,14 @@ static ssize_t set_mode_reset(struct device *dev, struct device_attribute *da, if (unlikely(status < 0)) { goto exit; } - //printk("set_mode_reset:reset=%d, reg=0x%x, mask=0x%x, ori_val=0x%x\n", reset, reg, mask, status); /* Update lp_mode status */ if (reset) { val = status&(~mask); - //printk("1:new val=0x%x\n", val); } else { val =status | (mask); - //printk("0:new val=0x%x\n", val); } status = as7716_32xb_cpld_write_internal(client, reg, val); diff --git a/platform/broadcom/sonic-platform-modules-accton/as7716-32xb/modules/accton_as7716_32xb_fan.c b/platform/broadcom/sonic-platform-modules-accton/as7716-32xb/modules/accton_as7716_32xb_fan.c index 65f3251c00ec..1b09578c5dd9 100644 --- a/platform/broadcom/sonic-platform-modules-accton/as7716-32xb/modules/accton_as7716_32xb_fan.c +++ b/platform/broadcom/sonic-platform-modules-accton/as7716-32xb/modules/accton_as7716_32xb_fan.c @@ -403,8 +403,6 @@ static ssize_t fan_value_store(struct device *dev, struct device_attribute *da, int status = -EINVAL; int index; long keyin = 0; - //printk("fan_value_store\n"); - //printk("attr->index=%d\n", attr->index); mutex_lock(&data->update_lock); switch (attr->index) { @@ -505,8 +503,6 @@ static ssize_t fan_value_show(struct device *dev, struct device_attribute *da, struct as7716_32xb_fan_data *data = i2c_get_clientdata(client); int status = -EINVAL; int index=0; - //printk("ffan_value_show\n"); - //printk("attr->index=%d\n", attr->index); mutex_lock(&data->update_lock); switch (attr->index) { @@ -662,13 +658,12 @@ static int as7716_32xb_fan_probe(struct i2c_client *client, return status; } -static int as7716_32xb_fan_remove(struct i2c_client *client) +static void as7716_32xb_fan_remove(struct i2c_client *client) { struct as7716_32xb_fan_data *data = i2c_get_clientdata(client); hwmon_device_unregister(data->hwmon_dev); sysfs_remove_group(&client->dev.kobj, &as7716_32xb_fan_group); - return 0; } /* Addresses to scan */ diff --git a/platform/broadcom/sonic-platform-modules-accton/as7716-32xb/modules/accton_as7716_32xb_oom.c b/platform/broadcom/sonic-platform-modules-accton/as7716-32xb/modules/accton_as7716_32xb_oom.c index 5e88d9efad5d..3aed7b359bbb 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as7716-32xb/modules/accton_as7716_32xb_oom.c +++ b/platform/broadcom/sonic-platform-modules-accton/as7716-32xb/modules/accton_as7716_32xb_oom.c @@ -69,12 +69,6 @@ static ssize_t oom_info_show(struct device *dev, struct device_attribute *da, mutex_lock(&data->lock); memcpy(buf, data->eeprom, EEPROM_DATA_SIZE); - //for(i=0; i < EEPROM_DATA_SIZE ; i++) - //{ - // buf[i]=data->eeprom[i]; - // printk("buf[%d]=0x%x ",i, buf[i]); - //} - //status = EEPROM_DATA_SIZE+1; memcpy(buf, data->eeprom, 256); @@ -92,7 +86,6 @@ static ssize_t oom_info_store(struct device *dev, struct device_attribute *da, unsigned char str[3]; unsigned int val; - // printk("strlen(buf)=%d\n",strlen(buf)); k=0; mutex_lock(&data->lock); memset(data->eeprom, 0xFF, EEPROM_DATA_SIZE); @@ -101,31 +94,20 @@ static ssize_t oom_info_store(struct device *dev, struct device_attribute *da, { for(i=0; i < strlen(buf) ; i++) { - // printk("i=%d ", i); for(j=0;j<2; j++) { str[j]=buf[i+j]; } sscanf(str, "%x", &val); - //printk("str=%s val=0x%x ", str, val); i=j+i-1; if(k>=EEPROM_DATA_SIZE) { break; } data->eeprom[k]=(unsigned char)val; - //printk("data->eeprom[%d]=0x%x\n",k, data->eeprom[k]); k++; } } - //printk("buf=\n"); - //for(i=0; i < strlen(buf) ; i++) - //{ - // printk("%c%c ", buf[i], buf[i+1]); - // if((i % 31)==0) - // printk("\n"); - //} - //printk("\n"); mutex_unlock(&data->lock); @@ -215,7 +197,7 @@ static int as7716_32xb_oom_probe(struct i2c_client *client, return status; } -static int as7716_32xb_oom_remove(struct i2c_client *client) +static void as7716_32xb_oom_remove(struct i2c_client *client) { struct as7716_32xb_oom_data *data = i2c_get_clientdata(client); @@ -223,7 +205,6 @@ static int as7716_32xb_oom_remove(struct i2c_client *client) sysfs_remove_group(&client->dev.kobj, &as7716_32xb_oom_group); kfree(data); - return 0; } diff --git a/platform/broadcom/sonic-platform-modules-accton/as7716-32xb/modules/accton_as7716_32xb_pmbus.c b/platform/broadcom/sonic-platform-modules-accton/as7716-32xb/modules/accton_as7716_32xb_pmbus.c index 3f4dba90d1aa..4d3e4226694d 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as7716-32xb/modules/accton_as7716_32xb_pmbus.c +++ b/platform/broadcom/sonic-platform-modules-accton/as7716-32xb/modules/accton_as7716_32xb_pmbus.c @@ -160,8 +160,6 @@ static ssize_t pmbus_info_show(struct device *dev, struct device_attribute *da, struct i2c_client *client = to_i2c_client(dev); struct as7716_32xb_pmbus_data *data = i2c_get_clientdata(client); int status = -EINVAL; - //printk("pmbus_info_show\n"); - printk("attr->index=%d\n", attr->index); mutex_lock(&data->update_lock); switch (attr->index) { @@ -190,11 +188,9 @@ static ssize_t pmbus_info_show(struct device *dev, struct device_attribute *da, status=snprintf(buf, PAGE_SIZE-1, "%d\r\n", data->i_out); break; case PSU_P_OUT: - printk("read PSU_P_OUT\n"); status=snprintf(buf, PAGE_SIZE-1, "%d\r\n", data->p_out); break; case PSU_P_OUT_UV: - printk("read PSU_P_OUT_UV\n"); status=snprintf(buf, PAGE_SIZE-1, "%ld\r\n", data->p_out * 1000000); break; case PSU_TEMP1_INPUT: @@ -256,8 +252,6 @@ static ssize_t pmbus_info_store(struct device *dev, struct device_attribute *da, struct as7716_32xb_pmbus_data *data = i2c_get_clientdata(client); long keyin = 0; int status = -EINVAL; - //printk("pmbus_info_store\n"); - //printk("attr->index=%d\n", attr->index); mutex_lock(&data->update_lock); status = kstrtol(buf, STRING_TO_DEC_VALUE, &keyin); switch (attr->index) @@ -286,7 +280,6 @@ static ssize_t pmbus_info_store(struct device *dev, struct device_attribute *da, data->i_out=keyin; break; case PSU_P_OUT: - printk("data->p_out=%d\n", data->p_out); data->p_out=keyin; break; case PSU_P_OUT_UV: @@ -392,7 +385,7 @@ static int as7716_32xb_pmbus_probe(struct i2c_client *client, return status; } -static int as7716_32xb_pmbus_remove(struct i2c_client *client) +static void as7716_32xb_pmbus_remove(struct i2c_client *client) { struct as7716_32xb_pmbus_data *data = i2c_get_clientdata(client); @@ -400,7 +393,6 @@ static int as7716_32xb_pmbus_remove(struct i2c_client *client) sysfs_remove_group(&client->dev.kobj, &as7716_32xb_pmbus_group); kfree(data); - return 0; } diff --git a/platform/broadcom/sonic-platform-modules-accton/as7716-32xb/modules/accton_as7716_32xb_psu.c b/platform/broadcom/sonic-platform-modules-accton/as7716-32xb/modules/accton_as7716_32xb_psu.c index 01756e8596eb..8cb57e414b4c 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as7716-32xb/modules/accton_as7716_32xb_psu.c +++ b/platform/broadcom/sonic-platform-modules-accton/as7716-32xb/modules/accton_as7716_32xb_psu.c @@ -96,25 +96,19 @@ static ssize_t psu_info_show(struct device *dev, struct device_attribute *da, struct i2c_client *client = to_i2c_client(dev); struct as7716_32xb_psu_data *data = i2c_get_clientdata(client); int status = -EINVAL; - //printk("psu_info_show\n"); - // printk("attr->index=%d\n", attr->index); mutex_lock(&data->update_lock); switch (attr->index) { case PSU_PRESENT: - //printk("data->present=%d\n",data->present); status = snprintf(buf, PAGE_SIZE - 1, "%d\r\n", data->present); break; case PSU_MODEL_NAME: - //printk("data->model_name=%s\n",data->model_name); status = snprintf(buf, PAGE_SIZE - 1, "%s\r\n", data->model_name); break; case PSU_POWER_GOOD: - // printk("data->present=%d\n",data->power_good); status = snprintf(buf, PAGE_SIZE - 1, "%d\r\n", data->power_good); break; case PSU_FAN_DIR: - //printk("data->fan_dir=%s\n",data->fan_dir); status = snprintf(buf, PAGE_SIZE - 1, "%s\r\n", data->fan_dir); break; default : @@ -132,8 +126,6 @@ static ssize_t psu_info_store(struct device *dev, struct device_attribute *da, struct as7716_32xb_psu_data *data = i2c_get_clientdata(client); long keyin = 0; int status = -EINVAL; - //printk("psu_info_store\n"); - //printk("attr->index=%d\n", attr->index); mutex_lock(&data->update_lock); switch (attr->index) { @@ -219,15 +211,14 @@ static int as7716_32xb_psu_probe(struct i2c_client *client, return status; } -static int as7716_32xb_psu_remove(struct i2c_client *client) +static void as7716_32xb_psu_remove(struct i2c_client *client) { struct as7716_32xb_psu_data *data = i2c_get_clientdata(client); hwmon_device_unregister(data->hwmon_dev); sysfs_remove_group(&client->dev.kobj, &as7716_32xb_psu_group); kfree(data); - - return 0; + } enum psu_index diff --git a/platform/broadcom/sonic-platform-modules-accton/as7716-32xb/modules/accton_as7716_32xb_sfp.c b/platform/broadcom/sonic-platform-modules-accton/as7716-32xb/modules/accton_as7716_32xb_sfp.c index 9c7a05632154..4f39a14fba06 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as7716-32xb/modules/accton_as7716_32xb_sfp.c +++ b/platform/broadcom/sonic-platform-modules-accton/as7716-32xb/modules/accton_as7716_32xb_sfp.c @@ -137,7 +137,6 @@ static ssize_t show_present(struct device *dev, struct device_attribute *da, struct as7716_32x_sfp_data *data = as7716_32x_sfp_update_device(dev); if (!data->valid) { - printk("return -EIO\n"); return -EIO; } @@ -216,7 +215,7 @@ static int as7716_32x_sfp_probe(struct i2c_client *client, return status; } -static int as7716_32x_sfp_remove(struct i2c_client *client) +static void as7716_32x_sfp_remove(struct i2c_client *client) { struct as7716_32x_sfp_data *data = i2c_get_clientdata(client); @@ -224,7 +223,6 @@ static int as7716_32x_sfp_remove(struct i2c_client *client) sysfs_remove_group(&client->dev.kobj, &as7716_32x_sfp_group); kfree(data); - return 0; } enum port_numbers { @@ -313,7 +311,6 @@ static struct as7716_32x_sfp_data *as7716_32x_sfp_update_device(struct device *d } data->is_present = (status & (1 << (data->port % 8))) ? 0 : 1; - printk("data->is_present=%d, data->port=%d, status=0x%x\n",data->is_present, data->port, status); /* Read eeprom data based on port number */ memset(data->eeprom, 0, sizeof(data->eeprom)); @@ -325,7 +322,6 @@ static struct as7716_32x_sfp_data *as7716_32x_sfp_update_device(struct device *d data->eeprom+(i*I2C_SMBUS_BLOCK_MAX), I2C_SMBUS_BLOCK_MAX); if (status < 0) { - printk("unable to read eeprom from port(%d)\n", data->port); dev_dbg(&client->dev, "unable to read eeprom from port(%d)\n", data->port); goto exit; } @@ -344,10 +340,6 @@ static struct as7716_32x_sfp_data *as7716_32x_sfp_update_device(struct device *d static int __init as7716_32x_sfp_init(void) { - //extern int platform_accton_as7716_32x(void); - //if (!platform_accton_as7716_32x()) { -// return -ENODEV; - //} return i2c_add_driver(&as7716_32x_sfp_driver); } diff --git a/platform/broadcom/sonic-platform-modules-accton/as7716-32xb/modules/accton_as7716_32xb_sys.c b/platform/broadcom/sonic-platform-modules-accton/as7716-32xb/modules/accton_as7716_32xb_sys.c index f0a8125139cc..63b15f7e2800 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as7716-32xb/modules/accton_as7716_32xb_sys.c +++ b/platform/broadcom/sonic-platform-modules-accton/as7716-32xb/modules/accton_as7716_32xb_sys.c @@ -49,36 +49,13 @@ static struct attribute *as7716_32xb_sys_attributes[] = { static ssize_t sys_info_show(struct device *dev, struct device_attribute *da, char *buf) { - //struct sensor_device_attribute *attr = to_sensor_dev_attr(da); struct i2c_client *client = to_i2c_client(dev); struct as7716_32xb_sys_data *data = i2c_get_clientdata(client); -// int status = -EINVAL; int i; - //printk("sys_info_show\n"); - // printk("attr->index=%d\n", attr->index); mutex_lock(&data->lock); - //for(i=0; i<8; i++) - // printk("data->eeprom[%d]=0x%x ",i, data->eeprom[i]); - //printk("\n"); memcpy(buf, data->eeprom, EEPROM_DATA_SIZE); - //for(i=0; i < EEPROM_DATA_SIZE ; i++) - //{ - // buf[i]=data->eeprom[i]; - // printk("buf[%d]=0x%x ",i, buf[i]); - //} - //status = EEPROM_DATA_SIZE+1; - - //printk("\n"); - //status = sprintf(buf, "%x", 0xA); - //data->eeprom[0]=0x0d; - //data->eeprom[1]=0x0; - //data->eeprom[2]=0x06; - // buf[3]=0xFF; - // for(i=0; i< 16; i++) - // printk("buf[%d]=0x%x ",i, buf[i]); - //printk("\n"); memcpy(buf, data->eeprom, 256); @@ -97,11 +74,6 @@ static ssize_t sys_info_store(struct device *dev, struct device_attribute *da, unsigned char str[3]; unsigned int val; - //printk("sys_info_store\n"); - //printk("attr->index=%d\n", attr->index); - //printk("buf[0]=0x%x, buf[1]=0x%x, buf[2]=0x%x, buf[3]=0x%x\n", buf[0], buf[1], buf[2], buf[3]); - - // printk("strlen(buf)=%d\n",strlen(buf)); k=0; mutex_lock(&data->lock); memset(data->eeprom, 0xFF, EEPROM_DATA_SIZE); @@ -110,34 +82,20 @@ static ssize_t sys_info_store(struct device *dev, struct device_attribute *da, { for(i=0; i < strlen(buf) ; i++) { - // printk("i=%d ", i); for(j=0;j<2; j++) { str[j]=buf[i+j]; } sscanf(str, "%x", &val); - // printk("str=%s val=0x%x ", str, val); i=j+i-1; if(k>=EEPROM_DATA_SIZE) { break; } data->eeprom[k]=(unsigned char)val; - // printk("data->eeprom[%d]=0x%x\n",k, data->eeprom[k]); k++; } } - //printk("buf=\n"); - //for(i=0; i < strlen(buf) ; i++) - //{ - // printk("%c%c ", buf[i], buf[i+1]); - // if((i % 31)==0) - // printk("\n"); - //} - //printk("\n"); - - //printk("eeprom[0]=0x%x, eeprom[1]=0x%x, eeprom[2]=0x%x, eeprom[3]=0x%x\n", - // data->eeprom[0], data->eeprom[1], data->eeprom[2], data->eeprom[3]); mutex_unlock(&data->lock); return size; @@ -191,7 +149,7 @@ static int as7716_32xb_sys_probe(struct i2c_client *client, return status; } -static int as7716_32xb_sys_remove(struct i2c_client *client) +static void as7716_32xb_sys_remove(struct i2c_client *client) { struct as7716_32xb_sys_data *data = i2c_get_clientdata(client); @@ -199,7 +157,6 @@ static int as7716_32xb_sys_remove(struct i2c_client *client) sysfs_remove_group(&client->dev.kobj, &as7716_32xb_sys_group); kfree(data); - return 0; } diff --git a/platform/broadcom/sonic-platform-modules-accton/as7716-32xb/modules/accton_as7716_32xb_thermal.c b/platform/broadcom/sonic-platform-modules-accton/as7716-32xb/modules/accton_as7716_32xb_thermal.c index d42341bb181a..b5977e0ea511 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as7716-32xb/modules/accton_as7716_32xb_thermal.c +++ b/platform/broadcom/sonic-platform-modules-accton/as7716-32xb/modules/accton_as7716_32xb_thermal.c @@ -162,7 +162,7 @@ static int as7716_32xb_thermal_probe(struct i2c_client *client, return status; } -static int as7716_32xb_thermal_remove(struct i2c_client *client) +static void as7716_32xb_thermal_remove(struct i2c_client *client) { struct as7716_32xb_thermal_data *data = i2c_get_clientdata(client); @@ -170,7 +170,6 @@ static int as7716_32xb_thermal_remove(struct i2c_client *client) sysfs_remove_group(&client->dev.kobj, &as7716_32xb_thermal_group); kfree(data); - return 0; } diff --git a/platform/broadcom/sonic-platform-modules-accton/as7716-32xb/modules/accton_i2c_cpld.c b/platform/broadcom/sonic-platform-modules-accton/as7716-32xb/modules/accton_i2c_cpld.c index 46d1e2773287..1508a0223a57 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as7716-32xb/modules/accton_i2c_cpld.c +++ b/platform/broadcom/sonic-platform-modules-accton/as7716-32xb/modules/accton_i2c_cpld.c @@ -151,12 +151,11 @@ static int accton_i2c_cpld_probe(struct i2c_client *client, return status; } -static int accton_i2c_cpld_remove(struct i2c_client *client) +static void accton_i2c_cpld_remove(struct i2c_client *client) { sysfs_remove_group(&client->dev.kobj, &as5712_54x_cpld_group); accton_i2c_cpld_remove_client(client); - return 0; } static const struct i2c_device_id accton_i2c_cpld_id[] = { @@ -234,23 +233,7 @@ static void __exit accton_i2c_cpld_exit(void) { i2c_del_driver(&accton_i2c_cpld_driver); } -/* -static struct dmi_system_id as7712_dmi_table[] = { - { - .ident = "Accton AS7712", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "Accton"), - DMI_MATCH(DMI_PRODUCT_NAME, "AS7712"), - }, - } -}; -int platform_accton_as7712_32x(void) -{ - return dmi_check_system(as7712_dmi_table); -} -EXPORT_SYMBOL(platform_accton_as7712_32x); -*/ MODULE_AUTHOR("Brandon Chuang "); MODULE_DESCRIPTION("accton_i2c_cpld driver"); MODULE_LICENSE("GPL"); diff --git a/platform/broadcom/sonic-platform-modules-accton/as7726-32x/classes/fanutil.py b/platform/broadcom/sonic-platform-modules-accton/as7726-32x/classes/fanutil.py index 164bdc22b81d..806165a64779 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as7726-32x/classes/fanutil.py +++ b/platform/broadcom/sonic-platform-modules-accton/as7726-32x/classes/fanutil.py @@ -110,7 +110,7 @@ def _get_fan_node_val(self, fan_num, node_num): return None try: - val_file.close() + val_file.close() except: logging.debug('GET. unable to close file. device_path:%s', device_path) return None @@ -141,7 +141,7 @@ def _set_fan_node_val(self, fan_num, node_num, val): val_file.write(content) try: - val_file.close() + val_file.close() except: logging.debug('GET. unable to close file. device_path:%s', device_path) return None diff --git a/platform/broadcom/sonic-platform-modules-accton/as7726-32x/classes/thermalutil.py b/platform/broadcom/sonic-platform-modules-accton/as7726-32x/classes/thermalutil.py index 66f5455e11ba..24db3d0fe38d 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as7726-32x/classes/thermalutil.py +++ b/platform/broadcom/sonic-platform-modules-accton/as7726-32x/classes/thermalutil.py @@ -80,7 +80,7 @@ def _get_thermal_val(self, thermal_num): logging.debug('GET. content is NULL. device_path:%s', device_path) return None try: - val_file.close() + val_file.close() except: logging.debug('GET. unable to close file. device_path:%s', device_path) return None @@ -111,12 +111,3 @@ def get_thermal_2_val(self): def get_thermal_temp(self): return (self._get_thermal_node_val(self.THERMAL_NUM_1_IDX) + self._get_thermal_node_val(self.THERMAL_NUM_2_IDX) +self._get_thermal_node_val(self.THERMAL_NUM_3_IDX)) -def main(): - thermal = ThermalUtil() - logging.debug('thermal1=%d', thermal._get_thermal_val(1)) - logging.debug('thermal2=%d', thermal._get_thermal_val(2)) - logging.debug('thermal3=%d', thermal._get_thermal_val(3)) - logging.debug('thermal4=%d', thermal._get_thermal_val(4)) - logging.debug('thermal5=%d', thermal._get_thermal_val(5)) -if __name__ == '__main__': - main() diff --git a/platform/broadcom/sonic-platform-modules-accton/as7726-32x/modules/accton_as7726_32x_cpld.c b/platform/broadcom/sonic-platform-modules-accton/as7726-32x/modules/accton_as7726_32x_cpld.c index 6ca5b1c1296a..cd0c5639aefd 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as7726-32x/modules/accton_as7726_32x_cpld.c +++ b/platform/broadcom/sonic-platform-modules-accton/as7726-32x/modules/accton_as7726_32x_cpld.c @@ -778,7 +778,7 @@ static int as7726_32x_cpld_probe(struct i2c_client *client, return ret; } -static int as7726_32x_cpld_remove(struct i2c_client *client) +static void as7726_32x_cpld_remove(struct i2c_client *client) { struct as7726_32x_cpld_data *data = i2c_get_clientdata(client); const struct attribute_group *group = NULL; @@ -806,7 +806,6 @@ static int as7726_32x_cpld_remove(struct i2c_client *client) kfree(data); - return 0; } static int as7726_32x_cpld_read_internal(struct i2c_client *client, u8 reg) diff --git a/platform/broadcom/sonic-platform-modules-accton/as7726-32x/modules/accton_as7726_32x_fan.c b/platform/broadcom/sonic-platform-modules-accton/as7726-32x/modules/accton_as7726_32x_fan.c index 0341b3802b0f..3f7489de2b0e 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as7726-32x/modules/accton_as7726_32x_fan.c +++ b/platform/broadcom/sonic-platform-modules-accton/as7726-32x/modules/accton_as7726_32x_fan.c @@ -456,13 +456,12 @@ static int as7726_32x_fan_probe(struct i2c_client *client, return status; } -static int as7726_32x_fan_remove(struct i2c_client *client) +static void as7726_32x_fan_remove(struct i2c_client *client) { struct as7726_32x_fan_data *data = i2c_get_clientdata(client); hwmon_device_unregister(data->hwmon_dev); sysfs_remove_group(&client->dev.kobj, &as7726_32x_fan_group); - return 0; } /* Addresses to scan */ diff --git a/platform/broadcom/sonic-platform-modules-accton/as7726-32x/modules/accton_as7726_32x_psu.c b/platform/broadcom/sonic-platform-modules-accton/as7726-32x/modules/accton_as7726_32x_psu.c index f4da01e86d9b..5bb63c6622e0 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as7726-32x/modules/accton_as7726_32x_psu.c +++ b/platform/broadcom/sonic-platform-modules-accton/as7726-32x/modules/accton_as7726_32x_psu.c @@ -155,7 +155,7 @@ static int as7726_32x_psu_probe(struct i2c_client *client, return status; } -static int as7726_32x_psu_remove(struct i2c_client *client) +static void as7726_32x_psu_remove(struct i2c_client *client) { struct as7726_32x_psu_data *data = i2c_get_clientdata(client); @@ -163,7 +163,6 @@ static int as7726_32x_psu_remove(struct i2c_client *client) sysfs_remove_group(&client->dev.kobj, &as7726_32x_psu_group); kfree(data); - return 0; } enum psu_index diff --git a/platform/broadcom/sonic-platform-modules-accton/as7726-32x/modules/ym2651y.c b/platform/broadcom/sonic-platform-modules-accton/as7726-32x/modules/ym2651y.c index 8e76c56b54fc..2b6470a87dd1 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as7726-32x/modules/ym2651y.c +++ b/platform/broadcom/sonic-platform-modules-accton/as7726-32x/modules/ym2651y.c @@ -413,7 +413,7 @@ static int ym2651y_probe(struct i2c_client *client, return status; } -static int ym2651y_remove(struct i2c_client *client) +static void ym2651y_remove(struct i2c_client *client) { struct ym2651y_data *data = i2c_get_clientdata(client); @@ -421,7 +421,6 @@ static int ym2651y_remove(struct i2c_client *client) sysfs_remove_group(&client->dev.kobj, &ym2651y_group); kfree(data); - return 0; } static const struct i2c_device_id ym2651y_id[] = { diff --git a/platform/broadcom/sonic-platform-modules-accton/as7816-64x/modules/x86-64-accton-as7816-64x-fan.c b/platform/broadcom/sonic-platform-modules-accton/as7816-64x/modules/x86-64-accton-as7816-64x-fan.c index 2cd85c43a9c2..10b4e3c77bba 100644 --- a/platform/broadcom/sonic-platform-modules-accton/as7816-64x/modules/x86-64-accton-as7816-64x-fan.c +++ b/platform/broadcom/sonic-platform-modules-accton/as7816-64x/modules/x86-64-accton-as7816-64x-fan.c @@ -424,13 +424,12 @@ static int as7816_64x_fan_probe(struct i2c_client *client, return status; } -static int as7816_64x_fan_remove(struct i2c_client *client) +static void as7816_64x_fan_remove(struct i2c_client *client) { struct as7816_64x_fan_data *data = i2c_get_clientdata(client); hwmon_device_unregister(data->hwmon_dev); sysfs_remove_group(&client->dev.kobj, &as7816_64x_fan_group); - return 0; } /* Addresses to scan */ diff --git a/platform/broadcom/sonic-platform-modules-accton/as7816-64x/modules/x86-64-accton-as7816-64x-psu.c b/platform/broadcom/sonic-platform-modules-accton/as7816-64x/modules/x86-64-accton-as7816-64x-psu.c index cdc535347dc0..b19567aee972 100644 --- a/platform/broadcom/sonic-platform-modules-accton/as7816-64x/modules/x86-64-accton-as7816-64x-psu.c +++ b/platform/broadcom/sonic-platform-modules-accton/as7816-64x/modules/x86-64-accton-as7816-64x-psu.c @@ -150,7 +150,7 @@ static int as7816_64x_psu_probe(struct i2c_client *client, return status; } -static int as7816_64x_psu_remove(struct i2c_client *client) +static void as7816_64x_psu_remove(struct i2c_client *client) { struct as7816_64x_psu_data *data = i2c_get_clientdata(client); @@ -158,7 +158,6 @@ static int as7816_64x_psu_remove(struct i2c_client *client) sysfs_remove_group(&client->dev.kobj, &as7816_64x_psu_group); kfree(data); - return 0; } enum psu_index diff --git a/platform/broadcom/sonic-platform-modules-accton/as7816-64x/modules/x86-64-accton-as7816-64x-sfp.c b/platform/broadcom/sonic-platform-modules-accton/as7816-64x/modules/x86-64-accton-as7816-64x-sfp.c index 76444ebbafcb..2a5d954cf39d 100644 --- a/platform/broadcom/sonic-platform-modules-accton/as7816-64x/modules/x86-64-accton-as7816-64x-sfp.c +++ b/platform/broadcom/sonic-platform-modules-accton/as7816-64x/modules/x86-64-accton-as7816-64x-sfp.c @@ -1530,7 +1530,7 @@ static int qsfp_remove(struct i2c_client *client, struct qsfp_data *data) return 0; } -static int sfp_device_remove(struct i2c_client *client) +static void sfp_device_remove(struct i2c_client *client) { int ret = 0; struct sfp_port_data *data = i2c_get_clientdata(client); @@ -1540,7 +1540,6 @@ static int sfp_device_remove(struct i2c_client *client) } kfree(data); - return ret; } /* Addresses scanned diff --git a/platform/broadcom/sonic-platform-modules-accton/as9716-32d/classes/fanutil.py b/platform/broadcom/sonic-platform-modules-accton/as9716-32d/classes/fanutil.py index 2afbf905a390..0719fcfe97dd 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as9716-32d/classes/fanutil.py +++ b/platform/broadcom/sonic-platform-modules-accton/as9716-32d/classes/fanutil.py @@ -106,7 +106,7 @@ def _get_fan_node_val(self, fan_num, node_num): return None try: - val_file.close() + val_file.close() except: logging.debug('GET. unable to close file. device_path:%s', device_path) return None @@ -137,7 +137,7 @@ def _set_fan_node_val(self, fan_num, node_num, val): val_file.write(content) try: - val_file.close() + val_file.close() except: logging.debug('GET. unable to close file. device_path:%s', device_path) return None diff --git a/platform/broadcom/sonic-platform-modules-accton/as9716-32d/classes/thermalutil.py b/platform/broadcom/sonic-platform-modules-accton/as9716-32d/classes/thermalutil.py index 5f6af3811f01..69d2e696828f 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as9716-32d/classes/thermalutil.py +++ b/platform/broadcom/sonic-platform-modules-accton/as9716-32d/classes/thermalutil.py @@ -76,7 +76,7 @@ def _get_thermal_val(self, thermal_num): logging.debug('GET. content is NULL. device_path:%s', device_path) return None try: - val_file.close() + val_file.close() except: logging.debug('GET. unable to close file. device_path:%s', device_path) return None @@ -94,9 +94,3 @@ def get_size_path_map(self): def get_thermal_path(self, thermal_num): return self.thermal_sysfspath[thermal_num][0] - -def main(): - thermal = ThermalUtil() - -if __name__ == '__main__': - main() \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-accton/as9716-32d/modules/accton_as9716_32d_cpld.c b/platform/broadcom/sonic-platform-modules-accton/as9716-32d/modules/accton_as9716_32d_cpld.c index d473bb452411..4cb51e301f27 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as9716-32d/modules/accton_as9716_32d_cpld.c +++ b/platform/broadcom/sonic-platform-modules-accton/as9716-32d/modules/accton_as9716_32d_cpld.c @@ -829,7 +829,7 @@ static int as9716_32d_cpld_probe(struct i2c_client *client, return ret; } -static int as9716_32d_cpld_remove(struct i2c_client *client) +static void as9716_32d_cpld_remove(struct i2c_client *client) { struct as9716_32d_cpld_data *data = i2c_get_clientdata(client); const struct attribute_group *group = NULL; @@ -857,7 +857,6 @@ static int as9716_32d_cpld_remove(struct i2c_client *client) kfree(data); - return 0; } static int as9716_32d_cpld_read_internal(struct i2c_client *client, u8 reg) diff --git a/platform/broadcom/sonic-platform-modules-accton/as9716-32d/modules/accton_as9716_32d_fan.c b/platform/broadcom/sonic-platform-modules-accton/as9716-32d/modules/accton_as9716_32d_fan.c index b586a47ed007..ac04fef9ce48 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as9716-32d/modules/accton_as9716_32d_fan.c +++ b/platform/broadcom/sonic-platform-modules-accton/as9716-32d/modules/accton_as9716_32d_fan.c @@ -455,13 +455,12 @@ static int as9716_32d_fan_probe(struct i2c_client *client, return status; } -static int as9716_32d_fan_remove(struct i2c_client *client) +static void as9716_32d_fan_remove(struct i2c_client *client) { struct as9716_32d_fan_data *data = i2c_get_clientdata(client); hwmon_device_unregister(data->hwmon_dev); sysfs_remove_group(&client->dev.kobj, &as9716_32d_fan_group); - return 0; } /* Addresses to scan */ diff --git a/platform/broadcom/sonic-platform-modules-accton/as9716-32d/modules/accton_as9716_32d_psu.c b/platform/broadcom/sonic-platform-modules-accton/as9716-32d/modules/accton_as9716_32d_psu.c index 06e8e23c3c53..06c6b8e5e346 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as9716-32d/modules/accton_as9716_32d_psu.c +++ b/platform/broadcom/sonic-platform-modules-accton/as9716-32d/modules/accton_as9716_32d_psu.c @@ -180,7 +180,7 @@ static int as9716_32d_psu_probe(struct i2c_client *client, return status; } -static int as9716_32d_psu_remove(struct i2c_client *client) +static void as9716_32d_psu_remove(struct i2c_client *client) { struct as9716_32d_psu_data *data = i2c_get_clientdata(client); @@ -188,7 +188,6 @@ static int as9716_32d_psu_remove(struct i2c_client *client) sysfs_remove_group(&client->dev.kobj, &as9716_32d_psu_group); kfree(data); - return 0; } enum psu_index diff --git a/platform/broadcom/sonic-platform-modules-accton/as9716-32d/modules/accton_i2c_psu.c b/platform/broadcom/sonic-platform-modules-accton/as9716-32d/modules/accton_i2c_psu.c index df7324de5604..da2b39d367f3 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as9716-32d/modules/accton_i2c_psu.c +++ b/platform/broadcom/sonic-platform-modules-accton/as9716-32d/modules/accton_i2c_psu.c @@ -372,7 +372,7 @@ static int accton_i2c_psu_probe(struct i2c_client *client, return status; } -static int accton_i2c_psu_remove(struct i2c_client *client) +static void accton_i2c_psu_remove(struct i2c_client *client) { struct accton_i2c_psu_data *data = i2c_get_clientdata(client); @@ -380,7 +380,6 @@ static int accton_i2c_psu_remove(struct i2c_client *client) sysfs_remove_group(&client->dev.kobj, &accton_i2c_psu_group); kfree(data); - return 0; } /* Support psu moduel */ diff --git a/platform/broadcom/sonic-platform-modules-accton/as9726-32d/classes/fanutil.py b/platform/broadcom/sonic-platform-modules-accton/as9726-32d/classes/fanutil.py index 4d6e177edc83..efac835486d4 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as9726-32d/classes/fanutil.py +++ b/platform/broadcom/sonic-platform-modules-accton/as9726-32d/classes/fanutil.py @@ -56,7 +56,7 @@ class FanUtil(object): #fan1_fault #fan1_present - #(FAN_NUM_2_IDX, FAN_NODE_DUTY_IDX_OF_MAP): 'fan2_duty_cycle_percentage', + _fan_device_node_mapping = { (FAN_NUM_1_IDX, FAN_NODE_FAULT_IDX_OF_MAP): 'fan1_fault', (FAN_NUM_1_IDX, FAN_NODE_DIR_IDX_OF_MAP): 'fan1_direction', @@ -104,7 +104,7 @@ def _get_fan_node_val(self, fan_num, node_num): return None try: - val_file.close() + val_file.close() except IOError: logging.debug('GET. unable to close file. device_path:%s', device_path) return None @@ -135,7 +135,7 @@ def _set_fan_node_val(self, fan_num, node_num, val): val_file.write(content) try: - val_file.close() + val_file.close() except BaseException: logging.debug('GET. unable to close file. device_path:%s', device_path) return None @@ -178,7 +178,7 @@ def get_fan_dir(self, fan_num): return self._get_fan_node_val(fan_num, self.FAN_NODE_DIR_IDX_OF_MAP) def get_fan_duty_cycle(self): - #duty_path = self.FAN_DUTY_PATH + try: val_file = open(self.FAN_DUTY_PATH) except IOError as e: diff --git a/platform/broadcom/sonic-platform-modules-accton/as9726-32d/classes/thermalutil.py b/platform/broadcom/sonic-platform-modules-accton/as9726-32d/classes/thermalutil.py index 1f00d72b8411..0b09f6cafa45 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as9726-32d/classes/thermalutil.py +++ b/platform/broadcom/sonic-platform-modules-accton/as9726-32d/classes/thermalutil.py @@ -39,7 +39,7 @@ class ThermalUtil(object): """ Dictionary where key1 = thermal id index (integer) starting from 1 value = path to fan device file (string) """ - #_thermal_to_device_path_mapping = {} + thermal_sysfspath ={ THERMAL_NUM_1_IDX: ["/sys/bus/i2c/devices/15-0048/hwmon/hwmon*/temp1_input"], @@ -51,7 +51,6 @@ class ThermalUtil(object): THERMAL_NUM_7_IDX: ["/sys/bus/i2c/devices/15-004b/hwmon/hwmon*/temp1_input"], } - #def __init__(self): def _get_thermal_val(self, thermal_num): if thermal_num < self.THERMAL_NUM_1_IDX or thermal_num > self.THERMAL_NUM_MAX: @@ -70,11 +69,11 @@ def _get_thermal_val(self, thermal_num): logging.debug('GET. content is NULL. device_path:%s', device_path) return None try: - val_file.close() + val_file.close() except BaseException: logging.debug('GET. unable to close file. device_path:%s', device_path) return None - + return int(content) return 0 diff --git a/platform/broadcom/sonic-platform-modules-accton/as9726-32d/modules/x86-64-accton-as9726-32d-cpld.c b/platform/broadcom/sonic-platform-modules-accton/as9726-32d/modules/x86-64-accton-as9726-32d-cpld.c index 096d1384b650..cc1c32a68a75 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as9726-32d/modules/x86-64-accton-as9726-32d-cpld.c +++ b/platform/broadcom/sonic-platform-modules-accton/as9726-32d/modules/x86-64-accton-as9726-32d-cpld.c @@ -839,7 +839,7 @@ static int as9726_32d_cpld_probe(struct i2c_client *client, return ret; } -static int as9726_32d_cpld_remove(struct i2c_client *client) +static void as9726_32d_cpld_remove(struct i2c_client *client) { struct as9726_32d_cpld_data *data = i2c_get_clientdata(client); const struct attribute_group *group = NULL; @@ -857,7 +857,7 @@ static int as9726_32d_cpld_remove(struct i2c_client *client) case as9726_32d_cpld3: group = &as9726_32d_cpld3_group; break; - case as9726_32d_cpld_cpu: + case as9726_32d_cpld_cpu: group = &as9726_32d_cpld_cpu_group; break; default: @@ -870,7 +870,6 @@ static int as9726_32d_cpld_remove(struct i2c_client *client) kfree(data); - return 0; } static int as9726_32d_cpld_read_internal(struct i2c_client *client, u8 reg) diff --git a/platform/broadcom/sonic-platform-modules-accton/as9726-32d/modules/x86-64-accton-as9726-32d-fan.c b/platform/broadcom/sonic-platform-modules-accton/as9726-32d/modules/x86-64-accton-as9726-32d-fan.c index 67a015f01c62..b220b137bf5a 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as9726-32d/modules/x86-64-accton-as9726-32d-fan.c +++ b/platform/broadcom/sonic-platform-modules-accton/as9726-32d/modules/x86-64-accton-as9726-32d-fan.c @@ -514,13 +514,12 @@ static int as9726_32d_fan_probe(struct i2c_client *client, return status; } -static int as9726_32d_fan_remove(struct i2c_client *client) +static void as9726_32d_fan_remove(struct i2c_client *client) { struct as9726_32d_fan_data *data = i2c_get_clientdata(client); hwmon_device_unregister(data->hwmon_dev); sysfs_remove_group(&client->dev.kobj, &as9726_32d_fan_group); - return 0; } /* Addresses to scan */ diff --git a/platform/broadcom/sonic-platform-modules-accton/as9726-32d/modules/x86-64-accton-as9726-32d-psu.c b/platform/broadcom/sonic-platform-modules-accton/as9726-32d/modules/x86-64-accton-as9726-32d-psu.c index cdf11f503d6e..13595fa12743 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as9726-32d/modules/x86-64-accton-as9726-32d-psu.c +++ b/platform/broadcom/sonic-platform-modules-accton/as9726-32d/modules/x86-64-accton-as9726-32d-psu.c @@ -187,7 +187,7 @@ static int as9726_32d_psu_probe(struct i2c_client *client, return status; } -static int as9726_32d_psu_remove(struct i2c_client *client) +static void as9726_32d_psu_remove(struct i2c_client *client) { struct as9726_32d_psu_data *data = i2c_get_clientdata(client); @@ -195,7 +195,6 @@ static int as9726_32d_psu_remove(struct i2c_client *client) sysfs_remove_group(&client->dev.kobj, &as9726_32d_psu_group); kfree(data); - return 0; } enum psu_index @@ -267,7 +266,6 @@ static struct as9726_32d_psu_data *as9726_32d_psu_update_device(struct device *d /* Read psu status */ status = as9726_32d_cpld_read(0x60, 0x03); - //printk("status=0x%x in %s\n", status, __FUNCTION__); if (status < 0) { dev_dbg(&client->dev, "cpld reg 0x60 err %d\n", status); diff --git a/platform/broadcom/sonic-platform-modules-accton/as9726-32d/modules/ym2651y.c b/platform/broadcom/sonic-platform-modules-accton/as9726-32d/modules/ym2651y.c index 63488d2c6c78..f1e517e0a17c 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as9726-32d/modules/ym2651y.c +++ b/platform/broadcom/sonic-platform-modules-accton/as9726-32d/modules/ym2651y.c @@ -480,7 +480,7 @@ static int ym2651y_probe(struct i2c_client *client, return status; } -static int ym2651y_remove(struct i2c_client *client) +static void ym2651y_remove(struct i2c_client *client) { struct ym2651y_data *data = i2c_get_clientdata(client); @@ -488,7 +488,6 @@ static int ym2651y_remove(struct i2c_client *client) sysfs_remove_group(&client->dev.kobj, &ym2651y_group); kfree(data); - return 0; } static const struct i2c_device_id ym2651y_id[] = { diff --git a/platform/broadcom/sonic-platform-modules-accton/common/modules/accton_i2c_cpld.c b/platform/broadcom/sonic-platform-modules-accton/common/modules/accton_i2c_cpld.c index 03e528ef8d5b..685a5e3fec14 100755 --- a/platform/broadcom/sonic-platform-modules-accton/common/modules/accton_i2c_cpld.c +++ b/platform/broadcom/sonic-platform-modules-accton/common/modules/accton_i2c_cpld.c @@ -787,7 +787,7 @@ static int accton_i2c_cpld_probe(struct i2c_client *client, } -static int accton_i2c_cpld_remove(struct i2c_client *client) +static void accton_i2c_cpld_remove(struct i2c_client *client) { struct cpld_data *data = i2c_get_clientdata(client); @@ -795,7 +795,6 @@ static int accton_i2c_cpld_remove(struct i2c_client *client) sysfs_remove_group(&client->dev.kobj, &data->group); kfree(data->group.attrs); accton_i2c_cpld_remove_client(client); - return 0; } int accton_i2c_cpld_read(u8 cpld_addr, u8 reg) diff --git a/platform/broadcom/sonic-platform-modules-accton/common/modules/accton_pmbus_3y.c b/platform/broadcom/sonic-platform-modules-accton/common/modules/accton_pmbus_3y.c index 76ac4368a8d4..0a776e7d19fb 100644 --- a/platform/broadcom/sonic-platform-modules-accton/common/modules/accton_pmbus_3y.c +++ b/platform/broadcom/sonic-platform-modules-accton/common/modules/accton_pmbus_3y.c @@ -1951,12 +1951,11 @@ static int pmbus_probe(struct i2c_client *client, return _pmbus_do_probe(client, id, info); } -int _pmbus_do_remove(struct i2c_client *client) +void _pmbus_do_remove(struct i2c_client *client) { struct pmbus_data *data = i2c_get_clientdata(client); hwmon_device_unregister(data->hwmon_dev); kfree(data->group.attrs); - return 0; } MODULE_DEVICE_TABLE(i2c, pmbus_id); diff --git a/platform/broadcom/sonic-platform-modules-accton/common/modules/cpr_4011_4mxx.c b/platform/broadcom/sonic-platform-modules-accton/common/modules/cpr_4011_4mxx.c index f1790b4515ff..0d0c8a91df85 100644 --- a/platform/broadcom/sonic-platform-modules-accton/common/modules/cpr_4011_4mxx.c +++ b/platform/broadcom/sonic-platform-modules-accton/common/modules/cpr_4011_4mxx.c @@ -293,7 +293,7 @@ static int cpr_4011_4mxx_probe(struct i2c_client *client, return status; } -static int cpr_4011_4mxx_remove(struct i2c_client *client) +static void cpr_4011_4mxx_remove(struct i2c_client *client) { struct cpr_4011_4mxx_data *data = i2c_get_clientdata(client); @@ -301,7 +301,6 @@ static int cpr_4011_4mxx_remove(struct i2c_client *client) sysfs_remove_group(&client->dev.kobj, &cpr_4011_4mxx_group); kfree(data); - return 0; } static const struct i2c_device_id cpr_4011_4mxx_id[] = { diff --git a/platform/broadcom/sonic-platform-modules-accton/common/modules/ym2651y.c b/platform/broadcom/sonic-platform-modules-accton/common/modules/ym2651y.c index 20cef5d61a38..4708d825f451 100755 --- a/platform/broadcom/sonic-platform-modules-accton/common/modules/ym2651y.c +++ b/platform/broadcom/sonic-platform-modules-accton/common/modules/ym2651y.c @@ -489,7 +489,7 @@ static int ym2651y_probe(struct i2c_client *client, return status; } -static int ym2651y_remove(struct i2c_client *client) +static void ym2651y_remove(struct i2c_client *client) { struct ym2651y_data *data = i2c_get_clientdata(client); @@ -497,7 +497,6 @@ static int ym2651y_remove(struct i2c_client *client) sysfs_remove_group(&client->dev.kobj, &ym2651y_group); kfree(data); - return 0; } static const struct i2c_device_id ym2651y_id[] = { diff --git a/platform/broadcom/sonic-platform-modules-accton/minipack/lib/fbfpgaiomodule.c b/platform/broadcom/sonic-platform-modules-accton/minipack/lib/fbfpgaiomodule.c index f5f8c8235fc5..26b0494dbd5d 100755 --- a/platform/broadcom/sonic-platform-modules-accton/minipack/lib/fbfpgaiomodule.c +++ b/platform/broadcom/sonic-platform-modules-accton/minipack/lib/fbfpgaiomodule.c @@ -1,16 +1,3 @@ -# Copyright (c) 2019 Edgecore Networks Corporation -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 -# -# THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR -# CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT -# LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS -# FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT. -# -# See the Apache Version 2.0 License for specific language governing -# permissions and limitations under the License. #include #include @@ -119,13 +106,6 @@ static char docstr[] = "\ In reading operation: data which is read from FPGA\n\ In writing operation: None\n"; -#if PY_MAJOR_VERSION < 3 -PyMODINIT_FUNC -initfbfpgaio(void) -{ - (void) Py_InitModule3("fbfpgaio", FbfpgaMethods, docstr); -} -#else static struct PyModuleDef FbfpgaModule = { PyModuleDef_HEAD_INIT, @@ -140,5 +120,5 @@ PyInit_fbfpgaio(void) { return PyModule_Create(&FbfpgaModule); } -#endif + diff --git a/platform/broadcom/sonic-platform-modules-accton/minipack/modules/minipack_psensor.c b/platform/broadcom/sonic-platform-modules-accton/minipack/modules/minipack_psensor.c index 3155b2b27c4f..72826f46093a 100755 --- a/platform/broadcom/sonic-platform-modules-accton/minipack/modules/minipack_psensor.c +++ b/platform/broadcom/sonic-platform-modules-accton/minipack/modules/minipack_psensor.c @@ -62,7 +62,8 @@ MODULE_PARM_DESC(poll_interval, "Time interval for data polling, in unit of seco #define CHASSIS_LED_COUNT (2) #define CHASSIS_PSU_VOUT_COUNT (1) /*V output only.*/ #define CHASSIS_PSU_VOUT_INDEX (1) /*V output start index.*/ - +#define MAX_MODEL_NAME 21 +#define MAX_SERIAL_NUMBER 19 #define ATTR_ALLOC_EXTRA 1 /*For last attribute which is NUll.*/ #define ATTR_NAME_SIZE 24 @@ -102,6 +103,14 @@ enum sensor_type_e { SENSOR_TYPE_PSU2, SENSOR_TYPE_PSU3, SENSOR_TYPE_PSU4, + SENSOR_TYPE_PSU1_MODEL, + SENSOR_TYPE_PSU2_MODEL, + SENSOR_TYPE_PSU3_MODEL, + SENSOR_TYPE_PSU4_MODEL, + SENSOR_TYPE_PSU1_SERIAL, + SENSOR_TYPE_PSU2_SERIAL, + SENSOR_TYPE_PSU3_SERIAL, + SENSOR_TYPE_PSU4_SERIAL, SENSOR_TYPE_MAX, }; @@ -113,6 +122,14 @@ enum sysfs_attributes_index { INDEX_PSU2_START = SENSOR_TYPE_PSU2 *ATTR_TYPE_INDEX_GAP, INDEX_PSU3_START = SENSOR_TYPE_PSU3 *ATTR_TYPE_INDEX_GAP, INDEX_PSU4_START = SENSOR_TYPE_PSU4 *ATTR_TYPE_INDEX_GAP, + INDEX_PSU1_MODEL = SENSOR_TYPE_PSU1_MODEL *ATTR_TYPE_INDEX_GAP, + INDEX_PSU2_MODEL = SENSOR_TYPE_PSU2_MODEL *ATTR_TYPE_INDEX_GAP, + INDEX_PSU3_MODEL = SENSOR_TYPE_PSU3_MODEL *ATTR_TYPE_INDEX_GAP, + INDEX_PSU4_MODEL = SENSOR_TYPE_PSU4_MODEL *ATTR_TYPE_INDEX_GAP, + INDEX_PSU1_SERIAL = SENSOR_TYPE_PSU1_SERIAL *ATTR_TYPE_INDEX_GAP, + INDEX_PSU2_SERIAL = SENSOR_TYPE_PSU2_SERIAL *ATTR_TYPE_INDEX_GAP, + INDEX_PSU3_SERIAL = SENSOR_TYPE_PSU3_SERIAL *ATTR_TYPE_INDEX_GAP, + INDEX_PSU4_SERIAL = SENSOR_TYPE_PSU4_SERIAL *ATTR_TYPE_INDEX_GAP, INDEX_NAME = SENSOR_TYPE_MAX *ATTR_TYPE_INDEX_GAP, }; @@ -123,6 +140,9 @@ enum sysfs_attributes_index { #define PMBUS_READ_IOUT 0x8C #define PMBUS_READ_POUT 0x96 #define PMBUS_READ_PIN 0x97 +#define PMBUS_READ_FAN 0x90 +#define PMBUS_READ_TEMP 0x8D + #define PMBUS_REG_START PMBUS_READ_VIN #define PMBUS_REG_END PMBUS_READ_PIN @@ -134,6 +154,8 @@ enum psu_data_e { PSU_DATA_IOUT, PSU_DATA_PIN, PSU_DATA_POUT, + PSU_DATA_FAN, + PSU_DATA_TEMP, PSU_DATA_MAX, }; @@ -147,6 +169,8 @@ struct pmbus_reg_t { [PSU_DATA_IOUT] = {PMBUS_READ_IOUT, false}, [PSU_DATA_PIN ] = {PMBUS_READ_PIN, true}, [PSU_DATA_POUT] = {PMBUS_READ_POUT, true}, + [PSU_DATA_FAN] = {PMBUS_READ_FAN, false}, + [PSU_DATA_TEMP] = {PMBUS_READ_TEMP, false}, }; struct sensor_data { @@ -154,6 +178,8 @@ struct sensor_data { int fan_rpm[MAX_FAN_COUNT]; int fan_rpm_dn[MAX_FAN_COUNT]; int psu_data [MAX_PSU_COUNT][PSU_DATA_MAX]; + int psu_model [MAX_PSU_COUNT][MAX_MODEL_NAME]; + int psu_serial [MAX_PSU_COUNT][MAX_SERIAL_NUMBER]; int led_bright[CHASSIS_LED_COUNT]; }; @@ -225,6 +251,10 @@ static struct attr_pattern psu##index##_curr = {CHASSIS_PSU_CHAR_COUNT, \ CHASSIS_PSU_CHAR_COUNT*index, "curr","_input", S_IRUGO, _attr_show, NULL}; \ static struct attr_pattern psu##index##_pwr = {CHASSIS_PSU_CHAR_COUNT, \ CHASSIS_PSU_CHAR_COUNT*index, "power","_input", S_IRUGO, _attr_show, NULL}; \ +static struct attr_pattern psu##index##_fan_speed = {1, \ +1*index, "psu","_fan_speed", S_IRUGO, _attr_show, NULL}; \ +static struct attr_pattern psu##index##_temp_input = {1, \ +1*index, "psu","_temp_input", S_IRUGO, _attr_show, NULL}; \ static struct attr_pattern psu##index##_vmax = {CHASSIS_PSU_VOUT_COUNT, \ CHASSIS_PSU_CHAR_COUNT*index + 1, "in","_max", S_IRUGO, show_psu_vout_max, NULL};\ static struct attr_pattern psu##index##_vmin = {CHASSIS_PSU_VOUT_COUNT, \ @@ -232,7 +262,21 @@ CHASSIS_PSU_CHAR_COUNT*index + 1, "in","_min", S_IRUGO, show_psu_vout_min, NULL} #define DECLARE_PSU_ATTR(index) \ &psu##index##_vin, &psu##index##_curr, &psu##index##_pwr, \ - &psu##index##_vmax, &psu##index##_vmin + &psu##index##_fan_speed, &psu##index##_temp_input ,&psu##index##_vmax, &psu##index##_vmin + +#define DECLARE_PSU_MODEL_NAME_SENSOR_DEVICE_ATTR(index) \ +static struct attr_pattern psu##index##_model_name = {1, \ +1*index, "psu","_model_name", S_IRUGO, _attr_show, NULL}; + +#define DECLARE_PSU_MODEL_NAME_ATTR(index) \ + &psu##index##_model_name + +#define DECLARE_PSU_SERIAL_NUMBER_SENSOR_DEVICE_ATTR(index) \ +static struct attr_pattern psu##index##_serial_name = {1, \ +1*index, "psu","_serial_num", S_IRUGO, _attr_show, NULL}; + +#define DECLARE_PSU_SERIAL_NUMBER_ATTR(index) \ + &psu##index##_serial_name DECLARE_PSU_SENSOR_DEVICE_ATTR(0); @@ -240,6 +284,15 @@ DECLARE_PSU_SENSOR_DEVICE_ATTR(1); DECLARE_PSU_SENSOR_DEVICE_ATTR(2); DECLARE_PSU_SENSOR_DEVICE_ATTR(3); +DECLARE_PSU_MODEL_NAME_SENSOR_DEVICE_ATTR(0); +DECLARE_PSU_MODEL_NAME_SENSOR_DEVICE_ATTR(1); +DECLARE_PSU_MODEL_NAME_SENSOR_DEVICE_ATTR(2); +DECLARE_PSU_MODEL_NAME_SENSOR_DEVICE_ATTR(3); + +DECLARE_PSU_SERIAL_NUMBER_SENSOR_DEVICE_ATTR(0); +DECLARE_PSU_SERIAL_NUMBER_SENSOR_DEVICE_ATTR(1); +DECLARE_PSU_SERIAL_NUMBER_SENSOR_DEVICE_ATTR(2); +DECLARE_PSU_SERIAL_NUMBER_SENSOR_DEVICE_ATTR(3); static char tty_cmd[SENSOR_TYPE_MAX][TTY_CMD_MAX_LEN] = { @@ -259,6 +312,14 @@ static char tty_cmd[SENSOR_TYPE_MAX][TTY_CMD_MAX_LEN] = { "i2cdump -y -f -r "\ __stringify(PMBUS_REG_START)"-" __stringify(PMBUS_REG_END)\ " 56 0x58 w\r", + "i2cdump -y -f 49 0x59 s 0x9a|tail -n +2|cut -c56-\r", + "i2cdump -y -f 48 0x58 s 0x9a|tail -n +2|cut -c56-\r", + "i2cdump -y -f 57 0x59 s 0x9a|tail -n +2|cut -c56-\r", + "i2cdump -y -f 56 0x58 s 0x9a|tail -n +2|cut -c56-\r", + "i2cdump -y -f 49 0x59 s 0x9e|tail -n +2|cut -c56-\r", + "i2cdump -y -f 48 0x58 s 0x9e|tail -n +2|cut -c56-\r", + "i2cdump -y -f 57 0x59 s 0x9e|tail -n +2|cut -c56-\r", + "i2cdump -y -f 56 0x58 s 0x9e|tail -n +2|cut -c56-\r", }; static struct attr_pattern temp_in = @@ -305,6 +366,31 @@ struct sensor_set model_ssets[SENSOR_TYPE_MAX] = { PSU_DATA_MAX, INDEX_PSU4_START, tty_cmd[SENSOR_TYPE_PSU4], TTY_PMBUS_INTERVAL, {DECLARE_PSU_ATTR(3), NULL}, }, + { 1, INDEX_PSU1_MODEL, tty_cmd[SENSOR_TYPE_PSU1_MODEL], + TTY_PMBUS_INTERVAL, {DECLARE_PSU_MODEL_NAME_ATTR(0), NULL}, + }, + { 1, INDEX_PSU2_MODEL, tty_cmd[SENSOR_TYPE_PSU2_MODEL], + TTY_PMBUS_INTERVAL, {DECLARE_PSU_MODEL_NAME_ATTR(1), NULL}, + }, + { 1, INDEX_PSU3_MODEL, tty_cmd[SENSOR_TYPE_PSU3_MODEL], + TTY_PMBUS_INTERVAL, {DECLARE_PSU_MODEL_NAME_ATTR(2), NULL}, + }, + { 1, INDEX_PSU4_MODEL, tty_cmd[SENSOR_TYPE_PSU4_MODEL], + TTY_PMBUS_INTERVAL, {DECLARE_PSU_MODEL_NAME_ATTR(3), NULL}, + }, + { 1, INDEX_PSU1_SERIAL, tty_cmd[SENSOR_TYPE_PSU1_SERIAL], + TTY_PMBUS_INTERVAL, {DECLARE_PSU_SERIAL_NUMBER_ATTR(0), NULL}, + }, + { 1, INDEX_PSU2_SERIAL, tty_cmd[SENSOR_TYPE_PSU2_SERIAL], + TTY_PMBUS_INTERVAL, {DECLARE_PSU_SERIAL_NUMBER_ATTR(1), NULL}, + }, + { 1, INDEX_PSU3_SERIAL, tty_cmd[SENSOR_TYPE_PSU3_SERIAL], + TTY_PMBUS_INTERVAL, {DECLARE_PSU_SERIAL_NUMBER_ATTR(2), NULL}, + }, + { 1, INDEX_PSU4_SERIAL, tty_cmd[SENSOR_TYPE_PSU4_SERIAL], + TTY_PMBUS_INTERVAL, {DECLARE_PSU_SERIAL_NUMBER_ATTR(3), NULL}, + }, + }; static struct minipack_data *mp_data = NULL; @@ -359,9 +445,7 @@ static int _tty_open(struct file **fd) kt.c_iflag = IGNPAR; kt.c_oflag = 0; kt.c_lflag = 0; - kt.c_cc[VMIN] = (unsigned char) - ((MAXIMUM_TTY_STRING_LENGTH > 0xFF) ? - 0xFF : MAXIMUM_TTY_STRING_LENGTH); + kt.c_cc[VMIN] = 0; kt.c_cc[VTIME] = 0; tty_set_termios(tty, &kt); @@ -393,11 +477,9 @@ static int _tty_tx(struct file *tty_fd, const char *str) /*Sanity check*/ if (tty_fd == NULL) return -EINVAL; - if(!(tty_fd->f_op) || !(tty_fd->f_op->read) ||!(tty_fd->f_op->write)) { - return -EINVAL; - } - rc = tty_fd->f_op->write(tty_fd, str, strlen(str)+1,0); + rc = kernel_write(tty_fd, str, strlen(str)+1,0); + if (rc < 0) { pr_info( "failed to write(%d)\n", rc); return -EBUSY; @@ -414,14 +496,11 @@ static int _tty_rx(struct file *tty_fd, char *buf, int max_len) /*Sanity check*/ if (tty_fd == NULL) return -EINVAL; - if(!(tty_fd->f_op) || !(tty_fd->f_op->read) ||!(tty_fd->f_op->write)) { - return -EINVAL; - } /*Clear for remained data cause ambiguous string*/ memset(buf, 0, max_len); do { - rc = tty_fd->f_op->read(tty_fd, buf, max_len, 0); + rc = kernel_read(tty_fd, buf, max_len, 0); if (rc == 0) { /*Buffer Empty, waits. */ timeout++; _tty_wait(TTY_RETRY_INTERVAL); @@ -441,22 +520,19 @@ static int _tty_rx(struct file *tty_fd, char *buf, int max_len) /*Clear Rx buffer by reading it out.*/ static int _tty_clear_rxbuf(struct file *tty_fd, char* buf, size_t max_size) { int rc, i; - mm_segment_t old_fs; int retry = TTY_CMD_RETRY; if (tty_fd == NULL) { return -EINVAL; } - old_fs = get_fs(); - set_fs(KERNEL_DS); + i = 0; do { - rc = tty_fd->f_op->read(tty_fd, buf, max_size, 0); + rc = kernel_read(tty_fd, buf, max_size, 0); memset(buf, 0, max_size); i++; } while (rc > 0 && i < retry); - set_fs(old_fs); return rc; } @@ -464,20 +540,13 @@ static int _tty_writeNread(struct file *tty_fd, char *wr_p, char *rd_p, int rx_max_len, u32 mdelay) { int rc; - mm_segment_t old_fs; /*Presumed file is opened!*/ if (tty_fd == NULL) return -EINVAL; - if(!(tty_fd->f_op) || !(tty_fd->f_op->read) ||!(tty_fd->f_op->write)) { - pr_info("file %s cann't readable or writable?\n", TTY_DEVICE); - return -EINVAL; - } - memset(rd_p, 0, rx_max_len); - old_fs = get_fs(); - set_fs(KERNEL_DS); + rc = _tty_tx(tty_fd, wr_p); if (rc < 0) { DEBUG_INTR( "failed to write(%d)\n", rc); @@ -491,7 +560,6 @@ static int _tty_writeNread(struct file *tty_fd, } exit: - set_fs(old_fs); return rc; } @@ -810,6 +878,27 @@ static int get_pmbus_regs_partial(int *in, int in_cnt, int *out, int *out_cnt) return 0; } +static int extract_psu_str(int type, char *buf, int *out, int len) +{ + char *ptr; + int x, i; + + ptr = buf; + + i=0; + for (x = 0; x < strlen(ptr); x++) { + if(ptr[x] > 0x7A || ptr[x] <0x1E) + continue; + + out[i]=ptr[x]; + i++; + if(i==(len-2)) + break; + } + out[len-1]=0x0; + + return 0; +} static int comm2BMC(enum sensor_type_e type, int *out, int out_cnt) { @@ -853,6 +942,18 @@ static int comm2BMC(enum sensor_type_e type, int *out, int out_cnt) get_pmbus_regs_partial(reg, total, out, &out_cnt); break; } + case SENSOR_TYPE_PSU1_MODEL: + case SENSOR_TYPE_PSU2_MODEL: + case SENSOR_TYPE_PSU3_MODEL: + case SENSOR_TYPE_PSU4_MODEL: + ret=extract_psu_str(type, ptr, out, MAX_MODEL_NAME); + break; + case SENSOR_TYPE_PSU1_SERIAL: + case SENSOR_TYPE_PSU2_SERIAL: + case SENSOR_TYPE_PSU3_SERIAL: + case SENSOR_TYPE_PSU4_SERIAL: + ret=extract_psu_str(type ,ptr, out, MAX_SERIAL_NUMBER); + break; default: return -EINVAL; } @@ -882,6 +983,18 @@ static int get_type_data ( case SENSOR_TYPE_PSU4: *out = &data->psu_data[type-SENSOR_TYPE_PSU1][index]; break; + case SENSOR_TYPE_PSU1_MODEL: + case SENSOR_TYPE_PSU2_MODEL: + case SENSOR_TYPE_PSU3_MODEL: + case SENSOR_TYPE_PSU4_MODEL: + *out = &data->psu_model[type-SENSOR_TYPE_PSU1_MODEL][index]; + break; + case SENSOR_TYPE_PSU1_SERIAL: + case SENSOR_TYPE_PSU2_SERIAL: + case SENSOR_TYPE_PSU3_SERIAL: + case SENSOR_TYPE_PSU4_SERIAL: + *out = &data->psu_serial[type-SENSOR_TYPE_PSU1_SERIAL][index]; + break; default: return -EINVAL; } @@ -942,6 +1055,9 @@ static ssize_t _attr_show(struct device *dev, struct device_attribute *da, struct sensor_device_attribute *attr = to_sensor_dev_attr(da); struct sensor_data* data; int *out = NULL; + int i; + char model_name[MAX_MODEL_NAME]; + char serial_number[MAX_SERIAL_NUMBER]; enum sensor_type_e type; type = attr->index / ATTR_TYPE_INDEX_GAP; @@ -958,6 +1074,35 @@ static ssize_t _attr_show(struct device *dev, struct device_attribute *da, if( index > count) return -EINVAL; + + if(type >=SENSOR_TYPE_PSU1_MODEL && type <=SENSOR_TYPE_PSU4_MODEL) + { + for(i=0; i=SENSOR_TYPE_PSU1_SERIAL && type <=SENSOR_TYPE_PSU4_SERIAL) + { + + for(i=0; idev.kobj, &fpgai2c_attribute_group); - board_i2c_fpga_remove_client(client); + board_i2c_fpga_remove_client(client); } static const struct i2c_device_id board_i2c_fpga_id[] = {