Skip to contentSkip to conversation

Introduce devm_fpga_mgr_register()

PATCH Superseded Moritz Fischer 3 participants 25 messages Oct 4, 2020 – Oct 5, 2020

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Moritz Fischer

author maintainer
#0 lore raw

cover Introduce devm_fpga_mgr_register()

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(-)
Signature · 1 line
2.28.0
author maintainer
#1 lore raw

PATCH 1/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().

---
 drivers/fpga/fpga-mgr.c       | 76 ++++++++++++++++++++++++++++++-----
 include/linux/fpga/fpga-mgr.h |  2 +
 2 files changed, 68 insertions(+), 10 deletions(-)
drivers/fpga/fpga-mgr.c +66 -10
index f38bab01432e..774ac98fb69c 100644
@@ -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)
 {
 }
include/linux/fpga/fpga-mgr.h +2 -0
index e8ca62b2cb5b..2bc3030a69e5 100644
@@ -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);
Signature · 1 line
2.28.0
reviewer Reviewed-by on v1 1/10
#2 lore raw

Re: [PATCH 01/10] fpga: fpga-mgr: Add devm_fpga_mgr_register() API

Quoted 81 lines · 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().

---
 drivers/fpga/fpga-mgr.c       | 76 ++++++++++++++++++++++++++++++-----
 include/linux/fpga/fpga-mgr.h |  2 +
 2 files changed, 68 insertions(+), 10 deletions(-)
drivers/fpga/fpga-mgr.c +31 -10
index f38bab01432e..774ac98fb69c 100644
@@ -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()

drivers/fpga/fpga-mgr.c void fpga_mgr_unregister(struct fpga_manager *mgr) · line 755

Quoted 10 lines
drivers/fpga/fpga-mgr.c +10 -0
+ * @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.

Quoted 41 lines
drivers/fpga/fpga-mgr.c +25 -0
+
+	/* 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)
 {
 }
include/linux/fpga/fpga-mgr.h +2 -0
index e8ca62b2cb5b..2bc3030a69e5 100644
@@ -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);
#3 lore raw

RE: [PATCH 01/10] fpga: fpga-mgr: Add devm_fpga_mgr_register() API

In reply to Moritz Fischer
Quoted 33 lines

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().

---
 drivers/fpga/fpga-mgr.c       | 76 ++++++++++++++++++++++++++++++-----
 include/linux/fpga/fpga-mgr.h |  2 +
 2 files changed, 68 insertions(+), 10 deletions(-)
drivers/fpga/fpga-mgr.c +4 -0
index f38bab01432e..774ac98fb69c 100644
@@ -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

drivers/fpga/fpga-mgr.c struct fpga_manager · line 663

Quoted 10 lines
drivers/fpga/fpga-mgr.c +2 -3
 *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?

Quoted 23 lines
drivers/fpga/fpga-mgr.c +8 -7
+	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);

drivers/fpga/fpga-mgr.c void fpga_mgr_unregister(struct fpga_manager · line 730

Quoted 5 lines
drivers/fpga/fpga-mgr.c +1 -0
@@ -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.

drivers/fpga/fpga-mgr.c void fpga_mgr_unregister(struct fpga_manager *mgr) · line 738

Quoted 9 lines
drivers/fpga/fpga-mgr.c +9 -0
+				 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.

Quoted 15 lines
drivers/fpga/fpga-mgr.c +12 -0
+	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.
+ */

drivers/fpga/fpga-mgr.c void fpga_mgr_unregister(struct fpga_manager *mgr) · line 759

Quoted 8 lines
drivers/fpga/fpga-mgr.c +8 -0
+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

author maintainer
#4 lore raw

Re: [PATCH 01/10] fpga: fpga-mgr: Add devm_fpga_mgr_register() API

Hi Hao,

Quoted 39 lines · Hao
Quoted 39 lines

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().

---
 drivers/fpga/fpga-mgr.c       | 76 ++++++++++++++++++++++++++++++-----
 include/linux/fpga/fpga-mgr.h |  2 +
 2 files changed, 68 insertions(+), 10 deletions(-)
drivers/fpga/fpga-mgr.c +5 -1
index f38bab01432e..774ac98fb69c 100644
@@ -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;
 
Quoted 6 lines

drivers/fpga/fpga-mgr.c struct fpga_manager *devm_fpga_mgr_create(struct device *dev, const char *name, · line 660

Quoted 4 lines
drivers/fpga/fpga-mgr.c +1 -2
-	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!

Quoted 28 lines
Quoted 28 lines
drivers/fpga/fpga-mgr.c +8 -7
+	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);

