public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Okan Tumuklu <okantumukluu@gmail.com>
To: shuah@kernel.org
Cc: linux-kernel@vger.kernel.org,
	"Okan Tümüklü" <117488504+Okan-tumuklu@users.noreply.github.com>
Subject: [PATCH] Update core.c
Date: Tue,  1 Oct 2024 01:06:49 +0300	[thread overview]
Message-ID: <20240930220649.6954-1-okantumukluu@gmail.com> (raw)

From: Okan Tümüklü <117488504+Okan-tumuklu@users.noreply.github.com>

1:The control flow was simplified by using else if statements instead of goto structure.

2:Error conditions are handled more clearly.

3:The device_unlock call at the end of the function is guaranteed in all cases.
---
 net/nfc/core.c | 28 ++++++++++------------------
 1 file changed, 10 insertions(+), 18 deletions(-)

diff --git a/net/nfc/core.c b/net/nfc/core.c
index e58dc6405054..4e8f01145c37 100644
--- a/net/nfc/core.c
+++ b/net/nfc/core.c
@@ -40,27 +40,19 @@ int nfc_fw_download(struct nfc_dev *dev, const char *firmware_name)
 
 	if (dev->shutting_down) {
 		rc = -ENODEV;
-		goto error;
-	}
-
-	if (dev->dev_up) {
+	}else if (dev->dev_up) {
 		rc = -EBUSY;
-		goto error;
-	}
-
-	if (!dev->ops->fw_download) {
+	}else if (!dev->ops->fw_download) {
 		rc = -EOPNOTSUPP;
-		goto error;
-	}
-
-	dev->fw_download_in_progress = true;
-	rc = dev->ops->fw_download(dev, firmware_name);
-	if (rc)
-		dev->fw_download_in_progress = false;
+	}else{
+		dev->fw_download_in_progress = true;
+		rc = dev->ops->fw_download(dev, firmware_name);
+		if (rc)
+			dev->fw_download_in_progress = false;
+		}
 
-error:
-	device_unlock(&dev->dev);
-	return rc;
+		device_unlock(&dev->dev);
+		return rc;
 }
 
 /**
-- 
2.39.5


             reply	other threads:[~2024-09-30 22:07 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-30 22:06 Okan Tumuklu [this message]
2024-09-30 22:12 ` [PATCH] Update core.c Shuah Khan
2024-09-30 22:20   ` Conor Dooley
2024-10-02 13:27     ` Jakub Kicinski
2024-10-02 15:26       ` Shuah Khan
2024-10-02 22:21       ` Al Viro
2024-10-02 23:41         ` Jakub Kicinski
2024-10-02 14:11 ` Bagas Sanjaya

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=20240930220649.6954-1-okantumukluu@gmail.com \
    --to=okantumukluu@gmail.com \
    --cc=117488504+Okan-tumuklu@users.noreply.github.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=shuah@kernel.org \
    /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