Skip to contentSkip to conversation

fpga: add devm managed create APIs

PATCH Superseded Alan Tull 4 participants 19 messages Sep 4, 2018 – Sep 6, 2018

Subsystems (5)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Alan Tull

author
#0 lore raw

v2 cover fpga: add devm managed create APIs

Fix one functional FPGA bug.

Implement managed devm_fpga_(mgr|bridge|region)_create() functions.

More documentation cleanup to make the documentation more helpful and to emphasize the use of FPGA regions for FPGA programming.

Fix a few minor documentation corrections.

v2: Add Suggested-by
Documentation changes from review comments

Alan Tull (8):
fpga: do not access region struct after fpga_region_unregister
fpga: mgr: add devm_fpga_mgr_create
fpga: bridge: add devm_fpga_bridge_create
fpga: add devm_fpga_region_create
dt-bindings: fpga: fix freeze controller compatible in region doc
fpga: bridge: fix obvious function documentation error
docs: fpga: document fpga manager flags
docs: fpga: document programming fpgas using regions

 .../devicetree/bindings/fpga/fpga-region.txt       |   4 +-
 Documentation/driver-api/fpga/fpga-bridge.rst      |  37 ++-----
 Documentation/driver-api/fpga/fpga-mgr.rst         | 121 +++------------------
 Documentation/driver-api/fpga/fpga-programming.rst | 107 ++++++++++++++++++
 Documentation/driver-api/fpga/fpga-region.rst      |  91 ++++++++--------
 Documentation/driver-api/fpga/index.rst            |   2 +
 Documentation/driver-api/fpga/intro.rst            |   2 +-
 drivers/fpga/altera-cvp.c                          |   8 +-
 drivers/fpga/altera-fpga2sdram.c                   |   8 +-
 drivers/fpga/altera-freeze-bridge.c                |  13 +--
 drivers/fpga/altera-hps2fpga.c                     |   7 +-
 drivers/fpga/altera-pr-ip-core.c                   |   9 +-
 drivers/fpga/altera-ps-spi.c                       |  11 +-
 drivers/fpga/dfl-fme-br.c                          |  11 +-
 drivers/fpga/dfl-fme-mgr.c                         |  11 +-
 drivers/fpga/dfl-fme-region.c                      |  10 +-
 drivers/fpga/dfl.c                                 |   6 +-
 drivers/fpga/fpga-bridge.c                         |  74 +++++++++++--
 drivers/fpga/fpga-mgr.c                            |  67 ++++++++++--
 drivers/fpga/fpga-region.c                         |  68 ++++++++++--
 drivers/fpga/ice40-spi.c                           |  10 +-
 drivers/fpga/machxo2-spi.c                         |  11 +-
 drivers/fpga/of-fpga-region.c                      |   9 +-
 drivers/fpga/socfpga-a10.c                         |   5 +-
 drivers/fpga/socfpga.c                             |  10 +-
 drivers/fpga/ts73xx-fpga.c                         |  11 +-
 drivers/fpga/xilinx-pr-decoupler.c                 |   4 +-
 drivers/fpga/xilinx-spi.c                          |  12 +-
 drivers/fpga/zynq-fpga.c                           |   5 +-
 include/linux/fpga/fpga-bridge.h                   |   4 +
 include/linux/fpga/fpga-mgr.h                      |  24 +++-
 include/linux/fpga/fpga-region.h                   |   4 +
 32 files changed, 444 insertions(+), 332 deletions(-)
 create mode 100644 Documentation/driver-api/fpga/fpga-programming.rst
Signature · 1 line
2.7.4
author
#1 lore raw

PATCH v2 1/8 fpga: do not access region struct after fpga_region_unregister

A couple drivers were accessing the region struct after it had been freed. Save off the pointer to the mgr before the region struct gets freed.

---
v2: no change in v2 of patchset

---
 drivers/fpga/dfl-fme-region.c | 4 +++-
 drivers/fpga/of-fpga-region.c | 3 ++-
 2 files changed, 5 insertions(+), 2 deletions(-)
drivers/fpga/dfl-fme-region.c +3 -1
index 0b7e19c..51a5ac2 100644
@@ -14,6 +14,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/fpga/fpga-mgr.h>
 #include <linux/fpga/fpga-region.h>
 
 #include "dfl-fme-pr.h"
@@ -66,9 +67,10 @@ static int fme_region_probe(struct platform_device *pdev)
 static int fme_region_remove(struct platform_device *pdev)
 {
 	struct fpga_region *region = dev_get_drvdata(&pdev->dev);
+	struct fpga_manager *mgr = region->mgr;
 
 	fpga_region_unregister(region);
-	fpga_mgr_put(region->mgr);
+	fpga_mgr_put(mgr);
 
 	return 0;
 }
drivers/fpga/of-fpga-region.c +2 -1
index 35fabb8..052a134 100644
@@ -437,9 +437,10 @@ static int of_fpga_region_probe(struct platform_device *pdev)
 static int of_fpga_region_remove(struct platform_device *pdev)
 {
 	struct fpga_region *region = platform_get_drvdata(pdev);
+	struct fpga_manager *mgr = region->mgr;
 
 	fpga_region_unregister(region);
-	fpga_mgr_put(region->mgr);
+	fpga_mgr_put(mgr);
 
 	return 0;
 }
Signature · 1 line
2.7.4
author
#4 lore raw

PATCH v2 2/8 fpga: mgr: add devm_fpga_mgr_create

In reply to Alan Tull

Add devm_fpga_mgr_create() which is the managed
version of fpga_mgr_create().

Change current FPGA manager drivers to use
devm_fpga_mgr_create()

---
v2: add suggested-by

---
 Documentation/driver-api/fpga/fpga-mgr.rst | 13 +++---
 drivers/fpga/altera-cvp.c                  |  8 ++--
 drivers/fpga/altera-pr-ip-core.c           |  9 +---
 drivers/fpga/altera-ps-spi.c               | 11 ++---
 drivers/fpga/dfl-fme-mgr.c                 | 11 ++---
 drivers/fpga/fpga-mgr.c                    | 67 ++++++++++++++++++++++++++----
 drivers/fpga/ice40-spi.c                   | 10 ++---
 drivers/fpga/machxo2-spi.c                 | 11 ++---
 drivers/fpga/socfpga-a10.c                 |  5 +--
 drivers/fpga/socfpga.c                     | 10 ++---
 drivers/fpga/ts73xx-fpga.c                 | 11 ++---
 drivers/fpga/xilinx-spi.c                  | 12 ++----
 drivers/fpga/zynq-fpga.c                   |  5 +--
 include/linux/fpga/fpga-mgr.h              |  4 ++
 14 files changed, 100 insertions(+), 87 deletions(-)
Documentation/driver-api/fpga/fpga-mgr.rst +6 -7
index 4b3825d..431556d 100644
@@ -49,18 +49,14 @@ probe function calls fpga_mgr_register(), such as::
 		 * them in priv
 		 */
 
-		mgr = fpga_mgr_create(dev, "Altera SOCFPGA FPGA Manager",
-				      &socfpga_fpga_ops, priv);
+		mgr = devm_fpga_mgr_create(dev, "Altera SOCFPGA FPGA Manager",
+					   &socfpga_fpga_ops, priv);
 		if (!mgr)
 			return -ENOMEM;
 
 		platform_set_drvdata(pdev, mgr);
 
-		ret = fpga_mgr_register(mgr);
-		if (ret)
-			fpga_mgr_free(mgr);
-
-		return ret;
+		return fpga_mgr_register(mgr);
 	}
 
 	static int socfpga_fpga_remove(struct platform_device *pdev)
@@ -170,6 +166,9 @@ API for implementing a new FPGA Manager driver
    :functions: fpga_manager_ops
 
 .. kernel-doc:: drivers/fpga/fpga-mgr.c
+   :functions: devm_fpga_mgr_create
+
+.. kernel-doc:: drivers/fpga/fpga-mgr.c
    :functions: fpga_mgr_create
 
 .. kernel-doc:: drivers/fpga/fpga-mgr.c
