ehea: New method to determine number of available ports

Count OFDT nodes to determine the number of available ports
instead of using the possibly outdated value from the hypervisor

Signed-off-by: Thomas Klein <tklein@de.ibm.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>

authored by Thomas Klein and committed by Jeff Garzik 4e996b32 e919b593

+14 -1
+14 -1
drivers/net/ehea/ehea_main.c
··· 2269 int ehea_sense_adapter_attr(struct ehea_adapter *adapter) 2270 { 2271 struct hcp_query_ehea *cb; 2272 u64 hret; 2273 int ret; 2274 ··· 2287 goto out_herr; 2288 } 2289 2290 - adapter->num_ports = cb->num_ports; 2291 adapter->max_mc_mac = cb->max_mc_mac - 1; 2292 ret = 0; 2293
··· 2269 int ehea_sense_adapter_attr(struct ehea_adapter *adapter) 2270 { 2271 struct hcp_query_ehea *cb; 2272 + struct device_node *lhea_dn = NULL; 2273 + struct device_node *eth_dn = NULL; 2274 u64 hret; 2275 int ret; 2276 ··· 2285 goto out_herr; 2286 } 2287 2288 + /* Determine the number of available logical ports 2289 + * by counting the child nodes of the lhea OFDT entry 2290 + */ 2291 + adapter->num_ports = 0; 2292 + lhea_dn = of_find_node_by_name(lhea_dn, "lhea"); 2293 + do { 2294 + eth_dn = of_get_next_child(lhea_dn, eth_dn); 2295 + if (eth_dn) 2296 + adapter->num_ports++; 2297 + } while ( eth_dn ); 2298 + of_node_put(lhea_dn); 2299 + 2300 adapter->max_mc_mac = cb->max_mc_mac - 1; 2301 ret = 0; 2302