Skip to contentSkip to conversation

tty/ldsem: Remove unused ldsem_down_write_trylock

PATCH In review [email protected] 2 participants 2 messages Jan 22, 2025 TTY layer and serial drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tty/ldsem: Remove unused ldsem_down_write_trylock

From: "Dr. David Alan Gilbert" <[email protected]>

ldsem_down_write_trylock() was added in 2013 by
commit 4898e640caf0 ("tty: Add timed, writer-prioritized rw semaphore") but hasn't been used.

Remove it.

---
 drivers/tty/tty_ldsem.c   | 17 -----------------
 include/linux/tty_ldisc.h |  1 -
 2 files changed, 18 deletions(-)
drivers/tty/tty_ldsem.c +0 -17
index 3be428c16260..4e18031a5ca3 100644
@@ -366,23 +366,6 @@ int __sched ldsem_down_write(struct ld_semaphore *sem, long timeout)
 	return __ldsem_down_write_nested(sem, 0, timeout);
 }
 
-/*
- * trylock for writing -- returns 1 if successful, 0 if contention
- */
-int ldsem_down_write_trylock(struct ld_semaphore *sem)
-{
-	long count = atomic_long_read(&sem->count);
-
-	while ((count & LDSEM_ACTIVE_MASK) == 0) {
-		if (atomic_long_try_cmpxchg(&sem->count, &count, count + LDSEM_WRITE_BIAS)) {
-			rwsem_acquire(&sem->dep_map, 0, 1, _RET_IP_);
-			lock_acquired(&sem->dep_map, _RET_IP_);
-			return 1;
-		}
-	}
-	return 0;
-}
-
 /*
  * release a read lock
  */
include/linux/tty_ldisc.h +0 -1
index af01e89074b2..c5cccc3fc1e8 100644
@@ -39,7 +39,6 @@ do {								\
 int ldsem_down_read(struct ld_semaphore *sem, long timeout);
 int ldsem_down_read_trylock(struct ld_semaphore *sem);
 int ldsem_down_write(struct ld_semaphore *sem, long timeout);
-int ldsem_down_write_trylock(struct ld_semaphore *sem);
 void ldsem_up_read(struct ld_semaphore *sem);
 void ldsem_up_write(struct ld_semaphore *sem);
 
Signature · 1 line
2.48.1
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · On 22. 01. 25, 2:25, [email protected] wrote:

From: "Dr. David Alan Gilbert" <[email protected]>

ldsem_down_write_trylock() was added in 2013 by
commit 4898e640caf0 ("tty: Add timed, writer-prioritized rw semaphore") but hasn't been used.

Remove it.

Right, it was likely added for symmetry. However having untested+unused code is indeed wrong.

thanks,

Signature · 2 lines
js
suse labs