drivers/fpga/altera-cvp.c +3 -5
index 7fa7936..610a155 100644
@@ -453,8 +453,8 @@ 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 = fpga_mgr_create(&pdev->dev, conf->mgr_name,
-			      &altera_cvp_ops, conf);
+	mgr = devm_fpga_mgr_create(&pdev->dev, conf->mgr_name,
+				   &altera_cvp_ops, conf);
 	if (!mgr) {
 		ret = -ENOMEM;
 		goto err_unmap;
@@ -463,10 +463,8 @@ static int altera_cvp_probe(struct pci_dev *pdev,
 	pci_set_drvdata(pdev, mgr);
 
 	ret = fpga_mgr_register(mgr);
-	if (ret) {
-		fpga_mgr_free(mgr);
+	if (ret)
 		goto err_unmap;
-	}
 
 	ret = driver_create_file(&altera_cvp_driver.driver,
 				 &driver_attr_chkcfg);
drivers/fpga/altera-pr-ip-core.c +2 -7
index 65e0b6a..a7a3bf0 100644
@@ -177,7 +177,6 @@ int alt_pr_register(struct device *dev, void __iomem *reg_base)
 {
 	struct alt_pr_priv *priv;
 	struct fpga_manager *mgr;
-	int ret;
 	u32 val;
 
 	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
@@ -192,17 +191,13 @@ 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 = fpga_mgr_create(dev, dev_name(dev), &alt_pr_ops, priv);
+	mgr = devm_fpga_mgr_create(dev, dev_name(dev), &alt_pr_ops, priv);
 	if (!mgr)
 		return -ENOMEM;
 
 	dev_set_drvdata(dev, mgr);
 
-	ret = fpga_mgr_register(mgr);
-	if (ret)
-		fpga_mgr_free(mgr);
-
-	return ret;
+	return fpga_mgr_register(mgr);
 }
 EXPORT_SYMBOL_GPL(alt_pr_register);
 
drivers/fpga/altera-ps-spi.c +3 -8
index 24b25c6..33aafda 100644
@@ -239,7 +239,6 @@ static int altera_ps_probe(struct spi_device *spi)
 	struct altera_ps_conf *conf;
 	const struct of_device_id *of_id;
 	struct fpga_manager *mgr;
-	int ret;
 
 	conf = devm_kzalloc(&spi->dev, sizeof(*conf), GFP_KERNEL);
 	if (!conf)
@@ -275,18 +274,14 @@ 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 = fpga_mgr_create(&spi->dev, conf->mgr_name,
-			      &altera_ps_ops, conf);
+	mgr = devm_fpga_mgr_create(&spi->dev, conf->mgr_name,
+				   &altera_ps_ops, conf);
 	if (!mgr)
 		return -ENOMEM;
 
 	spi_set_drvdata(spi, mgr);
 
-	ret = fpga_mgr_register(mgr);
-	if (ret)
-		fpga_mgr_free(mgr);
-
-	return ret;
+	return fpga_mgr_register(mgr);
 }
 
 static int altera_ps_remove(struct spi_device *spi)
drivers/fpga/dfl-fme-mgr.c +3 -8
index b5ef405..617ce0b 100644
@@ -287,7 +287,6 @@ static int fme_mgr_probe(struct platform_device *pdev)
 	struct fme_mgr_priv *priv;
 	struct fpga_manager *mgr;
 	struct resource *res;
-	int ret;
 
 	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
 	if (!priv)
@@ -309,19 +308,15 @@ static int fme_mgr_probe(struct platform_device *pdev)
 
 	fme_mgr_get_compat_id(priv->ioaddr, compat_id);
 
-	mgr = fpga_mgr_create(dev, "DFL FME FPGA Manager",
-			      &fme_mgr_ops, priv);
+	mgr = devm_fpga_mgr_create(dev, "DFL FME FPGA Manager",
+				   &fme_mgr_ops, priv);
 	if (!mgr)
 		return -ENOMEM;
 
 	mgr->compat_id = compat_id;
 	platform_set_drvdata(pdev, mgr);
 
-	ret = fpga_mgr_register(mgr);
-	if (ret)
-		fpga_mgr_free(mgr);
-
-	return ret;
+	return fpga_mgr_register(mgr);
 }
 
 static int fme_mgr_remove(struct platform_device *pdev)
drivers/fpga/fpga-mgr.c +59 -8

99 lines not on this page · raw message

drivers/fpga/ice40-spi.c +3 -7
index 5981c7e..6154661 100644
@@ -175,18 +175,14 @@ static int ice40_fpga_probe(struct spi_device *spi)
 		return ret;
 	}
 
-	mgr = fpga_mgr_create(dev, "Lattice iCE40 FPGA Manager",
-			      &ice40_fpga_ops, priv);
+	mgr = devm_fpga_mgr_create(dev, "Lattice iCE40 FPGA Manager",
+				   &ice40_fpga_ops, priv);
 	if (!mgr)
 		return -ENOMEM;
 
 	spi_set_drvdata(spi, mgr);
 
-	ret = fpga_mgr_register(mgr);
-	if (ret)
-		fpga_mgr_free(mgr);
-
-	return ret;
+	return fpga_mgr_register(mgr);
 }
 
 static int ice40_fpga_remove(struct spi_device *spi)
drivers/fpga/machxo2-spi.c +3 -8
index a582e00..4d8a876 100644
@@ -356,25 +356,20 @@ static int machxo2_spi_probe(struct spi_device *spi)
 {
 	struct device *dev = &spi->dev;
 	struct fpga_manager *mgr;
-	int ret;
 
 	if (spi->max_speed_hz > MACHXO2_MAX_SPEED) {
 		dev_err(dev, "Speed is too high\n");
 		return -EINVAL;
 	}
 
-	mgr = fpga_mgr_create(dev, "Lattice MachXO2 SPI FPGA Manager",
-			      &machxo2_ops, spi);
+	mgr = devm_fpga_mgr_create(dev, "Lattice MachXO2 SPI FPGA Manager",
+				   &machxo2_ops, spi);
 	if (!mgr)
 		return -ENOMEM;
 
 	spi_set_drvdata(spi, mgr);
 
-	ret = fpga_mgr_register(mgr);
-	if (ret)
-		fpga_mgr_free(mgr);
-
-	return ret;
+	return fpga_mgr_register(mgr);
 }
 
 static int machxo2_spi_remove(struct spi_device *spi)
drivers/fpga/socfpga-a10.c +2 -3
index be30c48..573d88b 100644
@@ -508,8 +508,8 @@ static int socfpga_a10_fpga_probe(struct platform_device *pdev)
 		return -EBUSY;
 	}
 
-	mgr = fpga_mgr_create(dev, "SoCFPGA Arria10 FPGA Manager",
-			      &socfpga_a10_fpga_mgr_ops, priv);
+	mgr = devm_fpga_mgr_create(dev, "SoCFPGA Arria10 FPGA Manager",
+				   &socfpga_a10_fpga_mgr_ops, priv);
 	if (!mgr)
 		return -ENOMEM;
 
@@ -517,7 +517,6 @@ static int socfpga_a10_fpga_probe(struct platform_device *pdev)
 
 	ret = fpga_mgr_register(mgr);
 	if (ret) {
-		fpga_mgr_free(mgr);
 		clk_disable_unprepare(priv->clk);
 		return ret;
 	}
drivers/fpga/socfpga.c +3 -7
index 959d71f..4a8a2fc 100644
@@ -571,18 +571,14 @@ static int socfpga_fpga_probe(struct platform_device *pdev)
 	if (ret)
 		return ret;
 
-	mgr = fpga_mgr_create(dev, "Altera SOCFPGA FPGA Manager",
-			      &socfpga_fpga_ops, priv);
+	mgr = devm_fpga_mgr_create(dev, "Altera SOCFPGA FPGA Manager",
+				   &socfpga_fpga_ops, priv);
 	if (!mgr)
 		return -ENOMEM;
 
 	platform_set_drvdata(pdev, mgr);
 
-	ret = fpga_mgr_register(mgr);
-	if (ret)
-		fpga_mgr_free(mgr);
-
-	return ret;
+	return fpga_mgr_register(mgr);
 }
 
 static int socfpga_fpga_remove(struct platform_device *pdev)
drivers/fpga/ts73xx-fpga.c +3 -8
index 08efd18..dc22a58 100644
@@ -118,7 +118,6 @@ static int ts73xx_fpga_probe(struct platform_device *pdev)
 	struct ts73xx_fpga_priv *priv;
 	struct fpga_manager *mgr;
 	struct resource *res;
-	int ret;
 
 	priv = devm_kzalloc(kdev, sizeof(*priv), GFP_KERNEL);
 	if (!priv)
@@ -133,18 +132,14 @@ static int ts73xx_fpga_probe(struct platform_device *pdev)
 		return PTR_ERR(priv->io_base);
 	}
 
-	mgr = fpga_mgr_create(kdev, "TS-73xx FPGA Manager",
-			      &ts73xx_fpga_ops, priv);
+	mgr = devm_fpga_mgr_create(kdev, "TS-73xx FPGA Manager",
+				   &ts73xx_fpga_ops, priv);
 	if (!mgr)
 		return -ENOMEM;
 
 	platform_set_drvdata(pdev, mgr);
 
-	ret = fpga_mgr_register(mgr);
-	if (ret)
-		fpga_mgr_free(mgr);
-
-	return ret;
+	return fpga_mgr_register(mgr);
 }
 
 static int ts73xx_fpga_remove(struct platform_device *pdev)
drivers/fpga/xilinx-spi.c +4 -8
index 8d19459..469486b 100644
@@ -144,7 +144,6 @@ static int xilinx_spi_probe(struct spi_device *spi)
 {
 	struct xilinx_spi_conf *conf;
 	struct fpga_manager *mgr;
-	int ret;
 
 	conf = devm_kzalloc(&spi->dev, sizeof(*conf), GFP_KERNEL);
 	if (!conf)
@@ -167,18 +166,15 @@ static int xilinx_spi_probe(struct spi_device *spi)
 		return PTR_ERR(conf->done);
 	}
 
-	mgr = fpga_mgr_create(&spi->dev, "Xilinx Slave Serial FPGA Manager",
-			      &xilinx_spi_ops, conf);
+	mgr = devm_fpga_mgr_create(&spi->dev,
+				   "Xilinx Slave Serial FPGA Manager",
+				   &xilinx_spi_ops, conf);
 	if (!mgr)
 		return -ENOMEM;
 
 	spi_set_drvdata(spi, mgr);
 
