Skip to content

Commit

Permalink
mmc: replace host->card_busy
Browse files Browse the repository at this point in the history
As card_busy was only used to indicate if the host was exclusively
claimed and not really used to identify a particular card, replacing
it with just a boolean makes things a lot more easily understandable.

Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
  • Loading branch information
Pierre Ossman committed Feb 4, 2007
1 parent 279bc44 commit f22ee4e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
16 changes: 8 additions & 8 deletions drivers/mmc/mmc.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ mmc_start_request(struct mmc_host *host, struct mmc_request *mrq)
mmc_hostname(host), mrq->cmd->opcode,
mrq->cmd->arg, mrq->cmd->flags);

WARN_ON(host->card_busy == NULL);
WARN_ON(!host->claimed);

mrq->cmd->error = 0;
mrq->cmd->mrq = mrq;
Expand Down Expand Up @@ -157,7 +157,7 @@ int mmc_wait_for_cmd(struct mmc_host *host, struct mmc_command *cmd, int retries
{
struct mmc_request mrq;

BUG_ON(host->card_busy == NULL);
BUG_ON(!host->claimed);

memset(&mrq, 0, sizeof(struct mmc_request));

Expand Down Expand Up @@ -195,7 +195,7 @@ int mmc_wait_for_app_cmd(struct mmc_host *host, unsigned int rca,

int i, err;

BUG_ON(host->card_busy == NULL);
BUG_ON(!host->claimed);
BUG_ON(retries < 0);

err = MMC_ERR_INVALID;
Expand Down Expand Up @@ -320,14 +320,14 @@ int __mmc_claim_host(struct mmc_host *host, struct mmc_card *card)
spin_lock_irqsave(&host->lock, flags);
while (1) {
set_current_state(TASK_UNINTERRUPTIBLE);
if (host->card_busy == NULL)
if (!host->claimed)
break;
spin_unlock_irqrestore(&host->lock, flags);
schedule();
spin_lock_irqsave(&host->lock, flags);
}
set_current_state(TASK_RUNNING);
host->card_busy = card;
host->claimed = 1;
spin_unlock_irqrestore(&host->lock, flags);
remove_wait_queue(&host->wq, &wait);

Expand All @@ -353,10 +353,10 @@ void mmc_release_host(struct mmc_host *host)
{
unsigned long flags;

BUG_ON(host->card_busy == NULL);
BUG_ON(!host->claimed);

spin_lock_irqsave(&host->lock, flags);
host->card_busy = NULL;
host->claimed = 0;
spin_unlock_irqrestore(&host->lock, flags);

wake_up(&host->wq);
Expand All @@ -381,7 +381,7 @@ static int mmc_select_card(struct mmc_host *host, struct mmc_card *card)
int err;
struct mmc_command cmd;

BUG_ON(host->card_busy == NULL);
BUG_ON(!host->claimed);

if (host->card_selected == card)
return MMC_ERR_NONE;
Expand Down
5 changes: 3 additions & 2 deletions include/linux/mmc/host.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,9 @@ struct mmc_host {
struct list_head cards; /* devices attached to this host */

wait_queue_head_t wq;
spinlock_t lock; /* card_busy lock */
struct mmc_card *card_busy; /* the MMC card claiming host */
spinlock_t lock; /* claimed lock */
unsigned int claimed:1; /* host exclusively claimed */

struct mmc_card *card_selected; /* the selected MMC card */

struct delayed_work detect;
Expand Down

0 comments on commit f22ee4e

Please sign in to comment.