ehea: fix for sysfs entries

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>
This commit is contained in:
Thomas Klein 2007-04-26 11:56:13 +02:00 committed by Jeff Garzik
parent 3b0dc5c1cf
commit d1dea38d54
2 changed files with 62 additions and 17 deletions

View 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)

View 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 @@ static struct device *ehea_register_port(struct ehea_port *port,
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;