ChangeSet 1.2231.1.181, 2005/03/28 20:06:44-08:00, [EMAIL PROTECTED]

        [PATCH] unified spinlock initialization
        
        - remove the usage of {SPIN,RW}_LOCK_UNLOCKED as far as possible
        
        - add a note to Documentation/spinlocks.txt about the deprecation of the
          macros {SPIN,RW}_LOCK_UNLOCKED
        
        Signed-off-by: Amit Gud <[EMAIL PROTECTED]>
        Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
        Signed-off-by: Linus Torvalds <[EMAIL PROTECTED]>



 Documentation/spinlocks.txt       |   26 ++++++++++++++++++++++++++
 arch/ppc/8xx_io/cs4218_tdm.c      |    2 +-
 arch/um/drivers/net_kern.c        |    2 +-
 drivers/char/tpm/tpm.c            |    2 +-
 drivers/input/serio/hil_mlc.c     |    4 ++--
 drivers/input/serio/hp_sdc.c      |    8 ++++----
 drivers/media/dvb/b2c2/skystar2.c |    2 +-
 drivers/serial/ioc4_serial.c      |    2 +-
 drivers/usb/media/pwc/pwc-if.c    |    2 +-
 9 files changed, 38 insertions(+), 12 deletions(-)


diff -Nru a/Documentation/spinlocks.txt b/Documentation/spinlocks.txt
--- a/Documentation/spinlocks.txt       2005-03-28 21:46:34 -08:00
+++ b/Documentation/spinlocks.txt       2005-03-28 21:46:34 -08:00
@@ -1,3 +1,29 @@
+UPDATE March 21 2005 Amit Gud <[EMAIL PROTECTED]>
+
+Macros SPIN_LOCK_UNLOCKED and RW_LOCK_UNLOCKED are deprecated and will be
+removed soon. So for any new code dynamic initialization should be used:
+
+   spinlock_t xxx_lock;
+   rwlock_t xxx_rw_lock;
+
+   static int __init xxx_init(void)
+   {
+       spin_lock_init(&xxx_lock);
+       rw_lock_init(&xxx_rw_lock);
+       ...
+   }
+
+   module_init(xxx_init);
+
+Reasons for deprecation
+  - it hurts automatic lock validators
+  - it becomes intrusive for the realtime preemption patches
+
+Following discussion is still valid, however, with the dynamic initialization
+of spinlocks instead of static.
+
+-----------------------
+
 On Fri, 2 Jan 1998, Doug Ledford wrote:
 > 
 > I'm working on making the aic7xxx driver more SMP friendly (as well as
diff -Nru a/arch/ppc/8xx_io/cs4218_tdm.c b/arch/ppc/8xx_io/cs4218_tdm.c
--- a/arch/ppc/8xx_io/cs4218_tdm.c      2005-03-28 21:46:34 -08:00
+++ b/arch/ppc/8xx_io/cs4218_tdm.c      2005-03-28 21:46:34 -08:00
@@ -55,7 +55,7 @@
 static char **sound_buffers = NULL;
 static char **sound_read_buffers = NULL;
 
