[PATCH] Update core.c
From: Okan Tumuklu
Date: Mon Sep 30 2024 - 18:07:26 EST
From: Okan Tümüklü <117488504+Okan-tumuklu@xxxxxxxxxxxxxxxxxxxxxxxx>
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