[ARM] Convert some arm semaphores to mutexes

The arm clock semaphores are strict mutexes, convert them to the new
mutex implementation

Signed-off-by: Arjan van de Ven <arjan@infradead.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>

authored by Arjan van de Ven and committed by Russell King 00431707 f4619025

+67 -58
+8 -7
arch/arm/common/rtctime.c
··· 18 #include <linux/miscdevice.h> 19 #include <linux/spinlock.h> 20 #include <linux/device.h> 21 22 #include <asm/rtc.h> 23 #include <asm/semaphore.h> ··· 35 /* 36 * rtc_sem protects rtc_inuse and rtc_ops 37 */ 38 - static DECLARE_MUTEX(rtc_sem); 39 static unsigned long rtc_inuse; 40 static struct rtc_ops *rtc_ops; 41 ··· 356 { 357 int ret; 358 359 - down(&rtc_sem); 360 361 if (rtc_inuse) { 362 ret = -EBUSY; ··· 374 rtc_inuse = 1; 375 } 376 } 377 - up(&rtc_sem); 378 379 return ret; 380 } ··· 480 { 481 int ret = -EBUSY; 482 483 - down(&rtc_sem); 484 if (rtc_ops == NULL) { 485 rtc_ops = ops; 486 ··· 489 create_proc_read_entry("driver/rtc", 0, NULL, 490 rtc_read_proc, ops); 491 } 492 - up(&rtc_sem); 493 494 return ret; 495 } ··· 497 498 void unregister_rtc(struct rtc_ops *rtc) 499 { 500 - down(&rtc_sem); 501 if (rtc == rtc_ops) { 502 remove_proc_entry("driver/rtc", NULL); 503 misc_deregister(&rtc_miscdev); 504 rtc_ops = NULL; 505 } 506 - up(&rtc_sem); 507 } 508 EXPORT_SYMBOL(unregister_rtc);
··· 18 #include <linux/miscdevice.h> 19 #include <linux/spinlock.h> 20 #include <linux/device.h> 21 + #include <linux/mutex.h> 22 23 #include <asm/rtc.h> 24 #include <asm/semaphore.h> ··· 34 /* 35 * rtc_sem protects rtc_inuse and rtc_ops 36 */ 37 + static DEFINE_MUTEX(rtc_mutex); 38 static unsigned long rtc_inuse; 39 static struct rtc_ops *rtc_ops; 40 ··· 355 { 356 int ret; 357 358 + mutex_lock(&rtc_mutex); 359 360 if (rtc_inuse) { 361 ret = -EBUSY; ··· 373 rtc_inuse = 1; 374 } 375 } 376 + mutex_unlock(&rtc_mutex); 377 378 return ret; 379 } ··· 479 { 480 int ret = -EBUSY; 481 482 + mutex_lock(&rtc_mutex); 483 if (rtc_ops == NULL) { 484 rtc_ops = ops; 485 ··· 488 create_proc_read_entry("driver/rtc", 0, NULL, 489 rtc_read_proc, ops); 490 } 491 + mutex_unlock(&rtc_mutex); 492 493 return ret; 494 } ··· 496 497 void unregister_rtc(struct rtc_ops *rtc) 498 { 499 + mutex_lock(&rtc_mutex); 500 if (rtc == rtc_ops) { 501 remove_proc_entry("driver/rtc", NULL); 502 misc_deregister(&rtc_miscdev); 503 rtc_ops = NULL; 504 } 505 + mutex_unlock(&rtc_mutex); 506 } 507 EXPORT_SYMBOL(unregister_rtc);
+4 -3
arch/arm/kernel/ecard.c
··· 40 #include <linux/proc_fs.h> 41 #include <linux/device.h> 42 #include <linux/init.h> 43 44 #include <asm/dma.h> 45 #include <asm/ecard.h> ··· 207 208 static DECLARE_WAIT_QUEUE_HEAD(ecard_wait); 209 static struct ecard_request *ecard_req; 210 - static DECLARE_MUTEX(ecard_sem); 211 212 /* 213 * Set up the expansion card daemon's page tables. ··· 300 301 req->complete = &completion; 302 303 - down(&ecard_sem); 304 ecard_req = req; 305 wake_up(&ecard_wait); 306 ··· 308 * Now wait for kecardd to run. 309 */ 310 wait_for_completion(&completion); 311 - up(&ecard_sem); 312 } 313 314 /* ======================= Mid-level card control ===================== */
··· 40 #include <linux/proc_fs.h> 41 #include <linux/device.h> 42 #include <linux/init.h> 43 + #include <linux/mutex.h> 44 45 #include <asm/dma.h> 46 #include <asm/ecard.h> ··· 206 207 static DECLARE_WAIT_QUEUE_HEAD(ecard_wait); 208 static struct ecard_request *ecard_req; 209 + static DEFINE_MUTEX(ecard_mutex); 210 211 /* 212 * Set up the expansion card daemon's page tables. ··· 299 300 req->complete = &completion; 301 302 + mutex_lock(&ecard_mutex); 303 ecard_req = req; 304 wake_up(&ecard_wait); 305 ··· 307 * Now wait for kecardd to run. 308 */ 309 wait_for_completion(&completion); 310 + mutex_unlock(&ecard_mutex); 311 } 312 313 /* ======================= Mid-level card control ===================== */
+8 -7
arch/arm/mach-aaec2000/clock.c
··· 16 #include <linux/err.h> 17 #include <linux/string.h> 18 #include <linux/clk.h> 19 20 #include <asm/semaphore.h> 21 22 #include "clock.h" 23 24 static LIST_HEAD(clocks); 25 - static DECLARE_MUTEX(clocks_sem); 26 27 struct clk *clk_get(struct device *dev, const char *id) 28 { 29 struct clk *p, *clk = ERR_PTR(-ENOENT); 30 31 - down(&clocks_sem); 32 list_for_each_entry(p, &clocks, node) { 33 if (strcmp(id, p->name) == 0 && try_module_get(p->owner)) { 34 clk = p; 35 break; 36 } 37 } 38 - up(&clocks_sem); 39 40 return clk; 41 } ··· 79 80 int clk_register(struct clk *clk) 81 { 82 - down(&clocks_sem); 83 list_add(&clk->node, &clocks); 84 - up(&clocks_sem); 85 return 0; 86 } 87 EXPORT_SYMBOL(clk_register); 88 89 void clk_unregister(struct clk *clk) 90 { 91 - down(&clocks_sem); 92 list_del(&clk->node); 93 - up(&clocks_sem); 94 } 95 EXPORT_SYMBOL(clk_unregister); 96
··· 16 #include <linux/err.h> 17 #include <linux/string.h> 18 #include <linux/clk.h> 19 + #include <linux/mutex.h> 20 21 #include <asm/semaphore.h> 22 23 #include "clock.h" 24 25 static LIST_HEAD(clocks); 26 + static DEFINE_MUTEX(clocks_mutex); 27 28 struct clk *clk_get(struct device *dev, const char *id) 29 { 30 struct clk *p, *clk = ERR_PTR(-ENOENT); 31 32 + mutex_lock(&clocks_mutex); 33 list_for_each_entry(p, &clocks, node) { 34 if (strcmp(id, p->name) == 0 && try_module_get(p->owner)) { 35 clk = p; 36 break; 37 } 38 } 39 + mutex_unlock(&clocks_mutex); 40 41 return clk; 42 } ··· 78 79 int clk_register(struct clk *clk) 80 { 81 + mutex_lock(&clocks_mutex); 82 list_add(&clk->node, &clocks); 83 + mutex_unlock(&clocks_mutex); 84 return 0; 85 } 86 EXPORT_SYMBOL(clk_register); 87 88 void clk_unregister(struct clk *clk) 89 { 90 + mutex_lock(&clocks_mutex); 91 list_del(&clk->node); 92 + mutex_unlock(&clocks_mutex); 93 } 94 EXPORT_SYMBOL(clk_unregister); 95
+8 -7
arch/arm/mach-integrator/clock.c
··· 15 #include <linux/err.h> 16 #include <linux/string.h> 17 #include <linux/clk.h> 18 19 #include <asm/semaphore.h> 20 #include <asm/hardware/icst525.h> ··· 23 #include "clock.h" 24 25 static LIST_HEAD(clocks); 26 - static DECLARE_MUTEX(clocks_sem); 27 28 struct clk *clk_get(struct device *dev, const char *id) 29 { 30 struct clk *p, *clk = ERR_PTR(-ENOENT); 31 32 - down(&clocks_sem); 33 list_for_each_entry(p, &clocks, node) { 34 if (strcmp(id, p->name) == 0 && try_module_get(p->owner)) { 35 clk = p; 36 break; 37 } 38 } 39 - up(&clocks_sem); 40 41 return clk; 42 } ··· 108 109 int clk_register(struct clk *clk) 110 { 111 - down(&clocks_sem); 112 list_add(&clk->node, &clocks); 113 - up(&clocks_sem); 114 return 0; 115 } 116 EXPORT_SYMBOL(clk_register); 117 118 void clk_unregister(struct clk *clk) 119 { 120 - down(&clocks_sem); 121 list_del(&clk->node); 122 - up(&clocks_sem); 123 } 124 EXPORT_SYMBOL(clk_unregister); 125
··· 15 #include <linux/err.h> 16 #include <linux/string.h> 17 #include <linux/clk.h> 18 + #include <linux/mutex.h> 19 20 #include <asm/semaphore.h> 21 #include <asm/hardware/icst525.h> ··· 22 #include "clock.h" 23 24 static LIST_HEAD(clocks); 25 + static DEFINE_MUTEX(clocks_mutex); 26 27 struct clk *clk_get(struct device *dev, const char *id) 28 { 29 struct clk *p, *clk = ERR_PTR(-ENOENT); 30 31 + mutex_lock(&clocks_mutex); 32 list_for_each_entry(p, &clocks, node) { 33 if (strcmp(id, p->name) == 0 && try_module_get(p->owner)) { 34 clk = p; 35 break; 36 } 37 } 38 + mutex_unlock(&clocks_mutex); 39 40 return clk; 41 } ··· 107 108 int clk_register(struct clk *clk) 109 { 110 + mutex_lock(&clocks_mutex); 111 list_add(&clk->node, &clocks); 112 + mutex_unlock(&clocks_mutex); 113 return 0; 114 } 115 EXPORT_SYMBOL(clk_register); 116 117 void clk_unregister(struct clk *clk) 118 { 119 + mutex_lock(&clocks_mutex); 120 list_del(&clk->node); 121 + mutex_unlock(&clocks_mutex); 122 } 123 EXPORT_SYMBOL(clk_unregister); 124
+9 -8
arch/arm/mach-pxa/ssp.c
··· 31 #include <linux/interrupt.h> 32 #include <linux/ioport.h> 33 #include <linux/init.h> 34 #include <asm/io.h> 35 #include <asm/irq.h> 36 #include <asm/hardware.h> ··· 60 #endif 61 }; 62 63 - static DECLARE_MUTEX(sem); 64 static int use_count[PXA_SSP_PORTS] = {0, 0, 0}; 65 66 static irqreturn_t ssp_interrupt(int irq, void *dev_id, struct pt_regs *regs) ··· 240 if (port > PXA_SSP_PORTS || port == 0) 241 return -ENODEV; 242 243 - down(&sem); 244 if (use_count[port - 1]) { 245 - up(&sem); 246 return -EBUSY; 247 } 248 use_count[port - 1]++; 249 250 if (!request_mem_region(__PREG(SSCR0_P(port)), 0x2c, "SSP")) { 251 use_count[port - 1]--; 252 - up(&sem); 253 return -EBUSY; 254 } 255 dev->port = port; ··· 266 267 /* turn on SSP port clock */ 268 pxa_set_cken(ssp_info[port-1].clock, 1); 269 - up(&sem); 270 return 0; 271 272 out_region: 273 release_mem_region(__PREG(SSCR0_P(port)), 0x2c); 274 use_count[port - 1]--; 275 - up(&sem); 276 return ret; 277 } 278 ··· 283 */ 284 void ssp_exit(struct ssp_dev *dev) 285 { 286 - down(&sem); 287 SSCR0_P(dev->port) &= ~SSCR0_SSE; 288 289 if (dev->port > PXA_SSP_PORTS || dev->port == 0) { ··· 296 free_irq(dev->irq, dev); 297 release_mem_region(__PREG(SSCR0_P(dev->port)), 0x2c); 298 use_count[dev->port - 1]--; 299 - up(&sem); 300 } 301 302 EXPORT_SYMBOL(ssp_write_word);
··· 31 #include <linux/interrupt.h> 32 #include <linux/ioport.h> 33 #include <linux/init.h> 34 + #include <linux/mutex.h> 35 #include <asm/io.h> 36 #include <asm/irq.h> 37 #include <asm/hardware.h> ··· 59 #endif 60 }; 61 62 + static DEFINE_MUTEX(mutex); 63 static int use_count[PXA_SSP_PORTS] = {0, 0, 0}; 64 65 static irqreturn_t ssp_interrupt(int irq, void *dev_id, struct pt_regs *regs) ··· 239 if (port > PXA_SSP_PORTS || port == 0) 240 return -ENODEV; 241 242 + mutex_lock(&mutex); 243 if (use_count[port - 1]) { 244 + mutex_unlock(&mutex); 245 return -EBUSY; 246 } 247 use_count[port - 1]++; 248 249 if (!request_mem_region(__PREG(SSCR0_P(port)), 0x2c, "SSP")) { 250 use_count[port - 1]--; 251 + mutex_unlock(&mutex); 252 return -EBUSY; 253 } 254 dev->port = port; ··· 265 266 /* turn on SSP port clock */ 267 pxa_set_cken(ssp_info[port-1].clock, 1); 268 + mutex_unlock(&mutex); 269 return 0; 270 271 out_region: 272 release_mem_region(__PREG(SSCR0_P(port)), 0x2c); 273 use_count[port - 1]--; 274 + mutex_unlock(&mutex); 275 return ret; 276 } 277 ··· 282 */ 283 void ssp_exit(struct ssp_dev *dev) 284 { 285 + mutex_lock(&mutex); 286 SSCR0_P(dev->port) &= ~SSCR0_SSE; 287 288 if (dev->port > PXA_SSP_PORTS || dev->port == 0) { ··· 295 free_irq(dev->irq, dev); 296 release_mem_region(__PREG(SSCR0_P(dev->port)), 0x2c); 297 use_count[dev->port - 1]--; 298 + mutex_unlock(&mutex); 299 } 300 301 EXPORT_SYMBOL(ssp_write_word);
+8 -7
arch/arm/mach-realview/clock.c
··· 14 #include <linux/errno.h> 15 #include <linux/err.h> 16 #include <linux/clk.h> 17 18 #include <asm/semaphore.h> 19 #include <asm/hardware/icst307.h> ··· 22 #include "clock.h" 23 24 static LIST_HEAD(clocks); 25 - static DECLARE_MUTEX(clocks_sem); 26 27 struct clk *clk_get(struct device *dev, const char *id) 28 { 29 struct clk *p, *clk = ERR_PTR(-ENOENT); 30 31 - down(&clocks_sem); 32 list_for_each_entry(p, &clocks, node) { 33 if (strcmp(id, p->name) == 0 && try_module_get(p->owner)) { 34 clk = p; 35 break; 36 } 37 } 38 - up(&clocks_sem); 39 40 return clk; 41 } ··· 110 111 int clk_register(struct clk *clk) 112 { 113 - down(&clocks_sem); 114 list_add(&clk->node, &clocks); 115 - up(&clocks_sem); 116 return 0; 117 } 118 EXPORT_SYMBOL(clk_register); 119 120 void clk_unregister(struct clk *clk) 121 { 122 - down(&clocks_sem); 123 list_del(&clk->node); 124 - up(&clocks_sem); 125 } 126 EXPORT_SYMBOL(clk_unregister); 127
··· 14 #include <linux/errno.h> 15 #include <linux/err.h> 16 #include <linux/clk.h> 17 + #include <linux/mutex.h> 18 19 #include <asm/semaphore.h> 20 #include <asm/hardware/icst307.h> ··· 21 #include "clock.h" 22 23 static LIST_HEAD(clocks); 24 + static DEFINE_MUTEX(clocks_mutex); 25 26 struct clk *clk_get(struct device *dev, const char *id) 27 { 28 struct clk *p, *clk = ERR_PTR(-ENOENT); 29 30 + mutex_lock(&clocks_mutex); 31 list_for_each_entry(p, &clocks, node) { 32 if (strcmp(id, p->name) == 0 && try_module_get(p->owner)) { 33 clk = p; 34 break; 35 } 36 } 37 + mutex_unlock(&clocks_mutex); 38 39 return clk; 40 } ··· 109 110 int clk_register(struct clk *clk) 111 { 112 + mutex_lock(&clocks_mutex); 113 list_add(&clk->node, &clocks); 114 + mutex_unlock(&clocks_mutex); 115 return 0; 116 } 117 EXPORT_SYMBOL(clk_register); 118 119 void clk_unregister(struct clk *clk) 120 { 121 + mutex_lock(&clocks_mutex); 122 list_del(&clk->node); 123 + mutex_unlock(&clocks_mutex); 124 } 125 EXPORT_SYMBOL(clk_unregister); 126
+6 -5
arch/arm/mach-s3c2410/clock.c
··· 37 #include <linux/interrupt.h> 38 #include <linux/ioport.h> 39 #include <linux/clk.h> 40 41 #include <asm/hardware.h> 42 #include <asm/atomic.h> ··· 52 /* clock information */ 53 54 static LIST_HEAD(clocks); 55 - static DECLARE_MUTEX(clocks_sem); 56 57 /* old functions */ 58 ··· 103 else 104 idno = to_platform_device(dev)->id; 105 106 - down(&clocks_sem); 107 108 list_for_each_entry(p, &clocks, list) { 109 if (p->id == idno && ··· 127 } 128 } 129 130 - up(&clocks_sem); 131 return clk; 132 } 133 ··· 363 364 /* add to the list of available clocks */ 365 366 - down(&clocks_sem); 367 list_add(&clk->list, &clocks); 368 - up(&clocks_sem); 369 370 return 0; 371 }
··· 37 #include <linux/interrupt.h> 38 #include <linux/ioport.h> 39 #include <linux/clk.h> 40 + #include <linux/mutex.h> 41 42 #include <asm/hardware.h> 43 #include <asm/atomic.h> ··· 51 /* clock information */ 52 53 static LIST_HEAD(clocks); 54 + static DEFINE_MUTEX(clocks_mutex); 55 56 /* old functions */ 57 ··· 102 else 103 idno = to_platform_device(dev)->id; 104 105 + mutex_lock(&clocks_mutex); 106 107 list_for_each_entry(p, &clocks, list) { 108 if (p->id == idno && ··· 126 } 127 } 128 129 + mutex_unlock(&clocks_mutex); 130 return clk; 131 } 132 ··· 362 363 /* add to the list of available clocks */ 364 365 + mutex_lock(&clocks_mutex); 366 list_add(&clk->list, &clocks); 367 + mutex_unlock(&clocks_mutex); 368 369 return 0; 370 }
+8 -7
arch/arm/mach-versatile/clock.c
··· 15 #include <linux/err.h> 16 #include <linux/string.h> 17 #include <linux/clk.h> 18 19 #include <asm/semaphore.h> 20 #include <asm/hardware/icst307.h> ··· 23 #include "clock.h" 24 25 static LIST_HEAD(clocks); 26 - static DECLARE_MUTEX(clocks_sem); 27 28 struct clk *clk_get(struct device *dev, const char *id) 29 { 30 struct clk *p, *clk = ERR_PTR(-ENOENT); 31 32 - down(&clocks_sem); 33 list_for_each_entry(p, &clocks, node) { 34 if (strcmp(id, p->name) == 0 && try_module_get(p->owner)) { 35 clk = p; 36 break; 37 } 38 } 39 - up(&clocks_sem); 40 41 return clk; 42 } ··· 111 112 int clk_register(struct clk *clk) 113 { 114 - down(&clocks_sem); 115 list_add(&clk->node, &clocks); 116 - up(&clocks_sem); 117 return 0; 118 } 119 EXPORT_SYMBOL(clk_register); 120 121 void clk_unregister(struct clk *clk) 122 { 123 - down(&clocks_sem); 124 list_del(&clk->node); 125 - up(&clocks_sem); 126 } 127 EXPORT_SYMBOL(clk_unregister); 128
··· 15 #include <linux/err.h> 16 #include <linux/string.h> 17 #include <linux/clk.h> 18 + #include <linux/mutex.h> 19 20 #include <asm/semaphore.h> 21 #include <asm/hardware/icst307.h> ··· 22 #include "clock.h" 23 24 static LIST_HEAD(clocks); 25 + static DEFINE_MUTEX(clocks_mutex); 26 27 struct clk *clk_get(struct device *dev, const char *id) 28 { 29 struct clk *p, *clk = ERR_PTR(-ENOENT); 30 31 + mutex_lock(&clocks_mutex); 32 list_for_each_entry(p, &clocks, node) { 33 if (strcmp(id, p->name) == 0 && try_module_get(p->owner)) { 34 clk = p; 35 break; 36 } 37 } 38 + mutex_unlock(&clocks_mutex); 39 40 return clk; 41 } ··· 110 111 int clk_register(struct clk *clk) 112 { 113 + mutex_lock(&clocks_mutex); 114 list_add(&clk->node, &clocks); 115 + mutex_unlock(&clocks_mutex); 116 return 0; 117 } 118 EXPORT_SYMBOL(clk_register); 119 120 void clk_unregister(struct clk *clk) 121 { 122 + mutex_lock(&clocks_mutex); 123 list_del(&clk->node); 124 + mutex_unlock(&clocks_mutex); 125 } 126 EXPORT_SYMBOL(clk_unregister); 127
+8 -7
arch/arm/plat-omap/clock.c
··· 20 #include <linux/err.h> 21 #include <linux/string.h> 22 #include <linux/clk.h> 23 24 #include <asm/io.h> 25 #include <asm/semaphore.h> ··· 28 #include <asm/arch/clock.h> 29 30 LIST_HEAD(clocks); 31 - static DECLARE_MUTEX(clocks_sem); 32 DEFINE_SPINLOCK(clockfw_lock); 33 34 static struct clk_functions *arch_clock; ··· 41 { 42 struct clk *p, *clk = ERR_PTR(-ENOENT); 43 44 - down(&clocks_sem); 45 list_for_each_entry(p, &clocks, node) { 46 if (strcmp(id, p->name) == 0 && try_module_get(p->owner)) { 47 clk = p; 48 break; 49 } 50 } 51 - up(&clocks_sem); 52 53 return clk; 54 } ··· 250 251 int clk_register(struct clk *clk) 252 { 253 - down(&clocks_sem); 254 list_add(&clk->node, &clocks); 255 if (clk->init) 256 clk->init(clk); 257 - up(&clocks_sem); 258 259 return 0; 260 } ··· 262 263 void clk_unregister(struct clk *clk) 264 { 265 - down(&clocks_sem); 266 list_del(&clk->node); 267 - up(&clocks_sem); 268 } 269 EXPORT_SYMBOL(clk_unregister); 270
··· 20 #include <linux/err.h> 21 #include <linux/string.h> 22 #include <linux/clk.h> 23 + #include <linux/mutex.h> 24 25 #include <asm/io.h> 26 #include <asm/semaphore.h> ··· 27 #include <asm/arch/clock.h> 28 29 LIST_HEAD(clocks); 30 + static DEFINE_MUTEX(clocks_mutex); 31 DEFINE_SPINLOCK(clockfw_lock); 32 33 static struct clk_functions *arch_clock; ··· 40 { 41 struct clk *p, *clk = ERR_PTR(-ENOENT); 42 43 + mutex_lock(&clocks_mutex); 44 list_for_each_entry(p, &clocks, node) { 45 if (strcmp(id, p->name) == 0 && try_module_get(p->owner)) { 46 clk = p; 47 break; 48 } 49 } 50 + mutex_unlock(&clocks_mutex); 51 52 return clk; 53 } ··· 249 250 int clk_register(struct clk *clk) 251 { 252 + mutex_lock(&clocks_mutex); 253 list_add(&clk->node, &clocks); 254 if (clk->init) 255 clk->init(clk); 256 + mutex_unlock(&clocks_mutex); 257 258 return 0; 259 } ··· 261 262 void clk_unregister(struct clk *clk) 263 { 264 + mutex_lock(&clocks_mutex); 265 list_del(&clk->node); 266 + mutex_unlock(&clocks_mutex); 267 } 268 EXPORT_SYMBOL(clk_unregister); 269