-	ret = fpga_mgr_register(mgr);
-	if (ret)
-		fpga_mgr_free(mgr);
-
-	return ret;
+	return fpga_mgr_register(mgr);
 }
 
 static int xilinx_spi_remove(struct spi_device *spi)
drivers/fpga/zynq-fpga.c +2 -3
index 3110e00..bb82efe 100644
@@ -614,8 +614,8 @@ static int zynq_fpga_probe(struct platform_device *pdev)
 
 	clk_disable(priv->clk);
 
-	mgr = fpga_mgr_create(dev, "Xilinx Zynq FPGA Manager",
-			      &zynq_fpga_ops, priv);
+	mgr = devm_fpga_mgr_create(dev, "Xilinx Zynq FPGA Manager",
+				   &zynq_fpga_ops, priv);
 	if (!mgr)
 		return -ENOMEM;
 
@@ -624,7 +624,6 @@ static int zynq_fpga_probe(struct platform_device *pdev)
 	err = fpga_mgr_register(mgr);
 	if (err) {
 		dev_err(dev, "unable to register FPGA manager\n");
-		fpga_mgr_free(mgr);
 		clk_unprepare(priv->clk);
 		return err;
 	}
include/linux/fpga/fpga-mgr.h +4 -0
index 8942e61..1ca02ce 100644
@@ -190,4 +190,8 @@ void fpga_mgr_free(struct fpga_manager *mgr);
 int fpga_mgr_register(struct fpga_manager *mgr);
 void fpga_mgr_unregister(struct fpga_manager *mgr);
 
+struct fpga_manager *devm_fpga_mgr_create(struct device *dev, const char *name,
+					  const struct fpga_manager_ops *mops,
+					  void *priv);
+
 #endif /*_LINUX_FPGA_MGR_H */
Signature · 1 line
2.7.4
author
#5 lore raw

PATCH v2 3/8 fpga: bridge: add devm_fpga_bridge_create

In reply to Alan Tull

Add devm_fpga_bridge_create() which is the managed version of fpga_bridge_create().

Change current bridge drivers to use
devm_fpga_bridge_create().

---
v2: add suggested-by

---
 Documentation/driver-api/fpga/fpga-bridge.rst |  3 ++
 drivers/fpga/altera-fpga2sdram.c              |  8 ++-
 drivers/fpga/altera-freeze-bridge.c           | 13 ++---
 drivers/fpga/altera-hps2fpga.c                |  7 ++-
 drivers/fpga/dfl-fme-br.c                     | 11 ++--
 drivers/fpga/fpga-bridge.c                    | 72 +++++++++++++++++++++++----
 drivers/fpga/xilinx-pr-decoupler.c            |  4 +-
 include/linux/fpga/fpga-bridge.h              |  4 ++
 8 files changed, 84 insertions(+), 38 deletions(-)
Documentation/driver-api/fpga/fpga-bridge.rst +3 -0
index 2c2aaca..ebbcbde 100644
@@ -11,6 +11,9 @@ API to implement a new FPGA bridge
    :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_create
 
 .. kernel-doc:: drivers/fpga/fpga-bridge.c
drivers/fpga/altera-fpga2sdram.c +3 -5
index 23660cc..a78e49c 100644
@@ -121,18 +121,16 @@ 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 = fpga_bridge_create(dev, F2S_BRIDGE_NAME,
-				&altera_fpga2sdram_br_ops, priv);
+	br = devm_fpga_bridge_create(dev, F2S_BRIDGE_NAME,
+				     &altera_fpga2sdram_br_ops, priv);
 	if (!br)
 		return -ENOMEM;
 
 	platform_set_drvdata(pdev, br);
 
 	ret = fpga_bridge_register(br);
-	if (ret) {
-		fpga_bridge_free(br);
+	if (ret)
 		return ret;
-	}
 
 	dev_info(dev, "driver initialized with handoff %08x\n", priv->mask);
 
drivers/fpga/altera-freeze-bridge.c +3 -10
index ffd586c..dd58c4a 100644
@@ -213,7 +213,6 @@ static int altera_freeze_br_probe(struct platform_device *pdev)
 	struct fpga_bridge *br;
 	struct resource *res;
 	u32 status, revision;
-	int ret;
 
 	if (!np)
 		return -ENODEV;
@@ -245,20 +244,14 @@ static int altera_freeze_br_probe(struct platform_device *pdev)
 
 	priv->base_addr = base_addr;
 
-	br = fpga_bridge_create(dev, FREEZE_BRIDGE_NAME,
-				&altera_freeze_br_br_ops, priv);
+	br = devm_fpga_bridge_create(dev, FREEZE_BRIDGE_NAME,
+				     &altera_freeze_br_br_ops, priv);
 	if (!br)
 		return -ENOMEM;
 
 	platform_set_drvdata(pdev, br);
 
-	ret = fpga_bridge_register(br);
-	if (ret) {
-		fpga_bridge_free(br);
-		return ret;
-	}
-
-	return 0;
+	return fpga_bridge_register(br);
 }
 
 static int altera_freeze_br_remove(struct platform_device *pdev)
drivers/fpga/altera-hps2fpga.c +3 -4
index a974d3f..77b95f2 100644
@@ -180,7 +180,8 @@ static int alt_fpga_bridge_probe(struct platform_device *pdev)
 		}
 	}
 
-	br = fpga_bridge_create(dev, priv->name, &altera_hps2fpga_br_ops, priv);
+	br = devm_fpga_bridge_create(dev, priv->name,
+				     &altera_hps2fpga_br_ops, priv);
 	if (!br) {
 		ret = -ENOMEM;
 		goto err;
@@ -190,12 +191,10 @@ static int alt_fpga_bridge_probe(struct platform_device *pdev)
 
 	ret = fpga_bridge_register(br);
 	if (ret)
-		goto err_free;
+		goto err;
 
 	return 0;
 
-err_free:
-	fpga_bridge_free(br);
 err:
 	clk_disable_unprepare(priv->clk);
 
drivers/fpga/dfl-fme-br.c +3 -8
index 7cc041d..3ff9f3a 100644
@@ -61,7 +61,6 @@ static int fme_br_probe(struct platform_device *pdev)
 	struct device *dev = &pdev->dev;
 	struct fme_br_priv *priv;
 	struct fpga_bridge *br;
-	int ret;
 
 	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
 	if (!priv)
@@ -69,18 +68,14 @@ static int fme_br_probe(struct platform_device *pdev)
 
 	priv->pdata = dev_get_platdata(dev);
 
-	br = fpga_bridge_create(dev, "DFL FPGA FME Bridge",
-				&fme_bridge_ops, priv);
+	br = devm_fpga_bridge_create(dev, "DFL FPGA FME Bridge",
+				     &fme_bridge_ops, priv);
 	if (!br)
 		return -ENOMEM;
 
 	platform_set_drvdata(pdev, br);
 
-	ret = fpga_bridge_register(br);
-	if (ret)
-		fpga_bridge_free(br);
-
-	return ret;
+	return fpga_bridge_register(br);
 }
 
 static int fme_br_remove(struct platform_device *pdev)
drivers/fpga/fpga-bridge.c +63 -9

103 lines not on this page · raw message

drivers/fpga/xilinx-pr-decoupler.c +2 -2
index 07ba153..6410361 100644
@@ -121,8 +121,8 @@ static int xlnx_pr_decoupler_probe(struct platform_device *pdev)
 
 	clk_disable(priv->clk);
 
