fpga: Use standard class dev_release function
v13 cover fpga: Use standard class dev_release function
The FPGA framework has a convention of using managed resource functions to allow parent drivers to manage the data structures allocated by the class drivers. They use an empty *_dev_release() function to satisfy the class driver.
This is inconsistent with linux driver model.
These changes remove the managed resource functions and populate the class dev_release callback functions. They also merge the create() and register() functions into a single register() or register_full() function for each of the fpga-mgr, fpga-region, and fpga-bridge class drivers.
The new *register_full() functions accept an info data structure to provide flexibility in passing optional parameters. The *register() functions support the legacy parameter list for users that don't require the use of optional parameters.
For more context, refer to this email thread:
https://marc.info/?l=linux-fpga&m=162127412218557&w=2
I turned on the configs assocated with each of the modified files, but I must have been missing some dependencies, because not all of them compiled. I did a run-time test specifically with the dfl-fme infrastructure. This would have exercised the region, bridge, and fpga-mgr frameworks.
Changelog v12 -> v13:
- Add Acked-by tag
Changelog v11 -> v12:
- Made the requisite changes to the new versal-fpga driver
Changelog v10 -> v11:
- Rebased to latest linux-next
- Resolved a single conflict in fpga-mgr.c with associated with wrapper
function: fpga_mgr_state(mgr)
Changelog v9 -> v10:
- Fixed commit messages to reference register_full() instead of register_simple().
- Removed the fpga_bridge_register_full() function, because there is not need for it yet. Updated the documentation and commit message accordingly.
- Updated documentation to reference the fpga_manager_info and fpga_region_info structures.
Changelog v8 -> v9:
- Cleaned up documentation for the FPGA Manager, Bridge, and Region register functions
- Renamed fpga_*_register() to fpga_*_register_full()
- Renamed fpga_*_register_simple() to fpga_*_register()
- Renamed devm_fpga_mgr_register() to devm_fpga_mgr_register_full()
- Renamed devm_fpga_mgr_register_simple() to devm_fpga_mgr_register()
Changelog v7 -> v8:
- Added reviewed-by tags.
- Updated Documentation/driver-api/fpga/ files: fpga-mgr.rst, fpga-bridge.rst, and fpga-region.rst.
Changelog v6 -> v7:
- Update the commit messages to describe the new parameters for the *register() functions and to mention the *register_simple() functions.
- Fix function prototypes in header file to rename dev to parent.
- Make use of the PTR_ERR_OR_ZERO() macro when possible.
- Some cleanup of comments.
- Update function definitions/prototypes to apply const to the new info parameter.
- Verify that info->br_ops is non-null in the fpga_bridge_register() function.
- Verify a non-null info pointer in the fpga_region_register() function.
Changelog v5 -> v6:
- Moved FPGA manager/bridge/region optional parameters out of the ops structure and back into the FPGA class driver structure.
- Changed fpga_*_register() function parameters to accept an info data structure to provide flexibility in passing optional parameters.
- Added fpga_*_register_simple() functions to support current parameters for users that don't require use of optional parameters.
Changelog v4 -> v5:
- Rebased on top of recently accepted patches.
- Removed compat_id from the fpga_mgr_register() parameter list and added it to the fpga_manager_ops structure. This also required dynamically allocating the dfl-fme-ops structure in order to add the appropriate compat_id.
- Created the fpga_region_ops data structure which is optionally passed to fpga_region_register(). compat_id, the get_bridges() pointer, and the priv pointer are included in the fpga_region_ops structure.
Changelog v3 -> v4:
- Added the compat_id parameter to fpga_mgr_register() and devm_fpga_mgr_register() to ensure that the compat_id is set before the device_register() call.
- Added the compat_id parameter to fpga_region_register() to ensure that the compat_id is set before the device_register() call.
- Modified the dfl_fpga_feature_devs_enumerate() function to restore the fpga_region_register() call to the correct location.
Changelog v2 -> v3:
- Cleaned up comment headers for fpga_mgr_register(), fpga_bridge_register(), and fpga_region_register().
- Fixed error return on ida_simple_get() failure for fpga_mgr_register(), fpga_bridge_register(), and fpga_region_register().
- Fixed error return value for fpga_bridge_register(): ERR_PTR(ret) instead of NULL.
Changelog v1 -> v2:
- Restored devm_fpga_mgr_register() functionality to the fpga-mgr class driver, adapted for the combined create/register functionality.
- All previous callers of devm_fpga_mgr_register() will continue to call devm_fpga_mgr_register().
- replaced unnecessary ternary operators in return statements with standard if conditions.
Russ Weight (3):
fpga: mgr: Use standard dev_release for class driver
fpga: bridge: Use standard dev_release for class driver
fpga: region: Use standard dev_release for class driver
Documentation/driver-api/fpga/fpga-bridge.rst | 6 +- Documentation/driver-api/fpga/fpga-mgr.rst | 38 +++- Documentation/driver-api/fpga/fpga-region.rst | 12 +- drivers/fpga/altera-cvp.c | 12 +- drivers/fpga/altera-fpga2sdram.c | 12 +- drivers/fpga/altera-freeze-bridge.c | 10 +- drivers/fpga/altera-hps2fpga.c | 12 +- drivers/fpga/altera-pr-ip-core.c | 7 +- drivers/fpga/altera-ps-spi.c | 9 +- drivers/fpga/dfl-fme-br.c | 10 +- drivers/fpga/dfl-fme-mgr.c | 22 +- drivers/fpga/dfl-fme-region.c | 17 +- drivers/fpga/dfl.c | 12 +- drivers/fpga/fpga-bridge.c | 122 +++------- drivers/fpga/fpga-mgr.c | 215 ++++++++---------- drivers/fpga/fpga-region.c | 119 ++++------ drivers/fpga/ice40-spi.c | 9 +- drivers/fpga/machxo2-spi.c | 9 +- drivers/fpga/of-fpga-region.c | 10 +- drivers/fpga/socfpga-a10.c | 16 +- drivers/fpga/socfpga.c | 9 +- drivers/fpga/stratix10-soc.c | 16 +- drivers/fpga/ts73xx-fpga.c | 9 +- drivers/fpga/versal-fpga.c | 9 +- drivers/fpga/xilinx-pr-decoupler.c | 17 +- drivers/fpga/xilinx-spi.c | 11 +- drivers/fpga/zynq-fpga.c | 16 +- drivers/fpga/zynqmp-fpga.c | 9 +- include/linux/fpga/fpga-bridge.h | 30 ++- include/linux/fpga/fpga-mgr.h | 62 +++-- include/linux/fpga/fpga-region.h | 36 ++- 31 files changed, 386 insertions(+), 517 deletions(-)
Signature · 1 line
2.25.1
PATCH v13 1/3 fpga: mgr: Use standard dev_release for class driver
The FPGA manager class driver data structure is being treated as a managed resource instead of using the standard dev_release call-back function to release the class data structure. This change removes the managed resource code for the freeing of the class data structure and combines the create() and register() functions into a single register() or register_full() function.
The register_full() function accepts an info data structure to provide flexibility in passing optional parameters. The register() function supports the current parameter list for users that don't require the use of optional parameters.
The devm_fpga_mgr_register() function is retained, and the devm_fpga_mgr_register_full() function is added.
---
v13:
- Add Acked-by tag
v12:
- Made the requisite changes to the new versal-fpga driver
v11:
- Rebased to latest linux-next
- Resolved a single conflict with associated with wrapper function:
fpga_mgr_state(mgr)
v10:
- Fixed commit message to reference register_full() instead of register_simple().
- Updated documentation to reference the fpga_manager_info structure
v9:
- Cleaned up documentation for the FPGA Manager register functions
- Renamed fpga_mgr_register() to fpga_mgr_register_full()
- Renamed fpga_mgr_register_simple() to fpga_mgr_register()
- Renamed devm_fpga_mgr_register() to devm_fpga_mgr_register_full()
- Renamed devm_fpga_mgr_register_simple() to devm_fpga_mgr_register()
v8:
- Added reviewed-by tag.
- Updated Documentation/driver-api/fpga/fpga-mgr.rst documentation.
v7:
- Update the commit message to describe the new parameters for the *fpga_mgr_register() functions and to mention the *fpga_mgr_register_simple() functions.
- Fix function prototypes in header file to rename dev to parent.
- Make use of the PTR_ERR_OR_ZERO() macro when possible.
- Some cleanup of comments.
- Update function definitions/prototypes to apply const to the new info parameter.
v6:
- Moved FPGA manager optional parameters out of the ops structure and back into the FPGA manager structure.
- Changed fpga_mgr_register()/devm_fpga_mgr_register() parameters to accept an info data structure to provide flexibility in passing optional parameters.
- Added fpga_mgr_register_simple()/devm_fpga_mgr_register_simple() functions to support current parameters for users that don't require the use of optional parameters.
v5:
- Rebased on top of recently accepted patches.
- Removed compat_id from the fpga_mgr_register() parameter list and added it to the fpga_manager_ops structure. This also required dynamically allocating the dfl-fme-ops structure in order to add the appropriate compat_id.
v4:
- Added the compat_id parameter to fpga_mgr_register() and devm_fpga_mgr_register() to ensure that the compat_id is set before the device_register() call.
v3:
- Cleaned up comment header for fpga_mgr_register()
- Fix error return on ida_simple_get() failure
v2:
- Restored devm_fpga_mgr_register() functionality, adapted for the combined create/register functionality.
- All previous callers of devm_fpga_mgr_register() will continue to call devm_fpga_mgr_register().
- replaced unnecessary ternary operators in return statements with standard if conditions.
--- Documentation/driver-api/fpga/fpga-mgr.rst | 38 +++- drivers/fpga/altera-cvp.c | 12 +- drivers/fpga/altera-pr-ip-core.c | 7 +- drivers/fpga/altera-ps-spi.c | 9 +- drivers/fpga/dfl-fme-mgr.c | 22 +-- drivers/fpga/fpga-mgr.c | 215 +++++++++------------ drivers/fpga/ice40-spi.c | 9 +- drivers/fpga/machxo2-spi.c | 9 +- drivers/fpga/socfpga-a10.c | 16 +- drivers/fpga/socfpga.c | 9 +- drivers/fpga/stratix10-soc.c | 16 +- drivers/fpga/ts73xx-fpga.c | 9 +- drivers/fpga/versal-fpga.c | 9 +- drivers/fpga/xilinx-spi.c | 11 +- drivers/fpga/zynq-fpga.c | 16 +- drivers/fpga/zynqmp-fpga.c | 9 +- include/linux/fpga/fpga-mgr.h | 62 ++++-- 17 files changed, 217 insertions(+), 261 deletions(-)
Documentation/driver-api/fpga/fpga-mgr.rst +29 -9
@@ -24,7 +24,7 @@ How to support a new FPGA device -------------------------------- To add another FPGA manager, write a driver that implements a set of ops. The -probe function calls fpga_mgr_register(), such as:: +probe function calls fpga_mgr_register() or fpga_mgr_register_full(), such as:: static const struct fpga_manager_ops socfpga_fpga_ops = { .write_init = socfpga_fpga_ops_configure_init,
@@ -49,14 +49,14 @@ probe function calls fpga_mgr_register(), such as:: * them in priv */ - mgr = devm_fpga_mgr_create(dev, "Altera SOCFPGA FPGA Manager", - &socfpga_fpga_ops, priv); - if (!mgr) - return -ENOMEM; + mgr = fpga_mgr_register(dev, "Altera SOCFPGA FPGA Manager", + &socfpga_fpga_ops, priv); + if (IS_ERR(mgr)) + return PTR_ERR(mgr); platform_set_drvdata(pdev, mgr); - return fpga_mgr_register(mgr); + return 0; } static int socfpga_fpga_remove(struct platform_device *pdev)
@@ -68,6 +68,11 @@ probe function calls fpga_mgr_register(), such as:: return 0; } +Alternatively, the probe function could call one of the resource managed +register functions, devm_fpga_mgr_register() or devm_fpga_mgr_register_full(). +When these functions are used, the parameter syntax is the same, but the call +to fpga_mgr_unregister() should be removed. In the above example, the +socfpga_fpga_remove() function would not be required. The ops will implement whatever device specific register writes are needed to do the programming sequence for this particular FPGA. These ops return 0 for
@@ -104,8 +109,14 @@ API for implementing a new FPGA Manager driver * ``fpga_mgr_states`` - Values for :c:expr:`fpga_manager->state`. * struct fpga_manager - the FPGA manager struct * struct fpga_manager_ops - Low level FPGA manager driver ops -* devm_fpga_mgr_create() - Allocate and init a manager struct -* fpga_mgr_register() - Register an FPGA manager +* struct fpga_manager_info - Parameter structure for fpga_mgr_register_full() +* fpga_mgr_register_full() - Create and register an FPGA manager using the + fpga_mgr_info structure to provide the full flexibility of options +* fpga_mgr_register() - Create and register an FPGA manager using standard + arguments +* devm_fpga_mgr_register_full() - Resource managed version of + fpga_mgr_register_full() +* devm_fpga_mgr_register() - Resource managed version of fpga_mgr_register() * fpga_mgr_unregister() - Unregister an FPGA manager .. kernel-doc:: include/linux/fpga/fpga-mgr.h
@@ -117,11 +128,20 @@ API for implementing a new FPGA Manager driver .. kernel-doc:: include/linux/fpga/fpga-mgr.h :functions: fpga_manager_ops +.. kernel-doc:: include/linux/fpga/fpga-mgr.h + :functions: fpga_manager_info + .. kernel-doc:: drivers/fpga/fpga-mgr.c - :functions: devm_fpga_mgr_create + :functions: fpga_mgr_register_full .. kernel-doc:: drivers/fpga/fpga-mgr.c :functions: fpga_mgr_register +.. kernel-doc:: drivers/fpga/fpga-mgr.c + :functions: devm_fpga_mgr_register_full + +.. kernel-doc:: drivers/fpga/fpga-mgr.c + :functions: devm_fpga_mgr_register + .. kernel-doc:: drivers/fpga/fpga-mgr.c :functions: fpga_mgr_unregister
drivers/fpga/altera-cvp.c +4 -8
@@ -652,19 +652,15 @@ 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)); - mgr =devm_fpga_mgr_create (&pdev->dev, conf->mgr_name, - &altera_cvp_ops, conf); -if (!mgr) { - ret = -ENOMEM ; + mgr =fpga_mgr_register (&pdev->dev, conf->mgr_name, + &altera_cvp_ops, conf); +if (IS_ERR (mgr)) { + ret =PTR_ERR (mgr); goto err_unmap; }pci_set_drvdata (pdev, mgr); - ret =fpga_mgr_register (mgr); -if (ret) - goto err_unmap; -return 0 ; err_unmap:
drivers/fpga/altera-pr-ip-core.c +2 -5
@@ -191,11 +191,8 @@ int alt_pr_register(struct device *dev, void __iomem *reg_base) (val &ALT_PR_CSR_STATUS_MSK ) >>ALT_PR_CSR_STATUS_SFT , (int)(val & ALT_PR_CSR_PR_START)); - mgr =devm_fpga_mgr_create (dev,dev_name (dev), &alt_pr_ops, priv); -if (!mgr) -return -ENOMEM ; - -return devm_fpga_mgr_register (dev, mgr); + mgr =devm_fpga_mgr_register (dev,dev_name (dev), &alt_pr_ops, priv); +return PTR_ERR_OR_ZERO (mgr); }EXPORT_SYMBOL_GPL (alt_pr_register);
drivers/fpga/altera-ps-spi.c +3 -6
@@ -302,12 +302,9 @@ static int altera_ps_probe(struct spi_device *spi)snprintf (conf->mgr_name,sizeof (conf->mgr_name),"%s %s" ,dev_driver_string (&spi->dev),dev_name (&spi->dev)); - mgr =devm_fpga_mgr_create (&spi->dev, conf->mgr_name, - &altera_ps_ops, conf); -if (!mgr) -return -ENOMEM ; - -return devm_fpga_mgr_register (&spi->dev, mgr); + mgr =devm_fpga_mgr_register (&spi->dev, conf->mgr_name, + &altera_ps_ops, conf); +return PTR_ERR_OR_ZERO (mgr); }static const struct spi_device_id altera_ps_spi_ids[] = {
drivers/fpga/dfl-fme-mgr.c +9 -13
@@ -276,7 +276,7 @@ static void fme_mgr_get_compat_id(void __iomem *fme_pr,static int fme_mgr_probe (struct platform_device *pdev) {struct dfl_fme_mgr_pdata *pdata =dev_get_platdata (&pdev->dev); -struct fpga_compat_id *compat_id; +struct fpga_manager_info info = {0 };struct device *dev = &pdev->dev;struct fme_mgr_priv *priv;struct fpga_manager *mgr;
@@ -296,20 +296,16 @@ static int fme_mgr_probe(struct platform_device *pdev)return PTR_ERR (priv->ioaddr); } - compat_id =devm_kzalloc (dev,sizeof (*compat_id),GFP_KERNEL ); -if (!compat_id) + info.name ="DFL FME FPGA Manager" ; + info.mops = &fme_mgr_ops; + info.priv = priv; + info.compat_id =devm_kzalloc (dev,sizeof (*info.compat_id),GFP_KERNEL ); +if (!info.compat_id)return -ENOMEM ; -fme_mgr_get_compat_id (priv->ioaddr, compat_id); - - mgr =devm_fpga_mgr_create (dev,"DFL FME FPGA Manager" , - &fme_mgr_ops, priv); -if (!mgr) -return -ENOMEM ; - - mgr->compat_id = compat_id; - -return devm_fpga_mgr_register (dev, mgr); +fme_mgr_get_compat_id (priv->ioaddr, info.compat_id); + mgr =devm_fpga_mgr_register_full (dev, &info); +return PTR_ERR_OR_ZERO (mgr); }static struct platform_driver fme_mgr_driver = {
drivers/fpga/fpga-mgr.c +91 -124
301 lines not on this page · raw message
drivers/fpga/ice40-spi.c +3 -6
@@ -178,12 +178,9 @@ static int ice40_fpga_probe(struct spi_device *spi)return ret; } - mgr =devm_fpga_mgr_create (dev,"Lattice iCE40 FPGA Manager" , - &ice40_fpga_ops, priv); -if (!mgr) -return -ENOMEM ; - -return devm_fpga_mgr_register (dev, mgr); + mgr =devm_fpga_mgr_register (dev,"Lattice iCE40 FPGA Manager" , + &ice40_fpga_ops, priv); +return PTR_ERR_OR_ZERO (mgr); }static const struct of_device_id ice40_fpga_of_match[] = {
drivers/fpga/machxo2-spi.c +3 -6
@@ -370,12 +370,9 @@ static int machxo2_spi_probe(struct spi_device *spi)return -EINVAL ; } - mgr =devm_fpga_mgr_create (dev,"Lattice MachXO2 SPI FPGA Manager" , - &machxo2_ops, spi); -if (!mgr) -return -ENOMEM ; - -return devm_fpga_mgr_register (dev, mgr); + mgr =devm_fpga_mgr_register (dev,"Lattice MachXO2 SPI FPGA Manager" , + &machxo2_ops, spi); +return PTR_ERR_OR_ZERO (mgr); }#ifdef CONFIG_OF
drivers/fpga/socfpga-a10.c +6 -10
@@ -508,19 +508,15 @@ static int socfpga_a10_fpga_probe(struct platform_device *pdev)return -EBUSY ; } - mgr =devm_fpga_mgr_create (dev,"SoCFPGA Arria10 FPGA Manager" , - &socfpga_a10_fpga_mgr_ops, priv); -if (!mgr) -return -ENOMEM ; - -platform_set_drvdata (pdev, mgr); - - ret =fpga_mgr_register (mgr); -if (ret) { + mgr =fpga_mgr_register (dev,"SoCFPGA Arria10 FPGA Manager" , + &socfpga_a10_fpga_mgr_ops, priv); +if (IS_ERR (mgr)) {clk_disable_unprepare (priv->clk); -return ret; +return PTR_ERR (mgr); } +platform_set_drvdata (pdev, mgr); +return 0 ; }
drivers/fpga/socfpga.c +3 -6
@@ -571,12 +571,9 @@ static int socfpga_fpga_probe(struct platform_device *pdev)if (ret)return ret; - mgr =devm_fpga_mgr_create (dev,"Altera SOCFPGA FPGA Manager" , - &socfpga_fpga_ops, priv); -if (!mgr) -return -ENOMEM ; - -return devm_fpga_mgr_register (dev, mgr); + mgr =devm_fpga_mgr_register (dev,"Altera SOCFPGA FPGA Manager" , + &socfpga_fpga_ops, priv); +return PTR_ERR_OR_ZERO (mgr); }#ifdef CONFIG_OF
drivers/fpga/stratix10-soc.c +4 -12
@@ -419,18 +419,11 @@ static int s10_probe(struct platform_device *pdev)init_completion (&priv->status_return_completion); - mgr =fpga_mgr_create (dev,"Stratix10 SOC FPGA Manager" , - &s10_ops, priv); -if (!mgr) { -dev_err (dev,"unable to create FPGA manager\n" ); - ret = -ENOMEM ; - goto probe_err; - } - - ret =fpga_mgr_register (mgr); -if (ret) { + mgr =fpga_mgr_register (dev,"Stratix10 SOC FPGA Manager" , + &s10_ops, priv); +if (IS_ERR (mgr)) {dev_err (dev,"unable to register FPGA manager\n" ); -fpga_mgr_free (mgr); + ret =PTR_ERR (mgr); goto probe_err; }
@@ -448,7 +441,6 @@ static int s10_remove(struct platform_device *pdev)struct s10_priv *priv = mgr->priv;fpga_mgr_unregister (mgr); -fpga_mgr_free (mgr);stratix10_svc_free_channel (priv->chan);return 0 ;
drivers/fpga/ts73xx-fpga.c +3 -6
@@ -116,12 +116,9 @@ static int ts73xx_fpga_probe(struct platform_device *pdev)if (IS_ERR (priv->io_base))return PTR_ERR (priv->io_base); - mgr =devm_fpga_mgr_create (kdev,"TS-73xx FPGA Manager" , - &ts73xx_fpga_ops, priv); -if (!mgr) -return -ENOMEM ; - -return devm_fpga_mgr_register (kdev, mgr); + mgr =devm_fpga_mgr_register (kdev,"TS-73xx FPGA Manager" , + &ts73xx_fpga_ops, priv); +return PTR_ERR_OR_ZERO (mgr); }static struct platform_driver ts73xx_fpga_driver = {
drivers/fpga/versal-fpga.c +3 -6
@@ -54,12 +54,9 @@ static int versal_fpga_probe(struct platform_device *pdev)return ret; } - mgr =devm_fpga_mgr_create (dev,"Xilinx Versal FPGA Manager" , - &versal_fpga_ops,NULL ); -if (!mgr) -return -ENOMEM ; - -return devm_fpga_mgr_register (dev, mgr); + mgr =devm_fpga_mgr_register (dev,"Xilinx Versal FPGA Manager" , + &versal_fpga_ops,NULL ); +return PTR_ERR_OR_ZERO (mgr); }static const struct of_device_id versal_fpga_of_match[] = {
drivers/fpga/xilinx-spi.c +4 -7
@@ -247,13 +247,10 @@ static int xilinx_spi_probe(struct spi_device *spi)return dev_err_probe (&spi->dev,PTR_ERR (conf->done),"Failed to get DONE gpio\n" ); - mgr =devm_fpga_mgr_create (&spi->dev, -"Xilinx Slave Serial FPGA Manager" , - &xilinx_spi_ops, conf); -if (!mgr) -return -ENOMEM ; - -return devm_fpga_mgr_register (&spi->dev, mgr); + mgr =devm_fpga_mgr_register (&spi->dev, +"Xilinx Slave Serial FPGA Manager" , + &xilinx_spi_ops, conf); +return PTR_ERR_OR_ZERO (mgr); }#ifdef CONFIG_OF
drivers/fpga/zynq-fpga.c +6 -10
@@ -609,20 +609,16 @@ static int zynq_fpga_probe(struct platform_device *pdev)clk_disable (priv->clk); - mgr =devm_fpga_mgr_create (dev,"Xilinx Zynq FPGA Manager" , - &zynq_fpga_ops, priv); -if (!mgr) -return -ENOMEM ; - -platform_set_drvdata (pdev, mgr); - - err =fpga_mgr_register (mgr); -if (err) { + mgr =fpga_mgr_register (dev,"Xilinx Zynq FPGA Manager" , + &zynq_fpga_ops, priv); +if (IS_ERR (mgr)) {dev_err (dev,"unable to register FPGA manager\n" );clk_unprepare (priv->clk); -return err; +return PTR_ERR (mgr); } +platform_set_drvdata (pdev, mgr); +return 0 ; }
drivers/fpga/zynqmp-fpga.c +3 -6
@@ -95,12 +95,9 @@ static int zynqmp_fpga_probe(struct platform_device *pdev) priv->dev = dev; - mgr =devm_fpga_mgr_create (dev,"Xilinx ZynqMP FPGA Manager" , - &zynqmp_fpga_ops, priv); -if (!mgr) -return -ENOMEM ; - -return devm_fpga_mgr_register (dev, mgr); + mgr =devm_fpga_mgr_register (dev,"Xilinx ZynqMP FPGA Manager" , + &zynqmp_fpga_ops, priv); +return PTR_ERR_OR_ZERO (mgr); }#ifdef CONFIG_OF
include/linux/fpga/fpga-mgr.h +41 -21
81 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v13 2/3 fpga: bridge: Use standard dev_release for class driver
In reply to Russ WeightThe FPGA bridge class driver data structure is being treated as a managed resource instead of using the standard dev_release call-back function to release the class data structure. This change removes the managed resource code and combines the create() and register() functions into a single register() function.
---
v13:
- Add Acked-by tag
v12:
- No change
v11:
- Rebased to latest linux-next (no conflicts)
v10:
- Removed the fpga_bridge_register_full() function, because there is not need for it yet. Updated the documentation and commit message accordingly.
v9:
- Cleaned up documentation for the FPGA Bridge register functions
- Renamed fpga_bridge_register() to fpga_bridge_register_full()
- Renamed fpga_bridge_register_simple() to fpga_bridge_register()
v8:
- Added reviewed-by tag.
- Updated Documentation/driver-api/fpga/fpga-bridge.rst documentation.
v7:
- Update the commit message to describe the new parameters for the fpga_bridge_register() function and to mention the fpga_bridge_register_simple() function.
- Fix function prototypes in header file to rename dev to parent.
- Some cleanup of comments.
- Update function definitions/prototypes to apply const to the new info parameter.
- Verify that info->br_ops is non-null in register functions.
v6:
- Changed fpga_bridge_register() parameters to accept an info data structure to provide flexibility in passing optional parameters.
- Added fpga_bridge_register_simple() function to support current parameters for users that don't require the use of optional parameters.
v5:
- Rebased on top of recently accepted patches.
v4:
- Restore the previous format for the Return value in the comment header for fpga_bridge_register()
v3:
- Cleaned up comment header for fpga_bridge_register()
- Fix error return values for fpga_bridge_register()
v2:
- No changes
--- Documentation/driver-api/fpga/fpga-bridge.rst | 6 +- drivers/fpga/altera-fpga2sdram.c | 12 +- drivers/fpga/altera-freeze-bridge.c | 10 +- drivers/fpga/altera-hps2fpga.c | 12 +- drivers/fpga/dfl-fme-br.c | 10 +- drivers/fpga/fpga-bridge.c | 122 ++++-------------- drivers/fpga/xilinx-pr-decoupler.c | 17 +-- include/linux/fpga/fpga-bridge.h | 30 +++-- 8 files changed, 74 insertions(+), 145 deletions(-)
Documentation/driver-api/fpga/fpga-bridge.rst +1 -5
@@ -6,8 +6,7 @@ API to implement a new FPGA bridge * struct fpga_bridge - The FPGA Bridge structure * struct fpga_bridge_ops - Low level Bridge driver ops -* devm_fpga_bridge_create() - Allocate and init a bridge struct -* fpga_bridge_register() - Register a bridge +* fpga_bridge_register() - Create and register a bridge * fpga_bridge_unregister() - Unregister a bridge .. kernel-doc:: include/linux/fpga/fpga-bridge.h
@@ -16,9 +15,6 @@ API to implement a new FPGA bridge .. kernel-doc:: include/linux/fpga/fpga-bridge.h :functions: fpga_bridge_ops -.. kernel-doc:: drivers/fpga/fpga-bridge.c - :functions: devm_fpga_bridge_create - .. kernel-doc:: drivers/fpga/fpga-bridge.c :functions: fpga_bridge_register
drivers/fpga/altera-fpga2sdram.c +4 -8
@@ -121,17 +121,13 @@ static int alt_fpga_bridge_probe(struct platform_device *pdev)/* Get f2s bridge configuration saved in handoff register */ regmap_read (sysmgr,SYSMGR_ISWGRP_HANDOFF3 , &priv->mask); - br =devm_fpga_bridge_create (dev,F2S_BRIDGE_NAME , - &altera_fpga2sdram_br_ops, priv); -if (!br) -return -ENOMEM ; + br =fpga_bridge_register (dev,F2S_BRIDGE_NAME , + &altera_fpga2sdram_br_ops, priv); +if (IS_ERR (br)) +return PTR_ERR (mgr);platform_set_drvdata (pdev, br); - ret =fpga_bridge_register (br); -if (ret) -return ret; -dev_info (dev,"driver initialized with handoff %08x\n" , priv->mask);if (!of_property_read_u32 (dev->of_node,"bridge-enable" , &enable)) {
drivers/fpga/altera-freeze-bridge.c +5 -5
@@ -246,14 +246,14 @@ static int altera_freeze_br_probe(struct platform_device *pdev) priv->base_addr = base_addr; - br =devm_fpga_bridge_create (dev,FREEZE_BRIDGE_NAME , - &altera_freeze_br_br_ops, priv); -if (!br) -return -ENOMEM ; + br =fpga_bridge_register (dev,FREEZE_BRIDGE_NAME , + &altera_freeze_br_br_ops, priv); +if (IS_ERR (br)) +return PTR_ERR (br);platform_set_drvdata (pdev, br); -return fpga_bridge_register (br); +return 0 ; }static int altera_freeze_br_remove (struct platform_device *pdev)
drivers/fpga/altera-hps2fpga.c +4 -8
@@ -180,19 +180,15 @@ static int alt_fpga_bridge_probe(struct platform_device *pdev) } } - br =devm_fpga_bridge_create (dev, priv->name, - &altera_hps2fpga_br_ops, priv); -if (!br) { - ret = -ENOMEM ; + br =fpga_bridge_register (dev, priv->name, + &altera_hps2fpga_br_ops, priv); +if (IS_ERR (br)) { + ret =PTR_ERR (br); goto err; }platform_set_drvdata (pdev, br); - ret =fpga_bridge_register (br); -if (ret) - goto err; -return 0 ; err:
drivers/fpga/dfl-fme-br.c +5 -5
@@ -68,14 +68,14 @@ static int fme_br_probe(struct platform_device *pdev) priv->pdata =dev_get_platdata (dev); - br =devm_fpga_bridge_create (dev,"DFL FPGA FME Bridge" , - &fme_bridge_ops, priv); -if (!br) -return -ENOMEM ; + br =fpga_bridge_register (dev,"DFL FPGA FME Bridge" , + &fme_bridge_ops, priv); +if (IS_ERR (br)) +return PTR_ERR (br);platform_set_drvdata (pdev, br); -return fpga_bridge_register (br); +return 0 ; }static int fme_br_remove (struct platform_device *pdev)
drivers/fpga/fpga-bridge.c +28 -94
175 lines not on this page · raw message
drivers/fpga/xilinx-pr-decoupler.c +6 -11
@@ -140,22 +140,17 @@ static int xlnx_pr_decoupler_probe(struct platform_device *pdev)clk_disable (priv->clk); - br =devm_fpga_bridge_create (&pdev->dev, priv->ipconfig->name, - &xlnx_pr_decoupler_br_ops, priv); -if (!br) { - err = -ENOMEM ; - goto err_clk; - } - -platform_set_drvdata (pdev, br); - - err =fpga_bridge_register (br); -if (err) { + br =fpga_bridge_register (&pdev->dev, priv->ipconfig->name, + &xlnx_pr_decoupler_br_ops, priv); +if (IS_ERR (br)) { + err =PTR_ERR (br);dev_err (&pdev->dev,"unable to register %s" , priv->ipconfig->name); goto err_clk; } +platform_set_drvdata (pdev, br); +return 0 ; err_clk:
include/linux/fpga/fpga-bridge.h +21 -9
@@ -22,6 +22,23 @@ struct fpga_bridge_ops {const struct attribute_group **groups; }; +/** +* struct fpga_bridge_info - collection of parameters an FPGA Bridge +* @name: fpga bridge name +* @br_ops: pointer to structure of fpga bridge ops +* @priv: fpga bridge private data +* +* fpga_bridge_info contains parameters for the register function. These +* are separated into an info structure because they some are optional +* others could be added to in the future. The info structure facilitates +* maintaining a stable API. +*/ +struct fpga_bridge_info { +const char *name; +const struct fpga_bridge_ops *br_ops; +void *priv; +}; +/** * struct fpga_bridge - FPGA bridge structure * @name: name of low level FPGA bridge
@@ -62,15 +79,10 @@ int of_fpga_bridge_get_to_list(struct device_node *np,struct fpga_image_info *info, struct list_head *bridge_list); -struct fpga_bridge *fpga_bridge_create (struct device *dev,const char *name, -const struct fpga_bridge_ops *br_ops, -void *priv); -void fpga_bridge_free (struct fpga_bridge *br); -int fpga_bridge_register (struct fpga_bridge *br); +struct fpga_bridge * +fpga_bridge_register (struct device *parent,const char *name, +const struct fpga_bridge_ops *br_ops, +void *priv);void fpga_bridge_unregister (struct fpga_bridge *br); -struct fpga_bridge -*devm_fpga_bridge_create (struct device *dev,const char *name, -const struct fpga_bridge_ops *br_ops,void *priv); -#endif /* _LINUX_FPGA_BRIDGE_H */
Signature · 1 line
2.25.1
kernel test robot
build botRe: [PATCH v13 2/3] fpga: bridge: Use standard dev_release for class driver
Thank you for the patch! Yet something to improve:
Hi Russ,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on linux/master]
[also build test ERROR on linus/master v5.16-rc1 next-20211118] [cannot apply to xilinx-xlnx/master]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Russ-Weight/fpga-Use-standard-class-dev_release-function/20211117-092426 base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 8ab774587903771821b59471cc723bba6d893942 config: arm-randconfig-r021-20211118 (attached as .config)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# install arm cross compiling tool for clang build
# apt-get install binutils-arm-linux-gnueabi
# https://github.com/0day-ci/linux/commit/cbab51e5108b1de0ce5fca9901f5b462cc62a71d
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Russ-Weight/fpga-Use-standard-class-dev_release-function/20211117-092426 git checkout cbab51e5108b1de0ce5fca9901f5b462cc62a71d
# save the attached .config to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=arm SHELL=/bin/bash drivers/fpga/
If you fix the issue, kindly add following tag as appropriate
All errors (new ones prefixed by >>):
>> drivers/fpga/altera-fpga2sdram.c:127:18: error: use of undeclared identifier 'mgr'
return PTR_ERR(mgr);
^1 error generated.
vim +/mgr +127 drivers/fpga/altera-fpga2sdram.c
93
94 static int alt_fpga_bridge_probe(struct platform_device *pdev)
95 {
96 struct device *dev = &pdev->dev;
97 struct alt_fpga2sdram_data *priv;
98 struct fpga_bridge *br;
99 u32 enable;
100 struct regmap *sysmgr;
101 int ret = 0;
102
103 priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
104 if (!priv)
105 return -ENOMEM;
106
107 priv->dev = dev;
108
109 priv->sdrctl = syscon_regmap_lookup_by_compatible("altr,sdr-ctl");
110 if (IS_ERR(priv->sdrctl)) {
111 dev_err(dev, "regmap for altr,sdr-ctl lookup failed.\n");
112 return PTR_ERR(priv->sdrctl);
113 }
114
115 sysmgr = syscon_regmap_lookup_by_compatible("altr,sys-mgr");
116 if (IS_ERR(sysmgr)) {
117 dev_err(dev, "regmap for altr,sys-mgr lookup failed.\n");
118 return PTR_ERR(sysmgr);
119 }
120
121 /* Get f2s bridge configuration saved in handoff register */
122 regmap_read(sysmgr, SYSMGR_ISWGRP_HANDOFF3, &priv->mask);
123
124 br = fpga_bridge_register(dev, F2S_BRIDGE_NAME,
125 &altera_fpga2sdram_br_ops, priv);
126 if (IS_ERR(br))
> 127 return PTR_ERR(mgr); 128
129 platform_set_drvdata(pdev, br);
130
131 dev_info(dev, "driver initialized with handoff %08x\n", priv->mask);
132
133 if (!of_property_read_u32(dev->of_node, "bridge-enable", &enable)) {
134 if (enable > 1) {
135 dev_warn(dev, "invalid bridge-enable %u > 1\n", enable);
136 } else {
137 dev_info(dev, "%s bridge\n",
138 (enable ? "enabling" : "disabling"));
139 ret = _alt_fpga2sdram_enable_set(priv, enable);
140 if (ret) {
141 fpga_bridge_unregister(br);
142 return ret;
143 }
144 }
145 }
146
147 return ret;
148 }
149
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
kernel test robot
build botRe: [PATCH v13 2/3] fpga: bridge: Use standard dev_release for class driver
In reply to Russ WeightThank you for the patch! Yet something to improve:
Hi Russ,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on linux/master]
[also build test ERROR on linus/master v5.16-rc1 next-20211118] [cannot apply to xilinx-xlnx/master]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Russ-Weight/fpga-Use-standard-class-dev_release-function/20211117-092426 base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 8ab774587903771821b59471cc723bba6d893942 config: arm64-allyesconfig (attached as .config) compiler: aarch64-linux-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/cbab51e5108b1de0ce5fca9901f5b462cc62a71d
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Russ-Weight/fpga-Use-standard-class-dev_release-function/20211117-092426 git checkout cbab51e5108b1de0ce5fca9901f5b462cc62a71d
# save the attached .config to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=arm64 SHELL=/bin/bash drivers/
If you fix the issue, kindly add following tag as appropriate
All errors (new ones prefixed by >>):
drivers/fpga/altera-fpga2sdram.c: In function 'alt_fpga_bridge_probe':
>> drivers/fpga/altera-fpga2sdram.c:127:32: error: 'mgr' undeclared (first use in this function)
127 | return PTR_ERR(mgr);
| ^~~ drivers/fpga/altera-fpga2sdram.c:127:32: note: each undeclared identifier is reported only once for each function it appears in
vim +/mgr +127 drivers/fpga/altera-fpga2sdram.c
93
94 static int alt_fpga_bridge_probe(struct platform_device *pdev)
95 {
96 struct device *dev = &pdev->dev;
97 struct alt_fpga2sdram_data *priv;
98 struct fpga_bridge *br;
99 u32 enable;
100 struct regmap *sysmgr;
101 int ret = 0;
102
103 priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
104 if (!priv)
105 return -ENOMEM;
106
107 priv->dev = dev;
108
109 priv->sdrctl = syscon_regmap_lookup_by_compatible("altr,sdr-ctl");
110 if (IS_ERR(priv->sdrctl)) {
111 dev_err(dev, "regmap for altr,sdr-ctl lookup failed.\n");
112 return PTR_ERR(priv->sdrctl);
113 }
114
115 sysmgr = syscon_regmap_lookup_by_compatible("altr,sys-mgr");
116 if (IS_ERR(sysmgr)) {
117 dev_err(dev, "regmap for altr,sys-mgr lookup failed.\n");
118 return PTR_ERR(sysmgr);
119 }
120
121 /* Get f2s bridge configuration saved in handoff register */
122 regmap_read(sysmgr, SYSMGR_ISWGRP_HANDOFF3, &priv->mask);
123
124 br = fpga_bridge_register(dev, F2S_BRIDGE_NAME,
125 &altera_fpga2sdram_br_ops, priv);
126 if (IS_ERR(br))
> 127 return PTR_ERR(mgr); 128
129 platform_set_drvdata(pdev, br);
130
131 dev_info(dev, "driver initialized with handoff %08x\n", priv->mask);
132
133 if (!of_property_read_u32(dev->of_node, "bridge-enable", &enable)) {
134 if (enable > 1) {
135 dev_warn(dev, "invalid bridge-enable %u > 1\n", enable);
136 } else {
137 dev_info(dev, "%s bridge\n",
138 (enable ? "enabling" : "disabling"));
139 ret = _alt_fpga2sdram_enable_set(priv, enable);
140 if (ret) {
141 fpga_bridge_unregister(br);
142 return ret;
143 }
144 }
145 }
146
147 return ret;
148 }
149
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
PATCH v13 3/3 fpga: region: Use standard dev_release for class driver
In reply to Russ WeightThe FPGA region class driver data structure is being treated as a managed resource instead of using the standard dev_release call-back function to release the class data structure. This change removes the managed resource code and combines the create() and register() functions into a single register() or register_full() function.
The register_full() function accepts an info data structure to provide flexibility in passing optional parameters. The register() function supports the current parameter list for users that don't require the use of optional parameters.
---
v13:
- Add Acked-by tag
v12:
- No change
v11:
- Rebased to latest linux-next (no conflicts)
v10:
- Fixed commit message to reference register_full() instead of register_simple().
- Updated documentation to reference the fpga_region_info structure
v9:
- Cleaned up documentation for the FPGA Region register functions
- Renamed fpga_region_register() to fpga_region_register_full()
- Renamed fpga_region_register_simple() to fpga_region_register()
v8:
- Added reviewed-by tag.
- Updated Documentation/driver-api/fpga/fpga-region.rst documentation.
v7:
- Update the commit message to describe the new parameters for the fpga_region_register() function and to mention the fpga_region_register_simple() function.
- Fix function prototypes in header file to rename dev to parent.
- Some cleanup of comments.
- Update function definitions/prototypes to apply const to the new info parameter.
- Verify a non-null info pointer in the register() functions.
v6:
- Moved FPGA manager optional parameters out of the ops structure and back into the FPGA Region structure.
- Changed fpga_region_register() parameters to accept an info data structure to provide flexibility in passing optional parameters.
- Added fpga_region_register_simple() functions to support current parameters for users that don't require the use of optional parameters.
v5:
- Rebased on top of recently accepted patches.
- Created the fpga_region_ops data structure which is optionally passed to fpga_region_register(). compat_id, the get_bridges() pointer, and the priv pointer are included in the fpga_region_ops structure.
v4:
- Added the compat_id parameter to fpga_region_register() to ensure that the compat_id is set before the device_register() call.
- Modified the dfl_fpga_feature_devs_enumerate() function to restore the fpga_region_register() call to the correct location.
v3:
- Cleaned up comment header for fpga_region_register()
- Fix fpga_region_register() error return on ida_simple_get() failure
v2:
- No changes
--- Documentation/driver-api/fpga/fpga-region.rst | 12 +- drivers/fpga/dfl-fme-region.c | 17 ++- drivers/fpga/dfl.c | 12 +- drivers/fpga/fpga-region.c | 119 +++++++----------- drivers/fpga/of-fpga-region.c | 10 +- include/linux/fpga/fpga-region.h | 36 ++++-- 6 files changed, 95 insertions(+), 111 deletions(-)
Documentation/driver-api/fpga/fpga-region.rst +9 -3
@@ -46,8 +46,11 @@ API to add a new FPGA region ---------------------------- * struct fpga_region - The FPGA region struct -* devm_fpga_region_create() - Allocate and init a region struct -* fpga_region_register() - Register an FPGA region +* struct fpga_region_info - Parameter structure for fpga_region_register_full() +* fpga_region_register_full() - Create and register an FPGA region using the + fpga_region_info structure to provide the full flexibility of options +* fpga_region_register() - Create and register an FPGA region using standard + arguments * fpga_region_unregister() - Unregister an FPGA region The FPGA region's probe function will need to get a reference to the FPGA
@@ -75,8 +78,11 @@ following APIs to handle building or tearing down that list. .. kernel-doc:: include/linux/fpga/fpga-region.h :functions: fpga_region +.. kernel-doc:: include/linux/fpga/fpga-region.h + :functions: fpga_region_info + .. kernel-doc:: drivers/fpga/fpga-region.c - :functions: devm_fpga_region_create + :functions: fpga_region_register_full .. kernel-doc:: drivers/fpga/fpga-region.c :functions: fpga_region_register
drivers/fpga/dfl-fme-region.c +8 -9
@@ -30,6 +30,7 @@ static int fme_region_get_bridges(struct fpga_region *region)static int fme_region_probe (struct platform_device *pdev) {struct dfl_fme_region_pdata *pdata =dev_get_platdata (&pdev->dev); +struct fpga_region_info info = {0 };struct device *dev = &pdev->dev;struct fpga_region *region;struct fpga_manager *mgr;
@@ -39,20 +40,18 @@ static int fme_region_probe(struct platform_device *pdev)if (IS_ERR (mgr))return -EPROBE_DEFER ; - region =devm_fpga_region_create (dev, mgr, fme_region_get_bridges); -if (!region) { - ret = -ENOMEM ; + info.mgr = mgr; + info.compat_id = mgr->compat_id; + info.get_bridges = fme_region_get_bridges; + info.priv = pdata; + region =fpga_region_register_full (dev, &info); +if (IS_ERR (region)) { + ret =PTR_ERR (region); goto eprobe_mgr_put; } - region->priv = pdata; - region->compat_id = mgr->compat_id;platform_set_drvdata (pdev, region); - ret =fpga_region_register (region); -if (ret) - goto eprobe_mgr_put; -dev_dbg (dev,"DFL FME FPGA Region probed\n" );return 0 ;
drivers/fpga/dfl.c +4 -8
@@ -1407,19 +1407,15 @@ dfl_fpga_feature_devs_enumerate(struct dfl_fpga_enum_info *info)if (!cdev)return ERR_PTR (-ENOMEM ); - cdev->region =devm_fpga_region_create (info->dev,NULL ,NULL ); -if (!cdev->region) { - ret = -ENOMEM ; - goto free_cdev_exit; - } - cdev->parent = info->dev;mutex_init (&cdev->lock);INIT_LIST_HEAD (&cdev->port_dev_list); - ret =fpga_region_register (cdev->region); -if (ret) + cdev->region =fpga_region_register (info->dev,NULL ,NULL ); +if (IS_ERR (cdev->region)) { + ret =PTR_ERR (cdev->region); goto free_cdev_exit; + }/* create and init build info for enumeration */ binfo =devm_kzalloc (info->dev,sizeof (*binfo),GFP_KERNEL );
drivers/fpga/fpga-region.c +44 -75
171 lines not on this page · raw message
drivers/fpga/of-fpga-region.c +3 -7
@@ -405,16 +405,12 @@ static int of_fpga_region_probe(struct platform_device *pdev)if (IS_ERR (mgr))return -EPROBE_DEFER ; - region =devm_fpga_region_create (dev, mgr, of_fpga_region_get_bridges); -if (!region) { - ret = -ENOMEM ; + region =fpga_region_register (dev, mgr, of_fpga_region_get_bridges); +if (IS_ERR (region)) { + ret =PTR_ERR (region); goto eprobe_mgr_put; } - ret =fpga_region_register (region); -if (ret) - goto eprobe_mgr_put; -of_platform_populate (np, fpga_region_of_match,NULL , ®ion->dev);platform_set_drvdata (pdev, region);
include/linux/fpga/fpga-region.h +27 -9
@@ -7,6 +7,27 @@#include <linux/fpga/fpga-mgr.h> #include <linux/fpga/fpga-bridge.h> +struct fpga_region ; + +/** +* struct fpga_region_info - collection of parameters an FPGA Region +* @mgr: fpga region manager +* @compat_id: FPGA region id for compatibility check. +* @priv: fpga region private data +* @get_bridges: optional function to get bridges to a list +* +* fpga_region_info contains parameters for the register_full function. +* These are separated into an info structure because they some are optional +* others could be added to in the future. The info structure facilitates +* maintaining a stable API. +*/ +struct fpga_region_info { +struct fpga_manager *mgr; +struct fpga_compat_id *compat_id; +void *priv; +int (*get_bridges)(struct fpga_region *region); +}; +/** * struct fpga_region - FPGA Region structure * @dev: FPGA Region device
@@ -37,15 +58,12 @@ struct fpga_region *fpga_region_class_find(int fpga_region_program_fpga (struct fpga_region *region); -struct fpga_region -*fpga_region_create (struct device *dev,struct fpga_manager *mgr, -int (*get_bridges)(struct fpga_region *)); -void fpga_region_free (struct fpga_region *region); -int fpga_region_register (struct fpga_region *region); -void fpga_region_unregister (struct fpga_region *region); +struct fpga_region * +fpga_region_register_full (struct device *parent,const struct fpga_region_info *info); -struct fpga_region -*devm_fpga_region_create (struct device *dev,struct fpga_manager *mgr, -int (*get_bridges)(struct fpga_region *)); +struct fpga_region * +fpga_region_register (struct device *parent,struct fpga_manager *mgr, +int (*get_bridges)(struct fpga_region *)); +void fpga_region_unregister (struct fpga_region *region);#endif /* _FPGA_REGION_H */
Signature · 1 line
2.25.1