diff options
author | Marc Zyngier <maz@misterjones.org> | 2010-12-05 00:05:37 -0500 |
---|---|---|
committer | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2010-12-08 23:36:30 -0500 |
commit | 98b14d6b290d96b24ae993ceaccc59b2aa4b130c (patch) | |
tree | cbf1655199e699411b0ca0e1b92b551cf37abf28 /drivers | |
parent | 982cf00412a890ca738c2d78528b652ca431ad1a (diff) |
powerpc/powermac: Make auto-loading of therm_pm72 possible
The therm_pm72 driver, used on the PowerMac G5 range, cannot be
auto-loaded, since the driver itself creates both the device node
and the driver instance.
Moving the device node creation to the platform setup code and
adding the necessary MODULE_DEVICE_TABLE() information allows the
driver to be automatically loaded by udev on any semi-modern
distribution.
It "fixes" a major source of problem on G5 machines where the
driver wasn't explicitely loaded by default, and the system
would automatically shutdown under load.
Tested on an Xserve G5.
Signed-off-by: Marc Zyngier <maz@misterjones.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/macintosh/therm_pm72.c | 30 |
1 files changed, 5 insertions, 25 deletions
diff --git a/drivers/macintosh/therm_pm72.c b/drivers/macintosh/therm_pm72.c index 44549272333c..2e041fd0a00c 100644 --- a/drivers/macintosh/therm_pm72.c +++ b/drivers/macintosh/therm_pm72.c | |||
@@ -2213,6 +2213,9 @@ static void fcu_lookup_fans(struct device_node *fcu_node) | |||
2213 | static int fcu_of_probe(struct platform_device* dev, const struct of_device_id *match) | 2213 | static int fcu_of_probe(struct platform_device* dev, const struct of_device_id *match) |
2214 | { | 2214 | { |
2215 | state = state_detached; | 2215 | state = state_detached; |
2216 | of_dev = dev; | ||
2217 | |||
2218 | dev_info(&dev->dev, "PowerMac G5 Thermal control driver %s\n", VERSION); | ||
2216 | 2219 | ||
2217 | /* Lookup the fans in the device tree */ | 2220 | /* Lookup the fans in the device tree */ |
2218 | fcu_lookup_fans(dev->dev.of_node); | 2221 | fcu_lookup_fans(dev->dev.of_node); |
@@ -2235,6 +2238,7 @@ static const struct of_device_id fcu_match[] = | |||
2235 | }, | 2238 | }, |
2236 | {}, | 2239 | {}, |
2237 | }; | 2240 | }; |
2241 | MODULE_DEVICE_TABLE(of, fcu_match); | ||
2238 | 2242 | ||
2239 | static struct of_platform_driver fcu_of_platform_driver = | 2243 | static struct of_platform_driver fcu_of_platform_driver = |
2240 | { | 2244 | { |
@@ -2252,8 +2256,6 @@ static struct of_platform_driver fcu_of_platform_driver = | |||
2252 | */ | 2256 | */ |
2253 | static int __init therm_pm72_init(void) | 2257 | static int __init therm_pm72_init(void) |
2254 | { | 2258 | { |
2255 | struct device_node *np; | ||
2256 | |||
2257 | rackmac = of_machine_is_compatible("RackMac3,1"); | 2259 | rackmac = of_machine_is_compatible("RackMac3,1"); |
2258 | 2260 | ||
2259 | if (!of_machine_is_compatible("PowerMac7,2") && | 2261 | if (!of_machine_is_compatible("PowerMac7,2") && |
@@ -2261,34 +2263,12 @@ static int __init therm_pm72_init(void) | |||
2261 | !rackmac) | 2263 | !rackmac) |
2262 | return -ENODEV; | 2264 | return -ENODEV; |
2263 | 2265 | ||
2264 | printk(KERN_INFO "PowerMac G5 Thermal control driver %s\n", VERSION); | 2266 | return of_register_platform_driver(&fcu_of_platform_driver); |
2265 | |||
2266 | np = of_find_node_by_type(NULL, "fcu"); | ||
2267 | if (np == NULL) { | ||
2268 | /* Some machines have strangely broken device-tree */ | ||
2269 | np = of_find_node_by_path("/u3@0,f8000000/i2c@f8001000/fan@15e"); | ||
2270 | if (np == NULL) { | ||
2271 | printk(KERN_ERR "Can't find FCU in device-tree !\n"); | ||
2272 | return -ENODEV; | ||
2273 | } | ||
2274 | } | ||
2275 | of_dev = of_platform_device_create(np, "temperature", NULL); | ||
2276 | if (of_dev == NULL) { | ||
2277 | printk(KERN_ERR "Can't register FCU platform device !\n"); | ||
2278 | return -ENODEV; | ||
2279 | } | ||
2280 | |||
2281 | of_register_platform_driver(&fcu_of_platform_driver); | ||
2282 | |||
2283 | return 0; | ||
2284 | } | 2267 | } |
2285 | 2268 | ||
2286 | static void __exit therm_pm72_exit(void) | 2269 | static void __exit therm_pm72_exit(void) |
2287 | { | 2270 | { |
2288 | of_unregister_platform_driver(&fcu_of_platform_driver); | 2271 | of_unregister_platform_driver(&fcu_of_platform_driver); |
2289 | |||
2290 | if (of_dev) | ||
2291 | of_device_unregister(of_dev); | ||
2292 | } | 2272 | } |
2293 | 2273 | ||
2294 | module_init(therm_pm72_init); | 2274 | module_init(therm_pm72_init); |