fpga: manager: change api, don't use drvdata
Change fpga_mgr_register to not set or use drvdata. This supports the case where a PCIe device has more than one manager. Add fpga_mgr_create/free functions. Change fpga_mgr_register and fpga_mgr_unregister functions to take the mgr struct as their only parameter. struct fpga_manager *fpga_mgr_create(struct device *dev, const char *name, const struct fpga_manager_ops *mops, void *priv); void fpga_mgr_free(struct fpga_manager *mgr); int fpga_mgr_register(struct fpga_manager *mgr); void fpga_mgr_unregister(struct fpga_manager *mgr); Update the drivers that call fpga_mgr_register with the new API. Signed-off-by: Alan Tull <atull@kernel.org> [Moritz: Fixup whitespace issue] Reported-by: Jiuyue Ma <majiuyue@huawei.com> Signed-off-by: Moritz Fischer <mdf@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:

committed by
Greg Kroah-Hartman

parent
bbaa9cd3a6
commit
7085e2a94f
@@ -401,6 +401,7 @@ static int altera_cvp_probe(struct pci_dev *pdev,
|
||||
const struct pci_device_id *dev_id)
|
||||
{
|
||||
struct altera_cvp_conf *conf;
|
||||
struct fpga_manager *mgr;
|
||||
u16 cmd, val;
|
||||
int ret;
|
||||
|
||||
@@ -452,16 +453,24 @@ static int altera_cvp_probe(struct pci_dev *pdev,
|
||||
snprintf(conf->mgr_name, sizeof(conf->mgr_name), "%s @%s",
|
||||
ALTERA_CVP_MGR_NAME, pci_name(pdev));
|
||||
|
||||
ret = fpga_mgr_register(&pdev->dev, conf->mgr_name,
|
||||
&altera_cvp_ops, conf);
|
||||
if (ret)
|
||||
mgr = fpga_mgr_create(&pdev->dev, conf->mgr_name,
|
||||
&altera_cvp_ops, conf);
|
||||
if (!mgr)
|
||||
return -ENOMEM;
|
||||
|
||||
pci_set_drvdata(pdev, mgr);
|
||||
|
||||
ret = fpga_mgr_register(mgr);
|
||||
if (ret) {
|
||||
fpga_mgr_free(mgr);
|
||||
goto err_unmap;
|
||||
}
|
||||
|
||||
ret = driver_create_file(&altera_cvp_driver.driver,
|
||||
&driver_attr_chkcfg);
|
||||
if (ret) {
|
||||
dev_err(&pdev->dev, "Can't create sysfs chkcfg file\n");
|
||||
fpga_mgr_unregister(&pdev->dev);
|
||||
fpga_mgr_unregister(mgr);
|
||||
goto err_unmap;
|
||||
}
|
||||
|
||||
@@ -483,7 +492,7 @@ static void altera_cvp_remove(struct pci_dev *pdev)
|
||||
u16 cmd;
|
||||
|
||||
driver_remove_file(&altera_cvp_driver.driver, &driver_attr_chkcfg);
|
||||
fpga_mgr_unregister(&pdev->dev);
|
||||
fpga_mgr_unregister(mgr);
|
||||
pci_iounmap(pdev, conf->map);
|
||||
pci_release_region(pdev, CVP_BAR);
|
||||
pci_read_config_word(pdev, PCI_COMMAND, &cmd);
|
||||
|
Reference in New Issue
Block a user