All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/10] Introduce devm_fpga_mgr_register()
@ 2020-10-04  5:14 ` Moritz Fischer
  0 siblings, 0 replies; 51+ messages in thread
From: Moritz Fischer @ 2020-10-04  5:14 UTC (permalink / raw)
  To: linux-fpga
  Cc: trix, hao.wu, michal.simek, linux-kernel, linux-arm-kernel,
	russell.h.weight, matthew.gerlach, Moritz Fischer

This patchset introduces the devm_fpga_mgr_register API,
a devres managed version of fpga_mgr_register().

It reduces boilerplate being repeated literally in every
single driver by moving it to the fpga-mgr core.

Moritz Fischer (10):
  fpga: fpga-mgr: Add devm_fpga_mgr_register() API
  fpga: fpga-mgr: altera-ps-spi: Simplify registration
  fpga: fpga-mgr: dfl-fme-mgr: Simplify registration
  fpga: fpga-mgr: ice40-spi: Simplify registration
  fpga: fpga-mgr: machxo2-spi: Simplify registration
  fpga: fpga-mgr: socfpga: Simplify registration
  fpga: fpga-mgr: ts73xx: Simplify registration
  fpga: fpga-mgr: xilinx-spi: Simplify registration
  fpga: fpga-mgr: zynqmp: Simplify registration
  fpga: fpga-mgr: altera-pr-ip: Simplify registration

 drivers/fpga/altera-pr-ip-core-plat.c  | 10 ----
 drivers/fpga/altera-pr-ip-core.c       | 14 +----
 drivers/fpga/altera-ps-spi.c           | 14 +----
 drivers/fpga/dfl-fme-mgr.c             | 12 +---
 drivers/fpga/fpga-mgr.c                | 76 ++++++++++++++++++++++----
 drivers/fpga/ice40-spi.c               | 14 +----
 drivers/fpga/machxo2-spi.c             | 14 +----
 drivers/fpga/socfpga.c                 | 14 +----
 drivers/fpga/ts73xx-fpga.c             | 14 +----
 drivers/fpga/xilinx-spi.c              | 14 +----
 drivers/fpga/zynqmp-fpga.c             | 21 +------
 include/linux/fpga/altera-pr-ip-core.h |  1 -
 include/linux/fpga/fpga-mgr.h          |  2 +
 13 files changed, 77 insertions(+), 143 deletions(-)

-- 
2.28.0


^ permalink raw reply	[flat|nested] 51+ messages in thread

* [PATCH 00/10] Introduce devm_fpga_mgr_register()
@ 2020-10-04  5:14 ` Moritz Fischer
  0 siblings, 0 replies; 51+ messages in thread
From: Moritz Fischer @ 2020-10-04  5:14 UTC (permalink / raw)
  To: linux-fpga
  Cc: russell.h.weight, trix, michal.simek, matthew.gerlach,
	linux-kernel, Moritz Fischer, linux-arm-kernel, hao.wu

This patchset introduces the devm_fpga_mgr_register API,
a devres managed version of fpga_mgr_register().

It reduces boilerplate being repeated literally in every
single driver by moving it to the fpga-mgr core.

Moritz Fischer (10):
  fpga: fpga-mgr: Add devm_fpga_mgr_register() API
  fpga: fpga-mgr: altera-ps-spi: Simplify registration
  fpga: fpga-mgr: dfl-fme-mgr: Simplify registration
  fpga: fpga-mgr: ice40-spi: Simplify registration
  fpga: fpga-mgr: machxo2-spi: Simplify registration
  fpga: fpga-mgr: socfpga: Simplify registration
  fpga: fpga-mgr: ts73xx: Simplify registration
  fpga: fpga-mgr: xilinx-spi: Simplify registration
  fpga: fpga-mgr: zynqmp: Simplify registration
  fpga: fpga-mgr: altera-pr-ip: Simplify registration

 drivers/fpga/altera-pr-ip-core-plat.c  | 10 ----
 drivers/fpga/altera-pr-ip-core.c       | 14 +----
 drivers/fpga/altera-ps-spi.c           | 14 +----
 drivers/fpga/dfl-fme-mgr.c             | 12 +---
 drivers/fpga/fpga-mgr.c                | 76 ++++++++++++++++++++++----
 drivers/fpga/ice40-spi.c               | 14 +----
 drivers/fpga/machxo2-spi.c             | 14 +----
 drivers/fpga/socfpga.c                 | 14 +----
 drivers/fpga/ts73xx-fpga.c             | 14 +----
 drivers/fpga/xilinx-spi.c              | 14 +----
 drivers/fpga/zynqmp-fpga.c             | 21 +------
 include/linux/fpga/altera-pr-ip-core.h |  1 -
 include/linux/fpga/fpga-mgr.h          |  2 +
 13 files changed, 77 insertions(+), 143 deletions(-)

-- 
2.28.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 51+ messages in thread

* [PATCH 01/10] fpga: fpga-mgr: Add devm_fpga_mgr_register() API
  2020-10-04  5:14 ` Moritz Fischer
@ 2020-10-04  5:14   ` Moritz Fischer
  -1 siblings, 0 replies; 51+ messages in thread
From: Moritz Fischer @ 2020-10-04  5:14 UTC (permalink / raw)
  To: linux-fpga
  Cc: trix, hao.wu, michal.simek, linux-kernel, linux-arm-kernel,
	russell.h.weight, matthew.gerlach, Moritz Fischer

Add a devm_fpga_mgr_register() API that can be used to register a FPGA
Manager that was created using devm_fpga_mgr_create().

Introduce a struct fpga_mgr_devres that makes the devres
allocation a little bit more readable and gets reused for
devm_fpga_mgr_create() devm_fpga_mgr_register().

Signed-off-by: Moritz Fischer <mdf@kernel.org>
---
 drivers/fpga/fpga-mgr.c       | 76 ++++++++++++++++++++++++++++++-----
 include/linux/fpga/fpga-mgr.h |  2 +
 2 files changed, 68 insertions(+), 10 deletions(-)

diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c
index f38bab01432e..774ac98fb69c 100644
--- a/drivers/fpga/fpga-mgr.c
+++ b/drivers/fpga/fpga-mgr.c
@@ -21,6 +21,10 @@
 static DEFINE_IDA(fpga_mgr_ida);
 static struct class *fpga_mgr_class;
 
+struct fpga_mgr_devres {
+	struct fpga_manager *mgr;
+};
+
 /**
  * fpga_image_info_alloc - Allocate a FPGA image info struct
  * @dev: owning device
@@ -651,21 +655,21 @@ struct fpga_manager *devm_fpga_mgr_create(struct device *dev, const char *name,
 					  const struct fpga_manager_ops *mops,
 					  void *priv)
 {
-	struct fpga_manager **ptr, *mgr;
+	struct fpga_mgr_devres *dr;
 
-	ptr = devres_alloc(devm_fpga_mgr_release, sizeof(*ptr), GFP_KERNEL);
-	if (!ptr)
+	dr = devres_alloc(devm_fpga_mgr_release, sizeof(*dr), GFP_KERNEL);
+	if (!dr)
 		return NULL;
 
-	mgr = fpga_mgr_create(dev, name, mops, priv);
-	if (!mgr) {
-		devres_free(ptr);
-	} else {
-		*ptr = mgr;
-		devres_add(dev, ptr);
+	dr->mgr = fpga_mgr_create(dev, name, mops, priv);
+	if (!dr->mgr) {
+		devres_free(dr);
+		return NULL;
 	}
 
-	return mgr;
+	devres_add(dev, dr);
+
+	return dr->mgr;
 }
 EXPORT_SYMBOL_GPL(devm_fpga_mgr_create);
 
@@ -722,6 +726,58 @@ void fpga_mgr_unregister(struct fpga_manager *mgr)
 }
 EXPORT_SYMBOL_GPL(fpga_mgr_unregister);
 
+static int fpga_mgr_devres_match(struct device *dev, void *priv,
+				 void *match_data)
+{
+	struct fpga_mgr_devres *dr = priv;
+
+	return match_data == dr->mgr;
+}
+
+static void devm_fpga_mgr_unregister(struct device *dev, void *priv)
+{
+	struct fpga_mgr_devres *dr = priv;
+
+	fpga_mgr_unregister(dr->mgr);
+}
+
+/**
+ * devm_fpga_mgr_register - resource managed variant of fpga_mgr_register()
+ * @dev: managing device for this FPGA manager
+ * @mgr: fpga manager struct
+ *
+ * This is the devres variant of fpga_mgr_register() for which the unregister
+ * function will be called automatically when the managing device is detached.
+ */
+int devm_fpga_mgr_register(struct device *dev, struct fpga_manager *mgr)
+{
+	struct fpga_mgr_devres *dr;
+	int err;
+
+	/* Make sure that the struct fpga_manager * that is passed in is
+	 * managed itself.
+	 */
+	if (WARN_ON(!devres_find(dev, devm_fpga_mgr_release,
+				 fpga_mgr_devres_match, mgr)))
+		return -EINVAL;
+
+	dr = devres_alloc(devm_fpga_mgr_unregister, sizeof(*dr), GFP_KERNEL);
+	if (!dr)
+		return -ENOMEM;
+
+	err = fpga_mgr_register(mgr);
+	if (err) {
+		devres_free(dr);
+		return err;
+	}
+
+	dr->mgr = mgr;
+	devres_add(dev, dr);
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(devm_fpga_mgr_register);
+
 static void fpga_mgr_dev_release(struct device *dev)
 {
 }
diff --git a/include/linux/fpga/fpga-mgr.h b/include/linux/fpga/fpga-mgr.h
index e8ca62b2cb5b..2bc3030a69e5 100644
--- a/include/linux/fpga/fpga-mgr.h
+++ b/include/linux/fpga/fpga-mgr.h
@@ -198,6 +198,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);
 
+int devm_fpga_mgr_register(struct device *dev, 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);
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 51+ messages in thread

* [PATCH 01/10] fpga: fpga-mgr: Add devm_fpga_mgr_register() API
@ 2020-10-04  5:14   ` Moritz Fischer
  0 siblings, 0 replies; 51+ messages in thread
From: Moritz Fischer @ 2020-10-04  5:14 UTC (permalink / raw)
  To: linux-fpga
  Cc: russell.h.weight, trix, michal.simek, matthew.gerlach,
	linux-kernel, Moritz Fischer, linux-arm-kernel, hao.wu

Add a devm_fpga_mgr_register() API that can be used to register a FPGA
Manager that was created using devm_fpga_mgr_create().

Introduce a struct fpga_mgr_devres that makes the devres
allocation a little bit more readable and gets reused for
devm_fpga_mgr_create() devm_fpga_mgr_register().

Signed-off-by: Moritz Fischer <mdf@kernel.org>
---
 drivers/fpga/fpga-mgr.c       | 76 ++++++++++++++++++++++++++++++-----
 include/linux/fpga/fpga-mgr.h |  2 +
 2 files changed, 68 insertions(+), 10 deletions(-)

diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c
index f38bab01432e..774ac98fb69c 100644
--- a/drivers/fpga/fpga-mgr.c
+++ b/drivers/fpga/fpga-mgr.c
@@ -21,6 +21,10 @@
 static DEFINE_IDA(fpga_mgr_ida);
 static struct class *fpga_mgr_class;
 
+struct fpga_mgr_devres {
+	struct fpga_manager *mgr;
+};
+
 /**
  * fpga_image_info_alloc - Allocate a FPGA image info struct
  * @dev: owning device
@@ -651,21 +655,21 @@ struct fpga_manager *devm_fpga_mgr_create(struct device *dev, const char *name,
 					  const struct fpga_manager_ops *mops,
 					  void *priv)
 {
-	struct fpga_manager **ptr, *mgr;
+	struct fpga_mgr_devres *dr;
 
-	ptr = devres_alloc(devm_fpga_mgr_release, sizeof(*ptr), GFP_KERNEL);
-	if (!ptr)
+	dr = devres_alloc(devm_fpga_mgr_release, sizeof(*dr), GFP_KERNEL);
+	if (!dr)
 		return NULL;
 
-	mgr = fpga_mgr_create(dev, name, mops, priv);
-	if (!mgr) {
-		devres_free(ptr);
-	} else {
-		*ptr = mgr;
-		devres_add(dev, ptr);
+	dr->mgr = fpga_mgr_create(dev, name, mops, priv);
+	if (!dr->mgr) {
+		devres_free(dr);
+		return NULL;
 	}
 
-	return mgr;
+	devres_add(dev, dr);
+
+	return dr->mgr;
 }
 EXPORT_SYMBOL_GPL(devm_fpga_mgr_create);
 
@@ -722,6 +726,58 @@ void fpga_mgr_unregister(struct fpga_manager *mgr)
 }
 EXPORT_SYMBOL_GPL(fpga_mgr_unregister);
 
+static int fpga_mgr_devres_match(struct device *dev, void *priv,
+				 void *match_data)
+{
+	struct fpga_mgr_devres *dr = priv;
+
+	return match_data == dr->mgr;
+}
+
+static void devm_fpga_mgr_unregister(struct device *dev, void *priv)
+{
+	struct fpga_mgr_devres *dr = priv;
+
+	fpga_mgr_unregister(dr->mgr);
+}
+
+/**
+ * devm_fpga_mgr_register - resource managed variant of fpga_mgr_register()
+ * @dev: managing device for this FPGA manager
+ * @mgr: fpga manager struct
+ *
+ * This is the devres variant of fpga_mgr_register() for which the unregister
+ * function will be called automatically when the managing device is detached.
+ */
+int devm_fpga_mgr_register(struct device *dev, struct fpga_manager *mgr)
+{
+	struct fpga_mgr_devres *dr;
+	int err;
+
+	/* Make sure that the struct fpga_manager * that is passed in is
+	 * managed itself.
+	 */
+	if (WARN_ON(!devres_find(dev, devm_fpga_mgr_release,
+				 fpga_mgr_devres_match, mgr)))
+		return -EINVAL;
+
+	dr = devres_alloc(devm_fpga_mgr_unregister, sizeof(*dr), GFP_KERNEL);
+	if (!dr)
+		return -ENOMEM;
+
+	err = fpga_mgr_register(mgr);
+	if (err) {
+		devres_free(dr);
+		return err;
+	}
+
+	dr->mgr = mgr;
+	devres_add(dev, dr);
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(devm_fpga_mgr_register);
+
 static void fpga_mgr_dev_release(struct device *dev)
 {
 }
diff --git a/include/linux/fpga/fpga-mgr.h b/include/linux/fpga/fpga-mgr.h
index e8ca62b2cb5b..2bc3030a69e5 100644
--- a/include/linux/fpga/fpga-mgr.h
+++ b/include/linux/fpga/fpga-mgr.h
@@ -198,6 +198,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);
 
+int devm_fpga_mgr_register(struct device *dev, 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);
-- 
2.28.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 51+ messages in thread

* [PATCH 02/10] fpga: fpga-mgr: altera-ps-spi: Simplify registration
  2020-10-04  5:14 ` Moritz Fischer
@ 2020-10-04  5:14   ` Moritz Fischer
  -1 siblings, 0 replies; 51+ messages in thread
From: Moritz Fischer @ 2020-10-04  5:14 UTC (permalink / raw)
  To: linux-fpga
  Cc: trix, hao.wu, michal.simek, linux-kernel, linux-arm-kernel,
	russell.h.weight, matthew.gerlach, Moritz Fischer

Simplify registration by using new devm_fpga_mgr_register() API.

Signed-off-by: Moritz Fischer <mdf@kernel.org>
---
 drivers/fpga/altera-ps-spi.c | 14 +-------------
 1 file changed, 1 insertion(+), 13 deletions(-)

diff --git a/drivers/fpga/altera-ps-spi.c b/drivers/fpga/altera-ps-spi.c
index 0221dee8dd4c..23bfd4d1ad0f 100644
--- a/drivers/fpga/altera-ps-spi.c
+++ b/drivers/fpga/altera-ps-spi.c
@@ -307,18 +307,7 @@ static int altera_ps_probe(struct spi_device *spi)
 	if (!mgr)
 		return -ENOMEM;
 
-	spi_set_drvdata(spi, mgr);
-
-	return fpga_mgr_register(mgr);
-}
-
-static int altera_ps_remove(struct spi_device *spi)
-{
-	struct fpga_manager *mgr = spi_get_drvdata(spi);
-
-	fpga_mgr_unregister(mgr);
-
-	return 0;
+	return devm_fpga_mgr_register(&spi->dev, mgr);
 }
 
 static const struct spi_device_id altera_ps_spi_ids[] = {
@@ -337,7 +326,6 @@ static struct spi_driver altera_ps_driver = {
 	},
 	.id_table = altera_ps_spi_ids,
 	.probe = altera_ps_probe,
-	.remove = altera_ps_remove,
 };
 
 module_spi_driver(altera_ps_driver)
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 51+ messages in thread

* [PATCH 02/10] fpga: fpga-mgr: altera-ps-spi: Simplify registration
@ 2020-10-04  5:14   ` Moritz Fischer
  0 siblings, 0 replies; 51+ messages in thread
