diff options
Diffstat (limited to 'drivers/mtd/lpddr/lpddr_cmds.c')
| -rw-r--r-- | drivers/mtd/lpddr/lpddr_cmds.c | 79 | 
1 files changed, 39 insertions, 40 deletions
| diff --git a/drivers/mtd/lpddr/lpddr_cmds.c b/drivers/mtd/lpddr/lpddr_cmds.c index e22ca49583e7..eb6f437ca9ec 100644 --- a/drivers/mtd/lpddr/lpddr_cmds.c +++ b/drivers/mtd/lpddr/lpddr_cmds.c @@ -106,8 +106,7 @@ struct mtd_info *lpddr_cmdset(struct map_info *map)  			/* those should be reset too since  			   they create memory references. */  			init_waitqueue_head(&chip->wq); -			spin_lock_init(&chip->_spinlock); -			chip->mutex = &chip->_spinlock; +			mutex_init(&chip->mutex);  			chip++;  		}  	} @@ -143,7 +142,7 @@ static int wait_for_ready(struct map_info *map, struct flchip *chip,  		}  		/* OK Still waiting. Drop the lock, wait a while and retry. */ -		spin_unlock(chip->mutex); +		mutex_unlock(&chip->mutex);  		if (sleep_time >= 1000000/HZ) {  			/*  			 * Half of the normal delay still remaining @@ -158,17 +157,17 @@ static int wait_for_ready(struct map_info *map, struct flchip *chip,  			cond_resched();  			timeo--;  		} -		spin_lock(chip->mutex); +		mutex_lock(&chip->mutex);  		while (chip->state != chip_state) {  			/* Someone's suspended the operation: sleep */  			DECLARE_WAITQUEUE(wait, current);  			set_current_state(TASK_UNINTERRUPTIBLE);  			add_wait_queue(&chip->wq, &wait); -			spin_unlock(chip->mutex); +			mutex_unlock(&chip->mutex);  			schedule();  			remove_wait_queue(&chip->wq, &wait); -			spin_lock(chip->mutex); +			mutex_lock(&chip->mutex);  		}  		if (chip->erase_suspended || chip->write_suspended)  {  			/* Suspend has occured while sleep: reset timeout */ @@ -229,20 +228,20 @@ static int get_chip(struct map_info *map, struct flchip *chip, int mode)  			 * it'll happily send us to sleep.  In any case, when  			 * get_chip returns success we're clear to go ahead.  			 */ -			ret = spin_trylock(contender->mutex); +			ret = mutex_trylock(&contender->mutex);  			spin_unlock(&shared->lock);  			if (!ret)  				goto retry; -			spin_unlock(chip->mutex); +			mutex_unlock(&chip->mutex);  			ret = chip_ready(map, contender, mode); -			spin_lock(chip->mutex); +			mutex_lock(&chip->mutex);  			if (ret == -EAGAIN) { -				spin_unlock(contender->mutex); +				mutex_unlock(&contender->mutex);  				goto retry;  			}  			if (ret) { -				spin_unlock(contender->mutex); +				mutex_unlock(&contender->mutex);  				return ret;  			}  			spin_lock(&shared->lock); @@ -251,10 +250,10 @@ static int get_chip(struct map_info *map, struct flchip *chip, int mode)  			 * state. Put contender and retry. */  			if (chip->state == FL_SYNCING) {  				put_chip(map, contender); -				spin_unlock(contender->mutex); +				mutex_unlock(&contender->mutex);  				goto retry;  			} -			spin_unlock(contender->mutex); +			mutex_unlock(&contender->mutex);  		}  		/* Check if we have suspended erase on this chip. @@ -264,10 +263,10 @@ static int get_chip(struct map_info *map, struct flchip *chip, int mode)  			spin_unlock(&shared->lock);  			set_current_state(TASK_UNINTERRUPTIBLE);  			add_wait_queue(&chip->wq, &wait); -			spin_unlock(chip->mutex); +			mutex_unlock(&chip->mutex);  			schedule();  			remove_wait_queue(&chip->wq, &wait); -			spin_lock(chip->mutex); +			mutex_lock(&chip->mutex);  			goto retry;  		} @@ -336,10 +335,10 @@ static int chip_ready(struct map_info *map, struct flchip *chip, int mode)  sleep:  		set_current_state(TASK_UNINTERRUPTIBLE);  		add_wait_queue(&chip->wq, &wait); -		spin_unlock(chip->mutex); +		mutex_unlock(&chip->mutex);  		schedule();  		remove_wait_queue(&chip->wq, &wait); -		spin_lock(chip->mutex); +		mutex_lock(&chip->mutex);  		return -EAGAIN;  	}  } @@ -355,12 +354,12 @@ static void put_chip(struct map_info *map, struct flchip *chip)  			if (shared->writing && shared->writing != chip) {  				/* give back the ownership */  				struct flchip *loaner = shared->writing; -				spin_lock(loaner->mutex); +				mutex_lock(&loaner->mutex);  				spin_unlock(&shared->lock); -				spin_unlock(chip->mutex); +				mutex_unlock(&chip->mutex);  				put_chip(map, loaner); -				spin_lock(chip->mutex); -				spin_unlock(loaner->mutex); +				mutex_lock(&chip->mutex); +				mutex_unlock(&loaner->mutex);  				wake_up(&chip->wq);  				return;  			} @@ -413,10 +412,10 @@ int do_write_buffer(struct map_info *map, struct flchip *chip,  	wbufsize = 1 << lpddr->qinfo->BufSizeShift; -	spin_lock(chip->mutex); +	mutex_lock(&chip->mutex);  	ret = get_chip(map, chip, FL_WRITING);  	if (ret) { -		spin_unlock(chip->mutex); +		mutex_unlock(&chip->mutex);  		return ret;  	}  	/* Figure out the number of words to write */ @@ -477,7 +476,7 @@ int do_write_buffer(struct map_info *map, struct flchip *chip,  	}   out:	put_chip(map, chip); -	spin_unlock(chip->mutex); +	mutex_unlock(&chip->mutex);  	return ret;  } @@ -489,10 +488,10 @@ int do_erase_oneblock(struct mtd_info *mtd, loff_t adr)  	struct flchip *chip = &lpddr->chips[chipnum];  	int ret; -	spin_lock(chip->mutex); +	mutex_lock(&chip->mutex);  	ret = get_chip(map, chip, FL_ERASING);  	if (ret) { -		spin_unlock(chip->mutex); +		mutex_unlock(&chip->mutex);  		return ret;  	}  	send_pfow_command(map, LPDDR_BLOCK_ERASE, adr, 0, NULL); @@ -504,7 +503,7 @@ int do_erase_oneblock(struct mtd_info *mtd, loff_t adr)  		goto out;  	}   out:	put_chip(map, chip); -	spin_unlock(chip->mutex); +	mutex_unlock(&chip->mutex);  	return ret;  } @@ -517,10 +516,10 @@ static int lpddr_read(struct mtd_info *mtd, loff_t adr, size_t len,  	struct flchip *chip = &lpddr->chips[chipnum];  	int ret = 0; -	spin_lock(chip->mutex); +	mutex_lock(&chip->mutex);  	ret = get_chip(map, chip, FL_READY);  	if (ret) { -		spin_unlock(chip->mutex); +		mutex_unlock(&chip->mutex);  		return ret;  	} @@ -528,7 +527,7 @@ static int lpddr_read(struct mtd_info *mtd, loff_t adr, size_t len,  	*retlen = len;  	put_chip(map, chip); -	spin_unlock(chip->mutex); +	mutex_unlock(&chip->mutex);  	return ret;  } @@ -568,9 +567,9 @@ static int lpddr_point(struct mtd_info *mtd, loff_t adr, size_t len,  		else  			thislen = len;  		/* get the chip */ -		spin_lock(chip->mutex); +		mutex_lock(&chip->mutex);  		ret = get_chip(map, chip, FL_POINT); -		spin_unlock(chip->mutex); +		mutex_unlock(&chip->mutex);  		if (ret)  			break; @@ -610,7 +609,7 @@ static void lpddr_unpoint (struct mtd_info *mtd, loff_t adr, size_t len)  		else  			thislen = len; -		spin_lock(chip->mutex); +		mutex_lock(&chip->mutex);  		if (chip->state == FL_POINT) {  			chip->ref_point_counter--;  			if (chip->ref_point_counter == 0) @@ -620,7 +619,7 @@ static void lpddr_unpoint (struct mtd_info *mtd, loff_t adr, size_t len)  					"pointed region\n", map->name);  		put_chip(map, chip); -		spin_unlock(chip->mutex); +		mutex_unlock(&chip->mutex);  		len -= thislen;  		ofs = 0; @@ -726,10 +725,10 @@ int do_xxlock(struct mtd_info *mtd, loff_t adr, uint32_t len, int thunk)  	int chipnum = adr >> lpddr->chipshift;  	struct flchip *chip = &lpddr->chips[chipnum]; -	spin_lock(chip->mutex); +	mutex_lock(&chip->mutex);  	ret = get_chip(map, chip, FL_LOCKING);  	if (ret) { -		spin_unlock(chip->mutex); +		mutex_unlock(&chip->mutex);  		return ret;  	} @@ -749,7 +748,7 @@ int do_xxlock(struct mtd_info *mtd, loff_t adr, uint32_t len, int thunk)  		goto out;  	}  out:	put_chip(map, chip); -	spin_unlock(chip->mutex); +	mutex_unlock(&chip->mutex);  	return ret;  } @@ -770,10 +769,10 @@ int word_program(struct map_info *map, loff_t adr, uint32_t curval)  	int chipnum = adr >> lpddr->chipshift;  	struct flchip *chip = &lpddr->chips[chipnum]; -	spin_lock(chip->mutex); +	mutex_lock(&chip->mutex);  	ret = get_chip(map, chip, FL_WRITING);  	if (ret) { -		spin_unlock(chip->mutex); +		mutex_unlock(&chip->mutex);  		return ret;  	} @@ -787,7 +786,7 @@ int word_program(struct map_info *map, loff_t adr, uint32_t curval)  	}  out:	put_chip(map, chip); -	spin_unlock(chip->mutex); +	mutex_unlock(&chip->mutex);  	return ret;  } | 