drivers/fpga/fpga-mgr.c +0 -0
@@ -722,6 +726,58 @@ void fpga_mgr_unregister(struct fpga_manager
 *mgr)
 }
 EXPORT_SYMBOL_GPL(fpga_mgr_unregister);
 
Quoted 4 lines

drivers/fpga/fpga-mgr.c void fpga_mgr_unregister(struct fpga_manager *mgr) · line 729

Quoted 1 line
drivers/fpga/fpga-mgr.c +1 -0
+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.

Quoted 12 lines

drivers/fpga/fpga-mgr.c void fpga_mgr_unregister(struct fpga_manager *mgr) · line 738

Quoted 10 lines
drivers/fpga/fpga-mgr.c +9 -0
+				 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.

Quoted 19 lines
Quoted 19 lines
drivers/fpga/fpga-mgr.c +12 -0
+	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.
+ */

drivers/fpga/fpga-mgr.c +3 -0
+int devm_fpga_mgr_register(struct device *dev, struct fpga_manager *mgr)
+{
+	struct fpga_mgr_devres *dr;
Quoted 8 lines

drivers/fpga/fpga-mgr.c void fpga_mgr_unregister(struct fpga_manager *mgr) · line 759

Quoted 5 lines
drivers/fpga/fpga-mgr.c +5 -0
+	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.

Quoted 7 lines

/*
* ......
*/

Thanks
Hao

Thanks,
Moritz

author maintainer
#5 lore raw

PATCH 2/10 fpga: fpga-mgr: altera-ps-spi: Simplify registration

In reply to Moritz Fischer

Simplify registration by using new devm_fpga_mgr_register() API.

---
 drivers/fpga/altera-ps-spi.c | 14 +-------------
 1 file changed, 1 insertion(+), 13 deletions(-)
drivers/fpga/altera-ps-spi.c +1 -13
index 0221dee8dd4c..23bfd4d1ad0f 100644
@@ -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)
Signature · 1 line
2.28.0
reviewer Reviewed-by on v1 2/10
#6 lore raw

Re: [PATCH 02/10] fpga: fpga-mgr: altera-ps-spi: Simplify registration

Quoted 6 lines · Moritz Fischer

Simplify registration by using new devm_fpga_mgr_register() API.

---
 drivers/fpga/altera-ps-spi.c | 14 +-------------
 1 file changed, 1 insertion(+), 13 deletions(-)

Looks fine

author maintainer
#7 lore raw

PATCH 3/10 fpga: fpga-mgr: dfl-fme-mgr: Simplify registration

In reply to Moritz Fischer

Simplify registration using new devm_fpga_mgr_register() API.

---
 drivers/fpga/dfl-fme-mgr.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)
drivers/fpga/dfl-fme-mgr.c +1 -11
index b3f7eee3c93f..3fc2be87d059 100644
@@ -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);
Signature · 1 line
2.28.0
reviewer
#8 lore raw

Re: [PATCH 03/10] fpga: fpga-mgr: dfl-fme-mgr: Simplify registration

Quoted 12 lines · Moritz Fischer

Simplify registration using new devm_fpga_mgr_register() API.

---
 drivers/fpga/dfl-fme-mgr.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)
drivers/fpga/dfl-fme-mgr.c +0 -0
index b3f7eee3c93f..3fc2be87d059 100644

drivers/fpga/dfl-fme-mgr.c static int fme_mgr_probe(struct platform_device *pdev) · line 317

Quoted 2 lines
drivers/fpga/dfl-fme-mgr.c +0 -0
@@ -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

Quoted 23 lines
drivers/fpga/dfl-fme-mgr.c +1 -11
-	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);
author maintainer
#9 lore raw

Re: [PATCH 03/10] fpga: fpga-mgr: dfl-fme-mgr: Simplify registration

Quoted 9 lines · Tom Rix
Quoted 7 lines · Moritz Fischer

Simplify registration using new devm_fpga_mgr_register() API.

---
 drivers/fpga/dfl-fme-mgr.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)
Quoted 8 lines

drivers/fpga/dfl-fme-mgr.c static int fme_mgr_probe(struct platform_device *pdev) · line 317

Quoted 7 lines
drivers/fpga/dfl-fme-mgr.c +0 -0
index b3f7eee3c93f..3fc2be87d059 100644
@@ -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.

Quoted 26 lines

Is this call is still needed ?

Tom

Quoted 22 lines
drivers/fpga/dfl-fme-mgr.c +1 -11
-	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,
 };
 
Quoted 2 lines

