From: Jim Cromie Date: Tue, 27 Jun 2006 09:54:25 +0000 (-0700) Subject: [PATCH] chardev: GPIO for SCx200 & PC-8736x: replace spinlocks w mutexes X-Git-Tag: v2.6.18-rc1~520 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8bcf6135c3e8cdfab375f4041a48721483519eee;p=linux-2.6 [PATCH] chardev: GPIO for SCx200 & PC-8736x: replace spinlocks w mutexes Replace spinlocks guarding gpio config ops with mutexes. This is a me-too patch, and is justifiable insofar as mutexes have stricter semantics and better debugging support, so are preferred where they are applicable. Signed-off-by: Jim Cromie Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/arch/i386/kernel/scx200.c b/arch/i386/kernel/scx200.c index edead73ebe..9bf590cefc 100644 --- a/arch/i386/kernel/scx200.c +++ b/arch/i386/kernel/scx200.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include @@ -45,7 +46,7 @@ static struct pci_driver scx200_pci_driver = { .probe = scx200_probe, }; -static DEFINE_SPINLOCK(scx200_gpio_config_lock); +static DEFINE_MUTEX(scx200_gpio_config_lock); static void __devinit scx200_init_shadow(void) { @@ -95,9 +96,8 @@ static int __devinit scx200_probe(struct pci_dev *pdev, const struct pci_device_ u32 scx200_gpio_configure(unsigned index, u32 mask, u32 bits) { u32 config, new_config; - unsigned long flags; - spin_lock_irqsave(&scx200_gpio_config_lock, flags); + mutex_lock(&scx200_gpio_config_lock); outl(index, scx200_gpio_base + 0x20); config = inl(scx200_gpio_base + 0x24); @@ -105,7 +105,7 @@ u32 scx200_gpio_configure(unsigned index, u32 mask, u32 bits) new_config = (config & mask) | bits; outl(new_config, scx200_gpio_base + 0x24); - spin_unlock_irqrestore(&scx200_gpio_config_lock, flags); + mutex_unlock(&scx200_gpio_config_lock); return config; } diff --git a/drivers/char/pc8736x_gpio.c b/drivers/char/pc8736x_gpio.c index b8183d5083..72dcf222f1 100644 --- a/drivers/char/pc8736x_gpio.c +++ b/drivers/char/pc8736x_gpio.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -31,7 +32,7 @@ static int major; /* default to dynamic major */ module_param(major, int, 0); MODULE_PARM_DESC(major, "Major device number"); -static DEFINE_SPINLOCK(pc8736x_gpio_config_lock); +static DEFINE_MUTEX(pc8736x_gpio_config_lock); static unsigned pc8736x_gpio_base; static u8 pc8736x_gpio_shadow[4]; @@ -119,9 +120,8 @@ static inline u32 pc8736x_gpio_configure_fn(unsigned index, u32 mask, u32 bits, u32 func_slct) { u32 config, new_config; - unsigned long flags; - spin_lock_irqsave(&pc8736x_gpio_config_lock, flags); + mutex_lock(&pc8736x_gpio_config_lock); device_select(SIO_GPIO_UNIT); select_pin(index); @@ -133,7 +133,7 @@ static inline u32 pc8736x_gpio_configure_fn(unsigned index, u32 mask, u32 bits, new_config = (config & mask) | bits; superio_outb(func_slct, new_config); - spin_unlock_irqrestore(&pc8736x_gpio_config_lock, flags); + mutex_unlock(&pc8736x_gpio_config_lock); return config; }