diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2010-05-21 11:19:18 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2010-05-21 18:31:29 -0400 |
commit | 4f0447b8184acb1d21b0fd71683d72ef2b83167b (patch) | |
tree | 4a6e07c4211f0c88f246d3c459b080b99078adcb /arch | |
parent | 48c1e44aceca577aa35be509714bd9ec4b4c3837 (diff) |
get rid of home-grown mutex in cris eeprom.c
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/cris/arch-v10/drivers/eeprom.c | 27 |
1 files changed, 8 insertions, 19 deletions
diff --git a/arch/cris/arch-v10/drivers/eeprom.c b/arch/cris/arch-v10/drivers/eeprom.c index 1f2ae909d3e6..b04b22ba00d1 100644 --- a/arch/cris/arch-v10/drivers/eeprom.c +++ b/arch/cris/arch-v10/drivers/eeprom.c | |||
@@ -73,8 +73,7 @@ struct eeprom_type | |||
73 | int adapt_state; /* 1 = To high , 0 = Even, -1 = To low */ | 73 | int adapt_state; /* 1 = To high , 0 = Even, -1 = To low */ |
74 | 74 | ||
75 | /* this one is to keep the read/write operations atomic */ | 75 | /* this one is to keep the read/write operations atomic */ |
76 | wait_queue_head_t wait_q; | 76 | struct mutex lock; |
77 | volatile int busy; | ||
78 | int retry_cnt_addr; /* Used to keep track of number of retries for | 77 | int retry_cnt_addr; /* Used to keep track of number of retries for |
79 | adaptive timing adjustments */ | 78 | adaptive timing adjustments */ |
80 | int retry_cnt_read; | 79 | int retry_cnt_read; |
@@ -115,8 +114,7 @@ const struct file_operations eeprom_fops = | |||
115 | 114 | ||
116 | int __init eeprom_init(void) | 115 | int __init eeprom_init(void) |
117 | { | 116 | { |
118 | init_waitqueue_head(&eeprom.wait_q); | 117 | mutex_init(&eeprom.lock); |
119 | eeprom.busy = 0; | ||
120 | 118 | ||
121 | #ifdef CONFIG_ETRAX_I2C_EEPROM_PROBE | 119 | #ifdef CONFIG_ETRAX_I2C_EEPROM_PROBE |
122 | #define EETEXT "Found" | 120 | #define EETEXT "Found" |
@@ -461,12 +459,9 @@ static ssize_t eeprom_read(struct file * file, char * buf, size_t count, loff_t | |||
461 | return -EFAULT; | 459 | return -EFAULT; |
462 | } | 460 | } |
463 | 461 | ||
464 | wait_event_interruptible(eeprom.wait_q, !eeprom.busy); | 462 | if (mutex_lock_interruptible(&eeprom.lock)) |
465 | if (signal_pending(current)) | ||
466 | return -EINTR; | 463 | return -EINTR; |
467 | 464 | ||
468 | eeprom.busy++; | ||
469 | |||
470 | page = (unsigned char) (p >> 8); | 465 | page = (unsigned char) (p >> 8); |
471 | 466 | ||
472 | if(!eeprom_address(p)) | 467 | if(!eeprom_address(p)) |
@@ -476,8 +471,7 @@ static ssize_t eeprom_read(struct file * file, char * buf, size_t count, loff_t | |||
476 | i2c_stop(); | 471 | i2c_stop(); |
477 | 472 | ||
478 | /* don't forget to wake them up */ | 473 | /* don't forget to wake them up */ |
479 | eeprom.busy--; | 474 | mutex_unlock(&eeprom.lock); |
480 | wake_up_interruptible(&eeprom.wait_q); | ||
481 | return -EFAULT; | 475 | return -EFAULT; |
482 | } | 476 | } |
483 | 477 | ||
@@ -504,8 +498,7 @@ static ssize_t eeprom_read(struct file * file, char * buf, size_t count, loff_t | |||
504 | file->f_pos += read; | 498 | file->f_pos += read; |
505 | } | 499 | } |
506 | 500 | ||
507 | eeprom.busy--; | 501 | mutex_unlock(&eeprom.lock); |
508 | wake_up_interruptible(&eeprom.wait_q); | ||
509 | return read; | 502 | return read; |
510 | } | 503 | } |
511 | 504 | ||
@@ -534,11 +527,9 @@ static ssize_t eeprom_write(struct file * file, const char * buf, size_t count, | |||
534 | return -EFAULT; | 527 | return -EFAULT; |
535 | } | 528 | } |
536 | 529 | ||
537 | wait_event_interruptible(eeprom.wait_q, !eeprom.busy); | ||
538 | /* bail out if we get interrupted */ | 530 | /* bail out if we get interrupted */ |
539 | if (signal_pending(current)) | 531 | if (mutex_lock_interruptible(&eeprom.lock)) |
540 | return -EINTR; | 532 | return -EINTR; |
541 | eeprom.busy++; | ||
542 | for(i = 0; (i < EEPROM_RETRIES) && (restart > 0); i++) | 533 | for(i = 0; (i < EEPROM_RETRIES) && (restart > 0); i++) |
543 | { | 534 | { |
544 | restart = 0; | 535 | restart = 0; |
@@ -556,8 +547,7 @@ static ssize_t eeprom_write(struct file * file, const char * buf, size_t count, | |||
556 | i2c_stop(); | 547 | i2c_stop(); |
557 | 548 | ||
558 | /* don't forget to wake them up */ | 549 | /* don't forget to wake them up */ |
559 | eeprom.busy--; | 550 | mutex_unlock(&eeprom.lock); |
560 | wake_up_interruptible(&eeprom.wait_q); | ||
561 | return -EFAULT; | 551 | return -EFAULT; |
562 | } | 552 | } |
563 | #ifdef EEPROM_ADAPTIVE_TIMING | 553 | #ifdef EEPROM_ADAPTIVE_TIMING |
@@ -669,8 +659,7 @@ static ssize_t eeprom_write(struct file * file, const char * buf, size_t count, | |||
669 | } /* while */ | 659 | } /* while */ |
670 | } /* for */ | 660 | } /* for */ |
671 | 661 | ||
672 | eeprom.busy--; | 662 | mutex_unlock(&eeprom.lock); |
673 | wake_up_interruptible(&eeprom.wait_q); | ||
674 | if (written == 0 && file->f_pos >= eeprom.size){ | 663 | if (written == 0 && file->f_pos >= eeprom.size){ |
675 | return -ENOSPC; | 664 | return -ENOSPC; |
676 | } | 665 | } |