mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2] staging: nvec: use guard(mutex) in nvec_write_sync()
       [not found] <20261012222926.7754-1-deaner92.ref@yahoo.com>
@ 2026-10-12 22:29 ` Jeremy Dean Clifton
  2026-10-13  6:15   ` Greg Kroah-Hartman
  0 siblings, 1 reply; 3+ messages in thread
From: Jeremy Dean Clifton @ 2026-10-12 22:29 UTC (permalink / raw)
  To: Marc Dietrich, Greg Kroah-Hartman
  Cc: ac100, linux-tegra, linux-staging, linux-kernel, outreachy,
	Julia Lawall, Jeremy Dean Clifton

The three return paths of nvec_write_sync() each release
sync_write_mutex with explicit unlock calls.

Use guard(mutex) to unlock the lock automatically on any return
path.

This removes the three mutex_unlock() calls.

No functional change.

Signed-off-by: Jeremy Dean Clifton <deaner92@yahoo.com>
---
v2:
 - Reword the commit message to state the motivation and to make
   clear that removing the mutex_unlock() calls is the result of
   the change (Julia Lawall).
v1: https://lore.kernel.org/all/20261012171312.5998-1-deaner92@yahoo.com/

 drivers/staging/nvec/nvec.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/nvec/nvec.c b/drivers/staging/nvec/nvec.c
index 41cbdfdc1da6..716b1b482568 100644
--- a/drivers/staging/nvec/nvec.c
+++ b/drivers/staging/nvec/nvec.c
@@ -298,17 +298,15 @@ int nvec_write_sync(struct nvec_chip *nvec,
 		    const unsigned char *data, short size,
 		    struct nvec_msg **msg)
 {
-	mutex_lock(&nvec->sync_write_mutex);
+	guard(mutex)(&nvec->sync_write_mutex);
 
 	if (msg)
 		*msg = NULL;
 
 	nvec->sync_write_pending = (data[1] << 8) + data[0];
 
-	if (nvec_write_async(nvec, data, size) < 0) {
-		mutex_unlock(&nvec->sync_write_mutex);
+	if (nvec_write_async(nvec, data, size) < 0)
 		return -ENOMEM;
-	}
 
 	dev_dbg(nvec->dev, "nvec_sync_write: 0x%04x\n",
 		nvec->sync_write_pending);
@@ -316,7 +314,6 @@ int nvec_write_sync(struct nvec_chip *nvec,
 					  msecs_to_jiffies(2000)))) {
 		dev_warn(nvec->dev,
 			 "Timeout waiting for sync write to complete\n");
-		mutex_unlock(&nvec->sync_write_mutex);
 		return -ETIMEDOUT;
 	}
 
@@ -327,8 +324,6 @@ int nvec_write_sync(struct nvec_chip *nvec,
 	else
 		nvec_msg_free(nvec, nvec->last_sync_msg);
 
-	mutex_unlock(&nvec->sync_write_mutex);
-
 	return 0;
 }
 EXPORT_SYMBOL(nvec_write_sync);
-- 
2.43.0


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

* Re: [PATCH v2] staging: nvec: use guard(mutex) in nvec_write_sync()
  2026-10-12 22:29 ` [PATCH v2] staging: nvec: use guard(mutex) in nvec_write_sync() Jeremy Dean Clifton
@ 2026-10-13  6:15   ` Greg Kroah-Hartman
  2026-10-13 15:13     ` Jeremy Clifton
  0 siblings, 1 reply; 3+ messages in thread
From: Greg Kroah-Hartman @ 2026-10-13  6:15 UTC (permalink / raw)
  To: Jeremy Dean Clifton
  Cc: Marc Dietrich, ac100, linux-tegra, linux-staging, linux-kernel,
	outreachy, Julia Lawall

On Mon, Oct 12, 2026 at 10:29:26PM +0000, Jeremy Dean Clifton wrote:
> The three return paths of nvec_write_sync() each release
> sync_write_mutex with explicit unlock calls.
> 
> Use guard(mutex) to unlock the lock automatically on any return
> path.
> 
> This removes the three mutex_unlock() calls.
> 
> No functional change.
> 
> Signed-off-by: Jeremy Dean Clifton <deaner92@yahoo.com>
> ---
> v2:
>  - Reword the commit message to state the motivation and to make
>    clear that removing the mutex_unlock() calls is the result of
>    the change (Julia Lawall).
> v1: https://lore.kernel.org/all/20261012171312.5998-1-deaner92@yahoo.com/

Please read the archives for why I will not take guard() rewrites of
staging drivers (nor do I want to see you use a LLM in here either.)

sorry,

greg k-h

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

* Re: [PATCH v2] staging: nvec: use guard(mutex) in nvec_write_sync()
  2026-10-13  6:15   ` Greg Kroah-Hartman
@ 2026-10-13 15:13     ` Jeremy Clifton
  0 siblings, 0 replies; 3+ messages in thread
From: Jeremy Clifton @ 2026-10-13 15:13 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Marc Dietrich, ac100, linux-tegra, linux-staging, linux-kernel,
	outreachy, Julia Lawall

OK, it's understood. I'll look for another candidate.

Thanks for your feedback.

Jeremy

On 10/13/26 12:15 AM, Greg Kroah-Hartman wrote:
> On Mon, Oct 12, 2026 at 10:29:26PM +0000, Jeremy Dean Clifton wrote:
>> The three return paths of nvec_write_sync() each release
>> sync_write_mutex with explicit unlock calls.
>>
>> Use guard(mutex) to unlock the lock automatically on any return
>> path.
>>
>> This removes the three mutex_unlock() calls.
>>
>> No functional change.
>>
>> Signed-off-by: Jeremy Dean Clifton <deaner92@yahoo.com>
>> ---
>> v2:
>>   - Reword the commit message to state the motivation and to make
>>     clear that removing the mutex_unlock() calls is the result of
>>     the change (Julia Lawall).
>> v1: https://lore.kernel.org/all/20261012171312.5998-1-deaner92@yahoo.com/
> 
> Please read the archives for why I will not take guard() rewrites of
> staging drivers (nor do I want to see you use a LLM in here either.)
> 
> sorry,
> 
> greg k-h


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

end of thread, other threads:[~2026-10-13 15:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20261012222926.7754-1-deaner92.ref@yahoo.com>
2026-10-12 22:29 ` [PATCH v2] staging: nvec: use guard(mutex) in nvec_write_sync() Jeremy Dean Clifton
2026-10-13  6:15   ` Greg Kroah-Hartman
2026-10-13 15:13     ` Jeremy Clifton

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

all inboxes | Powered by JetHome®