diff options
author | Corey Minyard <cminyard@mvista.com> | 2019-02-22 02:21:50 +0300 |
---|---|---|
committer | Corey Minyard <cminyard@mvista.com> | 2019-02-22 16:12:41 +0300 |
commit | bdb57b7bc16252599cbcb826dfdf7e394dd2af4b (patch) | |
tree | 377900c887e5721b13705fa01ae16276be248a31 /drivers/char/ipmi/ipmi_si_hotmod.c | |
parent | 1a84df2df8ebb1083cb57be6808fbf36d9cabe0e (diff) | |
download | linux-bdb57b7bc16252599cbcb826dfdf7e394dd2af4b.tar.xz |
ipmi_si: Remove hotmod devices on removal and exit
When a hotmod-added device is removed or when the module is removed,
remove the platform devices that was created for it.
Signed-off-by: Corey Minyard <cminyard@mvista.com>
Diffstat (limited to 'drivers/char/ipmi/ipmi_si_hotmod.c')
-rw-r--r-- | drivers/char/ipmi/ipmi_si_hotmod.c | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/drivers/char/ipmi/ipmi_si_hotmod.c b/drivers/char/ipmi/ipmi_si_hotmod.c index f0728be00bd2..230b10e7d288 100644 --- a/drivers/char/ipmi/ipmi_si_hotmod.c +++ b/drivers/char/ipmi/ipmi_si_hotmod.c @@ -219,7 +219,18 @@ static int hotmod_handler(const char *val, const struct kernel_param *kp) atomic_inc_return(&hotmod_nr), &h); } else { - ipmi_si_remove_by_data(h.space, h.type, h.addr); + struct device *dev; + + dev = ipmi_si_remove_by_data(h.space, h.type, h.addr); + if (dev && dev_is_platform(dev)) { + struct platform_device *pdev; + + pdev = to_platform_device(dev); + if (strcmp(pdev->name, "hotmod-ipmi-si") == 0) + platform_device_unregister(pdev); + } + if (dev) + put_device(dev); } } rv = len; @@ -227,3 +238,22 @@ out: kfree(str); return rv; } + +static int pdev_match_name(struct device *dev, void *data) +{ + struct platform_device *pdev = to_platform_device(dev); + + return strcmp(pdev->name, "hotmod-ipmi-si") == 0; +} + +void ipmi_si_hotmod_exit(void) +{ + struct device *dev; + + while ((dev = bus_find_device(&platform_bus_type, NULL, NULL, + pdev_match_name))) { + struct platform_device *pdev = to_platform_device(dev); + + platform_device_unregister(pdev); + } +} |