aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/fpga/altera-cvp.c
diff options
context:
space:
mode:
authorAnatolij Gustschin <agust@denx.de>2018-11-26 12:35:27 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-11-26 14:12:05 -0500
commit30522a951f9d02f261d0697c35cb42205b1fae17 (patch)
treef4387b10b0ae9bba29f76788bc4492c4cec3bd0e /drivers/fpga/altera-cvp.c
parent324fa64cf4189094bc4df744a9e7214a1b81d845 (diff)
fpga: altera-cvp: fix probing for multiple FPGAs on the bus
Currently registering CvP managers works only for first probed CvP device, for all other devices it is refused due to duplicated chkcfg sysfs entry: fpga_manager fpga3: Altera CvP FPGA Manager @0000:0c:00.0 registered sysfs: cannot create duplicate filename '/bus/pci/drivers/altera-cvp/chkcfg' CPU: 0 PID: 3808 Comm: bash Tainted: G O 4.19.0-custom+ #5 Call Trace: dump_stack+0x46/0x5b sysfs_warn_dup+0x53/0x60 sysfs_add_file_mode_ns+0x16d/0x180 sysfs_create_file_ns+0x51/0x60 altera_cvp_probe+0x16f/0x2a0 [altera_cvp] local_pci_probe+0x3f/0xa0 ? pci_match_device+0xb1/0xf0 pci_device_probe+0x116/0x170 really_probe+0x21b/0x2c0 driver_probe_device+0x4b/0xe0 bind_store+0xcb/0x130 kernfs_fop_write+0xfd/0x180 __vfs_write+0x21/0x150 ? selinux_file_permission+0xdc/0x130 vfs_write+0xa8/0x1a0 ? find_vma+0xd/0x60 ksys_write+0x3d/0x90 do_syscall_64+0x44/0xf0 entry_SYSCALL_64_after_hwframe+0x44/0xa9 ... altera-cvp 0000:0c:00.0: Can't create sysfs chkcfg file fpga_manager fpga3: fpga_mgr_unregister Altera CvP FPGA Manager @0000:0c:00.0 Move chkcfg creation to module init as suggested by Alan. Signed-off-by: Anatolij Gustschin <agust@denx.de> Acked-by: Alan Tull <atull@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/fpga/altera-cvp.c')
-rw-r--r--drivers/fpga/altera-cvp.c34
1 files changed, 24 insertions, 10 deletions
diff --git a/drivers/fpga/altera-cvp.c b/drivers/fpga/altera-cvp.c
index 73950851e404..35c3aa5792e2 100644
--- a/drivers/fpga/altera-cvp.c
+++ b/drivers/fpga/altera-cvp.c
@@ -475,14 +475,6 @@ static int altera_cvp_probe(struct pci_dev *pdev,
475 if (ret) 475 if (ret)
476 goto err_unmap; 476 goto err_unmap;
477 477
478 ret = driver_create_file(&altera_cvp_driver.driver,
479 &driver_attr_chkcfg);
480 if (ret) {
481 dev_err(&pdev->dev, "Can't create sysfs chkcfg file\n");
482 fpga_mgr_unregister(mgr);
483 goto err_unmap;
484 }
485
486 return 0; 478 return 0;
487 479
488err_unmap: 480err_unmap:
@@ -501,7 +493,6 @@ static void altera_cvp_remove(struct pci_dev *pdev)
501 struct altera_cvp_conf *conf = mgr->priv; 493 struct altera_cvp_conf *conf = mgr->priv;
502 u16 cmd; 494 u16 cmd;
503 495
504 driver_remove_file(&altera_cvp_driver.driver, &driver_attr_chkcfg);
505 fpga_mgr_unregister(mgr); 496 fpga_mgr_unregister(mgr);
506 if (conf->map) 497 if (conf->map)
507 pci_iounmap(pdev, conf->map); 498 pci_iounmap(pdev, conf->map);
@@ -511,7 +502,30 @@ static void altera_cvp_remove(struct pci_dev *pdev)
511 pci_write_config_word(pdev, PCI_COMMAND, cmd); 502 pci_write_config_word(pdev, PCI_COMMAND, cmd);
512} 503}
513 504
514module_pci_driver(altera_cvp_driver); 505static int __init altera_cvp_init(void)
506{
507 int ret;
508
509 ret = pci_register_driver(&altera_cvp_driver);
510 if (ret)
511 return ret;
512
513 ret = driver_create_file(&altera_cvp_driver.driver,
514 &driver_attr_chkcfg);
515 if (ret)
516 pr_warn("Can't create sysfs chkcfg file\n");
517
518 return 0;
519}
520
521static void __exit altera_cvp_exit(void)
522{
523 driver_remove_file(&altera_cvp_driver.driver, &driver_attr_chkcfg);
524 pci_unregister_driver(&altera_cvp_driver);
525}
526
527module_init(altera_cvp_init);
528module_exit(altera_cvp_exit);
515 529
516MODULE_LICENSE("GPL v2"); 530MODULE_LICENSE("GPL v2");
517MODULE_AUTHOR("Anatolij Gustschin <agust@denx.de>"); 531MODULE_AUTHOR("Anatolij Gustschin <agust@denx.de>");