aboutsummaryrefslogtreecommitdiff
path: root/drivers/char
diff options
context:
space:
mode:
authorCorey Minyard2019-02-21 17:04:17 -0600
committerCorey Minyard2019-02-22 07:12:41 -0600
commit1a84df2df8ebb1083cb57be6808fbf36d9cabe0e (patch)
tree0efed7bc3b203b328e167c3378b0992ebdf68282 /drivers/char
parent3bb8ea400cbe2ae4d5b51e4306ff9d14d6c6627c (diff)
ipmi_si: Remove hardcode IPMI devices by scanning the platform bus
Instead of keeping track of each one, just scan the platform bus for hardcode devices and remove them. Signed-off-by: Corey Minyard <cminyard@mvista.com>
Diffstat (limited to 'drivers/char')
-rw-r--r--drivers/char/ipmi/ipmi_si_hardcode.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/drivers/char/ipmi/ipmi_si_hardcode.c b/drivers/char/ipmi/ipmi_si_hardcode.c
index cb58298d80f5..540b0871bff0 100644
--- a/drivers/char/ipmi/ipmi_si_hardcode.c
+++ b/drivers/char/ipmi/ipmi_si_hardcode.c
@@ -74,8 +74,6 @@ MODULE_PARM_DESC(slave_addrs, "Set the default IPMB slave address for"
" overridden by this parm. This is an array indexed"
" by interface number.");
-static struct platform_device *ipmi_hc_pdevs[SI_MAX_PARMS];
-
static void __init ipmi_hardcode_init_one(const char *si_type_str,
unsigned int i,
unsigned long addr,
@@ -111,7 +109,7 @@ static void __init ipmi_hardcode_init_one(const char *si_type_str,
p.addr = addr;
p.space = addr_space;
- ipmi_hc_pdevs[i] = ipmi_platform_add("hardcode-ipmi-si", i, &p);
+ ipmi_platform_add("hardcode-ipmi-si", i, &p);
}
void __init ipmi_hardcode_init(void)
@@ -145,13 +143,23 @@ void __init ipmi_hardcode_init(void)
}
}
+
+static int pdev_match_name(struct device *dev, void *data)
+{
+ struct platform_device *pdev = to_platform_device(dev);
+
+ return strcmp(pdev->name, "hardcode-ipmi-si") == 0;
+}
+
void ipmi_si_hardcode_exit(void)
{
- unsigned int i;
+ struct device *dev;
- for (i = 0; i < SI_MAX_PARMS; i++) {
- if (ipmi_hc_pdevs[i])
- platform_device_unregister(ipmi_hc_pdevs[i]);
+ 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);
}
}