aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/chips
diff options
context:
space:
mode:
authorStefani Seibold <stefani@seibold.net>2010-08-05 03:19:26 -0400
committerDavid Woodhouse <David.Woodhouse@intel.com>2010-08-06 04:22:16 -0400
commit8ae664184c45def51ff0b61d4bd6c6671db6cb4f (patch)
treee377d32da757a7c61150f2569bda85411a1835eb /drivers/mtd/chips
parentb8664b3762dc81e7a19ad4ffaae4055d6d5a7196 (diff)
mtd: change struct flchip_shared spinlock locking into mutex
This patch prevent to schedule while atomic by changing the flchip_shared spinlock into a mutex. This should be save since no atomic path will use this lock. It was suggested by Arnd Bergmann and Vasiliy Kulikov. Signed-off-by: Stefani Seibold <stefani@seibold.net> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'drivers/mtd/chips')
-rw-r--r--drivers/mtd/chips/cfi_cmdset_0001.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/drivers/mtd/chips/cfi_cmdset_0001.c b/drivers/mtd/chips/cfi_cmdset_0001.c
index 2fadb0239ba3..97d5546f9ea4 100644
--- a/drivers/mtd/chips/cfi_cmdset_0001.c
+++ b/drivers/mtd/chips/cfi_cmdset_0001.c
@@ -720,7 +720,7 @@ static int cfi_intelext_partition_fixup(struct mtd_info *mtd,
720 chip = &newcfi->chips[0]; 720 chip = &newcfi->chips[0];
721 for (i = 0; i < cfi->numchips; i++) { 721 for (i = 0; i < cfi->numchips; i++) {
722 shared[i].writing = shared[i].erasing = NULL; 722 shared[i].writing = shared[i].erasing = NULL;
723 spin_lock_init(&shared[i].lock); 723 mutex_init(&shared[i].lock);
724 for (j = 0; j < numparts; j++) { 724 for (j = 0; j < numparts; j++) {
725 *chip = cfi->chips[i]; 725 *chip = cfi->chips[i];
726 chip->start += j << partshift; 726 chip->start += j << partshift;
@@ -889,7 +889,7 @@ static int get_chip(struct map_info *map, struct flchip *chip, unsigned long adr
889 */ 889 */
890 struct flchip_shared *shared = chip->priv; 890 struct flchip_shared *shared = chip->priv;
891 struct flchip *contender; 891 struct flchip *contender;
892 spin_lock(&shared->lock); 892 mutex_lock(&shared->lock);
893 contender = shared->writing; 893 contender = shared->writing;
894 if (contender && contender != chip) { 894 if (contender && contender != chip) {
895 /* 895 /*
@@ -902,7 +902,7 @@ static int get_chip(struct map_info *map, struct flchip *chip, unsigned long adr
902 * get_chip returns success we're clear to go ahead. 902 * get_chip returns success we're clear to go ahead.
903 */ 903 */
904 ret = mutex_trylock(&contender->mutex); 904 ret = mutex_trylock(&contender->mutex);
905 spin_unlock(&shared->lock); 905 mutex_unlock(&shared->lock);
906 if (!ret) 906 if (!ret)
907 goto retry; 907 goto retry;
908 mutex_unlock(&chip->mutex); 908 mutex_unlock(&chip->mutex);
@@ -917,7 +917,7 @@ static int get_chip(struct map_info *map, struct flchip *chip, unsigned long adr
917 mutex_unlock(&contender->mutex); 917 mutex_unlock(&contender->mutex);
918 return ret; 918 return ret;
919 } 919 }
920 spin_lock(&shared->lock); 920 mutex_lock(&shared->lock);
921 921
922 /* We should not own chip if it is already 922 /* We should not own chip if it is already
923 * in FL_SYNCING state. Put contender and retry. */ 923 * in FL_SYNCING state. Put contender and retry. */
@@ -933,7 +933,7 @@ static int get_chip(struct map_info *map, struct flchip *chip, unsigned long adr
933 * on this chip. Sleep. */ 933 * on this chip. Sleep. */
934 if (mode == FL_ERASING && shared->erasing 934 if (mode == FL_ERASING && shared->erasing
935 && shared->erasing->oldstate == FL_ERASING) { 935 && shared->erasing->oldstate == FL_ERASING) {
936 spin_unlock(&shared->lock); 936 mutex_unlock(&shared->lock);
937 set_current_state(TASK_UNINTERRUPTIBLE); 937 set_current_state(TASK_UNINTERRUPTIBLE);
938 add_wait_queue(&chip->wq, &wait); 938 add_wait_queue(&chip->wq, &wait);
939 mutex_unlock(&chip->mutex); 939 mutex_unlock(&chip->mutex);
@@ -947,7 +947,7 @@ static int get_chip(struct map_info *map, struct flchip *chip, unsigned long adr
947 shared->writing = chip; 947 shared->writing = chip;
948 if (mode == FL_ERASING) 948 if (mode == FL_ERASING)
949 shared->erasing = chip; 949 shared->erasing = chip;
950 spin_unlock(&shared->lock); 950 mutex_unlock(&shared->lock);
951 } 951 }
952 ret = chip_ready(map, chip, adr, mode); 952 ret = chip_ready(map, chip, adr, mode);
953 if (ret == -EAGAIN) 953 if (ret == -EAGAIN)
@@ -962,7 +962,7 @@ static void put_chip(struct map_info *map, struct flchip *chip, unsigned long ad
962 962
963 if (chip->priv) { 963 if (chip->priv) {
964 struct flchip_shared *shared = chip->priv; 964 struct flchip_shared *shared = chip->priv;
965 spin_lock(&shared->lock); 965 mutex_lock(&shared->lock);
966 if (shared->writing == chip && chip->oldstate == FL_READY) { 966 if (shared->writing == chip && chip->oldstate == FL_READY) {
967 /* We own the ability to write, but we're done */ 967 /* We own the ability to write, but we're done */
968 shared->writing = shared->erasing; 968 shared->writing = shared->erasing;
@@ -970,7 +970,7 @@ static void put_chip(struct map_info *map, struct flchip *chip, unsigned long ad
970 /* give back ownership to who we loaned it from */ 970 /* give back ownership to who we loaned it from */
971 struct flchip *loaner = shared->writing; 971 struct flchip *loaner = shared->writing;
972 mutex_lock(&loaner->mutex); 972 mutex_lock(&loaner->mutex);
973 spin_unlock(&shared->lock); 973 mutex_unlock(&shared->lock);
974 mutex_unlock(&chip->mutex); 974 mutex_unlock(&chip->mutex);
975 put_chip(map, loaner, loaner->start); 975 put_chip(map, loaner, loaner->start);
976 mutex_lock(&chip->mutex); 976 mutex_lock(&chip->mutex);
@@ -988,11 +988,11 @@ static void put_chip(struct map_info *map, struct flchip *chip, unsigned long ad
988 * Don't let the switch below mess things up since 988 * Don't let the switch below mess things up since
989 * we don't have ownership to resume anything. 989 * we don't have ownership to resume anything.
990 */ 990 */
991 spin_unlock(&shared->lock); 991 mutex_unlock(&shared->lock);
992 wake_up(&chip->wq); 992 wake_up(&chip->wq);
993 return; 993 return;
994 } 994 }
995 spin_unlock(&shared->lock); 995 mutex_unlock(&shared->lock);
996 } 996 }
997 997
998 switch(chip->oldstate) { 998 switch(chip->oldstate) {