drivers/fpga/dfl-fme-mgr.c static struct platform_driver fme_mgr_driver = { · line 329

Quoted 1 line
drivers/fpga/dfl-fme-mgr.c +0 -0
 module_platform_driver(fme_mgr_driver);

Cheers,
Moritz

author maintainer
#10 lore raw

PATCH 4/10 fpga: fpga-mgr: ice40-spi: Simplify registration

In reply to Moritz Fischer

Simplify registration using new devm_fpga_mgr_register() API.

---
 drivers/fpga/ice40-spi.c | 14 +-------------
 1 file changed, 1 insertion(+), 13 deletions(-)
drivers/fpga/ice40-spi.c +1 -13
index 8d689fea0dab..69dec5af23c3 100644
@@ -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),
Signature · 1 line
2.28.0
reviewer Reviewed-by on v1 4/10
#11 lore raw

Re: [PATCH 04/10] fpga: fpga-mgr: ice40-spi: Simplify registration

Quoted 6 lines · Moritz Fischer

Simplify registration using new devm_fpga_mgr_register() API.

---
 drivers/fpga/ice40-spi.c | 14 +-------------
 1 file changed, 1 insertion(+), 13 deletions(-)

LOTM

author maintainer
#12 lore raw

PATCH 5/10 fpga: fpga-mgr: machxo2-spi: Simplify registration

In reply to Moritz Fischer

Simplify registration using new devm_fpga_mgr_register() API.

---
 drivers/fpga/machxo2-spi.c | 14 +-------------
 1 file changed, 1 insertion(+), 13 deletions(-)
drivers/fpga/machxo2-spi.c +1 -13
index b316369156fe..114a64d2b7a4 100644
@@ -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,
 };
 
Signature · 1 line
2.28.0
reviewer Reviewed-by on v1 5/10
#13 lore raw

Re: [PATCH 05/10] fpga: fpga-mgr: machxo2-spi: Simplify registration

Quoted 6 lines · Moritz Fischer

Simplify registration using new devm_fpga_mgr_register() API.

---
 drivers/fpga/machxo2-spi.c | 14 +-------------
 1 file changed, 1 insertion(+), 13 deletions(-)

LOTM

author maintainer
#14 lore raw

PATCH 6/10 fpga: fpga-mgr: socfpga: Simplify registration

In reply to Moritz Fischer

Simplify registration using new devm_fpga_mgr_register() API.

---
 drivers/fpga/socfpga.c | 14 +-------------
 1 file changed, 1 insertion(+), 13 deletions(-)
drivers/fpga/socfpga.c +1 -13
index 4a8a2fcd4e6c..1f467173fc1f 100644
@@ -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),
Signature · 1 line
2.28.0
reviewer Reviewed-by on v1 6/10
#15 lore raw

Re: [PATCH 06/10] fpga: fpga-mgr: socfpga: Simplify registration

Quoted 6 lines · Moritz Fischer

Simplify registration using new devm_fpga_mgr_register() API.

---
 drivers/fpga/socfpga.c | 14 +-------------
 1 file changed, 1 insertion(+), 13 deletions(-)

LOTM

author maintainer
#16 lore raw

PATCH 7/10 fpga: fpga-mgr: ts73xx: Simplify registration

In reply to Moritz Fischer

Simplify registration using new devm_fpga_mgr_register() API.

---
 drivers/fpga/ts73xx-fpga.c | 14 +-------------
 1 file changed, 1 insertion(+), 13 deletions(-)
drivers/fpga/ts73xx-fpga.c +1 -13
index 2888ff000e4d..101f016c6ed8 100644
@@ -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);
 
Signature · 1 line
2.28.0
reviewer Reviewed-by on v1 7/10
#17 lore raw

Re: [PATCH 07/10] fpga: fpga-mgr: ts73xx: Simplify registration

Quoted 6 lines · Moritz Fischer

Simplify registration using new devm_fpga_mgr_register() API.

---
 drivers/fpga/ts73xx-fpga.c | 14 +-------------
 1 file changed, 1 insertion(+), 13 deletions(-)

LOTM

author maintainer
#18 lore raw

PATCH 8/10 fpga: fpga-mgr: xilinx-spi: Simplify registration

In reply to Moritz Fischer

Simplify registration using new devm_fpga_mgr_register() API.

---
 drivers/fpga/xilinx-spi.c | 14 +-------------
 1 file changed, 1 insertion(+), 13 deletions(-)
drivers/fpga/xilinx-spi.c +1 -13
index 824abbbd631e..27defa98092d 100644
@@ -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)
Signature · 1 line
2.28.0
reviewer Reviewed-by on v1 8/10
#19 lore raw

Re: [PATCH 08/10] fpga: fpga-mgr: xilinx-spi: Simplify registration

Quoted 6 lines · Moritz Fischer

Simplify registration using new devm_fpga_mgr_register() API.