From: Moritz Fischer @ 2020-10-04  5:14 UTC (permalink / raw)
  To: linux-fpga
  Cc: russell.h.weight, trix, michal.simek, matthew.gerlach,
	linux-kernel, Moritz Fischer, linux-arm-kernel, hao.wu

Simplify registration by using new devm_fpga_mgr_register() API.

Signed-off-by: Moritz Fischer <mdf@kernel.org>
---
 drivers/fpga/altera-ps-spi.c | 14 +-------------
 1 file changed, 1 insertion(+), 13 deletions(-)

diff --git a/drivers/fpga/altera-ps-spi.c b/drivers/fpga/altera-ps-spi.c
index 0221dee8dd4c..23bfd4d1ad0f 100644
--- a/drivers/fpga/altera-ps-spi.c
+++ b/drivers/fpga/altera-ps-spi.c
@@ -307,18 +307,7 @@ static int altera_ps_probe(struct spi_device *spi)
 	if (!mgr)
 		return -ENOMEM;
 
-	spi_set_drvdata(spi, mgr);
-
-	return fpga_mgr_register(mgr);
-}
-
-static int altera_ps_remove(struct spi_device *spi)
-{
-	struct fpga_manager *mgr = spi_get_drvdata(spi);
-
-	fpga_mgr_unregister(mgr);
-
-	return 0;
+	return devm_fpga_mgr_register(&spi->dev, mgr);
 }
 
 static const struct spi_device_id altera_ps_spi_ids[] = {
@@ -337,7 +326,6 @@ static struct spi_driver altera_ps_driver = {
 	},
 	.id_table = altera_ps_spi_ids,
 	.probe = altera_ps_probe,
-	.remove = altera_ps_remove,
 };
 
 module_spi_driver(altera_ps_driver)
-- 
2.28.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 51+ messages in thread

* [PATCH 03/10] fpga: fpga-mgr: dfl-fme-mgr: Simplify registration
  2020-10-04  5:14 ` Moritz Fischer
@ 2020-10-04  5:14   ` Moritz Fischer
  -1 siblings, 0 replies; 51+ messages in thread
From: Moritz Fischer @ 2020-10-04  5:14 UTC (permalink / raw)
  To: linux-fpga
  Cc: trix, hao.wu, michal.simek, linux-kernel, linux-arm-kernel,
	russell.h.weight, matthew.gerlach, Moritz Fischer

Simplify registration using new devm_fpga_mgr_register() API.

Signed-off-by: Moritz Fischer <mdf@kernel.org>
---
 drivers/fpga/dfl-fme-mgr.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)

diff --git a/drivers/fpga/dfl-fme-mgr.c b/drivers/fpga/dfl-fme-mgr.c
index b3f7eee3c93f..3fc2be87d059 100644
--- a/drivers/fpga/dfl-fme-mgr.c
+++ b/drivers/fpga/dfl-fme-mgr.c
@@ -316,16 +316,7 @@ static int fme_mgr_probe(struct platform_device *pdev)
 	mgr->compat_id = compat_id;
 	platform_set_drvdata(pdev, mgr);
 
-	return fpga_mgr_register(mgr);
-}
-
-static int fme_mgr_remove(struct platform_device *pdev)
-{
-	struct fpga_manager *mgr = platform_get_drvdata(pdev);
-
-	fpga_mgr_unregister(mgr);
-
-	return 0;
+	return devm_fpga_mgr_register(dev, mgr);
 }
 
 static struct platform_driver fme_mgr_driver = {
@@ -333,7 +324,6 @@ static struct platform_driver fme_mgr_driver = {
 		.name    = DFL_FPGA_FME_MGR,
 	},
 	.probe   = fme_mgr_probe,
-	.remove  = fme_mgr_remove,
 };
 
 module_platform_driver(fme_mgr_driver);
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 51+ messages in thread

* [PATCH 03/10] fpga: fpga-mgr: dfl-fme-mgr: Simplify registration
@ 2020-10-04  5:14   ` Moritz Fischer
  0 siblings, 0 replies; 51+ messages in thread
From: Moritz Fischer @ 2020-10-04  5:14 UTC (permalink / raw)
  To: linux-fpga
  Cc: russell.h.weight, trix, michal.simek, matthew.gerlach,
	linux-kernel, Moritz Fischer, linux-arm-kernel, hao.wu

Simplify registration using new devm_fpga_mgr_register() API.

Signed-off-by: Moritz Fischer <mdf@kernel.org>
---
 drivers/fpga/dfl-fme-mgr.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)

diff --git a/drivers/fpga/dfl-fme-mgr.c b/drivers/fpga/dfl-fme-mgr.c
index b3f7eee3c93f..3fc2be87d059 100644
--- a/drivers/fpga/dfl-fme-mgr.c
+++ b/drivers/fpga/dfl-fme-mgr.c
@@ -316,16 +316,7 @@ static int fme_mgr_probe(struct platform_device *pdev)
 	mgr->compat_id = compat_id;
 	platform_set_drvdata(pdev, mgr);
 
-	return fpga_mgr_register(mgr);
-}
-
-static int fme_mgr_remove(struct platform_device *pdev)
-{
-	struct fpga_manager *mgr = platform_get_drvdata(pdev);
-
-	fpga_mgr_unregister(mgr);
-
-	return 0;
+	return devm_fpga_mgr_register(dev, mgr);
 }
 
 static struct platform_driver fme_mgr_driver = {
@@ -333,7 +324,6 @@ static struct platform_driver fme_mgr_driver = {
 		.name    = DFL_FPGA_FME_MGR,
 	},
 	.probe   = fme_mgr_probe,
-	.remove  = fme_mgr_remove,
 };
 
 module_platform_driver(fme_mgr_driver);
-- 
2.28.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 51+ messages in thread

* [PATCH 04/10] fpga: fpga-mgr: ice40-spi: Simplify registration
  2020-10-04  5:14 ` Moritz Fischer
@ 2020-10-04  5:14   ` Moritz Fischer
  -1 siblings, 0 replies; 51+ messages in thread
From: Moritz Fischer @ 2020-10-04  5:14 UTC (permalink / raw)
  To: linux-fpga
  Cc: trix, hao.wu, michal.simek, linux-kernel, linux-arm-kernel,
	russell.h.weight, matthew.gerlach, Moritz Fischer

Simplify registration using new devm_fpga_mgr_register() API.

Signed-off-by: Moritz Fischer <mdf@kernel.org>
---
 drivers/fpga/ice40-spi.c | 14 +-------------
 1 file changed, 1 insertion(+), 13 deletions(-)

diff --git a/drivers/fpga/ice40-spi.c b/drivers/fpga/ice40-spi.c
index 8d689fea0dab..69dec5af23c3 100644
--- a/drivers/fpga/ice40-spi.c
+++ b/drivers/fpga/ice40-spi.c
@@ -183,18 +183,7 @@ static int ice40_fpga_probe(struct spi_device *spi)
 	if (!mgr)
 		return -ENOMEM;
 
-	spi_set_drvdata(spi, mgr);
-
-	return fpga_mgr_register(mgr);
-}
-
-static int ice40_fpga_remove(struct spi_device *spi)
-{
-	struct fpga_manager *mgr = spi_get_drvdata(spi);
-
-	fpga_mgr_unregister(mgr);
-
-	return 0;
+	return devm_fpga_mgr_register(dev, mgr);
 }
 
 static const struct of_device_id ice40_fpga_of_match[] = {
@@ -205,7 +194,6 @@ MODULE_DEVICE_TABLE(of, ice40_fpga_of_match);
 
 static struct spi_driver ice40_fpga_driver = {
 	.probe = ice40_fpga_probe,
-	.remove = ice40_fpga_remove,
 	.driver = {
 		.name = "ice40spi",
 		.of_match_table = of_match_ptr(ice40_fpga_of_match),
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 51+ messages in thread

* [PATCH 04/10] fpga: fpga-mgr: ice40-spi: Simplify registration
@ 2020-10-04  5:14   ` Moritz Fischer
  0 siblings, 0 replies; 51+ messages in thread
From: Moritz Fischer @ 2020-10-04  5:14 UTC (permalink / raw)
  To: linux-fpga
  Cc: russell.h.weight, trix, michal.simek, matthew.gerlach,
	linux-kernel, Moritz Fischer, linux-arm-kernel, hao.wu

Simplify registration using new devm_fpga_mgr_register() API.

Signed-off-by: Moritz Fischer <mdf@kernel.org>
---
 drivers/fpga/ice40-spi.c | 14 +-------------
 1 file changed, 1 insertion(+), 13 deletions(-)

diff --git a/drivers/fpga/ice40-spi.c b/drivers/fpga/ice40-spi.c
index 8d689fea0dab..69dec5af23c3 100644
--- a/drivers/fpga/ice40-spi.c
+++ b/drivers/fpga/ice40-spi.c
@@ -183,18 +183,7 @@ static int ice40_fpga_probe(struct spi_device *spi)
 	if (!mgr)
 		return -ENOMEM;
 
