lkml.org 
[lkml]   [2017]   [Nov]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] staging/rts5208/rtsx: Improve unlocking of a mutex in rtsx_resume()
Date
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 3 Nov 2017 20:02:22 +0100

* Add a jump target so that a call of the function "mutex_unlock" is stored
only twice in this function implementation.

* Replace two calls by goto statements.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/staging/rts5208/rtsx.c | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/rts5208/rtsx.c b/drivers/staging/rts5208/rtsx.c
index 89e2cfe7d1cc..14022a76ecfb 100644
--- a/drivers/staging/rts5208/rtsx.c
+++ b/drivers/staging/rts5208/rtsx.c
@@ -349,9 +349,7 @@ static int rtsx_resume(struct pci_dev *pci)
dev_err(&dev->pci->dev,
"%s: pci_enable_device failed, disabling device\n",
CR_DRIVER_NAME);
- /* unlock the device pointers */
- mutex_unlock(&dev->dev_mutex);
- return -EIO;
+ goto unlock;
}
pci_set_master(pci);

@@ -360,11 +358,8 @@ static int rtsx_resume(struct pci_dev *pci)
chip->msi_en = 0;
}

- if (rtsx_acquire_irq(dev) < 0) {
- /* unlock the device pointers */
- mutex_unlock(&dev->dev_mutex);
- return -EIO;
- }
+ if (rtsx_acquire_irq(dev) < 0)
+ goto unlock;

rtsx_write_register(chip, HOST_SLEEP_STATE, 0x03, 0x00);
rtsx_init_chip(chip);
@@ -373,6 +368,10 @@ static int rtsx_resume(struct pci_dev *pci)
mutex_unlock(&dev->dev_mutex);

return 0;
+
+unlock:
+ mutex_unlock(&dev->dev_mutex);
+ return -EIO;
}
#endif /* CONFIG_PM */

--
2.15.0
\
 
 \ /
  Last update: 2017-11-03 20:10    [W:0.030 / U:0.024 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site