Skip to content

Commit e17c657

Browse files
committed
ipmi_si: Consolidate scanning the platform bus
The same basic code was in two places. Signed-off-by: Corey Minyard <[email protected]>
1 parent bdb57b7 commit e17c657

File tree

4 files changed

+23
-30
lines changed

4 files changed

+23
-30
lines changed

drivers/char/ipmi/ipmi_si.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ void ipmi_si_hotmod_exit(void);
2929
int ipmi_si_hardcode_match(int addr_space, unsigned long addr);
3030
void ipmi_si_platform_init(void);
3131
void ipmi_si_platform_shutdown(void);
32+
void ipmi_remove_platform_device_by_name(char *name);
3233

3334
extern struct platform_driver ipmi_platform_driver;
3435

drivers/char/ipmi/ipmi_si_hardcode.c

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -144,23 +144,9 @@ void __init ipmi_hardcode_init(void)
144144
}
145145

146146

147-
static int pdev_match_name(struct device *dev, void *data)
148-
{
149-
struct platform_device *pdev = to_platform_device(dev);
150-
151-
return strcmp(pdev->name, "hardcode-ipmi-si") == 0;
152-
}
153-
154147
void ipmi_si_hardcode_exit(void)
155148
{
156-
struct device *dev;
157-
158-
while ((dev = bus_find_device(&platform_bus_type, NULL, NULL,
159-
pdev_match_name))) {
160-
struct platform_device *pdev = to_platform_device(dev);
161-
162-
platform_device_unregister(pdev);
163-
}
149+
ipmi_remove_platform_device_by_name("hardcode-ipmi-si");
164150
}
165151

166152
/*

drivers/char/ipmi/ipmi_si_hotmod.c

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -239,21 +239,7 @@ static int hotmod_handler(const char *val, const struct kernel_param *kp)
239239
return rv;
240240
}
241241

242-
static int pdev_match_name(struct device *dev, void *data)
243-
{
244-
struct platform_device *pdev = to_platform_device(dev);
245-
246-
return strcmp(pdev->name, "hotmod-ipmi-si") == 0;
247-
}
248-
249242
void ipmi_si_hotmod_exit(void)
250243
{
251-
struct device *dev;
252-
253-
while ((dev = bus_find_device(&platform_bus_type, NULL, NULL,
254-
pdev_match_name))) {
255-
struct platform_device *pdev = to_platform_device(dev);
256-
257-
platform_device_unregister(pdev);
258-
}
244+
ipmi_remove_platform_device_by_name("hotmod-ipmi-si");
259245
}

drivers/char/ipmi/ipmi_si_platform.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,26 @@ static int ipmi_remove(struct platform_device *pdev)
428428
return ipmi_si_remove_by_dev(&pdev->dev);
429429
}
430430

431+
static int pdev_match_name(struct device *dev, void *data)
432+
{
433+
struct platform_device *pdev = to_platform_device(dev);
434+
const char *name = data;
435+
436+
return strcmp(pdev->name, name) == 0;
437+
}
438+
439+
void ipmi_remove_platform_device_by_name(char *name)
440+
{
441+
struct device *dev;
442+
443+
while ((dev = bus_find_device(&platform_bus_type, NULL, name,
444+
pdev_match_name))) {
445+
struct platform_device *pdev = to_platform_device(dev);
446+
447+
platform_device_unregister(pdev);
448+
}
449+
}
450+
431451
static const struct platform_device_id si_plat_ids[] = {
432452
{ "dmi-ipmi-si", 0 },
433453
{ "hardcode-ipmi-si", 0 },

0 commit comments

Comments
 (0)