mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: <atull@opensource.altera.com>
To: <gregkh@linuxfoundation.org>
Cc: Josh Cartwright <joshc@ni.com>,
	Moritz Fischer <moritz.fischer@ettus.com>,
	<linux-kernel@vger.kernel.org>, <delicious.quinoa@gmail.com>,
	<dinguyen@opensource.altera.com>,
	Alan Tull <atull@opensource.altera.com>
Subject: [PATCH 2/2] fpga manager: remove unnecessary null pointer checks
Date: Thu, 22 Oct 2015 12:38:38 -0500	[thread overview]
Message-ID: <1445535518-13406-3-git-send-email-atull@opensource.altera.com> (raw)
In-Reply-To: <1445535518-13406-1-git-send-email-atull@opensource.altera.com>

From: Alan Tull <atull@opensource.altera.com>

Remove unnecessary null pointer checks.  We want the caller of
these functions to do their own pointer checks.  Add some
comments to document this.

Signed-off-by: Alan Tull <atull@opensource.altera.com>
---
 drivers/fpga/fpga-mgr.c |   12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c
index 68d7b41..a24f5cb 100644
--- a/drivers/fpga/fpga-mgr.c
+++ b/drivers/fpga/fpga-mgr.c
@@ -38,7 +38,8 @@ static struct class *fpga_mgr_class;
  *
  * Step the low level fpga manager through the device-specific steps of getting
  * an FPGA ready to be configured, writing the image to it, then doing whatever
- * post-configuration steps necessary.
+ * post-configuration steps necessary.  This code assumes the caller got the
+ * mgr pointer from of_fpga_mgr_get() and checked that it is not an error code.
  *
  * Return: 0 on success, negative error code otherwise.
  */
@@ -48,9 +49,6 @@ int fpga_mgr_buf_load(struct fpga_manager *mgr, u32 flags, const char *buf,
 	struct device *dev = &mgr->dev;
 	int ret;
 
-	if (!mgr)
-		return -ENODEV;
-
 	/*
 	 * Call the low level driver's write_init function.  This will do the
 	 * device-specific things to get the FPGA into the state where it is
@@ -100,7 +98,8 @@ EXPORT_SYMBOL_GPL(fpga_mgr_buf_load);
  *
  * Request an FPGA image using the firmware class, then write out to the FPGA.
  * Update the state before each step to provide info on what step failed if
- * there is a failure.
+ * there is a failure.  This code assumes the caller got the mgr pointer
+ * from of_fpga_mgr_get() and checked that it is not an error code.
  *
  * Return: 0 on success, negative error code otherwise.
  */
@@ -111,9 +110,6 @@ int fpga_mgr_firmware_load(struct fpga_manager *mgr, u32 flags,
 	const struct firmware *fw;
 	int ret;
 
-	if (!mgr)
-		return -ENODEV;
-
 	dev_info(dev, "writing %s to %s\n", image_name, mgr->name);
 
 	mgr->state = FPGA_MGR_STATE_FIRMWARE_REQ;
-- 
1.7.9.5


  parent reply	other threads:[~2015-10-22 18:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-22 17:38 [PATCH 0/2] fpga manager fixes atull
2015-10-22 17:38 ` [PATCH 1/2] fpga manager: ensure lifetime with of_fpga_mgr_get atull
2015-10-22 17:38 ` atull [this message]
2015-10-22 17:50   ` [PATCH 2/2] fpga manager: remove unnecessary null pointer checks Moritz Fischer

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=1445535518-13406-3-git-send-email-atull@opensource.altera.com \
    --to=atull@opensource.altera.com \
    --cc=delicious.quinoa@gmail.com \
    --cc=dinguyen@opensource.altera.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=joshc@ni.com \
    --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

Powered by JetHome