-	br = fpga_bridge_create(&pdev->dev, "Xilinx PR Decoupler",
-				&xlnx_pr_decoupler_br_ops, priv);
+	br = devm_fpga_bridge_create(&pdev->dev, "Xilinx PR Decoupler",
+				     &xlnx_pr_decoupler_br_ops, priv);
 	if (!br) {
 		err = -ENOMEM;
 		goto err_clk;
include/linux/fpga/fpga-bridge.h +4 -0
index ce550fc..817600a 100644
@@ -69,4 +69,8 @@ void fpga_bridge_free(struct fpga_bridge *br);
 int fpga_bridge_register(struct fpga_bridge *br);
 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.7.4
author
#10 lore raw

PATCH v2 4/8 fpga: add devm_fpga_region_create

In reply to Alan Tull

Add devm_fpga_region_create() which is the
managed version of fpga_region_create().

Change current region drivers to use
devm_fpga_region_create().

---
v2: add suggested-by

---
 Documentation/driver-api/fpga/fpga-region.rst |  3 ++
 drivers/fpga/dfl-fme-region.c                 |  6 +--
 drivers/fpga/dfl.c                            |  6 +--
 drivers/fpga/fpga-region.c                    | 68 +++++++++++++++++++++++----
 drivers/fpga/of-fpga-region.c                 |  6 +--
 include/linux/fpga/fpga-region.h              |  4 ++
 6 files changed, 73 insertions(+), 20 deletions(-)
Documentation/driver-api/fpga/fpga-region.rst +3 -0
index f30333c..dc9f75c 100644
@@ -90,6 +90,9 @@ API to add a new FPGA region
    :functions: fpga_region
 
 .. kernel-doc:: drivers/fpga/fpga-region.c
+   :functions: devm_fpga_region_create
+
+.. kernel-doc:: drivers/fpga/fpga-region.c
    :functions: fpga_region_create
 
 .. kernel-doc:: drivers/fpga/fpga-region.c
drivers/fpga/dfl-fme-region.c +2 -4
index 51a5ac2..ec134ec 100644
@@ -39,7 +39,7 @@ static int fme_region_probe(struct platform_device *pdev)
 	if (IS_ERR(mgr))
 		return -EPROBE_DEFER;
 
-	region = fpga_region_create(dev, mgr, fme_region_get_bridges);
+	region = devm_fpga_region_create(dev, mgr, fme_region_get_bridges);
 	if (!region) {
 		ret = -ENOMEM;
 		goto eprobe_mgr_put;
@@ -51,14 +51,12 @@ static int fme_region_probe(struct platform_device *pdev)
 
 	ret = fpga_region_register(region);
 	if (ret)
-		goto region_free;
+		goto eprobe_mgr_put;
 
 	dev_dbg(dev, "DFL FME FPGA Region probed\n");
 
 	return 0;
 
-region_free:
-	fpga_region_free(region);
 eprobe_mgr_put:
 	fpga_mgr_put(mgr);
 	return ret;
drivers/fpga/dfl.c +2 -4
index a9b521b..2c09e50 100644
@@ -899,7 +899,7 @@ dfl_fpga_feature_devs_enumerate(struct dfl_fpga_enum_info *info)
 	if (!cdev)
 		return ERR_PTR(-ENOMEM);
 
-	cdev->region = fpga_region_create(info->dev, NULL, NULL);
+	cdev->region = devm_fpga_region_create(info->dev, NULL, NULL);
 	if (!cdev->region) {
 		ret = -ENOMEM;
 		goto free_cdev_exit;
@@ -911,7 +911,7 @@ dfl_fpga_feature_devs_enumerate(struct dfl_fpga_enum_info *info)
 
 	ret = fpga_region_register(cdev->region);
 	if (ret)
-		goto free_region_exit;
+		goto free_cdev_exit;
 
 	/* create and init build info for enumeration */
 	binfo = devm_kzalloc(info->dev, sizeof(*binfo), GFP_KERNEL);
@@ -942,8 +942,6 @@ dfl_fpga_feature_devs_enumerate(struct dfl_fpga_enum_info *info)
 
 unregister_region_exit:
 	fpga_region_unregister(cdev->region);
-free_region_exit:
-	fpga_region_free(cdev->region);
 free_cdev_exit:
 	devm_kfree(info->dev, cdev);
 	return ERR_PTR(ret);
drivers/fpga/fpga-region.c +60 -8

104 lines not on this page · raw message

drivers/fpga/of-fpga-region.c +2 -4
index 052a134..122286f 100644
@@ -410,7 +410,7 @@ static int of_fpga_region_probe(struct platform_device *pdev)
 	if (IS_ERR(mgr))
 		return -EPROBE_DEFER;
 
-	region = fpga_region_create(dev, mgr, of_fpga_region_get_bridges);
+	region = devm_fpga_region_create(dev, mgr, of_fpga_region_get_bridges);
 	if (!region) {
 		ret = -ENOMEM;
 		goto eprobe_mgr_put;
@@ -418,7 +418,7 @@ static int of_fpga_region_probe(struct platform_device *pdev)
 
 	ret = fpga_region_register(region);
 	if (ret)
-		goto eprobe_free;
+		goto eprobe_mgr_put;
 
 	of_platform_populate(np, fpga_region_of_match, NULL, &region->dev);
 	dev_set_drvdata(dev, region);
@@ -427,8 +427,6 @@ static int of_fpga_region_probe(struct platform_device *pdev)
 
 	return 0;
 
-eprobe_free:
-	fpga_region_free(region);
 eprobe_mgr_put:
 	fpga_mgr_put(mgr);
 	return ret;
include/linux/fpga/fpga-region.h +4 -0
index 0521b7f..27cb706 100644
@@ -44,4 +44,8 @@ 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
+*devm_fpga_region_create(struct device *dev, struct fpga_manager *mgr,
+			int (*get_bridges)(struct fpga_region *));
+
 #endif /* _FPGA_REGION_H */
Signature · 1 line
2.7.4
author
#11 lore raw

PATCH v2 5/8 dt-bindings: fpga: fix freeze controller compatible in region doc

In reply to Alan Tull

Documentation/devicetree/bindings/fpga/fpga-region.txt has an error regarding the freeze controller bridge, secifically:

compatible = "altr,freeze-bridge";

The compatibility string should be "altr,freeze-bridge-controller" as set forth in altera-freeze-bridge.txt.

---
v2: no change in v2 of patchset

---
 Documentation/devicetree/bindings/fpga/fpga-region.txt | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/fpga/fpga-region.txt +2 -2
index 6db8aed..90c4469 100644
@@ -415,7 +415,7 @@ DT Overlay contains:
 			firmware-name = "base.rbf";
 
 			fpga-bridge@4400 {
-				compatible = "altr,freeze-bridge";
+				compatible = "altr,freeze-bridge-controller";
 				reg = <0x4400 0x10>;
 
 				fpga_region1: fpga-region1 {
@@ -427,7 +427,7 @@ DT Overlay contains:
 			};
 
 			fpga-bridge@4420 {
-				compatible = "altr,freeze-bridge";
+				compatible = "altr,freeze-bridge-controller";
 				reg = <0x4420 0x10>;
 
 				fpga_region2: fpga-region2 {
Signature · 1 line
2.7.4
author
#13 lore raw

PATCH v2 6/8 fpga: bridge: fix obvious function documentation error

In reply to Alan Tull

fpga_bridge_dev_match() returns a FPGA bridge struct, not a FPGA manager struct so s/manager/bridge/.

---
v2: no change in v2 of patchset

---
 drivers/fpga/fpga-bridge.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/fpga/fpga-bridge.c +1 -1
index c39d35f..7b0071a 100644
@@ -125,7 +125,7 @@ static int fpga_bridge_dev_match(struct device *dev, const void *data)
  *
  * Given a device, get an exclusive reference to a fpga bridge.
  *
- * Return: fpga manager struct or IS_ERR() condition containing error code.
+ * Return: fpga bridge struct or IS_ERR() condition containing error code.
  */
 struct fpga_bridge *fpga_bridge_get(struct device *dev,
 				    struct fpga_image_info *info)
Signature · 1 line
2.7.4
author
#16 lore raw

PATCH v2 7/8 docs: fpga: document fpga manager flags

In reply to Alan Tull

Add flags #defines to kerneldoc documentation in a useful place.

---
v2: add description for FPGA_MGR_ENCRYPTED_BITSTREAM

---
 Documentation/driver-api/fpga/fpga-mgr.rst |  5 +++++
 include/linux/fpga/fpga-mgr.h              | 20 ++++++++++++++------
 2 files changed, 19 insertions(+), 6 deletions(-)
Documentation/driver-api/fpga/fpga-mgr.rst +5 -0
index 431556d..db8885e 100644
@@ -183,6 +183,11 @@ API for implementing a new FPGA Manager driver
 API for programming an FPGA
 ---------------------------
 
+FPGA Manager flags
+
+.. kernel-doc:: include/linux/fpga/fpga-mgr.h
+   :doc: FPGA Manager flags
+
 .. kernel-doc:: include/linux/fpga/fpga-mgr.h
    :functions: fpga_image_info
 
include/linux/fpga/fpga-mgr.h +14 -6
index 1ca02ce..e8ca62b 100644
@@ -53,12 +53,20 @@ enum fpga_mgr_states {
 	FPGA_MGR_STATE_OPERATING,
 };
 
-/*
- * FPGA Manager flags
- * FPGA_MGR_PARTIAL_RECONFIG: do partial reconfiguration if supported
- * FPGA_MGR_EXTERNAL_CONFIG: FPGA has been configured prior to Linux booting
- * FPGA_MGR_BITSTREAM_LSB_FIRST: SPI bitstream bit order is LSB first
- * FPGA_MGR_COMPRESSED_BITSTREAM: FPGA bitstream is compressed
+/**
+ * DOC: FPGA Manager flags
+ *
+ * Flags used in the &fpga_image_info->flags field
+ *
+ * %FPGA_MGR_PARTIAL_RECONFIG: do partial reconfiguration if supported
+ *
+ * %FPGA_MGR_EXTERNAL_CONFIG: FPGA has been configured prior to Linux booting
+ *
+ * %FPGA_MGR_ENCRYPTED_BITSTREAM: indicates bitstream is encrypted
+ *
+ * %FPGA_MGR_BITSTREAM_LSB_FIRST: SPI bitstream bit order is LSB first
+ *
+ * %FPGA_MGR_COMPRESSED_BITSTREAM: FPGA bitstream is compressed
  */
 #define FPGA_MGR_PARTIAL_RECONFIG	BIT(0)
 #define FPGA_MGR_EXTERNAL_CONFIG	BIT(1)
Signature · 1 line
2.7.4
author
#18 lore raw

PATCH v2 8/8 docs: fpga: document programming fpgas using regions

In reply to Alan Tull

Clarify the intention that interfaces and upper layers use regions rather than managers directly.

Rearrange API documentation to better group the API functions used to create FPGA mgr/bridge/regions and the API used for programming FPGAs.

---
v2: Add suggested-by
s/a FPGA/an FPGA/
document freeing the fpga_mgr_info on success path minor formatting fixes and suggested edits

---
 Documentation/driver-api/fpga/fpga-bridge.rst      |  38 ++-----
 Documentation/driver-api/fpga/fpga-mgr.rst         | 117 ++-------------------
 Documentation/driver-api/fpga/fpga-programming.rst | 107 +++++++++++++++++++
 Documentation/driver-api/fpga/fpga-region.rst      |  92 ++++++++--------
 Documentation/driver-api/fpga/index.rst            |   2 +
 Documentation/driver-api/fpga/intro.rst            |   2 +-
 6 files changed, 171 insertions(+), 187 deletions(-)
 create mode 100644 Documentation/driver-api/fpga/fpga-programming.rst
Documentation/driver-api/fpga/fpga-bridge.rst +6 -32
index ebbcbde..71c5a40 100644
@@ -4,6 +4,12 @@ FPGA Bridge
 API to implement a new FPGA bridge
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
+* struct :c:type:`fpga_bridge` — The FPGA Bridge structure
+* struct :c:type:`fpga_bridge_ops` — Low level Bridge driver ops
+* :c:func:`devm_fpga_bridge_create()` — Allocate and init a bridge struct
+* :c:func:`fpga_bridge_register()` — Register a bridge
+* :c:func:`fpga_bridge_unregister()` — Unregister a bridge
+
 .. kernel-doc:: include/linux/fpga/fpga-bridge.h
    :functions: fpga_bridge
 
@@ -14,39 +20,7 @@ API to implement a new FPGA bridge
    :functions: devm_fpga_bridge_create
 
 .. kernel-doc:: drivers/fpga/fpga-bridge.c
-   :functions: fpga_bridge_create
-
-.. kernel-doc:: drivers/fpga/fpga-bridge.c
-   :functions: fpga_bridge_free
-
-.. kernel-doc:: drivers/fpga/fpga-bridge.c
    :functions: fpga_bridge_register
 
 .. kernel-doc:: drivers/fpga/fpga-bridge.c
    :functions: fpga_bridge_unregister
-
-API to control an FPGA bridge
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-You probably won't need these directly.  FPGA regions should handle this.
-
-.. kernel-doc:: drivers/fpga/fpga-bridge.c
-   :functions: of_fpga_bridge_get
-
-.. kernel-doc:: drivers/fpga/fpga-bridge.c
-   :functions: fpga_bridge_get
-
-.. kernel-doc:: drivers/fpga/fpga-bridge.c
-   :functions: fpga_bridge_put
-
-.. kernel-doc:: drivers/fpga/fpga-bridge.c
-   :functions: fpga_bridge_get_to_list
-
-.. kernel-doc:: drivers/fpga/fpga-bridge.c
-   :functions: of_fpga_bridge_get_to_list
-
-.. kernel-doc:: drivers/fpga/fpga-bridge.c
-   :functions: fpga_bridge_enable
-
-.. kernel-doc:: drivers/fpga/fpga-bridge.c
-   :functions: fpga_bridge_disable
Documentation/driver-api/fpga/fpga-mgr.rst +10 -107

133 lines not on this page · raw message

Documentation/driver-api/fpga/fpga-programming.rst new file +107 -0

107 lines not on this page · raw message

Documentation/driver-api/fpga/fpga-region.rst +45 -47

114 lines not on this page · raw message

Documentation/driver-api/fpga/index.rst +2 -0
index c51e5eb..31a4773 100644
@@ -11,3 +11,5 @@ FPGA Subsystem
    fpga-mgr
    fpga-bridge
    fpga-region
+   fpga-programming
+
Documentation/driver-api/fpga/intro.rst +1 -1
index 50d1cab..f54c7da 100644
@@ -44,7 +44,7 @@ FPGA Region
 -----------
 
 If you are adding a new interface to the FPGA framework, add it on top
-of an FPGA region to allow the most reuse of your interface.
+of an FPGA region.
 
 The FPGA Region framework (fpga-region.c) associates managers and
 bridges as reconfigurable regions.  A region may refer to the whole
Signature · 1 line
2.7.4
Acked-by on v2 1/8
#2 lore raw

Re: [PATCH v2 1/8] fpga: do not access region struct after fpga_region_unregister

In reply to Alan Tull

Hi Alan,

Quoted 5 lines · Alan Tull

A couple drivers were accessing the region struct after it had been freed. Save off the pointer to the mgr before the region struct gets freed.

Quoted 48 lines

---
v2: no change in v2 of patchset

---
 drivers/fpga/dfl-fme-region.c | 4 +++-
 drivers/fpga/of-fpga-region.c | 3 ++-
 2 files changed, 5 insertions(+), 2 deletions(-)
drivers/fpga/dfl-fme-region.c +3 -1
index 0b7e19c..51a5ac2 100644
@@ -14,6 +14,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/fpga/fpga-mgr.h>
 #include <linux/fpga/fpga-region.h>
 
 #include "dfl-fme-pr.h"
@@ -66,9 +67,10 @@ static int fme_region_probe(struct platform_device *pdev)
 static int fme_region_remove(struct platform_device *pdev)
 {
        struct fpga_region *region = dev_get_drvdata(&pdev->dev);
+       struct fpga_manager *mgr = region->mgr;
 
        fpga_region_unregister(region);
-       fpga_mgr_put(region->mgr);
+       fpga_mgr_put(mgr);
 
        return 0;
 }
drivers/fpga/of-fpga-region.c +2 -2
index 35fabb8..052a134 100644
@@ -437,9 +437,10 @@ static int of_fpga_region_probe(struct platform_device *pdev)
 static int of_fpga_region_remove(struct platform_device *pdev)
 {
        struct fpga_region *region = platform_get_drvdata(pdev);
+       struct fpga_manager *mgr = region->mgr;
 
        fpga_region_unregister(region);
-       fpga_mgr_put(region->mgr);
+       fpga_mgr_put(mgr);
 
        return 0;
 }
--
Quoted 2 lines

2.7.4

Thanks,
Moritz

author
#3 lore raw

Re: [PATCH v2 1/8] fpga: do not access region struct after fpga_region_unregister

On Tue, Sep 4, 2018 at 6:41 PM Moritz Fischer <[email protected]> wrote:

Hi Moritz,

Quoted 10 lines

Hi Alan,

Quoted 5 lines · Alan Tull

A couple drivers were accessing the region struct after it had been freed. Save off the pointer to the mgr before the region struct gets freed.

Thanks!

Alan

Acked-by on v2 3/8
#6 lore raw

Re: [PATCH v2 3/8] fpga: bridge: add devm_fpga_bridge_create

In reply to Alan Tull

Hi Alan,

looks good to me: Small nit inline. Not a showstopper.

Quoted 8 lines · Alan Tull

Add devm_fpga_bridge_create() which is the managed version of fpga_bridge_create().

Change current bridge drivers to use
devm_fpga_bridge_create().

Quoted 241 lines

---
v2: add suggested-by

---
 Documentation/driver-api/fpga/fpga-bridge.rst |  3 ++
 drivers/fpga/altera-fpga2sdram.c              |  8 ++-
 drivers/fpga/altera-freeze-bridge.c           | 13 ++---
 drivers/fpga/altera-hps2fpga.c                |  7 ++-
 drivers/fpga/dfl-fme-br.c                     | 11 ++--
 drivers/fpga/fpga-bridge.c                    | 72 +++++++++++++++++++++++----
 drivers/fpga/xilinx-pr-decoupler.c            |  4 +-
 include/linux/fpga/fpga-bridge.h              |  4 ++
 8 files changed, 84 insertions(+), 38 deletions(-)
Documentation/driver-api/fpga/fpga-bridge.rst +3 -0
index 2c2aaca..ebbcbde 100644
@@ -11,6 +11,9 @@ API to implement a new FPGA bridge
    :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_create
 
 .. kernel-doc:: drivers/fpga/fpga-bridge.c
drivers/fpga/altera-fpga2sdram.c +3 -5
index 23660cc..a78e49c 100644
@@ -121,18 +121,16 @@ 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 = fpga_bridge_create(dev, F2S_BRIDGE_NAME,
-                               &altera_fpga2sdram_br_ops, priv);
+       br = devm_fpga_bridge_create(dev, F2S_BRIDGE_NAME,
+                                    &altera_fpga2sdram_br_ops, priv);
        if (!br)
                return -ENOMEM;
 
        platform_set_drvdata(pdev, br);
 
        ret = fpga_bridge_register(br);
-       if (ret) {
-               fpga_bridge_free(br);
+       if (ret)
                return ret;
-       }
 
        dev_info(dev, "driver initialized with handoff %08x\n", priv->mask);
 
drivers/fpga/altera-freeze-bridge.c +3 -10
index ffd586c..dd58c4a 100644
@@ -213,7 +213,6 @@ static int altera_freeze_br_probe(struct platform_device *pdev)
        struct fpga_bridge *br;
        struct resource *res;
        u32 status, revision;
-       int ret;
 
        if (!np)
                return -ENODEV;
@@ -245,20 +244,14 @@ static int altera_freeze_br_probe(struct platform_device *pdev)
 
        priv->base_addr = base_addr;
 
-       br = fpga_bridge_create(dev, FREEZE_BRIDGE_NAME,
-                               &altera_freeze_br_br_ops, priv);
+       br = devm_fpga_bridge_create(dev, FREEZE_BRIDGE_NAME,
+                                    &altera_freeze_br_br_ops, priv);
        if (!br)
                return -ENOMEM;
 
        platform_set_drvdata(pdev, br);
 
-       ret = fpga_bridge_register(br);
-       if (ret) {
-               fpga_bridge_free(br);
-               return ret;
-       }
-
-       return 0;
+       return fpga_bridge_register(br);
 }
 
 static int altera_freeze_br_remove(struct platform_device *pdev)
drivers/fpga/altera-hps2fpga.c +3 -4
index a974d3f..77b95f2 100644
@@ -180,7 +180,8 @@ static int alt_fpga_bridge_probe(struct platform_device *pdev)
                }
        }
 
-       br = fpga_bridge_create(dev, priv->name, &altera_hps2fpga_br_ops, priv);
+       br = devm_fpga_bridge_create(dev, priv->name,
+                                    &altera_hps2fpga_br_ops, priv);
        if (!br) {
                ret = -ENOMEM;
                goto err;
@@ -190,12 +191,10 @@ static int alt_fpga_bridge_probe(struct platform_device *pdev)
 
        ret = fpga_bridge_register(br);
        if (ret)
-               goto err_free;
+               goto err;
 
        return 0;
 
-err_free:
-       fpga_bridge_free(br);
 err:
        clk_disable_unprepare(priv->clk);
 
drivers/fpga/dfl-fme-br.c +3 -8
index 7cc041d..3ff9f3a 100644
@@ -61,7 +61,6 @@ static int fme_br_probe(struct platform_device *pdev)
        struct device *dev = &pdev->dev;
        struct fme_br_priv *priv;
        struct fpga_bridge *br;
-       int ret;
 
        priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
        if (!priv)
@@ -69,18 +68,14 @@ static int fme_br_probe(struct platform_device *pdev)
 
        priv->pdata = dev_get_platdata(dev);
 
-       br = fpga_bridge_create(dev, "DFL FPGA FME Bridge",
-                               &fme_bridge_ops, priv);
+       br = devm_fpga_bridge_create(dev, "DFL FPGA FME Bridge",
+                                    &fme_bridge_ops, priv);
        if (!br)
                return -ENOMEM;
 
        platform_set_drvdata(pdev, br);
 
-       ret = fpga_bridge_register(br);
-       if (ret)
-               fpga_bridge_free(br);
-
-       return ret;
+       return fpga_bridge_register(br);
 }
 
 static int fme_br_remove(struct platform_device *pdev)
drivers/fpga/fpga-bridge.c +54 -5
index 24b8f98..c39d35f 100644
@@ -324,6 +324,9 @@ ATTRIBUTE_GROUPS(fpga_bridge);
  * @br_ops:    pointer to structure of fpga bridge ops
  * @priv:      FPGA bridge private data
  *
+ * The caller of this function is responsible for freeing the bridge with
+ * fpga_bridge_free().  Using devm_fpga_bridge_create() instead is recommended.
+ *
  * Return: struct fpga_bridge or NULL
  */
 struct fpga_bridge *fpga_bridge_create(struct device *dev, const char *name,
@@ -378,8 +381,8 @@ struct fpga_bridge *fpga_bridge_create(struct device *dev, const char *name,
 EXPORT_SYMBOL_GPL(fpga_bridge_create);
 
 /**
- * fpga_bridge_free - free a fpga bridge and its id
- * @bridge:    FPGA bridge struct created by fpga_bridge_create
+ * fpga_bridge_free - free a fpga bridge created by fpga_bridge_create()
+ * @bridge:    FPGA bridge struct
  */
 void fpga_bridge_free(struct fpga_bridge *bridge)
 {
@@ -388,9 +391,56 @@ void fpga_bridge_free(struct fpga_bridge *bridge)
 }
 EXPORT_SYMBOL_GPL(fpga_bridge_free);
 
+static void devm_fpga_bridge_release(struct device *dev, void *res)
+{
+       struct fpga_bridge *bridge = *(struct fpga_bridge **)res;
+
+       fpga_bridge_free(bridge);
+}
+
 /**
- * fpga_bridge_register - register a fpga bridge
- * @bridge:    FPGA bridge struct created by fpga_bridge_create
+ * devm_fpga_bridge_create - create and init a managed struct fpga_bridge
+ * @dev:       FPGA bridge device from pdev
+ * @name:      FPGA bridge name
+ * @br_ops:    pointer to structure of fpga bridge ops
+ * @priv:      FPGA bridge private data
+ *
+ * This function is intended for use in a FPGA bridge driver's probe function.
+ * After the bridge driver creates the struct with devm_fpga_bridge_create(), it
+ * should register the bridge with fpga_bridge_register().  The bridge driver's
+ * remove function should call fpga_bridge_unregister().  The bridge struct
+ * allocated with this function will be freed automatically on driver detach.
+ * This includes the case of a probe function returning error before calling
+ * fpga_bridge_register(), the struct will still get cleaned up.
+ *
+ *  Return: struct fpga_bridge or NULL
+ */
+struct fpga_bridge
+*devm_fpga_bridge_create(struct device *dev, const char *name,
+                        const struct fpga_bridge_ops *br_ops, void *priv)
+{
+       struct fpga_bridge **ptr, *bridge;
+
+       ptr = devres_alloc(devm_fpga_bridge_release, sizeof(*ptr), GFP_KERNEL);
+       if (!ptr)
+               return NULL;
+
+       bridge = fpga_bridge_create(dev, name, br_ops, priv);
+       if (!bridge) {
+               devres_free(ptr);
+       } else {
+               *ptr = bridge;
+               devres_add(dev, ptr);
+       }
+
+       return bridge;
+}
+EXPORT_SYMBOL_GPL(devm_fpga_bridge_create);
+
+/**
+ * fpga_bridge_register - register a FPGA bridge
+ *
+ * @bridge: FPGA bridge struct
  *
  * Return: 0 for success, error code otherwise.
  */
@@ -412,8 +462,15 @@ int fpga_bridge_register(struct fpga_bridge *bridge)
 EXPORT_SYMBOL_GPL(fpga_bridge_register);
 
 /**
- * fpga_bridge_unregister - unregister and free a fpga bridge

drivers/fpga/fpga-bridge.c int fpga_bridge_register(struct fpga_bridge *bridge) · line 473

Quoted 10 lines
drivers/fpga/fpga-bridge.c +9 -1
- * @bridge:    FPGA bridge struct created by fpga_bridge_create
+ * fpga_bridge_unregister - unregister a FPGA bridge
+ *
+ * @bridge: FPGA bridge struct
+ *
+ * This function is intended for use in a FPGA bridge driver's remove function.
+ * If the bridge was created with devm_fpga_bridge_create(), the bridge struct
+ * will be automatically freed.  If the bridge was created with
+ * fpga_bridge_create(), the caller is responsible for freeing the bridge with
+ * fpga_bridge_free().

I find the formulation somewhat confusing, since it could be interpreted as if you
used the devm_() functions you don't have to call unregister().

Quoted 42 lines
drivers/fpga/fpga-bridge.c +0 -3
  */
 void fpga_bridge_unregister(struct fpga_bridge *bridge)
 {
@@ -430,9 +487,6 @@ EXPORT_SYMBOL_GPL(fpga_bridge_unregister);
 
 static void fpga_bridge_dev_release(struct device *dev)
 {
-       struct fpga_bridge *bridge = to_fpga_bridge(dev);
-
-       fpga_bridge_free(bridge);
 }
 
 static int __init fpga_bridge_dev_init(void)
drivers/fpga/xilinx-pr-decoupler.c +2 -2
index 07ba153..6410361 100644
@@ -121,8 +121,8 @@ static int xlnx_pr_decoupler_probe(struct platform_device *pdev)
 
        clk_disable(priv->clk);
 
-       br = fpga_bridge_create(&pdev->dev, "Xilinx PR Decoupler",
-                               &xlnx_pr_decoupler_br_ops, priv);
+       br = devm_fpga_bridge_create(&pdev->dev, "Xilinx PR Decoupler",
+                                    &xlnx_pr_decoupler_br_ops, priv);
        if (!br) {
                err = -ENOMEM;
                goto err_clk;
include/linux/fpga/fpga-bridge.h +4 -1
index ce550fc..817600a 100644
@@ -69,4 +69,8 @@ void fpga_bridge_free(struct fpga_bridge *br);
 int fpga_bridge_register(struct fpga_bridge *br);
 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 */
--
Quoted 2 lines

2.7.4

Thanks,

Moritz

author
#7 lore raw

Re: [PATCH v2 3/8] fpga: bridge: add devm_fpga_bridge_create

Quoted 253 lines · Moritz Fischer

Hi Alan,

looks good to me: Small nit inline. Not a showstopper.

Quoted 8 lines · Alan Tull

Add devm_fpga_bridge_create() which is the managed version of fpga_bridge_create().

Change current bridge drivers to use
devm_fpga_bridge_create().

Quoted 239 lines

---
v2: add suggested-by

---
 Documentation/driver-api/fpga/fpga-bridge.rst |  3 ++
 drivers/fpga/altera-fpga2sdram.c              |  8 ++-
 drivers/fpga/altera-freeze-bridge.c           | 13 ++---
 drivers/fpga/altera-hps2fpga.c                |  7 ++-
 drivers/fpga/dfl-fme-br.c                     | 11 ++--
 drivers/fpga/fpga-bridge.c                    | 72 +++++++++++++++++++++++----
 drivers/fpga/xilinx-pr-decoupler.c            |  4 +-
 include/linux/fpga/fpga-bridge.h              |  4 ++
 8 files changed, 84 insertions(+), 38 deletions(-)
Documentation/driver-api/fpga/fpga-bridge.rst +3 -0
index 2c2aaca..ebbcbde 100644
@@ -11,6 +11,9 @@ API to implement a new FPGA bridge
    :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_create
 
 .. kernel-doc:: drivers/fpga/fpga-bridge.c
drivers/fpga/altera-fpga2sdram.c +3 -5
index 23660cc..a78e49c 100644
@@ -121,18 +121,16 @@ 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 = fpga_bridge_create(dev, F2S_BRIDGE_NAME,
-                               &altera_fpga2sdram_br_ops, priv);
+       br = devm_fpga_bridge_create(dev, F2S_BRIDGE_NAME,
+                                    &altera_fpga2sdram_br_ops, priv);
        if (!br)
                return -ENOMEM;
 
        platform_set_drvdata(pdev, br);
 
        ret = fpga_bridge_register(br);
-       if (ret) {
-               fpga_bridge_free(br);
+       if (ret)
                return ret;
-       }
 
        dev_info(dev, "driver initialized with handoff %08x\n", priv->mask);
 
drivers/fpga/altera-freeze-bridge.c +3 -10
index ffd586c..dd58c4a 100644
@@ -213,7 +213,6 @@ static int altera_freeze_br_probe(struct platform_device *pdev)
        struct fpga_bridge *br;
        struct resource *res;
        u32 status, revision;
-       int ret;
 
        if (!np)
                return -ENODEV;
@@ -245,20 +244,14 @@ static int altera_freeze_br_probe(struct platform_device *pdev)
 
        priv->base_addr = base_addr;
 
-       br = fpga_bridge_create(dev, FREEZE_BRIDGE_NAME,
-                               &altera_freeze_br_br_ops, priv);
+       br = devm_fpga_bridge_create(dev, FREEZE_BRIDGE_NAME,
+                                    &altera_freeze_br_br_ops, priv);
        if (!br)
                return -ENOMEM;
 
        platform_set_drvdata(pdev, br);
 
-       ret = fpga_bridge_register(br);
-       if (ret) {
-               fpga_bridge_free(br);
-               return ret;
-       }
-
-       return 0;
+       return fpga_bridge_register(br);
 }
 
 static int altera_freeze_br_remove(struct platform_device *pdev)
drivers/fpga/altera-hps2fpga.c +3 -4
index a974d3f..77b95f2 100644
@@ -180,7 +180,8 @@ static int alt_fpga_bridge_probe(struct platform_device *pdev)
                }
        }
 
-       br = fpga_bridge_create(dev, priv->name, &altera_hps2fpga_br_ops, priv);
+       br = devm_fpga_bridge_create(dev, priv->name,
+                                    &altera_hps2fpga_br_ops, priv);
        if (!br) {
                ret = -ENOMEM;
                goto err;
@@ -190,12 +191,10 @@ static int alt_fpga_bridge_probe(struct platform_device *pdev)
 
        ret = fpga_bridge_register(br);
        if (ret)
-               goto err_free;
+               goto err;
 
        return 0;
 
-err_free:
-       fpga_bridge_free(br);
 err:
        clk_disable_unprepare(priv->clk);
 
drivers/fpga/dfl-fme-br.c +3 -8
index 7cc041d..3ff9f3a 100644
@@ -61,7 +61,6 @@ static int fme_br_probe(struct platform_device *pdev)
        struct device *dev = &pdev->dev;
        struct fme_br_priv *priv;
        struct fpga_bridge *br;
-       int ret;
 
        priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
        if (!priv)
@@ -69,18 +68,14 @@ static int fme_br_probe(struct platform_device *pdev)
 
        priv->pdata = dev_get_platdata(dev);
 
-       br = fpga_bridge_create(dev, "DFL FPGA FME Bridge",
-                               &fme_bridge_ops, priv);
+       br = devm_fpga_bridge_create(dev, "DFL FPGA FME Bridge",
+                                    &fme_bridge_ops, priv);
        if (!br)
                return -ENOMEM;
 
        platform_set_drvdata(pdev, br);
 
-       ret = fpga_bridge_register(br);
-       if (ret)
-               fpga_bridge_free(br);
-
-       return ret;
+       return fpga_bridge_register(br);
 }
 
 static int fme_br_remove(struct platform_device *pdev)
drivers/fpga/fpga-bridge.c +54 -4
index 24b8f98..c39d35f 100644
@@ -324,6 +324,9 @@ ATTRIBUTE_GROUPS(fpga_bridge);
  * @br_ops:    pointer to structure of fpga bridge ops
  * @priv:      FPGA bridge private data
  *
+ * The caller of this function is responsible for freeing the bridge with
+ * fpga_bridge_free().  Using devm_fpga_bridge_create() instead is recommended.
+ *
  * Return: struct fpga_bridge or NULL
  */
 struct fpga_bridge *fpga_bridge_create(struct device *dev, const char *name,
@@ -378,8 +381,8 @@ struct fpga_bridge *fpga_bridge_create(struct device *dev, const char *name,
 EXPORT_SYMBOL_GPL(fpga_bridge_create);
 
 /**
- * fpga_bridge_free - free a fpga bridge and its id
- * @bridge:    FPGA bridge struct created by fpga_bridge_create
+ * fpga_bridge_free - free a fpga bridge created by fpga_bridge_create()
+ * @bridge:    FPGA bridge struct
  */
 void fpga_bridge_free(struct fpga_bridge *bridge)
 {
@@ -388,9 +391,56 @@ void fpga_bridge_free(struct fpga_bridge *bridge)
 }
 EXPORT_SYMBOL_GPL(fpga_bridge_free);
 
+static void devm_fpga_bridge_release(struct device *dev, void *res)
+{
+       struct fpga_bridge *bridge = *(struct fpga_bridge **)res;
+
+       fpga_bridge_free(bridge);
+}
+
 /**
- * fpga_bridge_register - register a fpga bridge
- * @bridge:    FPGA bridge struct created by fpga_bridge_create
+ * devm_fpga_bridge_create - create and init a managed struct fpga_bridge
+ * @dev:       FPGA bridge device from pdev
+ * @name:      FPGA bridge name
+ * @br_ops:    pointer to structure of fpga bridge ops
+ * @priv:      FPGA bridge private data
+ *
+ * This function is intended for use in a FPGA bridge driver's probe function.
+ * After the bridge driver creates the struct with devm_fpga_bridge_create(), it
+ * should register the bridge with fpga_bridge_register().  The bridge driver's
+ * remove function should call fpga_bridge_unregister().  The bridge struct
+ * allocated with this function will be freed automatically on driver detach.
+ * This includes the case of a probe function returning error before calling
+ * fpga_bridge_register(), the struct will still get cleaned up.
+ *
+ *  Return: struct fpga_bridge or NULL
+ */
+struct fpga_bridge
+*devm_fpga_bridge_create(struct device *dev, const char *name,
+                        const struct fpga_bridge_ops *br_ops, void *priv)
+{
+       struct fpga_bridge **ptr, *bridge;
+
+       ptr = devres_alloc(devm_fpga_bridge_release, sizeof(*ptr), GFP_KERNEL);
+       if (!ptr)
+               return NULL;
+
+       bridge = fpga_bridge_create(dev, name, br_ops, priv);
+       if (!bridge) {
+               devres_free(ptr);
+       } else {
+               *ptr = bridge;
+               devres_add(dev, ptr);
+       }
+
+       return bridge;
+}
+EXPORT_SYMBOL_GPL(devm_fpga_bridge_create);
+
+/**
+ * fpga_bridge_register - register a FPGA bridge
+ *
+ * @bridge: FPGA bridge struct
  *
  * Return: 0 for success, error code otherwise.
  */
@@ -412,8 +462,15 @@ int fpga_bridge_register(struct fpga_bridge *bridge)
 EXPORT_SYMBOL_GPL(fpga_bridge_register);
 
Quoted 16 lines

drivers/fpga/fpga-bridge.c int fpga_bridge_register(struct fpga_bridge *bridge) · line 473

Quoted 12 lines
drivers/fpga/fpga-bridge.c +9 -2
 /**
- * fpga_bridge_unregister - unregister and free a fpga bridge
- * @bridge:    FPGA bridge struct created by fpga_bridge_create
+ * fpga_bridge_unregister - unregister a FPGA bridge
+ *
+ * @bridge: FPGA bridge struct
+ *
+ * This function is intended for use in a FPGA bridge driver's remove function.
+ * If the bridge was created with devm_fpga_bridge_create(), the bridge struct
+ * will be automatically freed.  If the bridge was created with
+ * fpga_bridge_create(), the caller is responsible for freeing the bridge with
+ * fpga_bridge_free().

I find the formulation somewhat confusing, since it could be interpreted as if you
used the devm_() functions you don't have to call unregister().

Yes I'm being too verbose and it's making things muddled. How about if I take out the part that starts with "If bridge was created..."? That just leaves "This function is intended for use in a FPGA bridge driver's remove function."

Alan

Quoted 48 lines
Quoted 42 lines
drivers/fpga/fpga-bridge.c +0 -3
  */
 void fpga_bridge_unregister(struct fpga_bridge *bridge)
 {
@@ -430,9 +487,6 @@ EXPORT_SYMBOL_GPL(fpga_bridge_unregister);
 
 static void fpga_bridge_dev_release(struct device *dev)
 {
-       struct fpga_bridge *bridge = to_fpga_bridge(dev);
-
-       fpga_bridge_free(bridge);
 }
 
 static int __init fpga_bridge_dev_init(void)
drivers/fpga/xilinx-pr-decoupler.c +2 -2
index 07ba153..6410361 100644
@@ -121,8 +121,8 @@ static int xlnx_pr_decoupler_probe(struct platform_device *pdev)
 
        clk_disable(priv->clk);
 
-       br = fpga_bridge_create(&pdev->dev, "Xilinx PR Decoupler",
-                               &xlnx_pr_decoupler_br_ops, priv);
+       br = devm_fpga_bridge_create(&pdev->dev, "Xilinx PR Decoupler",
+                                    &xlnx_pr_decoupler_br_ops, priv);
        if (!br) {
                err = -ENOMEM;
                goto err_clk;
include/linux/fpga/fpga-bridge.h +4 -1
index ce550fc..817600a 100644
@@ -69,4 +69,8 @@ void fpga_bridge_free(struct fpga_bridge *br);
 int fpga_bridge_register(struct fpga_bridge *br);
 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 */
--
Quoted 2 lines

2.7.4

Thanks,

Moritz

author
#12 lore raw

Re: [PATCH v2 5/8] dt-bindings: fpga: fix freeze controller compatible in region doc

In reply to Alan Tull

On Tue, Sep 4, 2018 at 4:22 PM Alan Tull <[email protected]> wrote:

OK I left off the DT folk. I'll resend this one patch separately.

Alan

Quoted 16 lines

Documentation/devicetree/bindings/fpga/fpga-region.txt has an error regarding the freeze controller bridge, secifically:

compatible = "altr,freeze-bridge";

The compatibility string should be "altr,freeze-bridge-controller" as set forth in altera-freeze-bridge.txt.

---
v2: no change in v2 of patchset

---
 Documentation/devicetree/bindings/fpga/fpga-region.txt | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
maintainer
#8 lore raw

Re: [PATCH v2 3/8] fpga: bridge: add devm_fpga_bridge_create

In reply to Alan Tull

Hi Alan,

Quoted 12 lines · Alan Tull
Quoted 12 lines
Quoted 11 lines

- * fpga_bridge_unregister - unregister and free a fpga bridge
- * @bridge: FPGA bridge struct created by fpga_bridge_create
+ * fpga_bridge_unregister - unregister a FPGA bridge
+ *
+ * @bridge: FPGA bridge struct
+ *
+ * This function is intended for use in a FPGA bridge driver's remove function.
+ * If the bridge was created with devm_fpga_bridge_create(), the bridge struct
+ * will be automatically freed. If the bridge was created with
+ * fpga_bridge_create(), the caller is responsible for freeing the bridge with
+ * fpga_bridge_free().

Quoted 8 lines
Quoted 3 lines

I find the formulation somewhat confusing, since it could be interpreted as if you
used the devm_() functions you don't have to call unregister().

Yes I'm being too verbose and it's making things muddled. How about if I take out the part that starts with "If bridge was created..."? That just leaves "This function is intended for use in a FPGA bridge driver's remove function."

Sounds good.

Moritz

maintainer Acked-by on v2 7/8
#17 lore raw

Re: [PATCH v2 7/8] docs: fpga: document fpga manager flags

In reply to Alan Tull
Quoted 4 lines · Alan Tull

Add flags #defines to kerneldoc documentation in a useful place.

Quoted 57 lines

---
v2: add description for FPGA_MGR_ENCRYPTED_BITSTREAM

---
 Documentation/driver-api/fpga/fpga-mgr.rst |  5 +++++
 include/linux/fpga/fpga-mgr.h              | 20 ++++++++++++++------
 2 files changed, 19 insertions(+), 6 deletions(-)
Documentation/driver-api/fpga/fpga-mgr.rst +5 -0
index 431556d..db8885e 100644
@@ -183,6 +183,11 @@ API for implementing a new FPGA Manager driver
 API for programming an FPGA
 ---------------------------
 
+FPGA Manager flags
+
+.. kernel-doc:: include/linux/fpga/fpga-mgr.h
+   :doc: FPGA Manager flags
+
 .. kernel-doc:: include/linux/fpga/fpga-mgr.h
    :functions: fpga_image_info
 
include/linux/fpga/fpga-mgr.h +14 -6
index 1ca02ce..e8ca62b 100644
@@ -53,12 +53,20 @@ enum fpga_mgr_states {
 	FPGA_MGR_STATE_OPERATING,
 };
 
-/*
- * FPGA Manager flags
- * FPGA_MGR_PARTIAL_RECONFIG: do partial reconfiguration if supported
- * FPGA_MGR_EXTERNAL_CONFIG: FPGA has been configured prior to Linux booting
- * FPGA_MGR_BITSTREAM_LSB_FIRST: SPI bitstream bit order is LSB first
- * FPGA_MGR_COMPRESSED_BITSTREAM: FPGA bitstream is compressed
+/**
+ * DOC: FPGA Manager flags
+ *
+ * Flags used in the &fpga_image_info->flags field
+ *
+ * %FPGA_MGR_PARTIAL_RECONFIG: do partial reconfiguration if supported
+ *
+ * %FPGA_MGR_EXTERNAL_CONFIG: FPGA has been configured prior to Linux booting
+ *
+ * %FPGA_MGR_ENCRYPTED_BITSTREAM: indicates bitstream is encrypted
+ *
+ * %FPGA_MGR_BITSTREAM_LSB_FIRST: SPI bitstream bit order is LSB first
+ *
+ * %FPGA_MGR_COMPRESSED_BITSTREAM: FPGA bitstream is compressed
  */
 #define FPGA_MGR_PARTIAL_RECONFIG	BIT(0)
 #define FPGA_MGR_EXTERNAL_CONFIG	BIT(1)
Signature · 1 line
2.7.4

Thanks for doing this,

Moritz

maintainer Acked-by on v2 6/8
#14 lore raw

Re: [PATCH v2 6/8] fpga: bridge: fix obvious function documentation error

In reply to Alan Tull
Quoted 4 lines · Alan Tull

fpga_bridge_dev_match() returns a FPGA bridge struct, not a FPGA manager struct so s/manager/bridge/.

Quoted 22 lines

---
v2: no change in v2 of patchset

---
 drivers/fpga/fpga-bridge.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/fpga/fpga-bridge.c +1 -1
index c39d35f..7b0071a 100644
@@ -125,7 +125,7 @@ static int fpga_bridge_dev_match(struct device *dev, const void *data)
  *
  * Given a device, get an exclusive reference to a fpga bridge.
  *
- * Return: fpga manager struct or IS_ERR() condition containing error code.
+ * Return: fpga bridge struct or IS_ERR() condition containing error code.
  */
 struct fpga_bridge *fpga_bridge_get(struct device *dev,
 				    struct fpga_image_info *info)
Signature · 1 line
2.7.4

Thanks,

Moritz

author
#9 lore raw

Re: [PATCH v2 3/8] fpga: bridge: add devm_fpga_bridge_create

In reply to Moritz Fischer
Quoted 20 lines · Moritz Fischer

Hi Alan,

Quoted 16 lines · Alan Tull
Quoted 15 lines
Quoted 11 lines

- * fpga_bridge_unregister - unregister and free a fpga bridge
- * @bridge: FPGA bridge struct created by fpga_bridge_create
+ * fpga_bridge_unregister - unregister a FPGA bridge
+ *
+ * @bridge: FPGA bridge struct
+ *
+ * This function is intended for use in a FPGA bridge driver's remove function.
+ * If the bridge was created with devm_fpga_bridge_create(), the bridge struct
+ * will be automatically freed. If the bridge was created with
+ * fpga_bridge_create(), the caller is responsible for freeing the bridge with
+ * fpga_bridge_free().

I find the formulation somewhat confusing, since it could be interpreted as if you
used the devm_() functions you don't have to call unregister().

Quoted 6 lines
Quoted 4 lines

Yes I'm being too verbose and it's making things muddled. How about if I take out the part that starts with "If bridge was created..."? That just leaves "This function is intended for use in a FPGA bridge driver's remove function."

Sounds good.

OK, for v3 I'll make a similar change in patches 2 and 4.

Alan

Quoted 2 lines

Moritz