From: Amit Gud - 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 Signed-off-by: Andrew Morton --- 25-akpm/Documentation/spinlocks.txt | 26 ++++++++++++++++++++++++++ 25-akpm/arch/ppc/8xx_io/cs4218_tdm.c | 2 +- 25-akpm/arch/um/drivers/net_kern.c | 2 +- 25-akpm/drivers/char/tpm/tpm.c | 2 +- 25-akpm/drivers/input/serio/hil_mlc.c | 4 ++-- 25-akpm/drivers/input/serio/hp_sdc.c | 8 ++++---- 25-akpm/drivers/media/dvb/b2c2/skystar2.c | 2 +- 25-akpm/drivers/serial/ioc4_serial.c | 2 +- 25-akpm/drivers/usb/media/pwc/pwc-if.c | 2 +- 9 files changed, 38 insertions(+), 12 deletions(-) diff -puN arch/ppc/8xx_io/cs4218_tdm.c~unified-spinlock-initialization arch/ppc/8xx_io/cs4218_tdm.c --- 25/arch/ppc/8xx_io/cs4218_tdm.c~unified-spinlock-initialization 2005-03-23 13:11:53.000000000 -0800 +++ 25-akpm/arch/ppc/8xx_io/cs4218_tdm.c 2005-03-23 13:11:53.000000000 -0800 @@ -55,7 +55,7 @@ static int irq_installed = 0; 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 -puN arch/um/drivers/net_kern.c~unified-spinlock-initialization arch/um/drivers/net_kern.c --- 25/arch/um/drivers/net_kern.c~unified-spinlock-initialization 2005-03-23 13:11:53.000000000 -0800 +++ 25-akpm/arch/um/drivers/net_kern.c 2005-03-23 13:11:53.000000000 -0800 @@ -383,7 +383,6 @@ static int eth_configure(int n, void *in 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 @@ static int eth_configure(int n, void *in .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 -puN Documentation/spinlocks.txt~unified-spinlock-initialization Documentation/spinlocks.txt --- 25/Documentation/spinlocks.txt~unified-spinlock-initialization 2005-03-23 13:11:53.000000000 -0800 +++ 25-akpm/Documentation/spinlocks.txt 2005-03-23 13:11:53.000000000 -0800 @@ -1,3 +1,29 @@ +UPDATE March 21 2005 Amit Gud + +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 -puN drivers/char/tpm/tpm.c~unified-spinlock-initialization drivers/char/tpm/tpm.c --- 25/drivers/char/tpm/tpm.c~unified-spinlock-initialization 2005-03-23 13:11:53.000000000 -0800 +++ 25-akpm/drivers/char/tpm/tpm.c 2005-03-23 13:11:53.000000000 -0800 @@ -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 -puN drivers/input/serio/hil_mlc.c~unified-spinlock-initialization drivers/input/serio/hil_mlc.c --- 25/drivers/input/serio/hil_mlc.c~unified-spinlock-initialization 2005-03-23 13:11:53.000000000 -0800 +++ 25-akpm/drivers/input/serio/hil_mlc.c 2005-03-23 13:11:53.000000000 -0800 @@ -72,7 +72,7 @@ EXPORT_SYMBOL(hil_mlc_unregister); #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 @@ int hil_mlc_register(hil_mlc *mlc) { mlc->istarted = 0; mlc->ostarted = 0; - mlc->lock = RW_LOCK_UNLOCKED; + rwlock_init(&mlc->lock); init_MUTEX(&(mlc->osem)); init_MUTEX(&(mlc->isem)); diff -puN drivers/input/serio/hp_sdc.c~unified-spinlock-initialization drivers/input/serio/hp_sdc.c --- 25/drivers/input/serio/hp_sdc.c~unified-spinlock-initialization 2005-03-23 13:11:53.000000000 -0800 +++ 25-akpm/drivers/input/serio/hp_sdc.c 2005-03-23 13:11:53.000000000 -0800 @@ -779,10 +779,10 @@ static int __init hp_sdc_init(void) 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 -puN drivers/media/dvb/b2c2/skystar2.c~unified-spinlock-initialization drivers/media/dvb/b2c2/skystar2.c --- 25/drivers/media/dvb/b2c2/skystar2.c~unified-spinlock-initialization 2005-03-23 13:11:53.000000000 -0800 +++ 25-akpm/drivers/media/dvb/b2c2/skystar2.c 2005-03-23 13:11:53.000000000 -0800 @@ -1968,7 +1968,7 @@ static int driver_initialize(struct pci_ ctrl_enable_mac(adapter, 1); } - adapter->lock = SPIN_LOCK_UNLOCKED; + spin_lock_init(&adapter->lock); out: return ret; diff -puN drivers/serial/ioc4_serial.c~unified-spinlock-initialization drivers/serial/ioc4_serial.c --- 25/drivers/serial/ioc4_serial.c~unified-spinlock-initialization 2005-03-23 13:11:53.000000000 -0800 +++ 25-akpm/drivers/serial/ioc4_serial.c 2005-03-23 13:11:53.000000000 -0800 @@ -2665,7 +2665,7 @@ ioc4_serial_core_attach(struct pci_dev * __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 -puN drivers/usb/media/pwc/pwc-if.c~unified-spinlock-initialization drivers/usb/media/pwc/pwc-if.c --- 25/drivers/usb/media/pwc/pwc-if.c~unified-spinlock-initialization 2005-03-23 13:11:53.000000000 -0800 +++ 25-akpm/drivers/usb/media/pwc/pwc-if.c 2005-03-23 13:11:53.000000000 -0800 @@ -1896,7 +1896,7 @@ static int usb_pwc_probe(struct usb_inte } init_MUTEX(&pdev->modlock); - pdev->ptrlock = SPIN_LOCK_UNLOCKED; + spin_lock_init(&pdev->ptrlock); pdev->udev = udev; init_waitqueue_head(&pdev->frameq); _