Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 63050
b: refs/heads/master
c: 3936185
h: refs/heads/master
v: v3
  • Loading branch information
Adrian Bunk authored and Pierre Ossman committed Jul 26, 2007
1 parent 9c2f25c commit 07fe5f7
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 76 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: facba9179e3cd5fa91ff40bbc555c5cd4c101092
refs/heads/master: 393618510d5349e07d71dc28fb6fc49baf0d96a0
63 changes: 40 additions & 23 deletions trunk/drivers/mmc/core/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,7 @@ void mmc_request_done(struct mmc_host *host, struct mmc_request *mrq)

EXPORT_SYMBOL(mmc_request_done);

/**
* mmc_start_request - start a command on a host
* @host: MMC host to start command on
* @mrq: MMC request to start
*
* Queue a command on the specified host. We expect the
* caller to be holding the host lock with interrupts disabled.
*/
void
static void
mmc_start_request(struct mmc_host *host, struct mmc_request *mrq)
{
#ifdef CONFIG_MMC_DEBUG
Expand Down Expand Up @@ -165,8 +157,6 @@ mmc_start_request(struct mmc_host *host, struct mmc_request *mrq)
host->ops->request(host, mrq);
}

EXPORT_SYMBOL(mmc_start_request);

static void mmc_wait_done(struct mmc_request *mrq)
{
complete(mrq->done_data);
Expand Down Expand Up @@ -471,6 +461,45 @@ static void mmc_power_off(struct mmc_host *host)
mmc_set_ios(host);
}

/*
* Cleanup when the last reference to the bus operator is dropped.
*/
void __mmc_release_bus(struct mmc_host *host)
{
BUG_ON(!host);
BUG_ON(host->bus_refs);
BUG_ON(!host->bus_dead);

host->bus_ops = NULL;
}

/*
* Increase reference count of bus operator
*/
static inline void mmc_bus_get(struct mmc_host *host)
{
unsigned long flags;

spin_lock_irqsave(&host->lock, flags);
host->bus_refs++;
spin_unlock_irqrestore(&host->lock, flags);
}

/*
* Decrease reference count of bus operator and free it if
* it is the last reference.
*/
static inline void mmc_bus_put(struct mmc_host *host)
{
unsigned long flags;

spin_lock_irqsave(&host->lock, flags);
host->bus_refs--;
if ((host->bus_refs == 0) && host->bus_ops)
__mmc_release_bus(host);
spin_unlock_irqrestore(&host->lock, flags);
}

/*
* Assign a mmc bus handler to a host. Only one bus handler may control a
* host at any given time.
Expand Down Expand Up @@ -520,18 +549,6 @@ void mmc_detach_bus(struct mmc_host *host)
mmc_bus_put(host);
}

/*
* Cleanup when the last reference to the bus operator is dropped.
*/
void __mmc_release_bus(struct mmc_host *host)
{
BUG_ON(!host);
BUG_ON(host->bus_refs);
BUG_ON(!host->bus_dead);

host->bus_ops = NULL;
}

/**
* mmc_detect_change - process change of state on a MMC socket
* @host: host which changed state.
Expand Down
22 changes: 0 additions & 22 deletions trunk/drivers/mmc/core/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,28 +27,6 @@ struct mmc_bus_ops {
void mmc_attach_bus(struct mmc_host *host, const struct mmc_bus_ops *ops);
void mmc_detach_bus(struct mmc_host *host);

void __mmc_release_bus(struct mmc_host *host);

static inline void mmc_bus_get(struct mmc_host *host)
{
unsigned long flags;

spin_lock_irqsave(&host->lock, flags);
host->bus_refs++;
spin_unlock_irqrestore(&host->lock, flags);
}

static inline void mmc_bus_put(struct mmc_host *host)
{
unsigned long flags;

spin_lock_irqsave(&host->lock, flags);
host->bus_refs--;
if ((host->bus_refs == 0) && host->bus_ops)
__mmc_release_bus(host);
spin_unlock_irqrestore(&host->lock, flags);
}

void mmc_set_chip_select(struct mmc_host *host, int mode);
void mmc_set_clock(struct mmc_host *host, unsigned int hz);
void mmc_set_bus_mode(struct mmc_host *host, unsigned int mode);
Expand Down
58 changes: 29 additions & 29 deletions trunk/drivers/mmc/core/sd_ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,35 @@
#include "core.h"
#include "sd_ops.h"

static int mmc_app_cmd(struct mmc_host *host, struct mmc_card *card)
{
int err;
struct mmc_command cmd;

BUG_ON(!host);
BUG_ON(card && (card->host != host));

cmd.opcode = MMC_APP_CMD;

if (card) {
cmd.arg = card->rca << 16;
cmd.flags = MMC_RSP_R1 | MMC_CMD_AC;
} else {
cmd.arg = 0;
cmd.flags = MMC_RSP_R1 | MMC_CMD_BCR;
}

err = mmc_wait_for_cmd(host, &cmd, 0);
if (err != MMC_ERR_NONE)
return err;

/* Check that card supported application commands */
if (!(cmd.resp[0] & R1_APP_CMD))
return MMC_ERR_FAILED;

return MMC_ERR_NONE;
}

/**
* mmc_wait_for_app_cmd - start an application command and wait for
completion
Expand Down Expand Up @@ -77,35 +106,6 @@ int mmc_wait_for_app_cmd(struct mmc_host *host, struct mmc_card *card,

EXPORT_SYMBOL(mmc_wait_for_app_cmd);

int mmc_app_cmd(struct mmc_host *host, struct mmc_card *card)
{
int err;
struct mmc_command cmd;

BUG_ON(!host);
BUG_ON(card && (card->host != host));

cmd.opcode = MMC_APP_CMD;

if (card) {
cmd.arg = card->rca << 16;
cmd.flags = MMC_RSP_R1 | MMC_CMD_AC;
} else {
cmd.arg = 0;
cmd.flags = MMC_RSP_R1 | MMC_CMD_BCR;
}

err = mmc_wait_for_cmd(host, &cmd, 0);
if (err != MMC_ERR_NONE)
return err;

/* Check that card supported application commands */
if (!(cmd.resp[0] & R1_APP_CMD))
return MMC_ERR_FAILED;

return MMC_ERR_NONE;
}

int mmc_app_set_bus_width(struct mmc_card *card, int width)
{
int err;
Expand Down
1 change: 0 additions & 1 deletion trunk/drivers/mmc/core/sd_ops.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#ifndef _MMC_SD_OPS_H
#define _MMC_SD_OPS_H

int mmc_app_cmd(struct mmc_host *host, struct mmc_card *card);
int mmc_app_set_bus_width(struct mmc_card *card, int width);
int mmc_send_app_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr);
int mmc_send_if_cond(struct mmc_host *host, u32 ocr);
Expand Down

0 comments on commit 07fe5f7

Please sign in to comment.