Commit 759643b8 authored by Corey Minyard's avatar Corey Minyard Committed by Linus Torvalds

[PATCH] IPMI: pass sysfs name from lower level driver

Pass in the sysfs name from the lower-level IPMI driver, as the coming IPMI
serial driver will need that to link properly from the serial device sysfs
directory.
Signed-off-by: default avatarCorey Minyard <minyard@acm.org>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent bca0324d
...@@ -205,6 +205,7 @@ struct ipmi_smi ...@@ -205,6 +205,7 @@ struct ipmi_smi
struct bmc_device *bmc; struct bmc_device *bmc;
char *my_dev_name; char *my_dev_name;
char *sysfs_name;
/* This is the lower-layer's sender routine. */ /* This is the lower-layer's sender routine. */
struct ipmi_smi_handlers *handlers; struct ipmi_smi_handlers *handlers;
...@@ -2004,7 +2005,11 @@ static void ipmi_bmc_unregister(ipmi_smi_t intf) ...@@ -2004,7 +2005,11 @@ static void ipmi_bmc_unregister(ipmi_smi_t intf)
{ {
struct bmc_device *bmc = intf->bmc; struct bmc_device *bmc = intf->bmc;
sysfs_remove_link(&intf->si_dev->kobj, "bmc"); if (intf->sysfs_name) {
sysfs_remove_link(&intf->si_dev->kobj, intf->sysfs_name);
kfree(intf->sysfs_name);
intf->sysfs_name = NULL;
}
if (intf->my_dev_name) { if (intf->my_dev_name) {
sysfs_remove_link(&bmc->dev->dev.kobj, intf->my_dev_name); sysfs_remove_link(&bmc->dev->dev.kobj, intf->my_dev_name);
kfree(intf->my_dev_name); kfree(intf->my_dev_name);
...@@ -2140,7 +2145,8 @@ static int create_files(struct bmc_device *bmc) ...@@ -2140,7 +2145,8 @@ static int create_files(struct bmc_device *bmc)
return err; return err;
} }
static int ipmi_bmc_register(ipmi_smi_t intf) static int ipmi_bmc_register(ipmi_smi_t intf, int ifnum,
const char *sysfs_name)
{ {
int rv; int rv;
struct bmc_device *bmc = intf->bmc; struct bmc_device *bmc = intf->bmc;
...@@ -2257,29 +2263,44 @@ static int ipmi_bmc_register(ipmi_smi_t intf) ...@@ -2257,29 +2263,44 @@ static int ipmi_bmc_register(ipmi_smi_t intf)
* create symlink from system interface device to bmc device * create symlink from system interface device to bmc device
* and back. * and back.
*/ */
intf->sysfs_name = kstrdup(sysfs_name, GFP_KERNEL);
if (!intf->sysfs_name) {
rv = -ENOMEM;
printk(KERN_ERR
"ipmi_msghandler: allocate link to BMC: %d\n",
rv);
goto out_err;
}
rv = sysfs_create_link(&intf->si_dev->kobj, rv = sysfs_create_link(&intf->si_dev->kobj,
&bmc->dev->dev.kobj, "bmc"); &bmc->dev->dev.kobj, intf->sysfs_name);
if (rv) { if (rv) {
kfree(intf->sysfs_name);
intf->sysfs_name = NULL;
printk(KERN_ERR printk(KERN_ERR
"ipmi_msghandler: Unable to create bmc symlink: %d\n", "ipmi_msghandler: Unable to create bmc symlink: %d\n",
rv); rv);
goto out_err; goto out_err;
} }
size = snprintf(dummy, 0, "ipmi%d", intf->intf_num); size = snprintf(dummy, 0, "ipmi%d", ifnum);
intf->my_dev_name = kmalloc(size+1, GFP_KERNEL); intf->my_dev_name = kmalloc(size+1, GFP_KERNEL);
if (!intf->my_dev_name) { if (!intf->my_dev_name) {
kfree(intf->sysfs_name);
intf->sysfs_name = NULL;
rv = -ENOMEM; rv = -ENOMEM;
printk(KERN_ERR printk(KERN_ERR
"ipmi_msghandler: allocate link from BMC: %d\n", "ipmi_msghandler: allocate link from BMC: %d\n",
rv); rv);
goto out_err; goto out_err;
} }
snprintf(intf->my_dev_name, size+1, "ipmi%d", intf->intf_num); snprintf(intf->my_dev_name, size+1, "ipmi%d", ifnum);
rv = sysfs_create_link(&bmc->dev->dev.kobj, &intf->si_dev->kobj, rv = sysfs_create_link(&bmc->dev->dev.kobj, &intf->si_dev->kobj,
intf->my_dev_name); intf->my_dev_name);
if (rv) { if (rv) {
kfree(intf->sysfs_name);
intf->sysfs_name = NULL;
kfree(intf->my_dev_name); kfree(intf->my_dev_name);
intf->my_dev_name = NULL; intf->my_dev_name = NULL;
printk(KERN_ERR printk(KERN_ERR
...@@ -2464,6 +2485,7 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers, ...@@ -2464,6 +2485,7 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
void *send_info, void *send_info,
struct ipmi_device_id *device_id, struct ipmi_device_id *device_id,
struct device *si_dev, struct device *si_dev,
const char *sysfs_name,
unsigned char slave_addr) unsigned char slave_addr)
{ {
int i, j; int i, j;
...@@ -2579,7 +2601,7 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers, ...@@ -2579,7 +2601,7 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
if (rv == 0) if (rv == 0)
rv = add_proc_entries(intf, i); rv = add_proc_entries(intf, i);
rv = ipmi_bmc_register(intf); rv = ipmi_bmc_register(intf, i, sysfs_name);
out: out:
if (rv) { if (rv) {
......
...@@ -2362,6 +2362,7 @@ static int try_smi_init(struct smi_info *new_smi) ...@@ -2362,6 +2362,7 @@ static int try_smi_init(struct smi_info *new_smi)
new_smi, new_smi,
&new_smi->device_id, &new_smi->device_id,
new_smi->dev, new_smi->dev,
"bmc",
new_smi->slave_addr); new_smi->slave_addr);
if (rv) { if (rv) {
printk(KERN_ERR printk(KERN_ERR
......
...@@ -173,6 +173,7 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers, ...@@ -173,6 +173,7 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
void *send_info, void *send_info,
struct ipmi_device_id *device_id, struct ipmi_device_id *device_id,
struct device *dev, struct device *dev,
const char *sysfs_name,
unsigned char slave_addr); unsigned char slave_addr);
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment