lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1500925755-5727-4-git-send-email-atull@kernel.org>
Date:   Mon, 24 Jul 2017 14:49:13 -0500
From:   Alan Tull <atull@...nel.org>
To:     Moritz Fischer <moritz.fischer@...us.com>
Cc:     Alan Tull <atull@...nel.org>, linux-kernel@...r.kernel.org,
        linux-fpga@...r.kernel.org
Subject: [RFC 3/5] fpga: add dev to fpga_image_info

This patch should be rolled into the next version of my
"non-dt support for FPGA regions" patchset.

Add a pointer to the device that owns the fpga_image_info to
fpga_image_info.  That way the fpga_image_info_free can
drop the 'dev' parameter and we are left with:

struct fpga_image_info *fpga_image_info_alloc(struct device *dev);

void fpga_image_info_free(struct fpga_image_info *info);

Signed-off-by: Alan Tull <atull@...nel.org>
---
 drivers/fpga/fpga-mgr.c       | 14 ++++++++++----
 drivers/fpga/of-fpga-region.c |  6 +++---
 include/linux/fpga/fpga-mgr.h |  4 +++-
 3 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c
index be13cce..af33310 100644
--- a/drivers/fpga/fpga-mgr.c
+++ b/drivers/fpga/fpga-mgr.c
@@ -40,20 +40,26 @@ struct fpga_image_info *fpga_image_info_alloc(struct device *dev)
 	if (!info)
 		return ERR_PTR(-ENOMEM);
 
+	get_device(dev);
+	info->dev = dev;
+
 	return info;
 }
 EXPORT_SYMBOL_GPL(fpga_image_info_alloc);
 
-void fpga_image_info_free(struct device *dev,
-			  struct fpga_image_info *info)
+void fpga_image_info_free(struct fpga_image_info *info)
 {
+	struct device *dev;
+
 	if (!info)
 		return;
 
 	if (info->firmware_name)
-		devm_kfree(dev, info->firmware_name);
+		devm_kfree(info->dev, info->firmware_name);
 
-	devm_kfree(dev, info);
+	dev = info->dev;
+	devm_kfree(info->dev, info);
+	put_device(dev);
 }
 EXPORT_SYMBOL_GPL(fpga_image_info_free);
 
diff --git a/drivers/fpga/of-fpga-region.c b/drivers/fpga/of-fpga-region.c
index c2ea9b6..6bb5799 100644
--- a/drivers/fpga/of-fpga-region.c
+++ b/drivers/fpga/of-fpga-region.c
@@ -273,7 +273,7 @@ static struct fpga_image_info *of_fpga_region_parse_ov(
 
 	return info;
 ret_no_info:
-	fpga_image_info_free(dev, info);
+	fpga_image_info_free(info);
 	return ERR_PTR(ret);
 }
 
@@ -314,7 +314,7 @@ static int of_fpga_region_notify_pre_apply(struct fpga_region *region,
 	ret = fpga_region_program_fpga(region);
 	if (ret) {
 		/* error; reject overlay */
-		fpga_image_info_free(dev, info);
+		fpga_image_info_free(info);
 		region->info = NULL;
 	}
 
@@ -335,7 +335,7 @@ static void of_fpga_region_notify_post_remove(struct fpga_region *region,
 {
 	fpga_bridges_disable(&region->bridge_list);
 	fpga_bridges_put(&region->bridge_list);
-	fpga_image_info_free(&region->dev, region->info);
+	fpga_image_info_free(region->info);
 	region->info = NULL;
 }
 
diff --git a/include/linux/fpga/fpga-mgr.h b/include/linux/fpga/fpga-mgr.h
index 50954cb..ddc56c0 100644
--- a/include/linux/fpga/fpga-mgr.h
+++ b/include/linux/fpga/fpga-mgr.h
@@ -79,6 +79,7 @@ enum fpga_mgr_states {
 
 /**
  * struct fpga_image_info - information specific to a FPGA image
+ * @dev: device that owns this info
  * @flags: boolean flags as defined above
  * @enable_timeout_us: maximum time to enable traffic through bridge (uSec)
  * @disable_timeout_us: maximum time to disable traffic through bridge (uSec)
@@ -91,6 +92,7 @@ enum fpga_mgr_states {
  * @overlay: Device Tree overlay
  */
 struct fpga_image_info {
+	struct device *dev;
 	u32 flags;
 	u32 enable_timeout_us;
 	u32 disable_timeout_us;
@@ -153,7 +155,7 @@ struct fpga_manager {
 
 struct fpga_image_info *fpga_image_info_alloc(struct device *dev);
 
-void fpga_image_info_free(struct device *dev, struct fpga_image_info *info);
+void fpga_image_info_free(struct fpga_image_info *info);
 
 int fpga_mgr_load(struct fpga_manager *mgr, struct fpga_image_info *info);
 
-- 
2.7.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