Blob Blame History Raw
From 6489d3b00398f02457eea566d4a99698c68cc89f Mon Sep 17 00:00:00 2001
From: Tom Rix <trix@redhat.com>
Date: Fri, 25 Jun 2021 12:51:47 -0700
Subject: [PATCH] fpga: fpga-mgr: wrap the fpga_remove() op
Git-commit: 6489d3b00398f02457eea566d4a99698c68cc89f
Patch-mainline: v5.15-rc1
References: jsc#PED-1263

An FPGA manager is not required to provide a fpga_remove() op.
Add a wrapper consistent with the other op wrappers.
Move op check to wrapper.

[mdf@kernel.org: Reworded first line]
Signed-off-by: Tom Rix <trix@redhat.com>
Signed-off-by: Moritz Fischer <mdf@kernel.org>
Acked-by: Takashi Iwai <tiwai@suse.de>

---
 drivers/fpga/fpga-mgr.c |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

--- a/drivers/fpga/fpga-mgr.c
+++ b/drivers/fpga/fpga-mgr.c
@@ -46,6 +46,12 @@ static inline int fpga_mgr_write(struct
 	return -EOPNOTSUPP;
 }
 
+static inline void fpga_mgr_fpga_remove(struct fpga_manager *mgr)
+{
+	if (mgr->mops->fpga_remove)
+		mgr->mops->fpga_remove(mgr);
+}
+
 /*
  * After all the FPGA image has been written, do the device specific steps to
  * finish and set the FPGA into operating mode.
@@ -745,8 +751,7 @@ void fpga_mgr_unregister(struct fpga_man
 	 * If the low level driver provides a method for putting fpga into
 	 * a desired state upon unregister, do it.
 	 */
-	if (mgr->mops->fpga_remove)
-		mgr->mops->fpga_remove(mgr);
+	fpga_mgr_fpga_remove(mgr);
 
 	device_unregister(&mgr->dev);
 }