Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 65616
b: refs/heads/master
c: 2342f33
h: refs/heads/master
v: v3
  • Loading branch information
Nicolas Pitre authored and Pierre Ossman committed Sep 23, 2007
1 parent 1ce684a commit ff7dc97
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 8 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 55fe77a0a24e05c9aaf1a13550dde5efad8b49f2
refs/heads/master: 2342f3323c9a76367a1d7f9a35525ee3cb3911df
22 changes: 16 additions & 6 deletions trunk/drivers/mmc/core/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -273,35 +273,45 @@ void mmc_set_data_timeout(struct mmc_data *data, const struct mmc_card *card)
EXPORT_SYMBOL(mmc_set_data_timeout);

/**
* mmc_claim_host - exclusively claim a host
* __mmc_claim_host - exclusively claim a host
* @host: mmc host to claim
* @abort: whether or not the operation should be aborted
*
* Claim a host for a set of operations.
* Claim a host for a set of operations. If @abort is non null and
* dereference a non-zero value then this will return prematurely with
* that non-zero value without acquiring the lock. Returns zero
* with the lock held otherwise.
*/
void mmc_claim_host(struct mmc_host *host)
int __mmc_claim_host(struct mmc_host *host, atomic_t *abort)
{
DECLARE_WAITQUEUE(wait, current);
unsigned long flags;
int stop;

might_sleep();

add_wait_queue(&host->wq, &wait);
spin_lock_irqsave(&host->lock, flags);
while (1) {
set_current_state(TASK_UNINTERRUPTIBLE);
if (!host->claimed)
stop = abort ? atomic_read(abort) : 0;
if (stop || !host->claimed)
break;
spin_unlock_irqrestore(&host->lock, flags);
schedule();
spin_lock_irqsave(&host->lock, flags);
}
set_current_state(TASK_RUNNING);
host->claimed = 1;
if (!stop)
host->claimed = 1;
else
wake_up(&host->wq);
spin_unlock_irqrestore(&host->lock, flags);
remove_wait_queue(&host->wq, &wait);
return stop;
}

EXPORT_SYMBOL(mmc_claim_host);
EXPORT_SYMBOL(__mmc_claim_host);

/**
* mmc_release_host - release a host
Expand Down
13 changes: 12 additions & 1 deletion trunk/include/linux/mmc/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,18 @@ extern int mmc_wait_for_app_cmd(struct mmc_host *, struct mmc_card *,

extern void mmc_set_data_timeout(struct mmc_data *, const struct mmc_card *);

extern void mmc_claim_host(struct mmc_host *host);
extern int __mmc_claim_host(struct mmc_host *host, atomic_t *abort);
extern void mmc_release_host(struct mmc_host *host);

/**
* mmc_claim_host - exclusively claim a host
* @host: mmc host to claim
*
* Claim a host for a set of operations.
*/
static inline void mmc_claim_host(struct mmc_host *host)
{
__mmc_claim_host(host, NULL);
}

#endif

0 comments on commit ff7dc97

Please sign in to comment.