aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ehea/ehea_main.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/ehea/ehea_main.c')
-rw-r--r--drivers/net/ehea/ehea_main.c77
1 files changed, 61 insertions, 16 deletions
diff --git a/drivers/net/ehea/ehea_main.c b/drivers/net/ehea/ehea_main.c
index e6fe2cfbd999..368f8e3eb4a0 100644
--- a/drivers/net/ehea/ehea_main.c
+++ b/drivers/net/ehea/ehea_main.c
@@ -78,6 +78,28 @@ MODULE_PARM_DESC(sq_entries, " Number of entries for the Send Queue "
78 __MODULE_STRING(EHEA_DEF_ENTRIES_SQ) ")"); 78 __MODULE_STRING(EHEA_DEF_ENTRIES_SQ) ")");
79MODULE_PARM_DESC(use_mcs, " 0:NAPI, 1:Multiple receive queues, Default = 1 "); 79MODULE_PARM_DESC(use_mcs, " 0:NAPI, 1:Multiple receive queues, Default = 1 ");
80 80
81static int port_name_cnt = 0;
82
83static int __devinit ehea_probe_adapter(struct ibmebus_dev *dev,
84 const struct of_device_id *id);
85
86static int __devexit ehea_remove(struct ibmebus_dev *dev);
87
88static struct of_device_id ehea_device_table[] = {
89 {
90 .name = "lhea",
91 .compatible = "IBM,lhea",
92 },
93 {},
94};
95
96static struct ibmebus_driver ehea_driver = {
97 .name = "ehea",
98 .id_table = ehea_device_table,
99 .probe = ehea_probe_adapter,
100 .remove = ehea_remove,
101};
102
81void ehea_dump(void *adr, int len, char *msg) { 103void ehea_dump(void *adr, int len, char *msg) {
82 int x; 104 int x;
83 unsigned char *deb = adr; 105 unsigned char *deb = adr;
@@ -2364,6 +2386,34 @@ static void __devinit logical_port_release(struct device *dev)
2364 of_node_put(port->ofdev.node); 2386 of_node_put(port->ofdev.node);
2365} 2387}
2366 2388
2389static int ehea_driver_sysfs_add(struct device *dev,
2390 struct device_driver *driver)
2391{
2392 int ret;
2393
2394 ret = sysfs_create_link(&driver->kobj, &dev->kobj,
2395 kobject_name(&dev->kobj));
2396 if (ret == 0) {
2397 ret = sysfs_create_link(&dev->kobj, &driver->kobj,
2398 "driver");
2399 if (ret)
2400 sysfs_remove_link(&driver->kobj,
2401 kobject_name(&dev->kobj));
2402 }
2403 return ret;
2404}
2405
2406static void ehea_driver_sysfs_remove(struct device *dev,
2407 struct device_driver *driver)
2408{
2409 struct device_driver *drv = driver;
2410
2411 if (drv) {
2412 sysfs_remove_link(&drv->kobj, kobject_name(&dev->kobj));
2413 sysfs_remove_link(&dev->kobj, "driver");
2414 }
2415}
2416
2367static struct device *ehea_register_port(struct ehea_port *port, 2417static struct device *ehea_register_port(struct ehea_port *port,
2368 struct device_node *dn) 2418 struct device_node *dn)
2369{ 2419{
@@ -2371,8 +2421,9 @@ static struct device *ehea_register_port(struct ehea_port *port,
2371 2421
2372 port->ofdev.node = of_node_get(dn); 2422 port->ofdev.node = of_node_get(dn);
2373 port->ofdev.dev.parent = &port->adapter->ebus_dev->ofdev.dev; 2423 port->ofdev.dev.parent = &port->adapter->ebus_dev->ofdev.dev;
2424 port->ofdev.dev.bus = &ibmebus_bus_type;
2374 2425
2375 sprintf(port->ofdev.dev.bus_id, "port%d", port->logical_port_id); 2426 sprintf(port->ofdev.dev.bus_id, "port%d", port_name_cnt++);
2376 port->ofdev.dev.release = logical_port_release; 2427 port->ofdev.dev.release = logical_port_release;
2377 2428
2378 ret = of_device_register(&port->ofdev); 2429 ret = of_device_register(&port->ofdev);
@@ -2387,8 +2438,16 @@ static struct device *ehea_register_port(struct ehea_port *port,
2387 goto out_unreg_of_dev; 2438 goto out_unreg_of_dev;
2388 } 2439 }
2389 2440
2441 ret = ehea_driver_sysfs_add(&port->ofdev.dev, &ehea_driver.driver);
2442 if (ret) {
2443 ehea_error("failed to register sysfs driver link");
2444 goto out_rem_dev_file;
2445 }
2446
2390 return &port->ofdev.dev; 2447 return &port->ofdev.dev;
2391 2448
2449out_rem_dev_file:
2450 device_remove_file(&port->ofdev.dev, &dev_attr_log_port_id);
2392out_unreg_of_dev: 2451out_unreg_of_dev:
2393 of_device_unregister(&port->ofdev); 2452 of_device_unregister(&port->ofdev);
2394out: 2453out:
@@ -2397,6 +2456,7 @@ out:
2397 2456
2398static void ehea_unregister_port(struct ehea_port *port) 2457static void ehea_unregister_port(struct ehea_port *port)
2399{ 2458{
2459 ehea_driver_sysfs_remove(&port->ofdev.dev, &ehea_driver.driver);
2400 device_remove_file(&port->ofdev.dev, &dev_attr_log_port_id); 2460 device_remove_file(&port->ofdev.dev, &dev_attr_log_port_id);
2401 of_device_unregister(&port->ofdev); 2461 of_device_unregister(&port->ofdev);
2402} 2462}
@@ -2841,21 +2901,6 @@ static int check_module_parm(void)
2841 return ret; 2901 return ret;
2842} 2902}
2843 2903
2844static struct of_device_id ehea_device_table[] = {
2845 {
2846 .name = "lhea",
2847 .compatible = "IBM,lhea",
2848 },
2849 {},
2850};
2851
2852static struct ibmebus_driver ehea_driver = {
2853 .name = "ehea",
2854 .id_table = ehea_device_table,
2855 .probe = ehea_probe_adapter,
2856 .remove = ehea_remove,
2857};
2858
2859int __init ehea_module_init(void) 2904int __init ehea_module_init(void)
2860{ 2905{
2861 int ret; 2906 int ret;