public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] staging: vt6656: make spin_lock_irq() human readable
@ 2014-04-30 17:01 Martin Kepplinger
  2014-05-06  5:58 ` [RESEND PATCH] " Martin Kepplinger
  0 siblings, 1 reply; 3+ messages in thread
From: Martin Kepplinger @ 2014-04-30 17:01 UTC (permalink / raw)
  To: gregkh; +Cc: forest, linux-kernel, Martin Kepplinger

Don't require FIRMWAREbDownload() to, first off, unlock a held lock.
Thus do all locking in main_usb.c and hold it for a insignificantly
shorter period of time. This makes the affected area significantly more
readable though.

Signed-off-by: Martin Kepplinger <martink@posteo.de>
---
 drivers/staging/vt6656/firmware.c |    2 --
 drivers/staging/vt6656/main_usb.c |    5 ++++-
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/vt6656/firmware.c b/drivers/staging/vt6656/firmware.c
index cd2ea76..79129ad 100644
--- a/drivers/staging/vt6656/firmware.c
+++ b/drivers/staging/vt6656/firmware.c
@@ -54,7 +54,6 @@ int FIRMWAREbDownload(struct vnt_private *pDevice)
 	int ii, rc;
 
 	DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->Download firmware\n");
-	spin_unlock_irq(&pDevice->lock);
 
 	rc = request_firmware(&fw, FIRMWARE_NAME, dev);
 	if (rc) {
@@ -91,7 +90,6 @@ free_fw:
 out:
 	kfree(pBuffer);
 
-	spin_lock_irq(&pDevice->lock);
 	return result;
 }
 MODULE_FIRMWARE(FIRMWARE_NAME);
diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c
index 3c93230..1dc02c4 100644
--- a/drivers/staging/vt6656/main_usb.c
+++ b/drivers/staging/vt6656/main_usb.c
@@ -319,7 +319,11 @@ static int device_init_registers(struct vnt_private *pDevice)
 	memcpy(pDevice->abySNAP_Bridgetunnel, abySNAP_Bridgetunnel, ETH_ALEN);
 
 	if (!FIRMWAREbCheckVersion(pDevice)) {
+
+		spin_unlock_irq(&pDevice->lock);
 		if (FIRMWAREbDownload(pDevice) == true) {
+
+			spin_lock_irq(&pDevice->lock);
 			if (FIRMWAREbBrach2Sram(pDevice) == false) {
 				DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO
 					" FIRMWAREbBrach2Sram fail\n");
@@ -329,7 +333,6 @@ static int device_init_registers(struct vnt_private *pDevice)
 		} else {
 			DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO
 				" FIRMWAREbDownload fail\n");
-			spin_unlock_irq(&pDevice->lock);
 			return false;
 		}
 	}
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [RESEND PATCH] staging: vt6656: make spin_lock_irq() human readable
  2014-04-30 17:01 [PATCH] staging: vt6656: make spin_lock_irq() human readable Martin Kepplinger
@ 2014-05-06  5:58 ` Martin Kepplinger
  2014-05-06  8:37   ` Dan Carpenter
  0 siblings, 1 reply; 3+ messages in thread
From: Martin Kepplinger @ 2014-05-06  5:58 UTC (permalink / raw)
  To: gregkh; +Cc: forest, devel, linux-kernel, Martin Kepplinger

Don't require FIRMWAREbDownload() to, first off, unlock a held lock.
Thus do all locking in main_usb.c and hold it for a insignificantly
shorter period of time. This makes the affected area significantly more
readable though.

Signed-off-by: Martin Kepplinger <martink@posteo.de>
---
I resend https://lkml.org/lkml/2014/4/30/453 and add devel@driverdev.osuosl.org
after waiting a week or so.

This fixes a sparse warning too, and uses less spin_lock functions.
Maybe someone can think it through.

 drivers/staging/vt6656/firmware.c |    2 --
 drivers/staging/vt6656/main_usb.c |    5 ++++-
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/vt6656/firmware.c b/drivers/staging/vt6656/firmware.c
index cd2ea76..79129ad 100644
--- a/drivers/staging/vt6656/firmware.c
+++ b/drivers/staging/vt6656/firmware.c
@@ -54,7 +54,6 @@ int FIRMWAREbDownload(struct vnt_private *pDevice)
 	int ii, rc;
 
 	DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->Download firmware\n");
-	spin_unlock_irq(&pDevice->lock);
 
 	rc = request_firmware(&fw, FIRMWARE_NAME, dev);
 	if (rc) {
@@ -91,7 +90,6 @@ free_fw:
 out:
 	kfree(pBuffer);
 
-	spin_lock_irq(&pDevice->lock);
 	return result;
 }
 MODULE_FIRMWARE(FIRMWARE_NAME);
diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c
index 3c93230..1dc02c4 100644
--- a/drivers/staging/vt6656/main_usb.c
+++ b/drivers/staging/vt6656/main_usb.c
@@ -319,7 +319,11 @@ static int device_init_registers(struct vnt_private *pDevice)
 	memcpy(pDevice->abySNAP_Bridgetunnel, abySNAP_Bridgetunnel, ETH_ALEN);
 
 	if (!FIRMWAREbCheckVersion(pDevice)) {
+
+		spin_unlock_irq(&pDevice->lock);
 		if (FIRMWAREbDownload(pDevice) == true) {
+
+			spin_lock_irq(&pDevice->lock);
 			if (FIRMWAREbBrach2Sram(pDevice) == false) {
 				DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO
 					" FIRMWAREbBrach2Sram fail\n");
@@ -329,7 +333,6 @@ static int device_init_registers(struct vnt_private *pDevice)
 		} else {
 			DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO
 				" FIRMWAREbDownload fail\n");
-			spin_unlock_irq(&pDevice->lock);
 			return false;
 		}
 	}
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [RESEND PATCH] staging: vt6656: make spin_lock_irq() human readable
  2014-05-06  5:58 ` [RESEND PATCH] " Martin Kepplinger
@ 2014-05-06  8:37   ` Dan Carpenter
  0 siblings, 0 replies; 3+ messages in thread
From: Dan Carpenter @ 2014-05-06  8:37 UTC (permalink / raw)
  To: Martin Kepplinger; +Cc: gregkh, devel, forest, linux-kernel

On Tue, May 06, 2014 at 07:58:39AM +0200, Martin Kepplinger wrote:
> Don't require FIRMWAREbDownload() to, first off, unlock a held lock.
> Thus do all locking in main_usb.c and hold it for a insignificantly
> shorter period of time. This makes the affected area significantly more
> readable though.
> 
> Signed-off-by: Martin Kepplinger <martink@posteo.de>

Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-05-06  8:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-30 17:01 [PATCH] staging: vt6656: make spin_lock_irq() human readable Martin Kepplinger
2014-05-06  5:58 ` [RESEND PATCH] " Martin Kepplinger
2014-05-06  8:37   ` Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox