diff options
author | Corey Minyard <minyard@acm.org> | 2006-12-06 23:40:59 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.osdl.org> | 2006-12-07 11:39:47 -0500 |
commit | 759643b874907e76ae81e34df62f41ab6683f5c2 (patch) | |
tree | cdbe93ef9d246e162e9dcb496266693551989e45 /drivers/char/ipmi/ipmi_msghandler.c | |
parent | bca0324d09e413ee089f44cc71263ae1fc582b35 (diff) |
[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: Corey Minyard <minyard@acm.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/char/ipmi/ipmi_msghandler.c')
-rw-r--r-- | drivers/char/ipmi/ipmi_msghandler.c | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c index 761ed2699204..6a77b264eb2c 100644 --- a/drivers/char/ipmi/ipmi_msghandler.c +++ b/drivers/char/ipmi/ipmi_msghandler.c | |||
@@ -205,6 +205,7 @@ struct ipmi_smi | |||
205 | 205 | ||
206 | struct bmc_device *bmc; | 206 | struct bmc_device *bmc; |
207 | char *my_dev_name; | 207 | char *my_dev_name; |
208 | char *sysfs_name; | ||
208 | 209 | ||
209 | /* This is the lower-layer's sender routine. */ | 210 | /* This is the lower-layer's sender routine. */ |
210 | struct ipmi_smi_handlers *handlers; | 211 | struct ipmi_smi_handlers *handlers; |
@@ -2004,7 +2005,11 @@ static void ipmi_bmc_unregister(ipmi_smi_t intf) | |||
2004 | { | 2005 | { |
2005 | struct bmc_device *bmc = intf->bmc; | 2006 | struct bmc_device *bmc = intf->bmc; |
2006 | 2007 | ||
2007 | sysfs_remove_link(&intf->si_dev->kobj, "bmc"); | 2008 | if (intf->sysfs_name) { |
2009 | sysfs_remove_link(&intf->si_dev->kobj, intf->sysfs_name); | ||
2010 | kfree(intf->sysfs_name); | ||
2011 | intf->sysfs_name = NULL; | ||
2012 | } | ||
2008 | if (intf->my_dev_name) { | 2013 | if (intf->my_dev_name) { |
2009 | sysfs_remove_link(&bmc->dev->dev.kobj, intf->my_dev_name); | 2014 | sysfs_remove_link(&bmc->dev->dev.kobj, intf->my_dev_name); |
2010 | kfree(intf->my_dev_name); | 2015 | kfree(intf->my_dev_name); |
@@ -2140,7 +2145,8 @@ out: | |||
2140 | return err; | 2145 | return err; |
2141 | } | 2146 | } |
2142 | 2147 | ||
2143 | static int ipmi_bmc_register(ipmi_smi_t intf) | 2148 | static int ipmi_bmc_register(ipmi_smi_t intf, int ifnum, |
2149 | const char *sysfs_name) | ||
2144 | { | 2150 | { |
2145 | int rv; | 2151 | int rv; |
2146 | struct bmc_device *bmc = intf->bmc; | 2152 | struct bmc_device *bmc = intf->bmc; |
@@ -2257,29 +2263,44 @@ static int ipmi_bmc_register(ipmi_smi_t intf) | |||
2257 | * create symlink from system interface device to bmc device | 2263 | * create symlink from system interface device to bmc device |
2258 | * and back. | 2264 | * and back. |
2259 | */ | 2265 | */ |
2266 | intf->sysfs_name = kstrdup(sysfs_name, GFP_KERNEL); | ||
2267 | if (!intf->sysfs_name) { | ||
2268 | rv = -ENOMEM; | ||
2269 | printk(KERN_ERR | ||
2270 | "ipmi_msghandler: allocate link to BMC: %d\n", | ||
2271 | rv); | ||
2272 | goto out_err; | ||
2273 | } | ||
2274 | |||
2260 | rv = sysfs_create_link(&intf->si_dev->kobj, | 2275 | rv = sysfs_create_link(&intf->si_dev->kobj, |
2261 | &bmc->dev->dev.kobj, "bmc"); | 2276 | &bmc->dev->dev.kobj, intf->sysfs_name); |
2262 | if (rv) { | 2277 | if (rv) { |
2278 | kfree(intf->sysfs_name); | ||
2279 | intf->sysfs_name = NULL; | ||
2263 | printk(KERN_ERR | 2280 | printk(KERN_ERR |
2264 | "ipmi_msghandler: Unable to create bmc symlink: %d\n", | 2281 | "ipmi_msghandler: Unable to create bmc symlink: %d\n", |
2265 | rv); | 2282 | rv); |
2266 | goto out_err; | 2283 | goto out_err; |
2267 | } | 2284 | } |
2268 | 2285 | ||
2269 | size = snprintf(dummy, 0, "ipmi%d", intf->intf_num); | 2286 | size = snprintf(dummy, 0, "ipmi%d", ifnum); |
2270 | intf->my_dev_name = kmalloc(size+1, GFP_KERNEL); | 2287 | intf->my_dev_name = kmalloc(size+1, GFP_KERNEL); |
2271 | if (!intf->my_dev_name) { | 2288 | if (!intf->my_dev_name) { |
2289 | kfree(intf->sysfs_name); | ||
2290 | intf->sysfs_name = NULL; | ||
2272 | rv = -ENOMEM; | 2291 | rv = -ENOMEM; |
2273 | printk(KERN_ERR | 2292 | printk(KERN_ERR |
2274 | "ipmi_msghandler: allocate link from BMC: %d\n", | 2293 | "ipmi_msghandler: allocate link from BMC: %d\n", |
2275 | rv); | 2294 | rv); |
2276 | goto out_err; | 2295 | goto out_err; |
2277 | } | 2296 | } |
2278 | snprintf(intf->my_dev_name, size+1, "ipmi%d", intf->intf_num); | 2297 | snprintf(intf->my_dev_name, size+1, "ipmi%d", ifnum); |
2279 | 2298 | ||
2280 | rv = sysfs_create_link(&bmc->dev->dev.kobj, &intf->si_dev->kobj, | 2299 | rv = sysfs_create_link(&bmc->dev->dev.kobj, &intf->si_dev->kobj, |
2281 | intf->my_dev_name); | 2300 | intf->my_dev_name); |
2282 | if (rv) { | 2301 | if (rv) { |
2302 | kfree(intf->sysfs_name); | ||
2303 | intf->sysfs_name = NULL; | ||
2283 | kfree(intf->my_dev_name); | 2304 | kfree(intf->my_dev_name); |
2284 | intf->my_dev_name = NULL; | 2305 | intf->my_dev_name = NULL; |
2285 | printk(KERN_ERR | 2306 | printk(KERN_ERR |
@@ -2464,6 +2485,7 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers, | |||
2464 | void *send_info, | 2485 | void *send_info, |
2465 | struct ipmi_device_id *device_id, | 2486 | struct ipmi_device_id *device_id, |
2466 | struct device *si_dev, | 2487 | struct device *si_dev, |
2488 | const char *sysfs_name, | ||
2467 | unsigned char slave_addr) | 2489 | unsigned char slave_addr) |
2468 | { | 2490 | { |
2469 | int i, j; | 2491 | int i, j; |
@@ -2579,7 +2601,7 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers, | |||
2579 | if (rv == 0) | 2601 | if (rv == 0) |
2580 | rv = add_proc_entries(intf, i); | 2602 | rv = add_proc_entries(intf, i); |
2581 | 2603 | ||
2582 | rv = ipmi_bmc_register(intf); | 2604 | rv = ipmi_bmc_register(intf, i, sysfs_name); |
2583 | 2605 | ||
2584 | out: | 2606 | out: |
2585 | if (rv) { | 2607 | if (rv) { |