Skip to contentSkip to conversation

RT: epca_lock to DEFINE_SPINLOCK

PATCH Applied Daniel Walker 7 participants 8 messages Sep 27, 2005 – Sep 29, 2005 Char and misc drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 RT: epca_lock to DEFINE_SPINLOCK

Convert epca_lock to the new syntax.

drivers/char/epca.c +1 -1
Index: linux-2.6.13/drivers/char/epca.c
===================================================================
@@ -80,7 +80,7 @@ static int invalid_lilo_config;
 /* The ISA boards do window flipping into the same spaces so its only sane
    with a single lock. It's still pretty efficient */
 
-static spinlock_t epca_lock = SPIN_LOCK_UNLOCKED;
+static DEFINE_SPINLOCK(epca_lock);
 
 /* -----------------------------------------------------------------------
 	MAXBOARDS is typically 12, but ISA and EISA cards are restricted to 
#1 lore raw
Quoted 9 lines · Daniel Walker

Convert epca_lock to the new syntax.

Index: linux-2.6.13/drivers/char/epca.c
===================================================================

drivers/char/epca.c static int invalid_lilo_config; · line 83

Quoted 5 lines
drivers/char/epca.c +1 -1
@@ -80,7 +80,7 @@ static int invalid_lilo_config;
 /* The ISA boards do window flipping into the same spaces so its only sane
    with a single lock. It's still pretty efficient */
 
-static spinlock_t epca_lock = SPIN_LOCK_UNLOCKED;
+static DEFINE_SPINLOCK(epca_lock);

Please submit also to Andrew/subsystem maintainer. Thats not a -RT related issue.

tglx

#3 lore raw
In reply to Daniel Walker
Quoted 9 lines · Daniel Walker

Convert epca_lock to the new syntax.

Index: linux-2.6.13/drivers/char/epca.c
===================================================================

drivers/char/epca.c static int invalid_lilo_config; · line 85

Quoted 7 lines
drivers/char/epca.c +1 -1
@@ -80,7 +80,7 @@ static int invalid_lilo_config;
 /* The ISA boards do window flipping into the same spaces so its only sane
    with a single lock. It's still pretty efficient */
 
-static spinlock_t epca_lock = SPIN_LOCK_UNLOCKED;
+static DEFINE_SPINLOCK(epca_lock);
 
 /* ------------------

this is really ugly though; at minimum a DEFINE_STATIC_SPINLOCK() would be needed to make this less ugly.

#4 lore raw
Quoted 2 lines · Arjan van de Ven

this is really ugly though; at minimum a DEFINE_STATIC_SPINLOCK() would be needed to make this less ugly.

Doesn't exists as far as I know .. Shall we make one ?

Daniel

#5 lore raw
In reply to Arjan van de Ven

Arjan> this is really ugly though; at minimum a DEFINE_STATIC_SPINLOCK() Arjan> would be needed to make this less ugly.

huh? This is a totally standard kernel idiom -- just do

grep -Er 'static (DECLARE|DEFINE)' .

in a kernel tree to see how prevalent it is.

- R.

#6 lore raw
Quoted 8 lines · Roland Dreier

Arjan> this is really ugly though; at minimum a DEFINE_STATIC_SPINLOCK() Arjan> would be needed to make this less ugly.

huh? This is a totally standard kernel idiom -- just do

grep -Er 'static (DECLARE|DEFINE)' .

in a kernel tree to see how prevalent it is.

It may be widely used and still ugly. The general problem with DEFINE_FOO() macros is that they obfuscate things: they do not _look_ like C variable declarations, and, in particular, type of variable is not immediately obvious.

The only reasonable case where DEFINE_FOO(x) is really necessary is when initializer uses address of x, but even in that case something like

        spinlock_t guard = SPINLOCK_UNLOCKED(guard);

is much more readable than

        DEFINE_SPIN_LOCK(guard);

The question is: does RT really have to force DEFINE_* as the only way to define things?

Quoted 2 lines

- R.

Nikita.

#7 lore raw
Quoted 10 lines · Nikita Danilov

The only reasonable case where DEFINE_FOO(x) is really necessary is when initializer uses address of x, but even in that case something like

        spinlock_t guard = SPINLOCK_UNLOCKED(guard);

is much more readable than

        DEFINE_SPIN_LOCK(guard);

Except that the former is also error prone. I just found a bug in my code (I customize Ingo's RT kernel) where I had a cut and paste error:

spinlock_t a = SPINLOCK_UNLOCKED(a);
spinlock_t b = SPINLOCK_UNLOCKED(a);

This took me two days to find since the problems occurred elsewhere.

-- Steve