edac: mpc85xx fix pci ofdev 2nd pass

Convert PCI err device from platform to open firmware of_dev to comply
with powerpc schemes.

[akpm@linux-foundation.org: coding-style fixes]
Signed-off-by: Dave Jiang <djiang@mvista.com>
Signed-off-by: Doug Thompson <dougthompson@xmission.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Dave Jiang and committed by
Linus Torvalds
f87bd330 fcb19171

+43 -24
+43 -24
drivers/edac/mpc85xx_edac.c
··· 195 195 return IRQ_HANDLED; 196 196 } 197 197 198 - static int __devinit mpc85xx_pci_err_probe(struct platform_device *pdev) 198 + static int __devinit mpc85xx_pci_err_probe(struct of_device *op, 199 + const struct of_device_id *match) 199 200 { 200 201 struct edac_pci_ctl_info *pci; 201 202 struct mpc85xx_pci_pdata *pdata; 202 - struct resource *r; 203 + struct resource r; 203 204 int res = 0; 204 205 205 - if (!devres_open_group(&pdev->dev, mpc85xx_pci_err_probe, GFP_KERNEL)) 206 + if (!devres_open_group(&op->dev, mpc85xx_pci_err_probe, GFP_KERNEL)) 206 207 return -ENOMEM; 207 208 208 209 pci = edac_pci_alloc_ctl_info(sizeof(*pdata), "mpc85xx_pci_err"); ··· 213 212 pdata = pci->pvt_info; 214 213 pdata->name = "mpc85xx_pci_err"; 215 214 pdata->irq = NO_IRQ; 216 - platform_set_drvdata(pdev, pci); 217 - pci->dev = &pdev->dev; 215 + dev_set_drvdata(&op->dev, pci); 216 + pci->dev = &op->dev; 218 217 pci->mod_name = EDAC_MOD_STR; 219 218 pci->ctl_name = pdata->name; 220 - pci->dev_name = pdev->dev.bus_id; 219 + pci->dev_name = op->dev.bus_id; 221 220 222 221 if (edac_op_state == EDAC_OPSTATE_POLL) 223 222 pci->edac_check = mpc85xx_pci_check; 224 223 225 224 pdata->edac_idx = edac_pci_idx++; 226 225 227 - r = platform_get_resource(pdev, IORESOURCE_MEM, 0); 228 - if (!r) { 226 + res = of_address_to_resource(op->node, 0, &r); 227 + if (res) { 229 228 printk(KERN_ERR "%s: Unable to get resource for " 230 229 "PCI err regs\n", __func__); 231 230 goto err; 232 231 } 233 232 234 - if (!devm_request_mem_region(&pdev->dev, r->start, 235 - r->end - r->start + 1, pdata->name)) { 233 + /* we only need the error registers */ 234 + r.start += 0xe00; 235 + 236 + if (!devm_request_mem_region(&op->dev, r.start, 237 + r.end - r.start + 1, pdata->name)) { 236 238 printk(KERN_ERR "%s: Error while requesting mem region\n", 237 239 __func__); 238 240 res = -EBUSY; 239 241 goto err; 240 242 } 241 243 242 - pdata->pci_vbase = devm_ioremap(&pdev->dev, r->start, 243 - r->end - r->start + 1); 244 + pdata->pci_vbase = devm_ioremap(&op->dev, r.start, 245 + r.end - r.start + 1); 244 246 if (!pdata->pci_vbase) { 245 247 printk(KERN_ERR "%s: Unable to setup PCI err regs\n", __func__); 246 248 res = -ENOMEM; ··· 270 266 } 271 267 272 268 if (edac_op_state == EDAC_OPSTATE_INT) { 273 - pdata->irq = platform_get_irq(pdev, 0); 274 - res = devm_request_irq(&pdev->dev, pdata->irq, 269 + pdata->irq = irq_of_parse_and_map(op->node, 0); 270 + res = devm_request_irq(&op->dev, pdata->irq, 275 271 mpc85xx_pci_isr, IRQF_DISABLED, 276 272 "[EDAC] PCI err", pci); 277 273 if (res < 0) { 278 274 printk(KERN_ERR 279 275 "%s: Unable to requiest irq %d for " 280 276 "MPC85xx PCI err\n", __func__, pdata->irq); 277 + irq_dispose_mapping(pdata->irq); 281 278 res = -ENODEV; 282 279 goto err2; 283 280 } ··· 287 282 pdata->irq); 288 283 } 289 284 290 - devres_remove_group(&pdev->dev, mpc85xx_pci_err_probe); 285 + devres_remove_group(&op->dev, mpc85xx_pci_err_probe); 291 286 debugf3("%s(): success\n", __func__); 292 287 printk(KERN_INFO EDAC_MOD_STR " PCI err registered\n"); 293 288 294 289 return 0; 295 290 296 291 err2: 297 - edac_pci_del_device(&pdev->dev); 292 + edac_pci_del_device(&op->dev); 298 293 err: 299 294 edac_pci_free_ctl_info(pci); 300 - devres_release_group(&pdev->dev, mpc85xx_pci_err_probe); 295 + devres_release_group(&op->dev, mpc85xx_pci_err_probe); 301 296 return res; 302 297 } 303 298 304 - static int mpc85xx_pci_err_remove(struct platform_device *pdev) 299 + static int mpc85xx_pci_err_remove(struct of_device *op) 305 300 { 306 - struct edac_pci_ctl_info *pci = platform_get_drvdata(pdev); 301 + struct edac_pci_ctl_info *pci = dev_get_drvdata(&op->dev); 307 302 struct mpc85xx_pci_pdata *pdata = pci->pvt_info; 308 303 309 304 debugf0("%s()\n", __func__); ··· 323 318 return 0; 324 319 } 325 320 326 - static struct platform_driver mpc85xx_pci_err_driver = { 321 + static struct of_device_id mpc85xx_pci_err_of_match[] = { 322 + { 323 + .compatible = "fsl,mpc8540-pcix", 324 + }, 325 + { 326 + .compatible = "fsl,mpc8540-pci", 327 + }, 328 + {}, 329 + }; 330 + 331 + static struct of_platform_driver mpc85xx_pci_err_driver = { 332 + .owner = THIS_MODULE, 333 + .name = "mpc85xx_pci_err", 334 + .match_table = mpc85xx_pci_err_of_match, 327 335 .probe = mpc85xx_pci_err_probe, 328 336 .remove = __devexit_p(mpc85xx_pci_err_remove), 329 337 .driver = { 330 - .name = "mpc85xx_pci_err", 331 - } 338 + .name = "mpc85xx_pci_err", 339 + .owner = THIS_MODULE, 340 + }, 332 341 }; 333 342 334 343 #endif /* CONFIG_PCI */ ··· 1021 1002 printk(KERN_WARNING EDAC_MOD_STR "L2 fails to register\n"); 1022 1003 1023 1004 #ifdef CONFIG_PCI 1024 - res = platform_driver_register(&mpc85xx_pci_err_driver); 1005 + res = of_register_platform_driver(&mpc85xx_pci_err_driver); 1025 1006 if (res) 1026 1007 printk(KERN_WARNING EDAC_MOD_STR "PCI fails to register\n"); 1027 1008 #endif ··· 1044 1025 { 1045 1026 mtspr(SPRN_HID1, orig_hid1); 1046 1027 #ifdef CONFIG_PCI 1047 - platform_driver_unregister(&mpc85xx_pci_err_driver); 1028 + of_unregister_platform_driver(&mpc85xx_pci_err_driver); 1048 1029 #endif 1049 1030 of_unregister_platform_driver(&mpc85xx_l2_err_driver); 1050 1031 of_unregister_platform_driver(&mpc85xx_mc_err_driver);