]> err.no Git - linux-2.6/commitdiff
ehea: fix for sysfs entries
authorThomas Klein <osstklei@de.ibm.com>
Thu, 26 Apr 2007 09:56:13 +0000 (11:56 +0200)
committerJeff Garzik <jeff@garzik.org>
Sat, 28 Apr 2007 15:01:06 +0000 (11:01 -0400)
Create symbolic link from each logical port to ehea driver

Signed-off-by: Thomas Klein <tklein@de.ibm.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
drivers/net/ehea/ehea.h
drivers/net/ehea/ehea_main.c

index 1405d0b0b7e7f9998b56254e11f4f8e2181ab2fd..136a6c19e259fed683f1f50e5cf17c45d067b561 100644 (file)
@@ -39,7 +39,7 @@
 #include <asm/io.h>
 
 #define DRV_NAME       "ehea"
-#define DRV_VERSION    "EHEA_0055"
+#define DRV_VERSION    "EHEA_0057"
 
 #define EHEA_MSG_DEFAULT (NETIF_MSG_LINK | NETIF_MSG_TIMER \
        | NETIF_MSG_RX_ERR | NETIF_MSG_TX_ERR)
index e6fe2cfbd999a194aa33594c03bad283e3f2789f..368f8e3eb4a07cc6a81e3c8a51cee56a05578cdb 100644 (file)
@@ -78,6 +78,28 @@ MODULE_PARM_DESC(sq_entries, " Number of entries for the Send Queue  "
                 __MODULE_STRING(EHEA_DEF_ENTRIES_SQ) ")");
 MODULE_PARM_DESC(use_mcs, " 0:NAPI, 1:Multiple receive queues, Default = 1 ");
 
+static int port_name_cnt = 0;
+
+static int __devinit ehea_probe_adapter(struct ibmebus_dev *dev,
+                                        const struct of_device_id *id);
+
+static int __devexit ehea_remove(struct ibmebus_dev *dev);
+
+static struct of_device_id ehea_device_table[] = {
+       {
+               .name = "lhea",
+               .compatible = "IBM,lhea",
+       },
+       {},
+};
+
+static struct ibmebus_driver ehea_driver = {
+       .name = "ehea",
+       .id_table = ehea_device_table,
+       .probe = ehea_probe_adapter,
+       .remove = ehea_remove,
+};
+
 void ehea_dump(void *adr, int len, char *msg) {
        int x;
        unsigned char *deb = adr;
@@ -2364,6 +2386,34 @@ static void __devinit logical_port_release(struct device *dev)
        of_node_put(port->ofdev.node);
 }
 
+static int ehea_driver_sysfs_add(struct device *dev,
+                                 struct device_driver *driver)
+{
+       int ret;
+
+       ret = sysfs_create_link(&driver->kobj, &dev->kobj,
+                               kobject_name(&dev->kobj));
+       if (ret == 0) {
+               ret = sysfs_create_link(&dev->kobj, &driver->kobj,
+                                       "driver");
+               if (ret)
+                       sysfs_remove_link(&driver->kobj,
+                                         kobject_name(&dev->kobj));
+       }
+       return ret;
+}
+
+static void ehea_driver_sysfs_remove(struct device *dev,
+                                     struct device_driver *driver)
+{
+       struct device_driver *drv = driver;
+
+       if (drv) {
+               sysfs_remove_link(&drv->kobj, kobject_name(&dev->kobj));
+               sysfs_remove_link(&dev->kobj, "driver");
+       }
+}
+
 static struct device *ehea_register_port(struct ehea_port *port,
                                         struct device_node *dn)
 {
@@ -2371,8 +2421,9 @@ static struct device *ehea_register_port(struct ehea_port *port,
 
        port->ofdev.node = of_node_get(dn);
        port->ofdev.dev.parent = &port->adapter->ebus_dev->ofdev.dev;
+       port->ofdev.dev.bus = &ibmebus_bus_type;
 
-       sprintf(port->ofdev.dev.bus_id, "port%d", port->logical_port_id);
+       sprintf(port->ofdev.dev.bus_id, "port%d", port_name_cnt++);
        port->ofdev.dev.release = logical_port_release;
 
        ret = of_device_register(&port->ofdev);
@@ -2387,8 +2438,16 @@ static struct device *ehea_register_port(struct ehea_port *port,
                goto out_unreg_of_dev;
        }
 
+       ret = ehea_driver_sysfs_add(&port->ofdev.dev, &ehea_driver.driver);
+       if (ret) {
+               ehea_error("failed to register sysfs driver link");
+               goto out_rem_dev_file;
+       }
+
        return &port->ofdev.dev;
 
+out_rem_dev_file:
+       device_remove_file(&port->ofdev.dev, &dev_attr_log_port_id);
 out_unreg_of_dev:
        of_device_unregister(&port->ofdev);
 out:
@@ -2397,6 +2456,7 @@ out:
 
 static void ehea_unregister_port(struct ehea_port *port)
 {
+       ehea_driver_sysfs_remove(&port->ofdev.dev, &ehea_driver.driver);
        device_remove_file(&port->ofdev.dev, &dev_attr_log_port_id);
        of_device_unregister(&port->ofdev);
 }
@@ -2841,21 +2901,6 @@ static int check_module_parm(void)
        return ret;
 }
 
-static struct of_device_id ehea_device_table[] = {
-       {
-               .name = "lhea",
-               .compatible = "IBM,lhea",
-       },
-       {},
-};
-
-static struct ibmebus_driver ehea_driver = {
-       .name = "ehea",
-       .id_table = ehea_device_table,
-       .probe = ehea_probe_adapter,
-       .remove = ehea_remove,
-};
-
 int __init ehea_module_init(void)
 {
        int ret;