-static spinlock_t cs4218_lock = SPIN_LOCK_UNLOCKED;
+static DEFINE_SPINLOCK(cs4218_lock);
 
 /* Local copies of things we put in the control register.  Output
  * volume, like most codecs is really attenuation.
diff -Nru a/arch/um/drivers/net_kern.c b/arch/um/drivers/net_kern.c
--- a/arch/um/drivers/net_kern.c        2005-03-28 21:46:34 -08:00
+++ b/arch/um/drivers/net_kern.c        2005-03-28 21:46:34 -08:00
@@ -383,7 +383,6 @@
        save = lp->user[0];
        *lp = ((struct uml_net_private)
                { .list                 = LIST_HEAD_INIT(lp->list),
-                 .lock                 = SPIN_LOCK_UNLOCKED,
                  .dev                  = dev,
                  .fd                   = -1,
                  .mac                  = { 0xfe, 0xfd, 0x0, 0x0, 0x0, 0x0},
@@ -400,6 +399,7 @@
                  .user                 = { save } });
 
        init_timer(&lp->tl);
+       spin_lock_init(&lp->lock);
        lp->tl.function = uml_net_user_timer_expire;
        if (lp->have_mac)
                memcpy(lp->mac, device->mac, sizeof(lp->mac));
diff -Nru a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c
--- a/drivers/char/tpm/tpm.c    2005-03-28 21:46:34 -08:00
+++ b/drivers/char/tpm/tpm.c    2005-03-28 21:46:34 -08:00
@@ -39,7 +39,7 @@
 #define        PCI_GEN2_DEC                    0xEC
 
 static LIST_HEAD(tpm_chip_list);
-static spinlock_t driver_lock = SPIN_LOCK_UNLOCKED;
+static DEFINE_SPINLOCK(driver_lock);
 static int dev_mask[32];
 
 static void user_reader_timeout(unsigned long ptr)
diff -Nru a/drivers/input/serio/hil_mlc.c b/drivers/input/serio/hil_mlc.c
--- a/drivers/input/serio/hil_mlc.c     2005-03-28 21:46:34 -08:00
+++ b/drivers/input/serio/hil_mlc.c     2005-03-28 21:46:34 -08:00
@@ -72,7 +72,7 @@
 #define PREFIX "HIL MLC: "
 
 static LIST_HEAD(hil_mlcs);
-static rwlock_t                        hil_mlcs_lock = RW_LOCK_UNLOCKED;
+static DEFINE_RWLOCK(hil_mlcs_lock);
 static struct timer_list       hil_mlcs_kicker;
 static int                     hil_mlcs_probe;
 
@@ -848,7 +848,7 @@
        mlc->istarted = 0;
         mlc->ostarted = 0;
 
-        mlc->lock = RW_LOCK_UNLOCKED;
+        rwlock_init(&mlc->lock);
         init_MUTEX(&(mlc->osem));
 
         init_MUTEX(&(mlc->isem));
diff -Nru a/drivers/input/serio/hp_sdc.c b/drivers/input/serio/hp_sdc.c
--- a/drivers/input/serio/hp_sdc.c      2005-03-28 21:46:34 -08:00
+++ b/drivers/input/serio/hp_sdc.c      2005-03-28 21:46:34 -08:00
@@ -779,10 +779,10 @@
        uint8_t ts_sync[6];
        struct semaphore s_sync;
 
-       hp_sdc.lock             = RW_LOCK_UNLOCKED;
-       hp_sdc.ibf_lock         = RW_LOCK_UNLOCKED;
-       hp_sdc.rtq_lock         = RW_LOCK_UNLOCKED;
-       hp_sdc.hook_lock        = RW_LOCK_UNLOCKED;
+       rwlock_init(&hp_sdc.lock);
+       rwlock_init(&hp_sdc.ibf_lock);
+       rwlock_init(&hp_sdc.rtq_lock);
+       rwlock_init(&hp_sdc.hook_lock);
 
        hp_sdc.timer            = NULL;
        hp_sdc.hil              = NULL;
diff -Nru a/drivers/media/dvb/b2c2/skystar2.c 
b/drivers/media/dvb/b2c2/skystar2.c
--- a/drivers/media/dvb/b2c2/skystar2.c 2005-03-28 21:46:34 -08:00
+++ b/drivers/media/dvb/b2c2/skystar2.c 2005-03-28 21:46:34 -08:00
@@ -1968,7 +1968,7 @@
                ctrl_enable_mac(adapter, 1);
        }
 
-       adapter->lock = SPIN_LOCK_UNLOCKED;
+       spin_lock_init(&adapter->lock);
 
 out:
        return ret;
diff -Nru a/drivers/serial/ioc4_serial.c b/drivers/serial/ioc4_serial.c
--- a/drivers/serial/ioc4_serial.c      2005-03-28 21:46:34 -08:00
+++ b/drivers/serial/ioc4_serial.c      2005-03-28 21:46:34 -08:00
@@ -2665,7 +2665,7 @@
                                __FUNCTION__, (void *)the_port,
                                (void *)port));
 
-               the_port->lock = SPIN_LOCK_UNLOCKED;
+               spin_lock_init(&the_port->lock);
                /* membase, iobase and mapbase just need to be non-0 */
                the_port->membase = (unsigned char __iomem *)1;
                the_port->line = the_port->iobase = ii;
diff -Nru a/drivers/usb/media/pwc/pwc-if.c b/drivers/usb/media/pwc/pwc-if.c
--- a/drivers/usb/media/pwc/pwc-if.c    2005-03-28 21:46:34 -08:00
+++ b/drivers/usb/media/pwc/pwc-if.c    2005-03-28 21:46:34 -08:00
@@ -1896,7 +1896,7 @@
        }
 
        init_MUTEX(&pdev->modlock);
-       pdev->ptrlock = SPIN_LOCK_UNLOCKED;
+       spin_lock_init(&pdev->ptrlock);
 
        pdev->udev = udev;
        init_waitqueue_head(&pdev->frameq);
-
To unsubscribe from this list: send the line "unsubscribe bk-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to