Skip to contentSkip to conversation

fpga: Use standard class dev_release function

PATCH Superseded Russ Weight 2 participants 9 messages Jul 9, 2021 – Jul 16, 2021

Subsystems (4)

v10 of 14 Superseded Latest is v14 →

lore
Share & tools
lore
#0 lore raw

v10 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 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/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 ++-
 30 files changed, 383 insertions(+), 511 deletions(-)
Signature · 1 line
2.25.1
#1 lore raw

PATCH v10 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.

---
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/xilinx-spi.c                  |  11 +-
 drivers/fpga/zynq-fpga.c                   |  16 +-
 drivers/fpga/zynqmp-fpga.c                 |   9 +-
 include/linux/fpga/fpga-mgr.h              |  62 ++++--
 16 files changed, 214 insertions(+), 255 deletions(-)
Documentation/driver-api/fpga/fpga-mgr.rst +29 -9
index 4d926b452cb3..42c01f396dce 100644
@@ -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
index ccf4546eff29..4ffb9da537d8 100644
@@ -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
index dfdf21ed34c4..be0667968d33 100644
@@ -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
index 23bfd4d1ad0f..5e1e009dba89 100644
@@ -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
index d5861d13b306..620e7874ab53 100644
@@ -282,7 +282,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;
@@ -302,20 +302,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

302 lines not on this page · raw message

drivers/fpga/ice40-spi.c +3 -6
index 69dec5af23c3..b7591912248f 100644
@@ -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
index 1afb41aa20d7..8469dfb5dd21 100644
@@ -366,12 +366,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
index 573d88bdf730..ac8e89b8a5cc 100644
@@ -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
index 1f467173fc1f..7e0741f99696 100644
@@ -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
index a2cea500f7cc..9155e888a133 100644
@@ -425,18 +425,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;
 	}
 
@@ -454,7 +447,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
index 101f016c6ed8..fd52de20ddb2 100644
@@ -122,12 +122,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/xilinx-spi.c +4 -7
index fee4d0abf6bf..db23626f9ab2 100644
@@ -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);
 }
 
 static const struct of_device_id xlnx_spi_of_match[] = {
drivers/fpga/zynq-fpga.c +6 -10
index 9b75bd4f93d8..426aa34c6a0d 100644
@@ -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
index 125743c9797f..975bdc4d0a65 100644
@@ -102,12 +102,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);
 }
 
 static const struct of_device_id zynqmp_fpga_of_match[] = {
include/linux/fpga/fpga-mgr.h +41 -21

81 lines not on this page · raw message

Signature · 1 line
2.25.1
#2 lore raw

PATCH v10 2/3 fpga: bridge: Use standard dev_release for class driver

In reply to Russ Weight

The 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.

---
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
index 8d650b4e2ce6..604208534095 100644
@@ -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
index a78e49c63c64..66063507116b 100644
@@ -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
index dd58c4aea92e..bfbfa43cd05b 100644
@@ -244,14 +244,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
index 77b95f251821..aa758426c22b 100644
@@ -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
index 3ff9f3a687ce..808d1f4d76df 100644
@@ -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
index ea2bde6e5bc4..c004e52b9464 100644
@@ -138,22 +138,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
index 6c3c28806ff1..223da48a6d18 100644
@@ -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
#3 lore raw

PATCH v10 3/3 fpga: region: Use standard dev_release for class driver

In reply to Russ Weight

The 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.

---
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
index 2636a27c11b2..dc55d60a0b4a 100644
@@ -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
index 1eeb42af1012..4aebde0a7f1c 100644
@@ -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
index 511b20ff35a3..3905995ef6d5 100644
@@ -1400,19 +1400,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
index e3c25576b6b9..9c662db1c508 100644
@@ -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, &region->dev);
 	platform_set_drvdata(pdev, region);
 
include/linux/fpga/fpga-region.h +27 -9
index 27cb706275db..ae111beeffba 100644
@@ -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
#4 lore raw
In reply to Russ Weight

It seems like these patches are stalled on the compat_id question (in other emails). My
two-cents: I don't see an issue with having two versions of the register functions, and I don't consider the issue important enough to force a move of the compat_id field. I think the compat_id issue should be considered separately.

Are there any other concers for these patches?

- Russ

