Commit 98b14d6b290d96b24ae993ceaccc59b2aa4b130c

Authored by Marc Zyngier
Committed by Benjamin Herrenschmidt
1 parent 982cf00412

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>

Showing 2 changed files with 14 additions and 25 deletions Side-by-side Diff

arch/powerpc/platforms/powermac/setup.c
... ... @@ -506,6 +506,15 @@
506 506 of_platform_device_create(np, "smu", NULL);
507 507 of_node_put(np);
508 508 }
  509 + np = of_find_node_by_type(NULL, "fcu");
  510 + if (np == NULL) {
  511 + /* Some machines have strangely broken device-tree */
  512 + np = of_find_node_by_path("/u3@0,f8000000/i2c@f8001000/fan@15e");
  513 + }
  514 + if (np) {
  515 + of_platform_device_create(np, "temperature", NULL);
  516 + of_node_put(np);
  517 + }
509 518  
510 519 return 0;
511 520 }
drivers/macintosh/therm_pm72.c
... ... @@ -2213,7 +2213,10 @@
2213 2213 static int fcu_of_probe(struct platform_device* dev, const struct of_device_id *match)
2214 2214 {
2215 2215 state = state_detached;
  2216 + of_dev = dev;
2216 2217  
  2218 + dev_info(&dev->dev, "PowerMac G5 Thermal control driver %s\n", VERSION);
  2219 +
2217 2220 /* Lookup the fans in the device tree */
2218 2221 fcu_lookup_fans(dev->dev.of_node);
2219 2222  
... ... @@ -2235,6 +2238,7 @@
2235 2238 },
2236 2239 {},
2237 2240 };
  2241 +MODULE_DEVICE_TABLE(of, fcu_match);
2238 2242  
2239 2243 static struct of_platform_driver fcu_of_platform_driver =
2240 2244 {
... ... @@ -2252,8 +2256,6 @@
2252 2256 */
2253 2257 static int __init therm_pm72_init(void)
2254 2258 {
2255   - struct device_node *np;
2256   -
2257 2259 rackmac = of_machine_is_compatible("RackMac3,1");
2258 2260  
2259 2261 if (!of_machine_is_compatible("PowerMac7,2") &&
2260 2262  
... ... @@ -2261,34 +2263,12 @@
2261 2263 !rackmac)
2262 2264 return -ENODEV;
2263 2265  
2264   - printk(KERN_INFO "PowerMac G5 Thermal control driver %s\n", VERSION);
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;
  2266 + return of_register_platform_driver(&fcu_of_platform_driver);
2284 2267 }
2285 2268  
2286 2269 static void __exit therm_pm72_exit(void)
2287 2270 {
2288 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 2274 module_init(therm_pm72_init);