From: Alan Tull <atull@kernel.org>
To: Moritz Fischer <moritz.fischer@ettus.com>
Cc: Alan Tull <atull@kernel.org>,
linux-kernel@vger.kernel.org, linux-fpga@vger.kernel.org
Subject: [RFC 3/5] fpga: add dev to fpga_image_info
Date: Mon, 24 Jul 2017 14:49:13 -0500 [thread overview]
Message-ID: <1500925755-5727-4-git-send-email-atull@kernel.org> (raw)
In-Reply-To: <1500925755-5727-1-git-send-email-atull@kernel.org>
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@kernel.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(®ion->bridge_list);
fpga_bridges_put(®ion->bridge_list);
- fpga_image_info_free(®ion->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
next prev parent reply other threads:[~2017-07-24 19:50 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-24 19:49 [RFC 0/5] Open source FPGA image header Alan Tull
2017-07-24 19:49 ` [RFC 1/5] doc: fpga: add document for the fdt FPGA header Alan Tull
2017-07-24 19:49 ` [RFC 2/5] doc: fpga: add sysfs document for fpga region Alan Tull
2017-07-24 19:49 ` Alan Tull [this message]
2017-07-24 19:49 ` [RFC 4/5] fpga-region: new function fpga_region_free Alan Tull
2017-07-24 19:49 ` [RFC 5/5] fpga-region support for fdt headers on fpga images Alan Tull
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1500925755-5727-4-git-send-email-atull@kernel.org \
--to=atull@kernel.org \
--cc=linux-fpga@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=moritz.fischer@ettus.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).