Quoted 140 lines · Russ Weight

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 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/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 ++-
 30 files changed, 383 insertions(+), 511 deletions(-)
reviewer
#5 lore raw
Quoted 6 lines · Russ Weight

It seems like these patches are stalled on the compat_id question (in other emails). My
two-cents: I don't see an issue with having two versions of the register functions, and I don't consider the issue important enough to force a move of the compat_id field. I think the compat_id issue should be considered separately.

Are there any other concers for these patches?

I am fine with it other than the two register functions.

To compat_id or not and which order, I believe is Moritz's call.

I'm ok with doing compat_id later.

Tom

Quoted 144 lines

- Russ

Quoted 140 lines · Russ Weight

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 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/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 ++-
  30 files changed, 383 insertions(+), 511 deletions(-)
reviewer
#6 lore raw
Quoted 7 lines · Tom Rix
Quoted 5 lines · Russ Weight

It seems like these patches are stalled on the compat_id question (in other emails). My
two-cents: I don't see an issue with having two versions of the register functions, and I don't consider the issue important enough to force a move of the compat_id field. I think the compat_id issue should be considered separately.

Quoted 7 lines
Quoted 1 line

Are there any other concers for these patches?

I am fine with it other than the two register functions.

To compat_id or not and which order, I believe is Moritz's call.

I'm ok with doing compat_id later.

Russ,

Though it seems like this patchset has stalled.  Either way it is stable enough to build on.

I am _really_ interested in the sec-mgr as it will make several cards usable.

Could you refresh it ?

Tom

Quoted 148 lines

Tom

Quoted 145 lines

- Russ

Quoted 141 lines · Russ Weight

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 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/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 ++-

  30 files changed, 383 insertions(+), 511 deletions(-)
#7 lore raw
Quoted 19 lines · Tom Rix
Quoted 7 lines · Tom Rix
Quoted 5 lines · Russ Weight

It seems like these patches are stalled on the compat_id question (in other emails). My
two-cents: I don't see an issue with having two versions of the register functions, and I don't consider the issue important enough to force a move of the compat_id field. I think the compat_id issue should be considered separately.

Quoted 7 lines
Quoted 1 line

Are there any other concers for these patches?

I am fine with it other than the two register functions.

To compat_id or not and which order, I believe is Moritz's call.

I'm ok with doing compat_id later.

Russ,

Quoted 7 lines

Though it seems like this patchset has stalled.  Either way it is stable enough to build on.

I am _really_ interested in the sec-mgr as it will make several cards usable.

Could you refresh it ?

Tom

Hi Tom,

I'll refresh the patch-set next week. There are several issues that Greg raised that won't be fully addressed in the first refresh, but I can address the registration and the functions and update dates in the documentation.

- Russ

Quoted 149 lines
Quoted 148 lines

Tom

Quoted 144 lines

- Russ

Quoted 140 lines · Russ Weight

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 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/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 ++-

  30 files changed, 383 insertions(+), 511 deletions(-)
reviewer
#8 lore raw
Quoted 20 lines · Russ Weight
Quoted 19 lines · Tom Rix
Quoted 6 lines · Tom Rix
Quoted 5 lines · Russ Weight

It seems like these patches are stalled on the compat_id question (in other emails). My
two-cents: I don't see an issue with having two versions of the register functions, and I don't consider the issue important enough to force a move of the compat_id field. I think the compat_id issue should be considered separately.

Quoted 6 lines
Quoted 1 line

Are there any other concers for these patches?

I am fine with it other than the two register functions.

To compat_id or not and which order, I believe is Moritz's call.

I'm ok with doing compat_id later.

Russ,

Though it seems like this patchset has stalled.  Either way it is stable enough to build on.

I am _really_ interested in the sec-mgr as it will make several cards usable.

Quoted 8 lines
Quoted 3 lines

Could you refresh it ?

Tom

Hi Tom,

I'll refresh the patch-set next week. There are several issues that Greg raised that won't be fully addressed in the first refresh, but I can address the registration and the functions and update dates in the documentation.

ok, thanks

Tom

Quoted 147 lines

- Russ

Quoted 145 lines
Quoted 145 lines

Tom

Quoted 143 lines

- Russ

Quoted 140 lines · Russ Weight

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 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/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 ++-
   30 files changed, 383 insertions(+), 511 deletions(-)