-	spi_set_drvdata(spi, mgr);
-
-	return fpga_mgr_register(mgr);
-}
-
-static int ice40_fpga_remove(struct spi_device *spi)
-{
-	struct fpga_manager *mgr = spi_get_drvdata(spi);
-
-	fpga_mgr_unregister(mgr);
-
-	return 0;
+	return devm_fpga_mgr_register(dev, mgr);
 }
 
 static const struct of_device_id ice40_fpga_of_match[] = {
@@ -205,7 +194,6 @@ MODULE_DEVICE_TABLE(of, ice40_fpga_of_match);
 
 static struct spi_driver ice40_fpga_driver = {
 	.probe = ice40_fpga_probe,
-	.remove = ice40_fpga_remove,
 	.driver = {
 		.name = "ice40spi",
 		.of_match_table = of_match_ptr(ice40_fpga_of_match),
-- 
2.28.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 51+ messages in thread

* [PATCH 05/10] fpga: fpga-mgr: machxo2-spi: Simplify registration
  2020-10-04  5:14 ` Moritz Fischer
@ 2020-10-04  5:14   ` Moritz Fischer
  -1 siblings, 0 replies; 51+ messages in thread
From: Moritz Fischer @ 2020-10-04  5:14 UTC (permalink / raw)
  To: linux-fpga
  Cc: trix, hao.wu, michal.simek, linux-kernel, linux-arm-kernel,
	russell.h.weight, matthew.gerlach, Moritz Fischer

Simplify registration using new devm_fpga_mgr_register() API.

Signed-off-by: Moritz Fischer <mdf@kernel.org>
---
 drivers/fpga/machxo2-spi.c | 14 +-------------
 1 file changed, 1 insertion(+), 13 deletions(-)

diff --git a/drivers/fpga/machxo2-spi.c b/drivers/fpga/machxo2-spi.c
index b316369156fe..114a64d2b7a4 100644
--- a/drivers/fpga/machxo2-spi.c
+++ b/drivers/fpga/machxo2-spi.c
@@ -371,18 +371,7 @@ static int machxo2_spi_probe(struct spi_device *spi)
 	if (!mgr)
 		return -ENOMEM;
 
-	spi_set_drvdata(spi, mgr);
-
-	return fpga_mgr_register(mgr);
-}
-
-static int machxo2_spi_remove(struct spi_device *spi)
-{
-	struct fpga_manager *mgr = spi_get_drvdata(spi);
-
-	fpga_mgr_unregister(mgr);
-
-	return 0;
+	return devm_fpga_mgr_register(dev, mgr);
 }
 
 static const struct of_device_id of_match[] = {
@@ -403,7 +392,6 @@ static struct spi_driver machxo2_spi_driver = {
 		.of_match_table = of_match_ptr(of_match),
 	},
 	.probe = machxo2_spi_probe,
-	.remove = machxo2_spi_remove,
 	.id_table = lattice_ids,
 };
 
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 51+ messages in thread

* [PATCH 05/10] fpga: fpga-mgr: machxo2-spi: Simplify registration
@ 2020-10-04  5:14   ` Moritz Fischer
  0 siblings, 0 replies; 51+ messages in thread
From: Moritz Fischer @ 2020-10-04  5:14 UTC (permalink / raw)
  To: linux-fpga
  Cc: russell.h.weight, trix, michal.simek, matthew.gerlach,
	linux-kernel, Moritz Fischer, linux-arm-kernel, hao.wu

Simplify registration using new devm_fpga_mgr_register() API.

Signed-off-by: Moritz Fischer <mdf@kernel.org>
---
 drivers/fpga/machxo2-spi.c | 14 +-------------
 1 file changed, 1 insertion(+), 13 deletions(-)

diff --git a/drivers/fpga/machxo2-spi.c b/drivers/fpga/machxo2-spi.c
index b316369156fe..114a64d2b7a4 100644
--- a/drivers/fpga/machxo2-spi.c
+++ b/drivers/fpga/machxo2-spi.c
@@ -371,18 +371,7 @@ static int machxo2_spi_probe(struct spi_device *spi)
 	if (!mgr)
 		return -ENOMEM;
 
-	spi_set_drvdata(spi, mgr);
-
-	return fpga_mgr_register(mgr);
-}
-
-static int machxo2_spi_remove(struct spi_device *spi)
-{
-	struct fpga_manager *mgr = spi_get_drvdata(spi);
-
-	fpga_mgr_unregister(mgr);
-
-	return 0;
+	return devm_fpga_mgr_register(dev, mgr);
 }
 
 static const struct of_device_id of_match[] = {
@@ -403,7 +392,6 @@ static struct spi_driver machxo2_spi_driver = {
 		.of_match_table = of_match_ptr(of_match),
 	},
 	.probe = machxo2_spi_probe,
-	.remove = machxo2_spi_remove,
 	.id_table = lattice_ids,
 };
 
-- 
2.28.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 51+ messages in thread

* [PATCH 06/10] fpga: fpga-mgr: socfpga: Simplify registration
  2020-10-04  5:14 ` Moritz Fischer
@ 2020-10-04  5:14   ` Moritz Fischer
  -1 siblings, 0 replies; 51+ messages in thread
From: Moritz Fischer @ 2020-10-04  5:14 UTC (permalink / raw)
  To: linux-fpga
  Cc: trix, hao.wu, michal.simek, linux-kernel, linux-arm-kernel,
	russell.h.weight, matthew.gerlach, Moritz Fischer

Simplify registration using new devm_fpga_mgr_register() API.

Signed-off-by: Moritz Fischer <mdf@kernel.org>
---
 drivers/fpga/socfpga.c | 14 +-------------
 1 file changed, 1 insertion(+), 13 deletions(-)

diff --git a/drivers/fpga/socfpga.c b/drivers/fpga/socfpga.c
index 4a8a2fcd4e6c..1f467173fc1f 100644
--- a/drivers/fpga/socfpga.c
+++ b/drivers/fpga/socfpga.c
@@ -576,18 +576,7 @@ static int socfpga_fpga_probe(struct platform_device *pdev)
 	if (!mgr)
 		return -ENOMEM;
 
-	platform_set_drvdata(pdev, mgr);
-
-	return fpga_mgr_register(mgr);
-}
-
-static int socfpga_fpga_remove(struct platform_device *pdev)
-{
-	struct fpga_manager *mgr = platform_get_drvdata(pdev);
-
-	fpga_mgr_unregister(mgr);
-
-	return 0;
+	return devm_fpga_mgr_register(dev, mgr);
 }
 
 #ifdef CONFIG_OF
@@ -601,7 +590,6 @@ MODULE_DEVICE_TABLE(of, socfpga_fpga_of_match);
 
 static struct platform_driver socfpga_fpga_driver = {
 	.probe = socfpga_fpga_probe,
-	.remove = socfpga_fpga_remove,
 	.driver = {
 		.name	= "socfpga_fpga_manager",
 		.of_match_table = of_match_ptr(socfpga_fpga_of_match),
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 51+ messages in thread

* [PATCH 06/10] fpga: fpga-mgr: socfpga: Simplify registration
@ 2020-10-04  5:14   ` Moritz Fischer
  0 siblings, 0 replies; 51+ messages in thread
From: Moritz Fischer @ 2020-10-04  5:14 UTC (permalink / raw)
  To: linux-fpga
  Cc: russell.h.weight, trix, michal.simek, matthew.gerlach,
	linux-kernel, Moritz Fischer, linux-arm-kernel, hao.wu

Simplify registration using new devm_fpga_mgr_register() API.

Signed-off-by: Moritz Fischer <mdf@kernel.org>
---
 drivers/fpga/socfpga.c | 14 +-------------
 1 file changed, 1 insertion(+), 13 deletions(-)

diff --git a/drivers/fpga/socfpga.c b/drivers/fpga/socfpga.c
index 4a8a2fcd4e6c..1f467173fc1f 100644
--- a/drivers/fpga/socfpga.c
+++ b/drivers/fpga/socfpga.c
@@ -576,18 +576,7 @@ static int socfpga_fpga_probe(struct platform_device *pdev)
 	if (!mgr)
 		return -ENOMEM;
 
-	platform_set_drvdata(pdev, mgr);
-
-	return fpga_mgr_register(mgr);
-}
-
-static int socfpga_fpga_remove(struct platform_device *pdev)
-{
-	struct fpga_manager *mgr = platform_get_drvdata(pdev);
-
-	fpga_mgr_unregister(mgr);
-
-	return 0;
+	return devm_fpga_mgr_register(dev, mgr);
 }
 
 #ifdef CONFIG_OF
@@ -601,7 +590,6 @@ MODULE_DEVICE_TABLE(of, socfpga_fpga_of_match);
 
 static struct platform_driver socfpga_fpga_driver = {
 	.probe = socfpga_fpga_probe,
-	.remove = socfpga_fpga_remove,
 	.driver = {
 		.name	= "socfpga_fpga_manager",
 		.of_match_table = of_match_ptr(socfpga_fpga_of_match),
-- 
2.28.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 51+ messages in thread

* [PATCH 07/10] fpga: fpga-mgr: ts73xx: Simplify registration
  2020-10-04  5:14 ` Moritz Fischer
@ 2020-10-04  5:14   ` Moritz Fischer
  -1 siblings, 0 replies; 51+ messages in thread
From: Moritz Fischer @ 2020-10-04  5:14 UTC (permalink / raw)
  To: linux-fpga
  Cc: trix, hao.wu, michal.simek, linux-kernel, linux-arm-kernel,
	russell.h.weight, matthew.gerlach, Moritz Fischer

Simplify registration using new devm_fpga_mgr_register() API.

Signed-off-by: Moritz Fischer <mdf@kernel.org>
---
 drivers/fpga/ts73xx-fpga.c | 14 +-------------
 1 file changed, 1 insertion(+), 13 deletions(-)

diff --git a/drivers/fpga/ts73xx-fpga.c b/drivers/fpga/ts73xx-fpga.c
index 2888ff000e4d..101f016c6ed8 100644
--- a/drivers/fpga/ts73xx-fpga.c
+++ b/drivers/fpga/ts73xx-fpga.c
@@ -127,18 +127,7 @@ static int ts73xx_fpga_probe(struct platform_device *pdev)
 	if (!mgr)
 		return -ENOMEM;
 
-	platform_set_drvdata(pdev, mgr);
-
-	return fpga_mgr_register(mgr);
-}
-
-static int ts73xx_fpga_remove(struct platform_device *pdev)
-{
-	struct fpga_manager *mgr = platform_get_drvdata(pdev);
-
-	fpga_mgr_unregister(mgr);
-
-	return 0;
+	return devm_fpga_mgr_register(kdev, mgr);
 }
 
 static struct platform_driver ts73xx_fpga_driver = {
@@ -146,7 +135,6 @@ static struct platform_driver ts73xx_fpga_driver = {
 		.name	= "ts73xx-fpga-mgr",
 	},
 	.probe	= ts73xx_fpga_probe,
-	.remove	= ts73xx_fpga_remove,
 };
 module_platform_driver(ts73xx_fpga_driver);
 
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 51+ messages in thread

* [PATCH 07/10] fpga: fpga-mgr: ts73xx: Simplify registration
@ 2020-10-04  5:14   ` Moritz Fischer
  0 siblings, 0 replies; 51+ messages in thread
From: Moritz Fischer @ 2020-10-04  5:14 UTC (permalink / raw)
  To: linux-fpga
  Cc: russell.h.weight, trix, michal.simek, matthew.gerlach,
	linux-kernel, Moritz Fischer, linux-arm-kernel, hao.wu

Simplify registration using new devm_fpga_mgr_register() API.

Signed-off-by: Moritz Fischer <mdf@kernel.org>
---
 drivers/fpga/ts73xx-fpga.c | 14 +-------------
 1 file changed, 1 insertion(+), 13 deletions(-)

diff --git a/drivers/fpga/ts73xx-fpga.c b/drivers/fpga/ts73xx-fpga.c
index 2888ff000e4d..101f016c6ed8 100644
--- a/drivers/fpga/ts73xx-fpga.c
+++ b/drivers/fpga/ts73xx-fpga.c
@@ -127,18 +127,7 @@ static int ts73xx_fpga_probe(struct platform_device *pdev)
 	if (!mgr)
 		return -ENOMEM;
 
-	platform_set_drvdata(pdev, mgr);
-
-	return fpga_mgr_register(mgr);
-}
-
-static int ts73xx_fpga_remove(struct platform_device *pdev)
-{
-	struct fpga_manager *mgr = platform_get_drvdata(pdev);
-
-	fpga_mgr_unregister(mgr);
-
-	return 0;
+	return devm_fpga_mgr_register(kdev, mgr);
 }
 
 static struct platform_driver ts73xx_fpga_driver = {
@@ -146,7 +135,6 @@ static struct platform_driver ts73xx_fpga_driver = {
 		.name	= "ts73xx-fpga-mgr",
 	},
 	.probe	= ts73xx_fpga_probe,
-	.remove	= ts73xx_fpga_remove,
 };
 module_platform_driver(ts73xx_fpga_driver);
 
-- 
2.28.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 51+ messages in thread

* [PATCH 08/10] fpga: fpga-mgr: xilinx-spi: Simplify registration
  2020-10-04  5:14 ` Moritz Fischer
@ 2020-10-04  5:14   ` Moritz Fischer
  -1 siblings, 0 replies; 51+ messages in thread
From: Moritz Fischer @ 2020-10-04  5:14 UTC (permalink / raw)
  To: linux-fpga
  Cc: trix, hao.wu, michal.simek, linux-kernel, linux-arm-kernel,
	russell.h.weight, matthew.gerlach, Moritz Fischer

Simplify registration using new devm_fpga_mgr_register() API.

Signed-off-by: Moritz Fischer <mdf@kernel.org>
---
 drivers/fpga/xilinx-spi.c | 14 +-------------
 1 file changed, 1 insertion(+), 13 deletions(-)

diff --git a/drivers/fpga/xilinx-spi.c b/drivers/fpga/xilinx-spi.c
index 824abbbd631e..27defa98092d 100644
--- a/drivers/fpga/xilinx-spi.c
+++ b/drivers/fpga/xilinx-spi.c
@@ -259,18 +259,7 @@ static int xilinx_spi_probe(struct spi_device *spi)
 	if (!mgr)
 		return -ENOMEM;
 
-	spi_set_drvdata(spi, mgr);
-
-	return fpga_mgr_register(mgr);
-}
-
-static int xilinx_spi_remove(struct spi_device *spi)
-{
-	struct fpga_manager *mgr = spi_get_drvdata(spi);
-
-	fpga_mgr_unregister(mgr);
-
-	return 0;
+	return devm_fpga_mgr_register(&spi->dev, mgr);
 }
 
 static const struct of_device_id xlnx_spi_of_match[] = {
@@ -285,7 +274,6 @@ static struct spi_driver xilinx_slave_spi_driver = {
 		.of_match_table = of_match_ptr(xlnx_spi_of_match),
 	},
 	.probe = xilinx_spi_probe,
-	.remove = xilinx_spi_remove,
 };
 
 module_spi_driver(xilinx_slave_spi_driver)
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 51+ messages in thread

* [PATCH 08/10] fpga: fpga-mgr: xilinx-spi: Simplify registration
@ 2020-10-04  5:14   ` Moritz Fischer
  0 siblings, 0 replies; 51+ messages in thread
From: Moritz Fischer @ 2020-10-04  5:14 UTC (permalink / raw)
  To: linux-fpga
  Cc: russell.h.weight, trix, michal.simek, matthew.gerlach,
	linux-kernel, Moritz Fischer, linux-arm-kernel, hao.wu

Simplify registration using new devm_fpga_mgr_register() API.

Signed-off-by: Moritz Fischer <mdf@kernel.org>
---
 drivers/fpga/xilinx-spi.c | 14 +-------------
 1 file changed, 1 insertion(+), 13 deletions(-)

diff --git a/drivers/fpga/xilinx-spi.c b/drivers/fpga/xilinx-spi.c
index 824abbbd631e..27defa98092d 100644
--- a/drivers/fpga/xilinx-spi.c
+++ b/drivers/fpga/xilinx-spi.c
@@ -259,18 +259,7 @@ static int xilinx_spi_probe(struct spi_device *spi)
 	if (!mgr)
 		return -ENOMEM;
 
-	spi_set_drvdata(spi, mgr);
-
-	return fpga_mgr_register(mgr);
-}
-
-static int xilinx_spi_remove(struct spi_device *spi)
-{
-	struct fpga_manager *mgr = spi_get_drvdata(spi);
-
-	fpga_mgr_unregister(mgr);
-
-	return 0;
+	return devm_fpga_mgr_register(&spi->dev, mgr);
 }
 
 static const struct of_device_id xlnx_spi_of_match[] = {
@@ -285,7 +274,6 @@ static struct spi_driver xilinx_slave_spi_driver = {
 		.of_match_table = of_match_ptr(xlnx_spi_of_match),
 	},
 	.probe = xilinx_spi_probe,
-	.remove = xilinx_spi_remove,
 };
 
 module_spi_driver(xilinx_slave_spi_driver)
-- 
2.28.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 51+ messages in thread

* [PATCH 09/10] fpga: fpga-mgr: zynqmp: Simplify registration
  2020-10-04  5:14 ` Moritz Fischer
@ 2020-10-04  5:14   ` Moritz Fischer
  -1 siblings, 0 replies; 51+ messages in thread
From: Moritz Fischer @ 2020-10-04  5:14 UTC (permalink / raw)
  To: linux-fpga
  Cc: trix, hao.wu, michal.simek, linux-kernel, linux-arm-kernel,
	russell.h.weight, matthew.gerlach, Moritz Fischer

Simplify registration using new devm_fpga_mgr_register() API.

Signed-off-by: Moritz Fischer <mdf@kernel.org>
---
 drivers/fpga/zynqmp-fpga.c | 21 +--------------------
 1 file changed, 1 insertion(+), 20 deletions(-)

diff --git a/drivers/fpga/zynqmp-fpga.c b/drivers/fpga/zynqmp-fpga.c
index 4a1139e05280..125743c9797f 100644
--- a/drivers/fpga/zynqmp-fpga.c
+++ b/drivers/fpga/zynqmp-fpga.c
@@ -95,7 +95,6 @@ static int zynqmp_fpga_probe(struct platform_device *pdev)
 	struct device *dev = &pdev->dev;
 	struct zynqmp_fpga_priv *priv;
 	struct fpga_manager *mgr;
-	int ret;
 
 	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
 	if (!priv)
@@ -108,24 +107,7 @@ static int zynqmp_fpga_probe(struct platform_device *pdev)
 	if (!mgr)
 		return -ENOMEM;
 
-	platform_set_drvdata(pdev, mgr);
-
-	ret = fpga_mgr_register(mgr);
-	if (ret) {
-		dev_err(dev, "unable to register FPGA manager");
-		return ret;
-	}
-
-	return 0;
-}
-
-static int zynqmp_fpga_remove(struct platform_device *pdev)
-{
-	struct fpga_manager *mgr = platform_get_drvdata(pdev);
-
-	fpga_mgr_unregister(mgr);
-
-	return 0;
+	return devm_fpga_mgr_register(dev, mgr);
 }
 
 static const struct of_device_id zynqmp_fpga_of_match[] = {
@@ -137,7 +119,6 @@ MODULE_DEVICE_TABLE(of, zynqmp_fpga_of_match);
 
 static struct platform_driver zynqmp_fpga_driver = {
 	.probe = zynqmp_fpga_probe,
-	.remove = zynqmp_fpga_remove,
 	.driver = {
 		.name = "zynqmp_fpga_manager",
 		.of_match_table = of_match_ptr(zynqmp_fpga_of_match),
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 51+ messages in thread

* [PATCH 09/10] fpga: fpga-mgr: zynqmp: Simplify registration
@ 2020-10-04  5:14   ` Moritz Fischer
  0 siblings, 0 replies; 51+ messages in thread
From: Moritz Fischer @ 2020-10-04  5:14 UTC (permalink / raw)
  To: linux-fpga
  Cc: russell.h.weight, trix, michal.simek, matthew.gerlach,
	linux-kernel, Moritz Fischer, linux-arm-kernel, hao.wu

Simplify registration using new devm_fpga_mgr_register() API.

Signed-off-by: Moritz Fischer <mdf@kernel.org>
---
 drivers/fpga/zynqmp-fpga.c | 21 +--------------------
 1 file changed, 1 insertion(+), 20 deletions(-)

diff --git a/drivers/fpga/zynqmp-fpga.c b/drivers/fpga/zynqmp-fpga.c
index 4a1139e05280..125743c9797f 100644
--- a/drivers/fpga/zynqmp-fpga.c
+++ b/drivers/fpga/zynqmp-fpga.c
@@ -95,7 +95,6 @@ static int zynqmp_fpga_probe(struct platform_device *pdev)
 	struct device *dev = &pdev->dev;
 	struct zynqmp_fpga_priv *priv;
 	struct fpga_manager *mgr;
-	int ret;
 
 	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
 	if (!priv)
@@ -108,24 +107,7 @@ static int zynqmp_fpga_probe(struct platform_device *pdev)
 	if (!mgr)
 		return -ENOMEM;
 
-	platform_set_drvdata(pdev, mgr);
-
-	ret = fpga_mgr_register(mgr);
-	if (ret) {
-		dev_err(dev, "unable to register FPGA manager");
-		return ret;
-	}
-
-	return 0;
-}
-
-static int zynqmp_fpga_remove(struct platform_device *pdev)
-{
-	struct fpga_manager *mgr = platform_get_drvdata(pdev);
-
-	fpga_mgr_unregister(mgr);
-
-	return 0;
+	return devm_fpga_mgr_register(dev, mgr);
 }
 
 static const struct of_device_id zynqmp_fpga_of_match[] = {
@@ -137,7 +119,6 @@ MODULE_DEVICE_TABLE(of, zynqmp_fpga_of_match);
 
 static struct platform_driver zynqmp_fpga_driver = {
 	.probe = zynqmp_fpga_probe,
-	.remove = zynqmp_fpga_remove,
 	.driver = {
 		.name = "zynqmp_fpga_manager",
 		.of_match_table = of_match_ptr(zynqmp_fpga_of_match),
-- 
2.28.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 51+ messages in thread

* [PATCH 10/10] fpga: fpga-mgr: altera-pr-ip: Simplify registration
  2020-10-04  5:14 ` Moritz Fischer
@ 2020-10-04  5:14   ` Moritz Fischer
  -1 siblings, 0 replies; 51+ messages in thread
From: Moritz Fischer @ 2020-10-04  5:14 UTC (permalink / raw)
  To: linux-fpga
  Cc: trix, hao.wu, michal.simek, linux-kernel, linux-arm-kernel,
	russell.h.weight, matthew.gerlach, Moritz Fischer

Simplify registration using new devm_fpga_mgr_register() API.
Remove the now obsolete altera_pr_unregister() function.

Signed-off-by: Moritz Fischer <mdf@kernel.org>
---

We should take another look at this, IIRC correctly the point of
splitting this up into a separate driver was to make it useable by a
different (pci?) driver later on.

It doesn't seem like this happened, and I think we should just make this
a platform driver?

---
 drivers/fpga/altera-pr-ip-core-plat.c  | 10 ----------
 drivers/fpga/altera-pr-ip-core.c       | 14 +-------------
 include/linux/fpga/altera-pr-ip-core.h |  1 -
 3 files changed, 1 insertion(+), 24 deletions(-)

diff --git a/drivers/fpga/altera-pr-ip-core-plat.c b/drivers/fpga/altera-pr-ip-core-plat.c
index 99b9cc0e70f0..b008a6b8d2d3 100644
--- a/drivers/fpga/altera-pr-ip-core-plat.c
+++ b/drivers/fpga/altera-pr-ip-core-plat.c
@@ -28,15 +28,6 @@ static int alt_pr_platform_probe(struct platform_device *pdev)
 	return alt_pr_register(dev, reg_base);
 }
 
-static int alt_pr_platform_remove(struct platform_device *pdev)
-{
-	struct device *dev = &pdev->dev;
-
-	alt_pr_unregister(dev);
-
-	return 0;
-}
-
 static const struct of_device_id alt_pr_of_match[] = {
 	{ .compatible = "altr,a10-pr-ip", },
 	{},
@@ -46,7 +37,6 @@ MODULE_DEVICE_TABLE(of, alt_pr_of_match);
 
 static struct platform_driver alt_pr_platform_driver = {
 	.probe = alt_pr_platform_probe,
-	.remove = alt_pr_platform_remove,
 	.driver = {
 		.name	= "alt_a10_pr_ip",
 		.of_match_table = alt_pr_of_match,
diff --git a/drivers/fpga/altera-pr-ip-core.c b/drivers/fpga/altera-pr-ip-core.c
index 2cf25fd5e897..dfdf21ed34c4 100644
--- a/drivers/fpga/altera-pr-ip-core.c
+++ b/drivers/fpga/altera-pr-ip-core.c
@@ -195,22 +195,10 @@ int alt_pr_register(struct device *dev, void __iomem *reg_base)
 	if (!mgr)
 		return -ENOMEM;
 
-	dev_set_drvdata(dev, mgr);
-
-	return fpga_mgr_register(mgr);
+	return devm_fpga_mgr_register(dev, mgr);
 }
 EXPORT_SYMBOL_GPL(alt_pr_register);
 
-void alt_pr_unregister(struct device *dev)
-{
-	struct fpga_manager *mgr = dev_get_drvdata(dev);
-
-	dev_dbg(dev, "%s\n", __func__);
-
-	fpga_mgr_unregister(mgr);
-}
-EXPORT_SYMBOL_GPL(alt_pr_unregister);
-
 MODULE_AUTHOR("Matthew Gerlach <matthew.gerlach@linux.intel.com>");
 MODULE_DESCRIPTION("Altera Partial Reconfiguration IP Core");
 MODULE_LICENSE("GPL v2");
diff --git a/include/linux/fpga/altera-pr-ip-core.h b/include/linux/fpga/altera-pr-ip-core.h
index 0b08ac20ab16..a6b4c07858cc 100644
--- a/include/linux/fpga/altera-pr-ip-core.h
+++ b/include/linux/fpga/altera-pr-ip-core.h
@@ -13,6 +13,5 @@
 #include <linux/io.h>
 
 int alt_pr_register(struct device *dev, void __iomem *reg_base);
-void alt_pr_unregister(struct device *dev);
 
 #endif /* _ALT_PR_IP_CORE_H */
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 51+ messages in thread

* [PATCH 10/10] fpga: fpga-mgr: altera-pr-ip: Simplify registration
@ 2020-10-04  5:14   ` Moritz Fischer
  0 siblings, 0 replies; 51+ messages in thread
From: Moritz Fischer @ 2020-10-04  5:14 UTC (permalink / raw)
  To: linux-fpga
  Cc: russell.h.weight, trix, michal.simek, matthew.gerlach,
	linux-kernel, Moritz Fischer, linux-arm-kernel, hao.wu

Simplify registration using new devm_fpga_mgr_register() API.
Remove the now obsolete altera_pr_unregister() function.

Signed-off-by: Moritz Fischer <mdf@kernel.org>
---

We should take another look at this, IIRC correctly the point of
splitting this up into a separate driver was to make it useable by a
different (pci?) driver later on.

It doesn't seem like this happened, and I think we should just make this
a platform driver?

---
 drivers/fpga/altera-pr-ip-core-plat.c  | 10 ----------
 drivers/fpga/altera-pr-ip-core.c       | 14 +-------------
 include/linux/fpga/altera-pr-ip-core.h |  1 -
 3 files changed, 1 insertion(+), 24 deletions(-)

diff --git a/drivers/fpga/altera-pr-ip-core-plat.c b/drivers/fpga/altera-pr-ip-core-plat.c
index 99b9cc0e70f0..b008a6b8d2d3 100644
--- a/drivers/fpga/altera-pr-ip-core-plat.c
+++ b/drivers/fpga/altera-pr-ip-core-plat.c
@@ -28,15 +28,6 @@ static int alt_pr_platform_probe(struct platform_device *pdev)
 	return alt_pr_register(dev, reg_base);
 }
 
-static int alt_pr_platform_remove(struct platform_device *pdev)
-{
-	struct device *dev = &pdev->dev;
-
-	alt_pr_unregister(dev);
-
-	return 0;
-}
-
 static const struct of_device_id alt_pr_of_match[] = {
 	{ .compatible = "altr,a10-pr-ip", },
 	{},
@@ -46,7 +37,6 @@ MODULE_DEVICE_TABLE(of, alt_pr_of_match);
 
 static struct platform_driver alt_pr_platform_driver = {
 	.probe = alt_pr_platform_probe,
-	.remove = alt_pr_platform_remove,
 	.driver = {
 		.name	= "alt_a10_pr_ip",
 		.of_match_table = alt_pr_of_match,
diff --git a/drivers/fpga/altera-pr-ip-core.c b/drivers/fpga/altera-pr-ip-core.c
index 2cf25fd5e897..dfdf21ed34c4 100644
--- a/drivers/fpga/altera-pr-ip-core.c
+++ b/drivers/fpga/altera-pr-ip-core.c
@@ -195,22 +195,10 @@ int alt_pr_register(struct device *dev, void __iomem *reg_base)
 	if (!mgr)
 		return -ENOMEM;
 
-	dev_set_drvdata(dev, mgr);
-
-	return fpga_mgr_register(mgr);
+	return devm_fpga_mgr_register(dev, mgr);
 }
 EXPORT_SYMBOL_GPL(alt_pr_register);
 
-void alt_pr_unregister(struct device *dev)
-{
-	struct fpga_manager *mgr = dev_get_drvdata(dev);
-
-	dev_dbg(dev, "%s\n", __func__);
-
-	fpga_mgr_unregister(mgr);
-}
-EXPORT_SYMBOL_GPL(alt_pr_unregister);
-
 MODULE_AUTHOR("Matthew Gerlach <matthew.gerlach@linux.intel.com>");
 MODULE_DESCRIPTION("Altera Partial Reconfiguration IP Core");
 MODULE_LICENSE("GPL v2");
diff --git a/include/linux/fpga/altera-pr-ip-core.h b/include/linux/fpga/altera-pr-ip-core.h
index 0b08ac20ab16..a6b4c07858cc 100644
--- a/include/linux/fpga/altera-pr-ip-core.h
+++ b/include/linux/fpga/altera-pr-ip-core.h
@@ -13,6 +13,5 @@
 #include <linux/io.h>
 
 int alt_pr_register(struct device *dev, void __iomem *reg_base);
-void alt_pr_unregister(struct device *dev);
 
 #endif /* _ALT_PR_IP_CORE_H */
-- 
2.28.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 51+ messages in thread

* Re: [PATCH 01/10] fpga: fpga-mgr: Add devm_fpga_mgr_register() API
  2020-10-04  5:14   ` Moritz Fischer
@ 2020-10-04 18:08     ` Tom Rix
  -1 siblings, 0 replies; 51+ messages in thread
From: Tom Rix @ 2020-10-04 18:08 UTC (permalink / raw)
  To: Moritz Fischer, linux-fpga
  Cc: hao.wu, michal.simek, linux-kernel, linux-arm-kernel,
	russell.h.weight, matthew.gerlach


On 10/3/20 10:14 PM, Moritz Fischer wrote:
> Add a devm_fpga_mgr_register() API that can be used to register a FPGA
> Manager that was created using devm_fpga_mgr_create().
>
> Introduce a struct fpga_mgr_devres that makes the devres
> allocation a little bit more readable and gets reused for
> devm_fpga_mgr_create() devm_fpga_mgr_register().
>
> Signed-off-by: Moritz Fischer <mdf@kernel.org>
> ---
>  drivers/fpga/fpga-mgr.c       | 76 ++++++++++++++++++++++++++++++-----
>  include/linux/fpga/fpga-mgr.h |  2 +
>  2 files changed, 68 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c
> index f38bab01432e..774ac98fb69c 100644
> --- a/drivers/fpga/fpga-mgr.c
> +++ b/drivers/fpga/fpga-mgr.c
> @@ -21,6 +21,10 @@
>  static DEFINE_IDA(fpga_mgr_ida);
>  static struct class *fpga_mgr_class;
>  
> +struct fpga_mgr_devres {
> +	struct fpga_manager *mgr;
> +};
> +
>  /**
>   * fpga_image_info_alloc - Allocate a FPGA image info struct
>   * @dev: owning device
> @@ -651,21 +655,21 @@ struct fpga_manager *devm_fpga_mgr_create(struct device *dev, const char *name,
>  					  const struct fpga_manager_ops *mops,
>  					  void *priv)
>  {
> -	struct fpga_manager **ptr, *mgr;
> +	struct fpga_mgr_devres *dr;
>  
> -	ptr = devres_alloc(devm_fpga_mgr_release, sizeof(*ptr), GFP_KERNEL);
> -	if (!ptr)
> +	dr = devres_alloc(devm_fpga_mgr_release, sizeof(*dr), GFP_KERNEL);
> +	if (!dr)
>  		return NULL;
>  
> -	mgr = fpga_mgr_create(dev, name, mops, priv);
> -	if (!mgr) {
> -		devres_free(ptr);
> -	} else {
> -		*ptr = mgr;
> -		devres_add(dev, ptr);
> +	dr->mgr = fpga_mgr_create(dev, name, mops, priv);
> +	if (!dr->mgr) {
> +		devres_free(dr);
> +		return NULL;
>  	}
>  
> -	return mgr;
> +	devres_add(dev, dr);
> +
> +	return dr->mgr;
>  }
>  EXPORT_SYMBOL_GPL(devm_fpga_mgr_create);
>  
> @@ -722,6 +726,58 @@ void fpga_mgr_unregister(struct fpga_manager *mgr)
>  }
>  EXPORT_SYMBOL_GPL(fpga_mgr_unregister);
>  
> +static int fpga_mgr_devres_match(struct device *dev, void *priv,
> +				 void *match_data)
> +{
> +	struct fpga_mgr_devres *dr = priv;
> +
> +	return match_data == dr->mgr;
> +}
> +
> +static void devm_fpga_mgr_unregister(struct device *dev, void *priv)
> +{
> +	struct fpga_mgr_devres *dr = priv;
> +
> +	fpga_mgr_unregister(dr->mgr);
> +}
> +
> +/**
> + * devm_fpga_mgr_register - resource managed variant of fpga_mgr_register()
> + * @dev: managing device for this FPGA manager
> + * @mgr: fpga manager struct
> + *
> + * This is the devres variant of fpga_mgr_register() for which the unregister
> + * function will be called automatically when the managing device is detached.
> + */
> +int devm_fpga_mgr_register(struct device *dev, struct fpga_manager *mgr)
> +{
> +	struct fpga_mgr_devres *dr;
> +	int err;

nit

int ret;

Fine if it isn't changed.

Reviewed-by: Tom Rix <trix@redhat.com>

> +
> +	/* Make sure that the struct fpga_manager * that is passed in is
> +	 * managed itself.
> +	 */
> +	if (WARN_ON(!devres_find(dev, devm_fpga_mgr_release,
> +				 fpga_mgr_devres_match, mgr)))
> +		return -EINVAL;
> +
> +	dr = devres_alloc(devm_fpga_mgr_unregister, sizeof(*dr), GFP_KERNEL);
> +	if (!dr)
> +		return -ENOMEM;
> +
> +	err = fpga_mgr_register(mgr);
> +	if (err) {
> +		devres_free(dr);
> +		return err;
> +	}
> +
> +	dr->mgr = mgr;
> +	devres_add(dev, dr);
> +
> +	return 0;
> +}
> +EXPORT_SYMBOL_GPL(devm_fpga_mgr_register);
> +
>  static void fpga_mgr_dev_release(struct device *dev)
>  {
>  }
> diff --git a/include/linux/fpga/fpga-mgr.h b/include/linux/fpga/fpga-mgr.h
> index e8ca62b2cb5b..2bc3030a69e5 100644
> --- a/include/linux/fpga/fpga-mgr.h
> +++ b/include/linux/fpga/fpga-mgr.h
> @@ -198,6 +198,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);
>  
> +int devm_fpga_mgr_register(struct device *dev, 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);


^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [PATCH 01/10] fpga: fpga-mgr: Add devm_fpga_mgr_register() API
@ 2020-10-04 18:08     ` Tom Rix
  0 siblings, 0 replies; 51+ messages in thread
From: Tom Rix @ 2020-10-04 18:08 UTC (permalink / raw)
  To: Moritz Fischer, linux-fpga
  Cc: russell.h.weight, linux-kernel, matthew.gerlach, michal.simek,
	linux-arm-kernel, hao.wu


On 10/3/20 10:14 PM, Moritz Fischer wrote:
> Add a devm_fpga_mgr_register() API that can be used to register a FPGA
> Manager that was created using devm_fpga_mgr_create().
>
> Introduce a struct fpga_mgr_devres that makes the devres
> allocation a little bit more readable and gets reused for
> devm_fpga_mgr_create() devm_fpga_mgr_register().
>
> Signed-off-by: Moritz Fischer <mdf@kernel.org>
> ---
>  drivers/fpga/fpga-mgr.c       | 76 ++++++++++++++++++++++++++++++-----
>  include/linux/fpga/fpga-mgr.h |  2 +
>  2 files changed, 68 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c
> index f38bab01432e..774ac98fb69c 100644
> --- a/drivers/fpga/fpga-mgr.c
> +++ b/drivers/fpga/fpga-mgr.c
> @@ -21,6 +21,10 @@
>  static DEFINE_IDA(fpga_mgr_ida);
>  static struct class *fpga_mgr_class;
>  
> +struct fpga_mgr_devres {
> +	struct fpga_manager *mgr;
> +};
> +
>  /**
>   * fpga_image_info_alloc - Allocate a FPGA image info struct
>   * @dev: owning device
> @@ -651,21 +655,21 @@ struct fpga_manager *devm_fpga_mgr_create(struct device *dev, const char *name,
>  					  const struct fpga_manager_ops *mops,
>  					  void *priv)
>  {
> -	struct fpga_manager **ptr, *mgr;
> +	struct fpga_mgr_devres *dr;
>  
> -	ptr = devres_alloc(devm_fpga_mgr_release, sizeof(*ptr), GFP_KERNEL);
> -	if (!ptr)
> +	dr = devres_alloc(devm_fpga_mgr_release, sizeof(*dr), GFP_KERNEL);
> +	if (!dr)
>  		return NULL;
>  
> -	mgr = fpga_mgr_create(dev, name, mops, priv);
> -	if (!mgr) {
> -		devres_free(ptr);
> -	} else {
> -		*ptr = mgr;
> -		devres_add(dev, ptr);
> +	dr->mgr = fpga_mgr_create(dev, name, mops, priv);
> +	if (!dr->mgr) {
> +		devres_free(dr);
> +		return NULL;
>  	}
>  
> -	return mgr;
> +	devres_add(dev, dr);
> +
> +	return dr->mgr;
>  }
>  EXPORT_SYMBOL_GPL(devm_fpga_mgr_create);
>  
> @@ -722,6 +726,58 @@ void fpga_mgr_unregister(struct fpga_manager *mgr)
>  }
>  EXPORT_SYMBOL_GPL(fpga_mgr_unregister);
>  
> +static int fpga_mgr_devres_match(struct device *dev, void *priv,
> +				 void *match_data)
> +{
> +	struct fpga_mgr_devres *dr = priv;
> +
> +	return match_data == dr->mgr;
> +}
> +
> +static void devm_fpga_mgr_unregister(struct device *dev, void *priv)
> +{
> +	struct fpga_mgr_devres *dr = priv;
> +
> +	fpga_mgr_unregister(dr->mgr);
> +}
> +
> +/**
> + * devm_fpga_mgr_register - resource managed variant of fpga_mgr_register()
> + * @dev: managing device for this FPGA manager
> + * @mgr: fpga manager struct
> + *
> + * This is the devres variant of fpga_mgr_register() for which the unregister
> + * function will be called automatically when the managing device is detached.
> + */
> +int devm_fpga_mgr_register(struct device *dev, struct fpga_manager *mgr)
> +{
> +	struct fpga_mgr_devres *dr;
> +	int err;

nit

int ret;

Fine if it isn't changed.

Reviewed-by: Tom Rix <trix@redhat.com>

> +
> +	/* Make sure that the struct fpga_manager * that is passed in is
> +	 * managed itself.
> +	 */
> +	if (WARN_ON(!devres_find(dev, devm_fpga_mgr_release,
> +				 fpga_mgr_devres_match, mgr)))
> +		return -EINVAL;
> +
> +	dr = devres_alloc(devm_fpga_mgr_unregister, sizeof(*dr), GFP_KERNEL);
> +	if (!dr)
> +		return -ENOMEM;
> +
> +	err = fpga_mgr_register(mgr);
> +	if (err) {
> +		devres_free(dr);
> +		return err;
> +	}
> +
> +	dr->mgr = mgr;
> +	devres_add(dev, dr);
> +
> +	return 0;
> +}
> +EXPORT_SYMBOL_GPL(devm_fpga_mgr_register);
> +
>  static void fpga_mgr_dev_release(struct device *dev)
>  {
>  }
> diff --git a/include/linux/fpga/fpga-mgr.h b/include/linux/fpga/fpga-mgr.h
> index e8ca62b2cb5b..2bc3030a69e5 100644
> --- a/include/linux/fpga/fpga-mgr.h
> +++ b/include/linux/fpga/fpga-mgr.h
> @@ -198,6 +198,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);
>  
> +int devm_fpga_mgr_register(struct device *dev, 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);


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [PATCH 02/10] fpga: fpga-mgr: altera-ps-spi: Simplify registration
  2020-10-04  5:14   ` Moritz Fischer
@ 2020-10-04 18:15     ` Tom Rix
  -1 siblings, 0 replies; 51+ messages in thread
From: Tom Rix @ 2020-10-04 18:15 UTC (permalink / raw)
  To: Moritz Fischer, linux-fpga
  Cc: hao.wu, michal.simek, linux-kernel, linux-arm-kernel,
	russell.h.weight, matthew.gerlach


On 10/3/20 10:14 PM, Moritz Fischer wrote:
> Simplify registration by using new devm_fpga_mgr_register() API.
>
> Signed-off-by: Moritz Fischer <mdf@kernel.org>
> ---
>  drivers/fpga/altera-ps-spi.c | 14 +-------------
>  1 file changed, 1 insertion(+), 13 deletions(-)

Looks fine

Reviewed-by: Tom Rix <trix@redhat.com>


^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [PATCH 02/10] fpga: fpga-mgr: altera-ps-spi: Simplify registration
@ 2020-10-04 18:15     ` Tom Rix
  0 siblings, 0 replies; 51+ messages in thread
From: Tom Rix @ 2020-10-04 18:15 UTC (permalink / raw)
  To: Moritz Fischer, linux-fpga
  Cc: russell.h.weight, linux-kernel, matthew.gerlach, michal.simek,
	linux-arm-kernel, hao.wu


On 10/3/20 10:14 PM, Moritz Fischer wrote:
> Simplify registration by using new devm_fpga_mgr_register() API.
>
> Signed-off-by: Moritz Fischer <mdf@kernel.org>
> ---
>  drivers/fpga/altera-ps-spi.c | 14 +-------------
>  1 file changed, 1 insertion(+), 13 deletions(-)

Looks fine

Reviewed-by: Tom Rix <trix@redhat.com>


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [PATCH 03/10] fpga: fpga-mgr: dfl-fme-mgr: Simplify registration
  2020-10-04  5:14   ` Moritz Fischer
@ 2020-10-04 18:22     ` Tom Rix
  -1 siblings, 0 replies; 51+ messages in thread
From: Tom Rix @ 2020-10-04 18:22 UTC (permalink / raw)
  To: Moritz Fischer, linux-fpga
  Cc: hao.wu, michal.simek, linux-kernel, linux-arm-kernel,
	russell.h.weight, matthew.gerlach


On 10/3/20 10:14 PM, Moritz Fischer wrote:
> Simplify registration using new devm_fpga_mgr_register() API.
>
> Signed-off-by: Moritz Fischer <mdf@kernel.org>
> ---
>  drivers/fpga/dfl-fme-mgr.c | 12 +-----------
>  1 file changed, 1 insertion(+), 11 deletions(-)
>
> diff --git a/drivers/fpga/dfl-fme-mgr.c b/drivers/fpga/dfl-fme-mgr.c
> index b3f7eee3c93f..3fc2be87d059 100644
> --- a/drivers/fpga/dfl-fme-mgr.c
> +++ b/drivers/fpga/dfl-fme-mgr.c
> @@ -316,16 +316,7 @@ static int fme_mgr_probe(struct platform_device *pdev)
>  	mgr->compat_id = compat_id;
>  	platform_set_drvdata(pdev, mgr);

Is this call is still needed ?

Tom

>  
> -	return fpga_mgr_register(mgr);
> -}
> -
> -static int fme_mgr_remove(struct platform_device *pdev)
> -{
> -	struct fpga_manager *mgr = platform_get_drvdata(pdev);
> -
> -	fpga_mgr_unregister(mgr);
> -
> -	return 0;
> +	return devm_fpga_mgr_register(dev, mgr);
>  }
>  
>  static struct platform_driver fme_mgr_driver = {
> @@ -333,7 +324,6 @@ static struct platform_driver fme_mgr_driver = {
>  		.name    = DFL_FPGA_FME_MGR,
>  	},
>  	.probe   = fme_mgr_probe,
> -	.remove  = fme_mgr_remove,
>  };
>  
>  module_platform_driver(fme_mgr_driver);


^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [PATCH 03/10] fpga: fpga-mgr: dfl-fme-mgr: Simplify registration
@ 2020-10-04 18:22     ` Tom Rix
  0 siblings, 0 replies; 51+ messages in thread
From: Tom Rix @ 2020-10-04 18:22 UTC (permalink / raw)
  To: Moritz Fischer, linux-fpga
  Cc: russell.h.weight, linux-kernel, matthew.gerlach, michal.simek,
	linux-arm-kernel, hao.wu


On 10/3/20 10:14 PM, Moritz Fischer wrote:
> Simplify registration using new devm_fpga_mgr_register() API.
>
> Signed-off-by: Moritz Fischer <mdf@kernel.org>
> ---
>  drivers/fpga/dfl-fme-mgr.c | 12 +-----------
>  1 file changed, 1 insertion(+), 11 deletions(-)
>
> diff --git a/drivers/fpga/dfl-fme-mgr.c b/drivers/fpga/dfl-fme-mgr.c
> index b3f7eee3c93f..3fc2be87d059 100644
> --- a/drivers/fpga/dfl-fme-mgr.c
> +++ b/drivers/fpga/dfl-fme-mgr.c
> @@ -316,16 +316,7 @@ static int fme_mgr_probe(struct platform_device *pdev)
>  	mgr->compat_id = compat_id;
>  	platform_set_drvdata(pdev, mgr);

Is this call is still needed ?

Tom

>  
> -	return fpga_mgr_register(mgr);
> -}
> -
> -static int fme_mgr_remove(struct platform_device *pdev)
> -{
> -	struct fpga_manager *mgr = platform_get_drvdata(pdev);
> -
> -	fpga_mgr_unregister(mgr);
> -
> -	return 0;
> +	return devm_fpga_mgr_register(dev, mgr);
>  }
>  
>  static struct platform_driver fme_mgr_driver = {
> @@ -333,7 +324,6 @@ static struct platform_driver fme_mgr_driver = {
>  		.name    = DFL_FPGA_FME_MGR,
>  	},
>  	.probe   = fme_mgr_probe,
> -	.remove  = fme_mgr_remove,
>  };
>  
>  module_platform_driver(fme_mgr_driver);


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [PATCH 04/10] fpga: fpga-mgr: ice40-spi: Simplify registration
  2020-10-04  5:14   ` Moritz Fischer
@ 2020-10-04 18:24     ` Tom Rix
  -1 siblings, 0 replies; 51+ messages in thread
From: Tom Rix @ 2020-10-04 18:24 UTC (permalink / raw)
  To: Moritz Fischer, linux-fpga
  Cc: hao.wu, michal.simek, linux-kernel, linux-arm-kernel,
	russell.h.weight, matthew.gerlach


On 10/3/20 10:14 PM, Moritz Fischer wrote:
> Simplify registration using new devm_fpga_mgr_register() API.
>
> Signed-off-by: Moritz Fischer <mdf@kernel.org>
> ---
>  drivers/fpga/ice40-spi.c | 14 +-------------
>  1 file changed, 1 insertion(+), 13 deletions(-)

LOTM

Reviewed-by: Tom Rix <trix@redhat.com>



^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [PATCH 04/10] fpga: fpga-mgr: ice40-spi: Simplify registration
@ 2020-10-04 18:24     ` Tom Rix
  0 siblings, 0 replies; 51+ messages in thread
From: Tom Rix @ 2020-10-04 18:24 UTC (permalink / raw)
  To: Moritz Fischer, linux-fpga
  Cc: russell.h.weight, linux-kernel, matthew.gerlach, michal.simek,
	linux-arm-kernel, hao.wu


On 10/3/20 10:14 PM, Moritz Fischer wrote:
> Simplify registration using new devm_fpga_mgr_register() API.
>
> Signed-off-by: Moritz Fischer <mdf@kernel.org>
> ---
>  drivers/fpga/ice40-spi.c | 14 +-------------
>  1 file changed, 1 insertion(+), 13 deletions(-)

LOTM

Reviewed-by: Tom Rix <trix@redhat.com>



_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [PATCH 05/10] fpga: fpga-mgr: machxo2-spi: Simplify registration
  2020-10-04  5:14   ` Moritz Fischer
@ 2020-10-04 18:25     ` Tom Rix
  -1 siblings, 0 replies; 51+ messages in thread
From: Tom Rix @ 2020-10-04 18:25 UTC (permalink / raw)
  To: Moritz Fischer, linux-fpga
  Cc: hao.wu, michal.simek, linux-kernel, linux-arm-kernel,
	russell.h.weight, matthew.gerlach


On 10/3/20 10:14 PM, Moritz Fischer wrote:
> Simplify registration using new devm_fpga_mgr_register() API.
>
> Signed-off-by: Moritz Fischer <mdf@kernel.org>
> ---
>  drivers/fpga/machxo2-spi.c | 14 +-------------
>  1 file changed, 1 insertion(+), 13 deletions(-)

LOTM

Reviewed-by: Tom Rix <trix@redhat.com>



^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [PATCH 05/10] fpga: fpga-mgr: machxo2-spi: Simplify registration
@ 2020-10-04 18:25     ` Tom Rix
  0 siblings, 0 replies; 51+ messages in thread
From: Tom Rix @ 2020-10-04 18:25 UTC (permalink / raw)
  To: Moritz Fischer, linux-fpga
  Cc: russell.h.weight, linux-kernel, matthew.gerlach, michal.simek,
	linux-arm-kernel, hao.wu


On 10/3/20 10:14 PM, Moritz Fischer wrote:
> Simplify registration using new devm_fpga_mgr_register() API.
>
> Signed-off-by: Moritz Fischer <mdf@kernel.org>
> ---
>  drivers/fpga/machxo2-spi.c | 14 +-------------
>  1 file changed, 1 insertion(+), 13 deletions(-)

LOTM

Reviewed-by: Tom Rix <trix@redhat.com>



_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [PATCH 06/10] fpga: fpga-mgr: socfpga: Simplify registration
  2020-10-04  5:14   ` Moritz Fischer
@ 2020-10-04 18:27     ` Tom Rix
  -1 siblings, 0 replies; 51+ messages in thread
From: Tom Rix @ 2020-10-04 18:27 UTC (permalink / raw)
  To: Moritz Fischer, linux-fpga
  Cc: hao.wu, michal.simek, linux-kernel, linux-arm-kernel,
	russell.h.weight, matthew.gerlach


On 10/3/20 10:14 PM, Moritz Fischer wrote:
> Simplify registration using new devm_fpga_mgr_register() API.
>
> Signed-off-by: Moritz Fischer <mdf@kernel.org>
> ---
>  drivers/fpga/socfpga.c | 14 +-------------
>  1 file changed, 1 insertion(+), 13 deletions(-)

LOTM

Reviewed-by: Tom Rix <trix@redhat.com>



^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [PATCH 06/10] fpga: fpga-mgr: socfpga: Simplify registration
@ 2020-10-04 18:27     ` Tom Rix
  0 siblings, 0 replies; 51+ messages in thread
From: Tom Rix @ 2020-10-04 18:27 UTC (permalink / raw)
  To: Moritz Fischer, linux-fpga
  Cc: russell.h.weight, linux-kernel, matthew.gerlach, michal.simek,
	linux-arm-kernel, hao.wu


On 10/3/20 10:14 PM, Moritz Fischer wrote:
> Simplify registration using new devm_fpga_mgr_register() API.
>
> Signed-off-by: Moritz Fischer <mdf@kernel.org>
> ---
>  drivers/fpga/socfpga.c | 14 +-------------
>  1 file changed, 1 insertion(+), 13 deletions(-)

LOTM

Reviewed-by: Tom Rix <trix@redhat.com>



_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [PATCH 07/10] fpga: fpga-mgr: ts73xx: Simplify registration
  2020-10-04  5:14   ` Moritz Fischer
@ 2020-10-04 18:27     ` Tom Rix
  -1 siblings, 0 replies; 51+ messages in thread
From: Tom Rix @ 2020-10-04 18:27 UTC (permalink / raw)
  To: Moritz Fischer, linux-fpga
  Cc: hao.wu, michal.simek, linux-kernel, linux-arm-kernel,
	russell.h.weight, matthew.gerlach


On 10/3/20 10:14 PM, Moritz Fischer wrote:
> Simplify registration using new devm_fpga_mgr_register() API.
>
> Signed-off-by: Moritz Fischer <mdf@kernel.org>
> ---
>  drivers/fpga/ts73xx-fpga.c | 14 +-------------
>  1 file changed, 1 insertion(+), 13 deletions(-)

LOTM

Reviewed-by: Tom Rix <trix@redhat.com>



^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [PATCH 07/10] fpga: fpga-mgr: ts73xx: Simplify registration
@ 2020-10-04 18:27     ` Tom Rix
  0 siblings, 0 replies; 51+ messages in thread
From: Tom Rix @ 2020-10-04 18:27 UTC (permalink / raw)
  To: Moritz Fischer, linux-fpga
  Cc: russell.h.weight, linux-kernel, matthew.gerlach, michal.simek,
	linux-arm-kernel, hao.wu


On 10/3/20 10:14 PM, Moritz Fischer wrote:
> Simplify registration using new devm_fpga_mgr_register() API.
>
> Signed-off-by: Moritz Fischer <mdf@kernel.org>
> ---
>  drivers/fpga/ts73xx-fpga.c | 14 +-------------
>  1 file changed, 1 insertion(+), 13 deletions(-)

LOTM

Reviewed-by: Tom Rix <trix@redhat.com>



_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [PATCH 08/10] fpga: fpga-mgr: xilinx-spi: Simplify registration
  2020-10-04  5:14   ` Moritz Fischer
@ 2020-10-04 18:28     ` Tom Rix
  -1 siblings, 0 replies; 51+ messages in thread
From: Tom Rix @ 2020-10-04 18:28 UTC (permalink / raw)
  To: Moritz Fischer, linux-fpga
  Cc: hao.wu, michal.simek, linux-kernel, linux-arm-kernel,
	russell.h.weight, matthew.gerlach


On 10/3/20 10:14 PM, Moritz Fischer wrote:
> Simplify registration using new devm_fpga_mgr_register() API.
>
> Signed-off-by: Moritz Fischer <mdf@kernel.org>
> ---
>  drivers/fpga/xilinx-spi.c | 14 +-------------
>  1 file changed, 1 insertion(+), 13 deletions(-)

LOTM

Reviewed-by: Tom Rix <trix@redhat.com>



^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [PATCH 08/10] fpga: fpga-mgr: xilinx-spi: Simplify registration
@ 2020-10-04 18:28     ` Tom Rix
  0 siblings, 0 replies; 51+ messages in thread
From: Tom Rix @ 2020-10-04 18:28 UTC (permalink / raw)
  To: Moritz Fischer, linux-fpga
  Cc: russell.h.weight, linux-kernel, matthew.gerlach, michal.simek,
	linux-arm-kernel, hao.wu


On 10/3/20 10:14 PM, Moritz Fischer wrote:
> Simplify registration using new devm_fpga_mgr_register() API.
>
> Signed-off-by: Moritz Fischer <mdf@kernel.org>
> ---
>  drivers/fpga/xilinx-spi.c | 14 +-------------
>  1 file changed, 1 insertion(+), 13 deletions(-)

LOTM

Reviewed-by: Tom Rix <trix@redhat.com>



_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [PATCH 09/10] fpga: fpga-mgr: zynqmp: Simplify registration
  2020-10-04  5:14   ` Moritz Fischer
@ 2020-10-04 18:33     ` Tom Rix
  -1 siblings, 0 replies; 51+ messages in thread
From: Tom Rix @ 2020-10-04 18:33 UTC (permalink / raw)
  To: Moritz Fischer, linux-fpga
  Cc: hao.wu, michal.simek, linux-kernel, linux-arm-kernel,
	russell.h.weight, matthew.gerlach


On 10/3/20 10:14 PM, Moritz Fischer wrote:
> Simplify registration using new devm_fpga_mgr_register() API.
>
> Signed-off-by: Moritz Fischer <mdf@kernel.org>
> ---
>  drivers/fpga/zynqmp-fpga.c | 21 +--------------------
>  1 file changed, 1 insertion(+), 20 deletions(-)

LOTM

Reviewed-by: Tom Rix <trix@redhat.com>



^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [PATCH 09/10] fpga: fpga-mgr: zynqmp: Simplify registration
@ 2020-10-04 18:33     ` Tom Rix
  0 siblings, 0 replies; 51+ messages in thread
From: Tom Rix @ 2020-10-04 18:33 UTC (permalink / raw)
  To: Moritz Fischer, linux-fpga
  Cc: russell.h.weight, linux-kernel, matthew.gerlach, michal.simek,
	linux-arm-kernel, hao.wu


On 10/3/20 10:14 PM, Moritz Fischer wrote:
> Simplify registration using new devm_fpga_mgr_register() API.
>
> Signed-off-by: Moritz Fischer <mdf@kernel.org>
> ---
>  drivers/fpga/zynqmp-fpga.c | 21 +--------------------
>  1 file changed, 1 insertion(+), 20 deletions(-)

LOTM

Reviewed-by: Tom Rix <trix@redhat.com>



_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [PATCH 10/10] fpga: fpga-mgr: altera-pr-ip: Simplify registration
  2020-10-04  5:14   ` Moritz Fischer
@ 2020-10-04 18:47     ` Tom Rix
  -1 siblings, 0 replies; 51+ messages in thread
From: Tom Rix @ 2020-10-04 18:47 UTC (permalink / raw)
  To: Moritz Fischer, linux-fpga
  Cc: hao.wu, michal.simek, linux-kernel, linux-arm-kernel,
	russell.h.weight, matthew.gerlach


On 10/3/20 10:14 PM, Moritz Fischer wrote:
> Simplify registration using new devm_fpga_mgr_register() API.
> Remove the now obsolete altera_pr_unregister() function.
>
> Signed-off-by: Moritz Fischer <mdf@kernel.org>
> ---
>
> We should take another look at this, IIRC correctly the point of
> splitting this up into a separate driver was to make it useable by a
> different (pci?) driver later on.
>
> It doesn't seem like this happened, and I think we should just make this
> a platform driver?
>
> ---
>  drivers/fpga/altera-pr-ip-core-plat.c  | 10 ----------
>  drivers/fpga/altera-pr-ip-core.c       | 14 +-------------
>  include/linux/fpga/altera-pr-ip-core.h |  1 -
>  3 files changed, 1 insertion(+), 24 deletions(-)
>
> diff --git a/drivers/fpga/altera-pr-ip-core-plat.c b/drivers/fpga/altera-pr-ip-core-plat.c
> index 99b9cc0e70f0..b008a6b8d2d3 100644
> --- a/drivers/fpga/altera-pr-ip-core-plat.c
> +++ b/drivers/fpga/altera-pr-ip-core-plat.c
> @@ -28,15 +28,6 @@ static int alt_pr_platform_probe(struct platform_device *pdev)
>  	return alt_pr_register(dev, reg_base);
>  }
>  
> -static int alt_pr_platform_remove(struct platform_device *pdev)
> -{
> -	struct device *dev = &pdev->dev;
> -
> -	alt_pr_unregister(dev);
> -
> -	return 0;
> -}
> -
>  static const struct of_device_id alt_pr_of_match[] = {
>  	{ .compatible = "altr,a10-pr-ip", },
>  	{},
> @@ -46,7 +37,6 @@ MODULE_DEVICE_TABLE(of, alt_pr_of_match);
>  
>  static struct platform_driver alt_pr_platform_driver = {
>  	.probe = alt_pr_platform_probe,
> -	.remove = alt_pr_platform_remove,
>  	.driver = {
>  		.name	= "alt_a10_pr_ip",
>  		.of_match_table = alt_pr_of_match,
> diff --git a/drivers/fpga/altera-pr-ip-core.c b/drivers/fpga/altera-pr-ip-core.c
> index 2cf25fd5e897..dfdf21ed34c4 100644
> --- a/drivers/fpga/altera-pr-ip-core.c
> +++ b/drivers/fpga/altera-pr-ip-core.c
> @@ -195,22 +195,10 @@ int alt_pr_register(struct device *dev, void __iomem *reg_base)
>  	if (!mgr)
>  		return -ENOMEM;
>  
> -	dev_set_drvdata(dev, mgr);
> -
> -	return fpga_mgr_register(mgr);
> +	return devm_fpga_mgr_register(dev, mgr);
>  }
>  EXPORT_SYMBOL_GPL(alt_pr_register);
>  
> -void alt_pr_unregister(struct device *dev)
> -{
> -	struct fpga_manager *mgr = dev_get_drvdata(dev);
> -
> -	dev_dbg(dev, "%s\n", __func__);
> -
> -	fpga_mgr_unregister(mgr);
> -}
> -EXPORT_SYMBOL_GPL(alt_pr_unregister);

Similar to the others, except for removing this symbol.

A patch should do one logical thing.

I'd rather this be split out of the patchset.

Tom

> -
>  MODULE_AUTHOR("Matthew Gerlach <matthew.gerlach@linux.intel.com>");
>  MODULE_DESCRIPTION("Altera Partial Reconfiguration IP Core");
>  MODULE_LICENSE("GPL v2");
> diff --git a/include/linux/fpga/altera-pr-ip-core.h b/include/linux/fpga/altera-pr-ip-core.h
> index 0b08ac20ab16..a6b4c07858cc 100644
> --- a/include/linux/fpga/altera-pr-ip-core.h
> +++ b/include/linux/fpga/altera-pr-ip-core.h
> @@ -13,6 +13,5 @@
>  #include <linux/io.h>
>  
>  int alt_pr_register(struct device *dev, void __iomem *reg_base);
> -void alt_pr_unregister(struct device *dev);
>  
>  #endif /* _ALT_PR_IP_CORE_H */


^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [PATCH 10/10] fpga: fpga-mgr: altera-pr-ip: Simplify registration
@ 2020-10-04 18:47     ` Tom Rix
  0 siblings, 0 replies; 51+ messages in thread
From: Tom Rix @ 2020-10-04 18:47 UTC (permalink / raw)
  To: Moritz Fischer, linux-fpga
  Cc: russell.h.weight, linux-kernel, matthew.gerlach, michal.simek,
	linux-arm-kernel, hao.wu


On 10/3/20 10:14 PM, Moritz Fischer wrote:
> Simplify registration using new devm_fpga_mgr_register() API.
> Remove the now obsolete altera_pr_unregister() function.
>
> Signed-off-by: Moritz Fischer <mdf@kernel.org>
> ---
>
> We should take another look at this, IIRC correctly the point of
> splitting this up into a separate driver was to make it useable by a
> different (pci?) driver later on.
>
> It doesn't seem like this happened, and I think we should just make this
> a platform driver?
>
> ---
>  drivers/fpga/altera-pr-ip-core-plat.c  | 10 ----------
>  drivers/fpga/altera-pr-ip-core.c       | 14 +-------------
>  include/linux/fpga/altera-pr-ip-core.h |  1 -
>  3 files changed, 1 insertion(+), 24 deletions(-)
>
> diff --git a/drivers/fpga/altera-pr-ip-core-plat.c b/drivers/fpga/altera-pr-ip-core-plat.c
> index 99b9cc0e70f0..b008a6b8d2d3 100644
> --- a/drivers/fpga/altera-pr-ip-core-plat.c
> +++ b/drivers/fpga/altera-pr-ip-core-plat.c
> @@ -28,15 +28,6 @@ static int alt_pr_platform_probe(struct platform_device *pdev)
>  	return alt_pr_register(dev, reg_base);
>  }
>  
> -static int alt_pr_platform_remove(struct platform_device *pdev)
> -{
> -	struct device *dev = &pdev->dev;
> -
> -	alt_pr_unregister(dev);
> -
> -	return 0;
> -}
> -
>  static const struct of_device_id alt_pr_of_match[] = {
>  	{ .compatible = "altr,a10-pr-ip", },
>  	{},
> @@ -46,7 +37,6 @@ MODULE_DEVICE_TABLE(of, alt_pr_of_match);
>  
>  static struct platform_driver alt_pr_platform_driver = {
>  	.probe = alt_pr_platform_probe,
> -	.remove = alt_pr_platform_remove,
>  	.driver = {
>  		.name	= "alt_a10_pr_ip",
>  		.of_match_table = alt_pr_of_match,
> diff --git a/drivers/fpga/altera-pr-ip-core.c b/drivers/fpga/altera-pr-ip-core.c
> index 2cf25fd5e897..dfdf21ed34c4 100644
> --- a/drivers/fpga/altera-pr-ip-core.c
> +++ b/drivers/fpga/altera-pr-ip-core.c
> @@ -195,22 +195,10 @@ int alt_pr_register(struct device *dev, void __iomem *reg_base)
>  	if (!mgr)
>  		return -ENOMEM;
>  
> -	dev_set_drvdata(dev, mgr);
> -
> -	return fpga_mgr_register(mgr);
> +	return devm_fpga_mgr_register(dev, mgr);
>  }
>  EXPORT_SYMBOL_GPL(alt_pr_register);
>  
> -void alt_pr_unregister(struct device *dev)
> -{
> -	struct fpga_manager *mgr = dev_get_drvdata(dev);
> -
> -	dev_dbg(dev, "%s\n", __func__);
> -
> -	fpga_mgr_unregister(mgr);
> -}
> -EXPORT_SYMBOL_GPL(alt_pr_unregister);

Similar to the others, except for removing this symbol.

A patch should do one logical thing.

I'd rather this be split out of the patchset.

Tom

> -
>  MODULE_AUTHOR("Matthew Gerlach <matthew.gerlach@linux.intel.com>");
>  MODULE_DESCRIPTION("Altera Partial Reconfiguration IP Core");
>  MODULE_LICENSE("GPL v2");
> diff --git a/include/linux/fpga/altera-pr-ip-core.h b/include/linux/fpga/altera-pr-ip-core.h
> index 0b08ac20ab16..a6b4c07858cc 100644
> --- a/include/linux/fpga/altera-pr-ip-core.h
> +++ b/include/linux/fpga/altera-pr-ip-core.h
> @@ -13,6 +13,5 @@
>  #include <linux/io.h>
>  
>  int alt_pr_register(struct device *dev, void __iomem *reg_base);
> -void alt_pr_unregister(struct device *dev);
>  
>  #endif /* _ALT_PR_IP_CORE_H */


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [PATCH 10/10] fpga: fpga-mgr: altera-pr-ip: Simplify registration
  2020-10-04 18:47     ` Tom Rix
@ 2020-10-04 23:39       ` Moritz Fischer
  -1 siblings, 0 replies; 51+ messages in thread
From: Moritz Fischer @ 2020-10-04 23:39 UTC (permalink / raw)
  To: Tom Rix
  Cc: Moritz Fischer, linux-fpga, hao.wu, michal.simek, linux-kernel,
	linux-arm-kernel, russell.h.weight, matthew.gerlach

On Sun, Oct 04, 2020 at 11:47:26AM -0700, Tom Rix wrote:
> 
> On 10/3/20 10:14 PM, Moritz Fischer wrote:
> > Simplify registration using new devm_fpga_mgr_register() API.
> > Remove the now obsolete altera_pr_unregister() function.
> >
> > Signed-off-by: Moritz Fischer <mdf@kernel.org>
> > ---
> >
> > We should take another look at this, IIRC correctly the point of
> > splitting this up into a separate driver was to make it useable by a
> > different (pci?) driver later on.
> >
> > It doesn't seem like this happened, and I think we should just make this
> > a platform driver?
> >
> > ---
> >  drivers/fpga/altera-pr-ip-core-plat.c  | 10 ----------
> >  drivers/fpga/altera-pr-ip-core.c       | 14 +-------------
> >  include/linux/fpga/altera-pr-ip-core.h |  1 -
> >  3 files changed, 1 insertion(+), 24 deletions(-)
> >
> > diff --git a/drivers/fpga/altera-pr-ip-core-plat.c b/drivers/fpga/altera-pr-ip-core-plat.c
> > index 99b9cc0e70f0..b008a6b8d2d3 100644
> > --- a/drivers/fpga/altera-pr-ip-core-plat.c
> > +++ b/drivers/fpga/altera-pr-ip-core-plat.c
> > @@ -28,15 +28,6 @@ static int alt_pr_platform_probe(struct platform_device *pdev)
> >  	return alt_pr_register(dev, reg_base);
> >  }
> >  
> > -static int alt_pr_platform_remove(struct platform_device *pdev)
> > -{
> > -	struct device *dev = &pdev->dev;
> > -
> > -	alt_pr_unregister(dev);
> > -
> > -	return 0;
> > -}
> > -
> >  static const struct of_device_id alt_pr_of_match[] = {
> >  	{ .compatible = "altr,a10-pr-ip", },
> >  	{},
> > @@ -46,7 +37,6 @@ MODULE_DEVICE_TABLE(of, alt_pr_of_match);
> >  
> >  static struct platform_driver alt_pr_platform_driver = {
> >  	.probe = alt_pr_platform_probe,
> > -	.remove = alt_pr_platform_remove,
> >  	.driver = {
> >  		.name	= "alt_a10_pr_ip",
> >  		.of_match_table = alt_pr_of_match,
> > diff --git a/drivers/fpga/altera-pr-ip-core.c b/drivers/fpga/altera-pr-ip-core.c
> > index 2cf25fd5e897..dfdf21ed34c4 100644
> > --- a/drivers/fpga/altera-pr-ip-core.c
> > +++ b/drivers/fpga/altera-pr-ip-core.c
> > @@ -195,22 +195,10 @@ int alt_pr_register(struct device *dev, void __iomem *reg_base)
> >  	if (!mgr)
> >  		return -ENOMEM;
> >  
> > -	dev_set_drvdata(dev, mgr);
> > -
> > -	return fpga_mgr_register(mgr);
> > +	return devm_fpga_mgr_register(dev, mgr);
> >  }
> >  EXPORT_SYMBOL_GPL(alt_pr_register);
> >  
> > -void alt_pr_unregister(struct device *dev)
> > -{
> > -	struct fpga_manager *mgr = dev_get_drvdata(dev);
> > -
> > -	dev_dbg(dev, "%s\n", __func__);
> > -
> > -	fpga_mgr_unregister(mgr);
> > -}
> > -EXPORT_SYMBOL_GPL(alt_pr_unregister);
> 
> Similar to the others, except for removing this symbol.
> 
> A patch should do one logical thing.

I was on the fence with this. Tbh, this driver should be a platform
driver. I'll create a separate series for that.

> 
> I'd rather this be split out of the patchset.
> 
> Tom
> 
> > -
> >  MODULE_AUTHOR("Matthew Gerlach <matthew.gerlach@linux.intel.com>");
> >  MODULE_DESCRIPTION("Altera Partial Reconfiguration IP Core");
> >  MODULE_LICENSE("GPL v2");
> > diff --git a/include/linux/fpga/altera-pr-ip-core.h b/include/linux/fpga/altera-pr-ip-core.h
> > index 0b08ac20ab16..a6b4c07858cc 100644
> > --- a/include/linux/fpga/altera-pr-ip-core.h
> > +++ b/include/linux/fpga/altera-pr-ip-core.h
> > @@ -13,6 +13,5 @@
> >  #include <linux/io.h>
> >  
> >  int alt_pr_register(struct device *dev, void __iomem *reg_base);
> > -void alt_pr_unregister(struct device *dev);
> >  
> >  #endif /* _ALT_PR_IP_CORE_H */
> 

Cheers,
Moritz

^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [PATCH 10/10] fpga: fpga-mgr: altera-pr-ip: Simplify registration
@ 2020-10-04 23:39       ` Moritz Fischer
  0 siblings, 0 replies; 51+ messages in thread
From: Moritz Fischer @ 2020-10-04 23:39 UTC (permalink / raw)
  To: Tom Rix
  Cc: russell.h.weight, linux-fpga, linux-kernel, matthew.gerlach,
	michal.simek, Moritz Fischer, linux-arm-kernel, hao.wu

On Sun, Oct 04, 2020 at 11:47:26AM -0700, Tom Rix wrote:
> 
> On 10/3/20 10:14 PM, Moritz Fischer wrote:
> > Simplify registration using new devm_fpga_mgr_register() API.
> > Remove the now obsolete altera_pr_unregister() function.
> >
> > Signed-off-by: Moritz Fischer <mdf@kernel.org>
> > ---
> >
> > We should take another look at this, IIRC correctly the point of
> > splitting this up into a separate driver was to make it useable by a
> > different (pci?) driver later on.
> >
> > It doesn't seem like this happened, and I think we should just make this
> > a platform driver?
> >
> > ---
> >  drivers/fpga/altera-pr-ip-core-plat.c  | 10 ----------
> >  drivers/fpga/altera-pr-ip-core.c       | 14 +-------------
> >  include/linux/fpga/altera-pr-ip-core.h |  1 -
> >  3 files changed, 1 insertion(+), 24 deletions(-)
> >
> > diff --git a/drivers/fpga/altera-pr-ip-core-plat.c b/drivers/fpga/altera-pr-ip-core-plat.c
> > index 99b9cc0e70f0..b008a6b8d2d3 100644
> > --- a/drivers/fpga/altera-pr-ip-core-plat.c
> > +++ b/drivers/fpga/altera-pr-ip-core-plat.c
> > @@ -28,15 +28,6 @@ static int alt_pr_platform_probe(struct platform_device *pdev)
> >  	return alt_pr_register(dev, reg_base);
> >  }
> >  
> > -static int alt_pr_platform_remove(struct platform_device *pdev)
> > -{
> > -	struct device *dev = &pdev->dev;
> > -
> > -	alt_pr_unregister(dev);
> > -
> > -	return 0;
> > -}
> > -
> >  static const struct of_device_id alt_pr_of_match[] = {
> >  	{ .compatible = "altr,a10-pr-ip", },
> >  	{},
> > @@ -46,7 +37,6 @@ MODULE_DEVICE_TABLE(of, alt_pr_of_match);
> >  
> >  static struct platform_driver alt_pr_platform_driver = {
> >  	.probe = alt_pr_platform_probe,
> > -	.remove = alt_pr_platform_remove,
> >  	.driver = {
> >  		.name	= "alt_a10_pr_ip",
> >  		.of_match_table = alt_pr_of_match,
> > diff --git a/drivers/fpga/altera-pr-ip-core.c b/drivers/fpga/altera-pr-ip-core.c
> > index 2cf25fd5e897..dfdf21ed34c4 100644
> > --- a/drivers/fpga/altera-pr-ip-core.c
> > +++ b/drivers/fpga/altera-pr-ip-core.c
> > @@ -195,22 +195,10 @@ int alt_pr_register(struct device *dev, void __iomem *reg_base)
> >  	if (!mgr)
> >  		return -ENOMEM;
> >  
> > -	dev_set_drvdata(dev, mgr);
> > -
> > -	return fpga_mgr_register(mgr);
> > +	return devm_fpga_mgr_register(dev, mgr);
> >  }
> >  EXPORT_SYMBOL_GPL(alt_pr_register);
> >  
> > -void alt_pr_unregister(struct device *dev)
> > -{
> > -	struct fpga_manager *mgr = dev_get_drvdata(dev);
> > -
> > -	dev_dbg(dev, "%s\n", __func__);
> > -
> > -	fpga_mgr_unregister(mgr);
> > -}
> > -EXPORT_SYMBOL_GPL(alt_pr_unregister);
> 
> Similar to the others, except for removing this symbol.
> 
> A patch should do one logical thing.

I was on the fence with this. Tbh, this driver should be a platform
driver. I'll create a separate series for that.

> 
> I'd rather this be split out of the patchset.
> 
> Tom
> 
> > -
> >  MODULE_AUTHOR("Matthew Gerlach <matthew.gerlach@linux.intel.com>");
> >  MODULE_DESCRIPTION("Altera Partial Reconfiguration IP Core");
> >  MODULE_LICENSE("GPL v2");
> > diff --git a/include/linux/fpga/altera-pr-ip-core.h b/include/linux/fpga/altera-pr-ip-core.h
> > index 0b08ac20ab16..a6b4c07858cc 100644
> > --- a/include/linux/fpga/altera-pr-ip-core.h
> > +++ b/include/linux/fpga/altera-pr-ip-core.h
> > @@ -13,6 +13,5 @@
> >  #include <linux/io.h>
> >  
> >  int alt_pr_register(struct device *dev, void __iomem *reg_base);
> > -void alt_pr_unregister(struct device *dev);
> >  
> >  #endif /* _ALT_PR_IP_CORE_H */
> 

Cheers,
Moritz

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [PATCH 03/10] fpga: fpga-mgr: dfl-fme-mgr: Simplify registration
  2020-10-04 18:22     ` Tom Rix
@ 2020-10-04 23:40       ` Moritz Fischer
  -1 siblings, 0 replies; 51+ messages in thread
From: Moritz Fischer @ 2020-10-04 23:40 UTC (permalink / raw)
  To: Tom Rix
  Cc: Moritz Fischer, linux-fpga, hao.wu, michal.simek, linux-kernel,
	linux-arm-kernel, russell.h.weight, matthew.gerlach

On Sun, Oct 04, 2020 at 11:22:31AM -0700, Tom Rix wrote:
> 
> On 10/3/20 10:14 PM, Moritz Fischer wrote:
> > Simplify registration using new devm_fpga_mgr_register() API.
> >
> > Signed-off-by: Moritz Fischer <mdf@kernel.org>
> > ---
> >  drivers/fpga/dfl-fme-mgr.c | 12 +-----------
> >  1 file changed, 1 insertion(+), 11 deletions(-)
> >
> > diff --git a/drivers/fpga/dfl-fme-mgr.c b/drivers/fpga/dfl-fme-mgr.c
> > index b3f7eee3c93f..3fc2be87d059 100644
> > --- a/drivers/fpga/dfl-fme-mgr.c
> > +++ b/drivers/fpga/dfl-fme-mgr.c
> > @@ -316,16 +316,7 @@ static int fme_mgr_probe(struct platform_device *pdev)
> >  	mgr->compat_id = compat_id;
> >  	platform_set_drvdata(pdev, mgr);
> 
Nice catch. Will fix.
> Is this call is still needed ?
> 
> Tom
> 
> >  
> > -	return fpga_mgr_register(mgr);
> > -}
> > -
> > -static int fme_mgr_remove(struct platform_device *pdev)
> > -{
> > -	struct fpga_manager *mgr = platform_get_drvdata(pdev);
> > -
> > -	fpga_mgr_unregister(mgr);
> > -
> > -	return 0;
> > +	return devm_fpga_mgr_register(dev, mgr);
> >  }
> >  
> >  static struct platform_driver fme_mgr_driver = {
> > @@ -333,7 +324,6 @@ static struct platform_driver fme_mgr_driver = {
> >  		.name    = DFL_FPGA_FME_MGR,
> >  	},
> >  	.probe   = fme_mgr_probe,
> > -	.remove  = fme_mgr_remove,
> >  };
> >  
> >  module_platform_driver(fme_mgr_driver);
> 

Cheers,
Moritz

^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [PATCH 03/10] fpga: fpga-mgr: dfl-fme-mgr: Simplify registration
@ 2020-10-04 23:40       ` Moritz Fischer
  0 siblings, 0 replies; 51+ messages in thread
From: Moritz Fischer @ 2020-10-04 23:40 UTC (permalink / raw)
  To: Tom Rix
  Cc: russell.h.weight, linux-fpga, linux-kernel, matthew.gerlach,
	michal.simek, Moritz Fischer, linux-arm-kernel, hao.wu

On Sun, Oct 04, 2020 at 11:22:31AM -0700, Tom Rix wrote:
> 
> On 10/3/20 10:14 PM, Moritz Fischer wrote:
> > Simplify registration using new devm_fpga_mgr_register() API.
> >
> > Signed-off-by: Moritz Fischer <mdf@kernel.org>
> > ---
> >  drivers/fpga/dfl-fme-mgr.c | 12 +-----------
> >  1 file changed, 1 insertion(+), 11 deletions(-)
> >
> > diff --git a/drivers/fpga/dfl-fme-mgr.c b/drivers/fpga/dfl-fme-mgr.c
> > index b3f7eee3c93f..3fc2be87d059 100644
> > --- a/drivers/fpga/dfl-fme-mgr.c
> > +++ b/drivers/fpga/dfl-fme-mgr.c
> > @@ -316,16 +316,7 @@ static int fme_mgr_probe(struct platform_device *pdev)
> >  	mgr->compat_id = compat_id;
> >  	platform_set_drvdata(pdev, mgr);
> 
Nice catch. Will fix.
> Is this call is still needed ?
> 
> Tom
> 
> >  
> > -	return fpga_mgr_register(mgr);
> > -}
> > -
> > -static int fme_mgr_remove(struct platform_device *pdev)
> > -{
> > -	struct fpga_manager *mgr = platform_get_drvdata(pdev);
> > -
> > -	fpga_mgr_unregister(mgr);
> > -
> > -	return 0;
> > +	return devm_fpga_mgr_register(dev, mgr);
> >  }
> >  
> >  static struct platform_driver fme_mgr_driver = {
> > @@ -333,7 +324,6 @@ static struct platform_driver fme_mgr_driver = {
> >  		.name    = DFL_FPGA_FME_MGR,
> >  	},
> >  	.probe   = fme_mgr_probe,
> > -	.remove  = fme_mgr_remove,
> >  };
> >  
> >  module_platform_driver(fme_mgr_driver);
> 

Cheers,
Moritz

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 51+ messages in thread

* RE: [PATCH 01/10] fpga: fpga-mgr: Add devm_fpga_mgr_register() API
  2020-10-04  5:14   ` Moritz Fischer
@ 2020-10-05  5:18     ` Wu, Hao
  -1 siblings, 0 replies; 51+ messages in thread
From: Wu, Hao @ 2020-10-05  5:18 UTC (permalink / raw)
  To: Moritz Fischer, linux-fpga
  Cc: trix, michal.simek, linux-kernel, linux-arm-kernel, Weight,
	Russell H, Gerlach, Matthew

> Subject: [PATCH 01/10] fpga: fpga-mgr: Add devm_fpga_mgr_register() API
> 
> Add a devm_fpga_mgr_register() API that can be used to register a FPGA
> Manager that was created using devm_fpga_mgr_create().
> 
> Introduce a struct fpga_mgr_devres that makes the devres
> allocation a little bit more readable and gets reused for
> devm_fpga_mgr_create() devm_fpga_mgr_register().
> 
> Signed-off-by: Moritz Fischer <mdf@kernel.org>
> ---
>  drivers/fpga/fpga-mgr.c       | 76 ++++++++++++++++++++++++++++++-----
>  include/linux/fpga/fpga-mgr.h |  2 +
>  2 files changed, 68 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c
> index f38bab01432e..774ac98fb69c 100644
> --- a/drivers/fpga/fpga-mgr.c
> +++ b/drivers/fpga/fpga-mgr.c
> @@ -21,6 +21,10 @@
>  static DEFINE_IDA(fpga_mgr_ida);
>  static struct class *fpga_mgr_class;
> 
> +struct fpga_mgr_devres {
> +	struct fpga_manager *mgr;
> +};
> +
>  /**
>   * fpga_image_info_alloc - Allocate a FPGA image info struct
>   * @dev: owning device
> @@ -651,21 +655,21 @@ struct fpga_manager
> *devm_fpga_mgr_create(struct device *dev, const char *name,
>  					  const struct fpga_manager_ops
> *mops,
>  					  void *priv)
>  {
> -	struct fpga_manager **ptr, *mgr;
> +	struct fpga_mgr_devres *dr;
> 
> -	ptr = devres_alloc(devm_fpga_mgr_release, sizeof(*ptr),
> GFP_KERNEL);
> -	if (!ptr)
> +	dr = devres_alloc(devm_fpga_mgr_release, sizeof(*dr), GFP_KERNEL);

Should we update devm_fpga_mgr_release function to use fpga_mgr_devres as well?

> +	if (!dr)
>  		return NULL;
> 
> -	mgr = fpga_mgr_create(dev, name, mops, priv);
> -	if (!mgr) {
> -		devres_free(ptr);
> -	} else {
> -		*ptr = mgr;
> -		devres_add(dev, ptr);
> +	dr->mgr = fpga_mgr_create(dev, name, mops, priv);
> +	if (!dr->mgr) {
> +		devres_free(dr);
> +		return NULL;
>  	}
> 
> -	return mgr;
> +	devres_add(dev, dr);
> +
> +	return dr->mgr;
>  }
>  EXPORT_SYMBOL_GPL(devm_fpga_mgr_create);
> 
> @@ -722,6 +726,58 @@ void fpga_mgr_unregister(struct fpga_manager
> *mgr)
>  }
>  EXPORT_SYMBOL_GPL(fpga_mgr_unregister);
> 
> +static int fpga_mgr_devres_match(struct device *dev, void *priv,

Maybe it's better to use "res" instead of "priv" which matches the
dr_match_t, and also devm_fpga_mgr_release function. 

> +				 void *match_data)
> +{
> +	struct fpga_mgr_devres *dr = priv;
> +
> +	return match_data == dr->mgr;
> +}
> +
> +static void devm_fpga_mgr_unregister(struct device *dev, void *priv)
> +{

Same.

> +	struct fpga_mgr_devres *dr = priv;
> +
> +	fpga_mgr_unregister(dr->mgr);
> +}
> +
> +/**
> + * devm_fpga_mgr_register - resource managed variant of
> fpga_mgr_register()
> + * @dev: managing device for this FPGA manager
> + * @mgr: fpga manager struct
> + *
> + * This is the devres variant of fpga_mgr_register() for which the unregister
> + * function will be called automatically when the managing device is
> detached.
> + */
> +int devm_fpga_mgr_register(struct device *dev, struct fpga_manager *mgr)
> +{
> +	struct fpga_mgr_devres *dr;
> +	int err;
> +
> +	/* Make sure that the struct fpga_manager * that is passed in is
> +	 * managed itself.
> +	 */

Should we use the same style for code comments here, 
I see other places in this file are using style like

/*
  * ......
  */

Thanks
Hao

^ permalink raw reply	[flat|nested] 51+ messages in thread

* RE: [PATCH 01/10] fpga: fpga-mgr: Add devm_fpga_mgr_register() API
@ 2020-10-05  5:18     ` Wu, Hao
  0 siblings, 0 replies; 51+ messages in thread
From: Wu, Hao @ 2020-10-05  5:18 UTC (permalink / raw)
  To: Moritz Fischer, linux-fpga
  Cc: Weight, Russell H, trix, michal.simek, Gerlach, Matthew,
	linux-kernel, linux-arm-kernel

> Subject: [PATCH 01/10] fpga: fpga-mgr: Add devm_fpga_mgr_register() API
> 
> Add a devm_fpga_mgr_register() API that can be used to register a FPGA
> Manager that was created using devm_fpga_mgr_create().
> 
> Introduce a struct fpga_mgr_devres that makes the devres
> allocation a little bit more readable and gets reused for
> devm_fpga_mgr_create() devm_fpga_mgr_register().
> 
> Signed-off-by: Moritz Fischer <mdf@kernel.org>
> ---
>  drivers/fpga/fpga-mgr.c       | 76 ++++++++++++++++++++++++++++++-----
>  include/linux/fpga/fpga-mgr.h |  2 +
>  2 files changed, 68 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c
> index f38bab01432e..774ac98fb69c 100644
> --- a/drivers/fpga/fpga-mgr.c
> +++ b/drivers/fpga/fpga-mgr.c
> @@ -21,6 +21,10 @@
>  static DEFINE_IDA(fpga_mgr_ida);
>  static struct class *fpga_mgr_class;
> 
> +struct fpga_mgr_devres {
> +	struct fpga_manager *mgr;
> +};
> +
>  /**
>   * fpga_image_info_alloc - Allocate a FPGA image info struct
>   * @dev: owning device
> @@ -651,21 +655,21 @@ struct fpga_manager
> *devm_fpga_mgr_create(struct device *dev, const char *name,
>  					  const struct fpga_manager_ops
> *mops,
>  					  void *priv)
>  {
> -	struct fpga_manager **ptr, *mgr;
> +	struct fpga_mgr_devres *dr;
> 
> -	ptr = devres_alloc(devm_fpga_mgr_release, sizeof(*ptr),
> GFP_KERNEL);
> -	if (!ptr)
> +	dr = devres_alloc(devm_fpga_mgr_release, sizeof(*dr), GFP_KERNEL);

Should we update devm_fpga_mgr_release function to use fpga_mgr_devres as well?

> +	if (!dr)
>  		return NULL;
> 
> -	mgr = fpga_mgr_create(dev, name, mops, priv);
> -	if (!mgr) {
> -		devres_free(ptr);
> -	} else {
> -		*ptr = mgr;
> -		devres_add(dev, ptr);
> +	dr->mgr = fpga_mgr_create(dev, name, mops, priv);
> +	if (!dr->mgr) {
> +		devres_free(dr);
> +		return NULL;
>  	}
> 
> -	return mgr;
> +	devres_add(dev, dr);
> +
> +	return dr->mgr;
>  }
>  EXPORT_SYMBOL_GPL(devm_fpga_mgr_create);
> 
> @@ -722,6 +726,58 @@ void fpga_mgr_unregister(struct fpga_manager
> *mgr)
>  }
>  EXPORT_SYMBOL_GPL(fpga_mgr_unregister);
> 
> +static int fpga_mgr_devres_match(struct device *dev, void *priv,

Maybe it's better to use "res" instead of "priv" which matches the
dr_match_t, and also devm_fpga_mgr_release function. 

> +				 void *match_data)
> +{
> +	struct fpga_mgr_devres *dr = priv;
> +
> +	return match_data == dr->mgr;
> +}
> +
> +static void devm_fpga_mgr_unregister(struct device *dev, void *priv)
> +{

Same.

> +	struct fpga_mgr_devres *dr = priv;
> +
> +	fpga_mgr_unregister(dr->mgr);
> +}
> +
> +/**
> + * devm_fpga_mgr_register - resource managed variant of
> fpga_mgr_register()
> + * @dev: managing device for this FPGA manager
> + * @mgr: fpga manager struct
> + *
> + * This is the devres variant of fpga_mgr_register() for which the unregister
> + * function will be called automatically when the managing device is
> detached.
> + */
> +int devm_fpga_mgr_register(struct device *dev, struct fpga_manager *mgr)
> +{
> +	struct fpga_mgr_devres *dr;
> +	int err;
> +
> +	/* Make sure that the struct fpga_manager * that is passed in is
> +	 * managed itself.
> +	 */

Should we use the same style for code comments here, 
I see other places in this file are using style like

/*
  * ......
  */

Thanks
Hao

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [PATCH 01/10] fpga: fpga-mgr: Add devm_fpga_mgr_register() API
  2020-10-05  5:18     ` Wu, Hao
@ 2020-10-05 16:45       ` Moritz Fischer
  -1 siblings, 0 replies; 51+ messages in thread
From: Moritz Fischer @ 2020-10-05 16:45 UTC (permalink / raw)
  To: Wu, Hao
  Cc: Moritz Fischer, linux-fpga, trix, michal.simek, linux-kernel,
	linux-arm-kernel, Weight, Russell H, Gerlach, Matthew

Hi Hao,

On Mon, Oct 05, 2020 at 05:18:40AM +0000, Wu, Hao wrote:
> > Subject: [PATCH 01/10] fpga: fpga-mgr: Add devm_fpga_mgr_register() API
> > 
> > Add a devm_fpga_mgr_register() API that can be used to register a FPGA
> > Manager that was created using devm_fpga_mgr_create().
> > 
> > Introduce a struct fpga_mgr_devres that makes the devres
> > allocation a little bit more readable and gets reused for
> > devm_fpga_mgr_create() devm_fpga_mgr_register().
> > 
> > Signed-off-by: Moritz Fischer <mdf@kernel.org>
> > ---
> >  drivers/fpga/fpga-mgr.c       | 76 ++++++++++++++++++++++++++++++-----
> >  include/linux/fpga/fpga-mgr.h |  2 +
> >  2 files changed, 68 insertions(+), 10 deletions(-)
> > 
> > diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c
> > index f38bab01432e..774ac98fb69c 100644
> > --- a/drivers/fpga/fpga-mgr.c
> > +++ b/drivers/fpga/fpga-mgr.c
> > @@ -21,6 +21,10 @@
> >  static DEFINE_IDA(fpga_mgr_ida);
> >  static struct class *fpga_mgr_class;
> > 
> > +struct fpga_mgr_devres {
> > +	struct fpga_manager *mgr;
> > +};
> > +
> >  /**
> >   * fpga_image_info_alloc - Allocate a FPGA image info struct
> >   * @dev: owning device
> > @@ -651,21 +655,21 @@ struct fpga_manager
> > *devm_fpga_mgr_create(struct device *dev, const char *name,
> >  					  const struct fpga_manager_ops
> > *mops,
> >  					  void *priv)
> >  {
> > -	struct fpga_manager **ptr, *mgr;
> > +	struct fpga_mgr_devres *dr;
> > 
> > -	ptr = devres_alloc(devm_fpga_mgr_release, sizeof(*ptr),
> > GFP_KERNEL);
> > -	if (!ptr)
> > +	dr = devres_alloc(devm_fpga_mgr_release, sizeof(*dr), GFP_KERNEL);
> 
> Should we update devm_fpga_mgr_release function to use fpga_mgr_devres as well?
Yes!
> 
> > +	if (!dr)
> >  		return NULL;
> > 
> > -	mgr = fpga_mgr_create(dev, name, mops, priv);
> > -	if (!mgr) {
> > -		devres_free(ptr);
> > -	} else {
> > -		*ptr = mgr;
> > -		devres_add(dev, ptr);
> > +	dr->mgr = fpga_mgr_create(dev, name, mops, priv);
> > +	if (!dr->mgr) {
> > +		devres_free(dr);
> > +		return NULL;
> >  	}
> > 
> > -	return mgr;
> > +	devres_add(dev, dr);
> > +
> > +	return dr->mgr;
> >  }
> >  EXPORT_SYMBOL_GPL(devm_fpga_mgr_create);
> > 
> > @@ -722,6 +726,58 @@ void fpga_mgr_unregister(struct fpga_manager
> > *mgr)
> >  }
> >  EXPORT_SYMBOL_GPL(fpga_mgr_unregister);
> > 
> > +static int fpga_mgr_devres_match(struct device *dev, void *priv,
> 
> Maybe it's better to use "res" instead of "priv" which matches the
> dr_match_t, and also devm_fpga_mgr_release function. 
Can do.
> 
> > +				 void *match_data)
> > +{
> > +	struct fpga_mgr_devres *dr = priv;
> > +
> > +	return match_data == dr->mgr;
> > +}
> > +
> > +static void devm_fpga_mgr_unregister(struct device *dev, void *priv)
> > +{
> 
> Same.
Ditto.
> 
> > +	struct fpga_mgr_devres *dr = priv;
> > +
> > +	fpga_mgr_unregister(dr->mgr);
> > +}
> > +
> > +/**
> > + * devm_fpga_mgr_register - resource managed variant of
> > fpga_mgr_register()
> > + * @dev: managing device for this FPGA manager
> > + * @mgr: fpga manager struct
> > + *
> > + * This is the devres variant of fpga_mgr_register() for which the unregister
> > + * function will be called automatically when the managing device is
> > detached.
> > + */
> > +int devm_fpga_mgr_register(struct device *dev, struct fpga_manager *mgr)
> > +{
> > +	struct fpga_mgr_devres *dr;
> > +	int err;
> > +
> > +	/* Make sure that the struct fpga_manager * that is passed in is
> > +	 * managed itself.
> > +	 */
> 
> Should we use the same style for code comments here, 
> I see other places in this file are using style like
Can do.
> 
> /*
>   * ......
>   */
> 
> Thanks
> Hao
Thanks,
Moritz

^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [PATCH 01/10] fpga: fpga-mgr: Add devm_fpga_mgr_register() API
@ 2020-10-05 16:45       ` Moritz Fischer
  0 siblings, 0 replies; 51+ messages in thread
From: Moritz Fischer @ 2020-10-05 16:45 UTC (permalink / raw)
  To: Wu, Hao
  Cc: Weight, Russell H, trix, linux-fpga, michal.simek, Gerlach,
	Matthew, linux-kernel, Moritz Fischer, linux-arm-kernel

Hi Hao,

On Mon, Oct 05, 2020 at 05:18:40AM +0000, Wu, Hao wrote:
> > Subject: [PATCH 01/10] fpga: fpga-mgr: Add devm_fpga_mgr_register() API
> > 
> > Add a devm_fpga_mgr_register() API that can be used to register a FPGA
> > Manager that was created using devm_fpga_mgr_create().
> > 
> > Introduce a struct fpga_mgr_devres that makes the devres
> > allocation a little bit more readable and gets reused for
> > devm_fpga_mgr_create() devm_fpga_mgr_register().
> > 
> > Signed-off-by: Moritz Fischer <mdf@kernel.org>
> > ---
> >  drivers/fpga/fpga-mgr.c       | 76 ++++++++++++++++++++++++++++++-----
> >  include/linux/fpga/fpga-mgr.h |  2 +
> >  2 files changed, 68 insertions(+), 10 deletions(-)
> > 
> > diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c
> > index f38bab01432e..774ac98fb69c 100644
> > --- a/drivers/fpga/fpga-mgr.c
> > +++ b/drivers/fpga/fpga-mgr.c
> > @@ -21,6 +21,10 @@
> >  static DEFINE_IDA(fpga_mgr_ida);
> >  static struct class *fpga_mgr_class;
> > 
> > +struct fpga_mgr_devres {
> > +	struct fpga_manager *mgr;
> > +};
> > +
> >  /**
> >   * fpga_image_info_alloc - Allocate a FPGA image info struct
> >   * @dev: owning device
> > @@ -651,21 +655,21 @@ struct fpga_manager
> > *devm_fpga_mgr_create(struct device *dev, const char *name,
> >  					  const struct fpga_manager_ops
> > *mops,
> >  					  void *priv)
> >  {
> > -	struct fpga_manager **ptr, *mgr;
> > +	struct fpga_mgr_devres *dr;
> > 
> > -	ptr = devres_alloc(devm_fpga_mgr_release, sizeof(*ptr),
> > GFP_KERNEL);
> > -	if (!ptr)
> > +	dr = devres_alloc(devm_fpga_mgr_release, sizeof(*dr), GFP_KERNEL);
> 
> Should we update devm_fpga_mgr_release function to use fpga_mgr_devres as well?
Yes!
> 
> > +	if (!dr)
> >  		return NULL;
> > 
> > -	mgr = fpga_mgr_create(dev, name, mops, priv);
> > -	if (!mgr) {
> > -		devres_free(ptr);
> > -	} else {
> > -		*ptr = mgr;
> > -		devres_add(dev, ptr);
> > +	dr->mgr = fpga_mgr_create(dev, name, mops, priv);
> > +	if (!dr->mgr) {
> > +		devres_free(dr);
> > +		return NULL;
> >  	}
> > 
> > -	return mgr;
> > +	devres_add(dev, dr);
> > +
> > +	return dr->mgr;
> >  }
> >  EXPORT_SYMBOL_GPL(devm_fpga_mgr_create);
> > 
> > @@ -722,6 +726,58 @@ void fpga_mgr_unregister(struct fpga_manager
> > *mgr)
> >  }
> >  EXPORT_SYMBOL_GPL(fpga_mgr_unregister);
> > 
> > +static int fpga_mgr_devres_match(struct device *dev, void *priv,
> 
> Maybe it's better to use "res" instead of "priv" which matches the
> dr_match_t, and also devm_fpga_mgr_release function. 
Can do.
> 
> > +				 void *match_data)
> > +{
> > +	struct fpga_mgr_devres *dr = priv;
> > +
> > +	return match_data == dr->mgr;
> > +}
> > +
> > +static void devm_fpga_mgr_unregister(struct device *dev, void *priv)
> > +{
> 
> Same.
Ditto.
> 
> > +	struct fpga_mgr_devres *dr = priv;
> > +
> > +	fpga_mgr_unregister(dr->mgr);
> > +}
> > +
> > +/**
> > + * devm_fpga_mgr_register - resource managed variant of
> > fpga_mgr_register()
> > + * @dev: managing device for this FPGA manager
> > + * @mgr: fpga manager struct
> > + *
> > + * This is the devres variant of fpga_mgr_register() for which the unregister
> > + * function will be called automatically when the managing device is
> > detached.
> > + */
> > +int devm_fpga_mgr_register(struct device *dev, struct fpga_manager *mgr)
> > +{
> > +	struct fpga_mgr_devres *dr;
> > +	int err;
> > +
> > +	/* Make sure that the struct fpga_manager * that is passed in is
> > +	 * managed itself.
> > +	 */
> 
> Should we use the same style for code comments here, 
> I see other places in this file are using style like
Can do.
> 
> /*
>   * ......
>   */
> 
> Thanks
> Hao
Thanks,
Moritz

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 51+ messages in thread

* [PATCH 09/10] fpga: fpga-mgr: zynqmp: Simplify registration
  2020-11-03  7:14 [PATCH 00/10] Introduce devm_fpga_mgr_register() API Moritz Fischer
@ 2020-11-03  7:14 ` Moritz Fischer
  0 siblings, 0 replies; 51+ messages in thread
From: Moritz Fischer @ 2020-11-03  7:14 UTC (permalink / raw)
  To: gregkh; +Cc: linux-fpga, Moritz Fischer, Tom Rix

Simplify registration using new devm_fpga_mgr_register() API.

Reviewed-by: Tom Rix <trix@redhat.com>
Signed-off-by: Moritz Fischer <mdf@kernel.org>
---
 drivers/fpga/zynqmp-fpga.c | 21 +--------------------
 1 file changed, 1 insertion(+), 20 deletions(-)

diff --git a/drivers/fpga/zynqmp-fpga.c b/drivers/fpga/zynqmp-fpga.c
index 4a1139e05280..125743c9797f 100644
--- a/drivers/fpga/zynqmp-fpga.c
+++ b/drivers/fpga/zynqmp-fpga.c
@@ -95,7 +95,6 @@ static int zynqmp_fpga_probe(struct platform_device *pdev)
 	struct device *dev = &pdev->dev;
 	struct zynqmp_fpga_priv *priv;
 	struct fpga_manager *mgr;
-	int ret;
 
 	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
 	if (!priv)
@@ -108,24 +107,7 @@ static int zynqmp_fpga_probe(struct platform_device *pdev)
 	if (!mgr)
 		return -ENOMEM;
 
-	platform_set_drvdata(pdev, mgr);
-
-	ret = fpga_mgr_register(mgr);
-	if (ret) {
-		dev_err(dev, "unable to register FPGA manager");
-		return ret;
-	}
-
-	return 0;
-}
-
-static int zynqmp_fpga_remove(struct platform_device *pdev)
-{
-	struct fpga_manager *mgr = platform_get_drvdata(pdev);
-
-	fpga_mgr_unregister(mgr);
-
-	return 0;
+	return devm_fpga_mgr_register(dev, mgr);
 }
 
 static const struct of_device_id zynqmp_fpga_of_match[] = {
@@ -137,7 +119,6 @@ MODULE_DEVICE_TABLE(of, zynqmp_fpga_of_match);
 
 static struct platform_driver zynqmp_fpga_driver = {
 	.probe = zynqmp_fpga_probe,
-	.remove = zynqmp_fpga_remove,
 	.driver = {
 		.name = "zynqmp_fpga_manager",
 		.of_match_table = of_match_ptr(zynqmp_fpga_of_match),
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 51+ messages in thread

end of thread, other threads:[~2020-11-03  7:14 UTC | newest]

Thread overview: 51+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-04  5:14 [PATCH 00/10] Introduce devm_fpga_mgr_register() Moritz Fischer
2020-10-04  5:14 ` Moritz Fischer
2020-10-04  5:14 ` [PATCH 01/10] fpga: fpga-mgr: Add devm_fpga_mgr_register() API Moritz Fischer
2020-10-04  5:14   ` Moritz Fischer
2020-10-04 18:08   ` Tom Rix
2020-10-04 18:08     ` Tom Rix
2020-10-05  5:18   ` Wu, Hao
2020-10-05  5:18     ` Wu, Hao
2020-10-05 16:45     ` Moritz Fischer
2020-10-05 16:45       ` Moritz Fischer
2020-10-04  5:14 ` [PATCH 02/10] fpga: fpga-mgr: altera-ps-spi: Simplify registration Moritz Fischer
2020-10-04  5:14   ` Moritz Fischer
2020-10-04 18:15   ` Tom Rix
2020-10-04 18:15     ` Tom Rix
2020-10-04  5:14 ` [PATCH 03/10] fpga: fpga-mgr: dfl-fme-mgr: " Moritz Fischer
2020-10-04  5:14   ` Moritz Fischer
2020-10-04 18:22   ` Tom Rix
2020-10-04 18:22     ` Tom Rix
2020-10-04 23:40     ` Moritz Fischer
2020-10-04 23:40       ` Moritz Fischer
2020-10-04  5:14 ` [PATCH 04/10] fpga: fpga-mgr: ice40-spi: " Moritz Fischer
2020-10-04  5:14   ` Moritz Fischer
2020-10-04 18:24   ` Tom Rix
2020-10-04 18:24     ` Tom Rix
2020-10-04  5:14 ` [PATCH 05/10] fpga: fpga-mgr: machxo2-spi: " Moritz Fischer
2020-10-04  5:14   ` Moritz Fischer
2020-10-04 18:25   ` Tom Rix
2020-10-04 18:25     ` Tom Rix
2020-10-04  5:14 ` [PATCH 06/10] fpga: fpga-mgr: socfpga: " Moritz Fischer
2020-10-04  5:14   ` Moritz Fischer
2020-10-04 18:27   ` Tom Rix
2020-10-04 18:27     ` Tom Rix
2020-10-04  5:14 ` [PATCH 07/10] fpga: fpga-mgr: ts73xx: " Moritz Fischer
2020-10-04  5:14   ` Moritz Fischer
2020-10-04 18:27   ` Tom Rix
2020-10-04 18:27     ` Tom Rix
2020-10-04  5:14 ` [PATCH 08/10] fpga: fpga-mgr: xilinx-spi: " Moritz Fischer
2020-10-04  5:14   ` Moritz Fischer
2020-10-04 18:28   ` Tom Rix
2020-10-04 18:28     ` Tom Rix
2020-10-04  5:14 ` [PATCH 09/10] fpga: fpga-mgr: zynqmp: " Moritz Fischer
2020-10-04  5:14   ` Moritz Fischer
2020-10-04 18:33   ` Tom Rix
2020-10-04 18:33     ` Tom Rix
2020-10-04  5:14 ` [PATCH 10/10] fpga: fpga-mgr: altera-pr-ip: " Moritz Fischer
2020-10-04  5:14   ` Moritz Fischer
2020-10-04 18:47   ` Tom Rix
2020-10-04 18:47     ` Tom Rix
2020-10-04 23:39     ` Moritz Fischer
2020-10-04 23:39       ` Moritz Fischer
2020-11-03  7:14 [PATCH 00/10] Introduce devm_fpga_mgr_register() API Moritz Fischer
2020-11-03  7:14 ` [PATCH 09/10] fpga: fpga-mgr: zynqmp: Simplify registration Moritz Fischer

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.