---
 drivers/fpga/xilinx-spi.c | 14 +-------------
 1 file changed, 1 insertion(+), 13 deletions(-)

LOTM

author maintainer
#20 lore raw

PATCH 9/10 fpga: fpga-mgr: zynqmp: Simplify registration

In reply to Moritz Fischer

Simplify registration using new devm_fpga_mgr_register() API.

---
 drivers/fpga/zynqmp-fpga.c | 21 +--------------------
 1 file changed, 1 insertion(+), 20 deletions(-)
drivers/fpga/zynqmp-fpga.c +1 -20
index 4a1139e05280..125743c9797f 100644
@@ -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),
Signature · 1 line
2.28.0
reviewer Reviewed-by on v1 9/10
#21 lore raw

Re: [PATCH 09/10] fpga: fpga-mgr: zynqmp: Simplify registration

Quoted 6 lines · Moritz Fischer

Simplify registration using new devm_fpga_mgr_register() API.

---
 drivers/fpga/zynqmp-fpga.c | 21 +--------------------
 1 file changed, 1 insertion(+), 20 deletions(-)

LOTM

author maintainer
#22 lore raw

PATCH 10/10 fpga: fpga-mgr: altera-pr-ip: Simplify registration

In reply to Moritz Fischer

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

---

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(-)
drivers/fpga/altera-pr-ip-core-plat.c +0 -10
index 99b9cc0e70f0..b008a6b8d2d3 100644
@@ -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,
drivers/fpga/altera-pr-ip-core.c +1 -13
index 2cf25fd5e897..dfdf21ed34c4 100644
@@ -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 <[email protected]>");
 MODULE_DESCRIPTION("Altera Partial Reconfiguration IP Core");
 MODULE_LICENSE("GPL v2");
include/linux/fpga/altera-pr-ip-core.h +0 -1
index 0b08ac20ab16..a6b4c07858cc 100644
@@ -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 */
Signature · 1 line
2.28.0
reviewer
#23 lore raw

Re: [PATCH 10/10] fpga: fpga-mgr: altera-pr-ip: Simplify registration

Quoted 61 lines · Moritz Fischer

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

---

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(-)
drivers/fpga/altera-pr-ip-core-plat.c +0 -10
index 99b9cc0e70f0..b008a6b8d2d3 100644
@@ -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,
drivers/fpga/altera-pr-ip-core.c +1 -3
index 2cf25fd5e897..dfdf21ed34c4 100644
@@ -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);

drivers/fpga/altera-pr-ip-core.c int alt_pr_register(struct device *dev, void __iomem *reg_base) · line 212

Quoted 10 lines
drivers/fpga/altera-pr-ip-core.c +0 -9
 
-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

Quoted 15 lines
drivers/fpga/altera-pr-ip-core.c +0 -1
-
 MODULE_AUTHOR("Matthew Gerlach <[email protected]>");
 MODULE_DESCRIPTION("Altera Partial Reconfiguration IP Core");
 MODULE_LICENSE("GPL v2");
include/linux/fpga/altera-pr-ip-core.h +0 -1
index 0b08ac20ab16..a6b4c07858cc 100644
@@ -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 */
author maintainer
#24 lore raw

Re: [PATCH 10/10] fpga: fpga-mgr: altera-pr-ip: Simplify registration

Quoted 76 lines · Tom Rix
Quoted 61 lines · Moritz Fischer

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

---

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(-)
drivers/fpga/altera-pr-ip-core-plat.c +0 -10
index 99b9cc0e70f0..b008a6b8d2d3 100644
@@ -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,
drivers/fpga/altera-pr-ip-core.c +1 -3
index 2cf25fd5e897..dfdf21ed34c4 100644
@@ -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);

drivers/fpga/altera-pr-ip-core.c int alt_pr_register(struct device *dev, void __iomem *reg_base) · line 212

Quoted 10 lines
drivers/fpga/altera-pr-ip-core.c +0 -9
 
-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.

Quoted 1 line

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.

Quoted 16 lines

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

Tom

Quoted 11 lines
drivers/fpga/altera-pr-ip-core.c +0 -1
-
 MODULE_AUTHOR("Matthew Gerlach <[email protected]>");
 MODULE_DESCRIPTION("Altera Partial Reconfiguration IP Core");
 MODULE_LICENSE("GPL v2");
include/linux/fpga/altera-pr-ip-core.h +0 -0
index 0b08ac20ab16..a6b4c07858cc 100644
@@ -13,6 +13,5 @@
 #include <linux/io.h>
 
Quoted 5 lines

include/linux/fpga/altera-pr-ip-core.h line 17

Quoted 4 lines
include/linux/fpga/altera-pr-ip-core.h +0 -1
 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