From 397ea57cbd37213d651ed388f4ac4fb35a97e0b2 Mon Sep 17 00:00:00 2001 From: Alex Forencich Date: Sat, 10 Jun 2023 20:14:29 -0700 Subject: [PATCH] modules/mqnic: software_node struct must be static, just set I2C mux props for all clients instead of attempting to do something dynamic Signed-off-by: Alex Forencich --- modules/mqnic/mqnic_board.c | 131 ++++++++++++++++++------------------ 1 file changed, 65 insertions(+), 66 deletions(-) diff --git a/modules/mqnic/mqnic_board.c b/modules/mqnic/mqnic_board.c index cd572af42..ad62f0893 100644 --- a/modules/mqnic/mqnic_board.c +++ b/modules/mqnic/mqnic_board.c @@ -44,14 +44,17 @@ static const struct property_entry i2c_mux_props[] = { {} }; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 13, 0) +static const struct software_node i2c_mux_node = { + .properties = i2c_mux_props +}; +#endif + static struct i2c_client *create_i2c_client(struct i2c_adapter *adapter, - const char *type, int addr, const struct property_entry *props) + const char *type, int addr) { struct i2c_client *client; struct i2c_board_info board_info; -#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 13, 0) - struct software_node sw_node; -#endif int err; if (!adapter) @@ -60,15 +63,11 @@ static struct i2c_client *create_i2c_client(struct i2c_adapter *adapter, memset(&board_info, 0, sizeof(board_info)); strscpy(board_info.type, type, I2C_NAME_SIZE); board_info.addr = addr; - if (props) { #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 13, 0) - memset(&sw_node, 0, sizeof(sw_node)); - sw_node.properties = props; - board_info.swnode = &sw_node; + board_info.swnode = &i2c_mux_node; #else - board_info.properties = props; + board_info.properties = i2c_mux_props; #endif - } #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 2, 0) client = i2c_new_client_device(adapter, &board_info); #else @@ -237,19 +236,19 @@ static int mqnic_generic_board_init(struct mqnic_dev *mqnic) adapter = mqnic_i2c_adapter_create(mqnic, 0); // IC31 TCA9548 I2C MUX - mux = create_i2c_client(adapter, "pca9548", 0x74, i2c_mux_props); + mux = create_i2c_client(adapter, "pca9548", 0x74); // IC3 SFP1 - mqnic->mod_i2c_client[0] = create_i2c_client(get_i2c_mux_channel(mux, 0), "24c02", 0x50, NULL); + mqnic->mod_i2c_client[0] = create_i2c_client(get_i2c_mux_channel(mux, 0), "24c02", 0x50); // IC5 SFP2 - mqnic->mod_i2c_client[1] = create_i2c_client(get_i2c_mux_channel(mux, 1), "24c02", 0x50, NULL); + mqnic->mod_i2c_client[1] = create_i2c_client(get_i2c_mux_channel(mux, 1), "24c02", 0x50); // IC6 SFP3 - mqnic->mod_i2c_client[2] = create_i2c_client(get_i2c_mux_channel(mux, 2), "24c02", 0x50, NULL); + mqnic->mod_i2c_client[2] = create_i2c_client(get_i2c_mux_channel(mux, 2), "24c02", 0x50); // IC8 SFP4 - mqnic->mod_i2c_client[3] = create_i2c_client(get_i2c_mux_channel(mux, 3), "24c02", 0x50, NULL); + mqnic->mod_i2c_client[3] = create_i2c_client(get_i2c_mux_channel(mux, 3), "24c02", 0x50); mqnic->mod_i2c_client_count = 4; @@ -278,16 +277,16 @@ static int mqnic_generic_board_init(struct mqnic_dev *mqnic) adapter = mqnic_i2c_adapter_create(mqnic, 0); // U28 TCA9548 I2C MUX - mux = create_i2c_client(adapter, "pca9548", 0x74, i2c_mux_props); + mux = create_i2c_client(adapter, "pca9548", 0x74); // U145 QSFP - mqnic->mod_i2c_client[0] = create_i2c_client(get_i2c_mux_channel(mux, 2), "24c02", 0x50, NULL); + mqnic->mod_i2c_client[0] = create_i2c_client(get_i2c_mux_channel(mux, 2), "24c02", 0x50); // U80 PCA9544 I2C MUX - mux = create_i2c_client(adapter, "pca9544", 0x75, i2c_mux_props); + mux = create_i2c_client(adapter, "pca9544", 0x75); // U12 I2C EEPROM - mqnic->eeprom_i2c_client = create_i2c_client(get_i2c_mux_channel(mux, 3), "24c08", 0x54, NULL); + mqnic->eeprom_i2c_client = create_i2c_client(get_i2c_mux_channel(mux, 3), "24c08", 0x54); mqnic->mod_i2c_client_count = 1; @@ -323,19 +322,19 @@ static int mqnic_generic_board_init(struct mqnic_dev *mqnic) adapter = mqnic_i2c_adapter_create(mqnic, 0); // U28 TCA9548 I2C MUX - mux = create_i2c_client(adapter, "pca9548", 0x74, i2c_mux_props); + mux = create_i2c_client(adapter, "pca9548", 0x74); // U145 QSFP1 - mqnic->mod_i2c_client[0] = create_i2c_client(get_i2c_mux_channel(mux, 2), "24c02", 0x50, NULL); + mqnic->mod_i2c_client[0] = create_i2c_client(get_i2c_mux_channel(mux, 2), "24c02", 0x50); // U123 QSFP2 - mqnic->mod_i2c_client[1] = create_i2c_client(get_i2c_mux_channel(mux, 3), "24c02", 0x50, NULL); + mqnic->mod_i2c_client[1] = create_i2c_client(get_i2c_mux_channel(mux, 3), "24c02", 0x50); // U80 PCA9548 I2C MUX - mux = create_i2c_client(adapter, "pca9548", 0x75, i2c_mux_props); + mux = create_i2c_client(adapter, "pca9548", 0x75); // U12 I2C EEPROM - mqnic->eeprom_i2c_client = create_i2c_client(get_i2c_mux_channel(mux, 3), "24c08", 0x54, NULL); + mqnic->eeprom_i2c_client = create_i2c_client(get_i2c_mux_channel(mux, 3), "24c08", 0x54); mqnic->mod_i2c_client_count = 2; @@ -359,16 +358,16 @@ static int mqnic_generic_board_init(struct mqnic_dev *mqnic) adapter = mqnic_i2c_adapter_create(mqnic, 0); // U28 TCA9546 I2C MUX - mux = create_i2c_client(adapter, "pca9546", 0x74, i2c_mux_props); + mux = create_i2c_client(adapter, "pca9546", 0x74); // J7 QSFP0 - mqnic->mod_i2c_client[0] = create_i2c_client(get_i2c_mux_channel(mux, 0), "24c02", 0x50, NULL); + mqnic->mod_i2c_client[0] = create_i2c_client(get_i2c_mux_channel(mux, 0), "24c02", 0x50); // J9 QSFP1 - mqnic->mod_i2c_client[1] = create_i2c_client(get_i2c_mux_channel(mux, 1), "24c02", 0x50, NULL); + mqnic->mod_i2c_client[1] = create_i2c_client(get_i2c_mux_channel(mux, 1), "24c02", 0x50); // U12 I2C EEPROM - mqnic->eeprom_i2c_client = create_i2c_client(get_i2c_mux_channel(mux, 2), "24c08", 0x54, NULL); + mqnic->eeprom_i2c_client = create_i2c_client(get_i2c_mux_channel(mux, 2), "24c08", 0x54); mqnic->mod_i2c_client_count = 2; @@ -412,19 +411,19 @@ static int mqnic_generic_board_init(struct mqnic_dev *mqnic) adapter = mqnic_i2c_adapter_create(mqnic, 0); // U34 TCA9548 I2C MUX - mux = create_i2c_client(adapter, "pca9548", 0x74, i2c_mux_props); + mux = create_i2c_client(adapter, "pca9548", 0x74); // U23 I2C EEPROM - mqnic->eeprom_i2c_client = create_i2c_client(get_i2c_mux_channel(mux, 0), "24c08", 0x54, NULL); + mqnic->eeprom_i2c_client = create_i2c_client(get_i2c_mux_channel(mux, 0), "24c08", 0x54); // U135 TCA9548 I2C MUX - mux = create_i2c_client(adapter, "pca9548", 0x75, i2c_mux_props); + mux = create_i2c_client(adapter, "pca9548", 0x75); // P1 SFP0 - mqnic->mod_i2c_client[0] = create_i2c_client(get_i2c_mux_channel(mux, 7), "24c02", 0x50, NULL); + mqnic->mod_i2c_client[0] = create_i2c_client(get_i2c_mux_channel(mux, 7), "24c02", 0x50); // P2 SFP1 - mqnic->mod_i2c_client[1] = create_i2c_client(get_i2c_mux_channel(mux, 6), "24c02", 0x50, NULL); + mqnic->mod_i2c_client[1] = create_i2c_client(get_i2c_mux_channel(mux, 6), "24c02", 0x50); mqnic->mod_i2c_client_count = 2; @@ -441,7 +440,7 @@ static int mqnic_generic_board_init(struct mqnic_dev *mqnic) // FPC202 default address 0x0f, module addresses 0x78 and 0x7c // release reset and deassert lpmode - client = create_i2c_client(adapter, "24c02", 0x0f, NULL); + client = create_i2c_client(adapter, "24c02", 0x0f); if (client) { i2c_smbus_write_i2c_block_data(client, 0x08, 1, "\x55"); @@ -451,15 +450,15 @@ static int mqnic_generic_board_init(struct mqnic_dev *mqnic) } // QSFP 1 - mqnic->mod_i2c_client[0] = create_i2c_client(adapter, "24c02", 0x78, NULL); + mqnic->mod_i2c_client[0] = create_i2c_client(adapter, "24c02", 0x78); // QSFP 2 - mqnic->mod_i2c_client[1] = create_i2c_client(adapter, "24c02", 0x7c, NULL); + mqnic->mod_i2c_client[1] = create_i2c_client(adapter, "24c02", 0x7c); mqnic->mod_i2c_client_count = 2; // U94 I2C EEPROM - mqnic->eeprom_i2c_client = create_i2c_client(adapter, "24c128", 0x57, NULL); + mqnic->eeprom_i2c_client = create_i2c_client(adapter, "24c128", 0x57); break; case MQNIC_BOARD_ID_DK_DEV_AGF014EA: @@ -470,7 +469,7 @@ static int mqnic_generic_board_init(struct mqnic_dev *mqnic) adapter = mqnic_i2c_adapter_create(mqnic, 0); // U23 I2C EEPROM - mqnic->eeprom_i2c_client = create_i2c_client(adapter, "24c64", 0x50, NULL); + mqnic->eeprom_i2c_client = create_i2c_client(adapter, "24c64", 0x50); break; case MQNIC_BOARD_ID_DE10_AGILEX: @@ -481,13 +480,13 @@ static int mqnic_generic_board_init(struct mqnic_dev *mqnic) adapter = mqnic_i2c_adapter_create(mqnic, 0); // QSFP-DD A - mqnic->mod_i2c_client[0] = create_i2c_client(adapter, "24c02", 0x50, NULL); + mqnic->mod_i2c_client[0] = create_i2c_client(adapter, "24c02", 0x50); // I2C adapter adapter = mqnic_i2c_adapter_create(mqnic, 1); // QSFP-DD B - mqnic->mod_i2c_client[1] = create_i2c_client(adapter, "24c02", 0x50, NULL); + mqnic->mod_i2c_client[1] = create_i2c_client(adapter, "24c02", 0x50); mqnic->mod_i2c_client_count = 2; @@ -513,13 +512,13 @@ static int mqnic_generic_board_init(struct mqnic_dev *mqnic) adapter = mqnic_i2c_adapter_create(mqnic, 0); // U34 TCA9548 I2C MUX - mux = create_i2c_client(adapter, "pca9548", 0x70, i2c_mux_props); + mux = create_i2c_client(adapter, "pca9548", 0x70); // QSFP0 - mqnic->mod_i2c_client[0] = create_i2c_client(get_i2c_mux_channel(mux, 6), "24c02", 0x50, NULL); + mqnic->mod_i2c_client[0] = create_i2c_client(get_i2c_mux_channel(mux, 6), "24c02", 0x50); // QSFP1 - mqnic->mod_i2c_client[1] = create_i2c_client(get_i2c_mux_channel(mux, 7), "24c02", 0x50, NULL); + mqnic->mod_i2c_client[1] = create_i2c_client(get_i2c_mux_channel(mux, 7), "24c02", 0x50); mqnic->mod_i2c_client_count = 2; @@ -530,7 +529,7 @@ static int mqnic_generic_board_init(struct mqnic_dev *mqnic) adapter = mqnic_i2c_adapter_create(mqnic, 2); // I2C EEPROM - mqnic->eeprom_i2c_client = create_i2c_client(adapter, "24c16", 0x50, NULL); + mqnic->eeprom_i2c_client = create_i2c_client(adapter, "24c16", 0x50); break; case MQNIC_BOARD_ID_XUPP3R: @@ -541,25 +540,25 @@ static int mqnic_generic_board_init(struct mqnic_dev *mqnic) adapter = mqnic_i2c_adapter_create(mqnic, 0); // QSFP0 - mqnic->mod_i2c_client[0] = create_i2c_client(adapter, "24c02", 0x50, NULL); + mqnic->mod_i2c_client[0] = create_i2c_client(adapter, "24c02", 0x50); // I2C adapter adapter = mqnic_i2c_adapter_create(mqnic, 1); // QSFP1 - mqnic->mod_i2c_client[1] = create_i2c_client(adapter, "24c02", 0x50, NULL); + mqnic->mod_i2c_client[1] = create_i2c_client(adapter, "24c02", 0x50); // I2C adapter adapter = mqnic_i2c_adapter_create(mqnic, 2); // QSFP2 - mqnic->mod_i2c_client[2] = create_i2c_client(adapter, "24c02", 0x50, NULL); + mqnic->mod_i2c_client[2] = create_i2c_client(adapter, "24c02", 0x50); // I2C adapter adapter = mqnic_i2c_adapter_create(mqnic, 3); // QSFP3 - mqnic->mod_i2c_client[3] = create_i2c_client(adapter, "24c02", 0x50, NULL); + mqnic->mod_i2c_client[3] = create_i2c_client(adapter, "24c02", 0x50); mqnic->mod_i2c_client_count = 4; @@ -567,7 +566,7 @@ static int mqnic_generic_board_init(struct mqnic_dev *mqnic) adapter = mqnic_i2c_adapter_create(mqnic, 4); // I2C EEPROM - mqnic->eeprom_i2c_client = create_i2c_client(adapter, "24c04", 0x50, NULL); + mqnic->eeprom_i2c_client = create_i2c_client(adapter, "24c04", 0x50); // read MACs from EEPROM init_mac_list_from_eeprom_base_hex(mqnic, mqnic->eeprom_i2c_client, 4, MQNIC_MAX_IF); @@ -583,7 +582,7 @@ static int mqnic_generic_board_init(struct mqnic_dev *mqnic) adapter = mqnic_i2c_adapter_create(mqnic, 1); // I2C EEPROM - mqnic->eeprom_i2c_client = create_i2c_client(adapter, "24c02", 0x50, NULL); + mqnic->eeprom_i2c_client = create_i2c_client(adapter, "24c02", 0x50); // read MACs from EEPROM init_mac_list_from_eeprom_base(mqnic, mqnic->eeprom_i2c_client, 0, MQNIC_MAX_IF); @@ -597,13 +596,13 @@ static int mqnic_generic_board_init(struct mqnic_dev *mqnic) adapter = mqnic_i2c_adapter_create(mqnic, 0); // QSFP0 - mqnic->mod_i2c_client[0] = create_i2c_client(adapter, "24c02", 0x50, NULL); + mqnic->mod_i2c_client[0] = create_i2c_client(adapter, "24c02", 0x50); // I2C adapter adapter = mqnic_i2c_adapter_create(mqnic, 1); // QSFP1 - mqnic->mod_i2c_client[1] = create_i2c_client(adapter, "24c02", 0x50, NULL); + mqnic->mod_i2c_client[1] = create_i2c_client(adapter, "24c02", 0x50); mqnic->mod_i2c_client_count = 2; @@ -611,7 +610,7 @@ static int mqnic_generic_board_init(struct mqnic_dev *mqnic) adapter = mqnic_i2c_adapter_create(mqnic, 2); // I2C EEPROM - mqnic->eeprom_i2c_client = create_i2c_client(adapter, "24c02", 0x50, NULL); + mqnic->eeprom_i2c_client = create_i2c_client(adapter, "24c02", 0x50); // read MACs from EEPROM init_mac_list_from_eeprom_base(mqnic, mqnic->eeprom_i2c_client, 0, MQNIC_MAX_IF); @@ -625,13 +624,13 @@ static int mqnic_generic_board_init(struct mqnic_dev *mqnic) adapter = mqnic_i2c_adapter_create(mqnic, 0); // QSFP0 - mqnic->mod_i2c_client[0] = create_i2c_client(adapter, "24c02", 0x50, NULL); + mqnic->mod_i2c_client[0] = create_i2c_client(adapter, "24c02", 0x50); // I2C adapter adapter = mqnic_i2c_adapter_create(mqnic, 1); // QSFP1 - mqnic->mod_i2c_client[1] = create_i2c_client(adapter, "24c02", 0x50, NULL); + mqnic->mod_i2c_client[1] = create_i2c_client(adapter, "24c02", 0x50); mqnic->mod_i2c_client_count = 2; @@ -639,7 +638,7 @@ static int mqnic_generic_board_init(struct mqnic_dev *mqnic) adapter = mqnic_i2c_adapter_create(mqnic, 2); // I2C EEPROM - mqnic->eeprom_i2c_client = create_i2c_client(adapter, "24c256", 0x50, NULL); + mqnic->eeprom_i2c_client = create_i2c_client(adapter, "24c256", 0x50); // read MACs from EEPROM // init_mac_list_from_eeprom(mqnic, mqnic->eeprom_i2c_client, 0x000E, MQNIC_MAX_IF); @@ -653,25 +652,25 @@ static int mqnic_generic_board_init(struct mqnic_dev *mqnic) adapter = mqnic_i2c_adapter_create(mqnic, 0); // QSFP0 - mqnic->mod_i2c_client[0] = create_i2c_client(adapter, "24c02", 0x50, NULL); + mqnic->mod_i2c_client[0] = create_i2c_client(adapter, "24c02", 0x50); // I2C adapter adapter = mqnic_i2c_adapter_create(mqnic, 1); // QSFP1 - mqnic->mod_i2c_client[1] = create_i2c_client(adapter, "24c02", 0x50, NULL); + mqnic->mod_i2c_client[1] = create_i2c_client(adapter, "24c02", 0x50); // I2C adapter adapter = mqnic_i2c_adapter_create(mqnic, 2); // QSFP2 - mqnic->mod_i2c_client[2] = create_i2c_client(adapter, "24c02", 0x50, NULL); + mqnic->mod_i2c_client[2] = create_i2c_client(adapter, "24c02", 0x50); // I2C adapter adapter = mqnic_i2c_adapter_create(mqnic, 3); // QSFP3 - mqnic->mod_i2c_client[3] = create_i2c_client(adapter, "24c02", 0x50, NULL); + mqnic->mod_i2c_client[3] = create_i2c_client(adapter, "24c02", 0x50); mqnic->mod_i2c_client_count = 4; @@ -801,16 +800,16 @@ static int mqnic_alveo_board_init(struct mqnic_dev *mqnic) adapter = mqnic_i2c_adapter_create(mqnic, 0); // U28 TCA9546 I2C MUX - mux = create_i2c_client(adapter, "pca9546", 0x74, i2c_mux_props); + mux = create_i2c_client(adapter, "pca9546", 0x74); // J7 QSFP0 - mqnic->mod_i2c_client[0] = create_i2c_client(get_i2c_mux_channel(mux, 0), "24c02", 0x50, NULL); + mqnic->mod_i2c_client[0] = create_i2c_client(get_i2c_mux_channel(mux, 0), "24c02", 0x50); // J9 QSFP1 - mqnic->mod_i2c_client[1] = create_i2c_client(get_i2c_mux_channel(mux, 1), "24c02", 0x50, NULL); + mqnic->mod_i2c_client[1] = create_i2c_client(get_i2c_mux_channel(mux, 1), "24c02", 0x50); // U12 I2C EEPROM - mqnic->eeprom_i2c_client = create_i2c_client(get_i2c_mux_channel(mux, 2), "24c08", 0x54, NULL); + mqnic->eeprom_i2c_client = create_i2c_client(get_i2c_mux_channel(mux, 2), "24c08", 0x54); mqnic->mod_i2c_client_count = 2; @@ -979,13 +978,13 @@ static int mqnic_gecko_board_init(struct mqnic_dev *mqnic) adapter = mqnic_i2c_adapter_create(mqnic, 0); // QSFP0 - mqnic->mod_i2c_client[0] = create_i2c_client(adapter, "24c02", 0x50, NULL); + mqnic->mod_i2c_client[0] = create_i2c_client(adapter, "24c02", 0x50); // I2C adapter adapter = mqnic_i2c_adapter_create(mqnic, 1); // QSFP1 - mqnic->mod_i2c_client[1] = create_i2c_client(adapter, "24c02", 0x50, NULL); + mqnic->mod_i2c_client[1] = create_i2c_client(adapter, "24c02", 0x50); mqnic->mod_i2c_client_count = 2;