mmc: bcm2835: Drop pointer to mmc_host from bcm2835_host
The BCM2835 MMC host driver uses a pointer to get from the private bcm2835_host structure to the generic mmc_host structure. However the latter is always immediately preceding the former in memory, so compute its address with a subtraction (which is cheaper than a dereference) and drop the superfluous pointer. No functional change intended. Signed-off-by: Lukas Wunner <lukas@wunner.de> Cc: Frank Pavlic <f.pavlic@kunbus.de> Cc: Alexander Graf <agraf@suse.de> Reviewed-by: Alexander Graf <agraf@suse.de> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
This commit is contained in:
parent
e5c1e63c93
commit
c58ccf2b6d
@ -148,7 +148,6 @@ struct bcm2835_host {
|
|||||||
void __iomem *ioaddr;
|
void __iomem *ioaddr;
|
||||||
u32 phys_addr;
|
u32 phys_addr;
|
||||||
|
|
||||||
struct mmc_host *mmc;
|
|
||||||
struct platform_device *pdev;
|
struct platform_device *pdev;
|
||||||
|
|
||||||
int clock; /* Current clock speed */
|
int clock; /* Current clock speed */
|
||||||
@ -618,7 +617,7 @@ static void bcm2835_finish_request(struct bcm2835_host *host)
|
|||||||
"failed to terminate DMA (%d)\n", err);
|
"failed to terminate DMA (%d)\n", err);
|
||||||
}
|
}
|
||||||
|
|
||||||
mmc_request_done(host->mmc, mrq);
|
mmc_request_done(mmc_from_priv(host), mrq);
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
@ -837,7 +836,7 @@ static void bcm2835_timeout(struct work_struct *work)
|
|||||||
dev_err(dev, "timeout waiting for hardware interrupt.\n");
|
dev_err(dev, "timeout waiting for hardware interrupt.\n");
|
||||||
bcm2835_dumpregs(host);
|
bcm2835_dumpregs(host);
|
||||||
|
|
||||||
bcm2835_reset(host->mmc);
|
bcm2835_reset(mmc_from_priv(host));
|
||||||
|
|
||||||
if (host->data) {
|
if (host->data) {
|
||||||
host->data->error = -ETIMEDOUT;
|
host->data->error = -ETIMEDOUT;
|
||||||
@ -1100,6 +1099,7 @@ static void bcm2835_dma_complete_work(struct work_struct *work)
|
|||||||
|
|
||||||
static void bcm2835_set_clock(struct bcm2835_host *host, unsigned int clock)
|
static void bcm2835_set_clock(struct bcm2835_host *host, unsigned int clock)
|
||||||
{
|
{
|
||||||
|
struct mmc_host *mmc = mmc_from_priv(host);
|
||||||
int div;
|
int div;
|
||||||
|
|
||||||
/* The SDCDIV register has 11 bits, and holds (div - 2). But
|
/* The SDCDIV register has 11 bits, and holds (div - 2). But
|
||||||
@ -1143,18 +1143,18 @@ static void bcm2835_set_clock(struct bcm2835_host *host, unsigned int clock)
|
|||||||
div = SDCDIV_MAX_CDIV;
|
div = SDCDIV_MAX_CDIV;
|
||||||
|
|
||||||
clock = host->max_clk / (div + 2);
|
clock = host->max_clk / (div + 2);
|
||||||
host->mmc->actual_clock = clock;
|
mmc->actual_clock = clock;
|
||||||
|
|
||||||
/* Calibrate some delays */
|
/* Calibrate some delays */
|
||||||
|
|
||||||
host->ns_per_fifo_word = (1000000000 / clock) *
|
host->ns_per_fifo_word = (1000000000 / clock) *
|
||||||
((host->mmc->caps & MMC_CAP_4_BIT_DATA) ? 8 : 32);
|
((mmc->caps & MMC_CAP_4_BIT_DATA) ? 8 : 32);
|
||||||
|
|
||||||
host->cdiv = div;
|
host->cdiv = div;
|
||||||
writel(host->cdiv, host->ioaddr + SDCDIV);
|
writel(host->cdiv, host->ioaddr + SDCDIV);
|
||||||
|
|
||||||
/* Set the timeout to 500ms */
|
/* Set the timeout to 500ms */
|
||||||
writel(host->mmc->actual_clock / 2, host->ioaddr + SDTOUT);
|
writel(mmc->actual_clock / 2, host->ioaddr + SDTOUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void bcm2835_request(struct mmc_host *mmc, struct mmc_request *mrq)
|
static void bcm2835_request(struct mmc_host *mmc, struct mmc_request *mrq)
|
||||||
@ -1264,7 +1264,7 @@ static const struct mmc_host_ops bcm2835_ops = {
|
|||||||
|
|
||||||
static int bcm2835_add_host(struct bcm2835_host *host)
|
static int bcm2835_add_host(struct bcm2835_host *host)
|
||||||
{
|
{
|
||||||
struct mmc_host *mmc = host->mmc;
|
struct mmc_host *mmc = mmc_from_priv(host);
|
||||||
struct device *dev = &host->pdev->dev;
|
struct device *dev = &host->pdev->dev;
|
||||||
char pio_limit_string[20];
|
char pio_limit_string[20];
|
||||||
int ret;
|
int ret;
|
||||||
@ -1370,7 +1370,6 @@ static int bcm2835_probe(struct platform_device *pdev)
|
|||||||
|
|
||||||
mmc->ops = &bcm2835_ops;
|
mmc->ops = &bcm2835_ops;
|
||||||
host = mmc_priv(mmc);
|
host = mmc_priv(mmc);
|
||||||
host->mmc = mmc;
|
|
||||||
host->pdev = pdev;
|
host->pdev = pdev;
|
||||||
spin_lock_init(&host->lock);
|
spin_lock_init(&host->lock);
|
||||||
|
|
||||||
@ -1441,8 +1440,9 @@ err:
|
|||||||
static int bcm2835_remove(struct platform_device *pdev)
|
static int bcm2835_remove(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct bcm2835_host *host = platform_get_drvdata(pdev);
|
struct bcm2835_host *host = platform_get_drvdata(pdev);
|
||||||
|
struct mmc_host *mmc = mmc_from_priv(host);
|
||||||
|
|
||||||
mmc_remove_host(host->mmc);
|
mmc_remove_host(mmc);
|
||||||
|
|
||||||
writel(SDVDD_POWER_OFF, host->ioaddr + SDVDD);
|
writel(SDVDD_POWER_OFF, host->ioaddr + SDVDD);
|
||||||
|
|
||||||
@ -1454,7 +1454,7 @@ static int bcm2835_remove(struct platform_device *pdev)
|
|||||||
if (host->dma_chan_rxtx)
|
if (host->dma_chan_rxtx)
|
||||||
dma_release_channel(host->dma_chan_rxtx);
|
dma_release_channel(host->dma_chan_rxtx);
|
||||||
|
|
||||||
mmc_free_host(host->mmc);
|
mmc_free_host(mmc);
|
||||||
platform_set_drvdata(pdev, NULL);
|
platform_set_drvdata(pdev, NULL);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -478,6 +478,11 @@ static inline void *mmc_priv(struct mmc_host *host)
|
|||||||
return (void *)host->private;
|
return (void *)host->private;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline struct mmc_host *mmc_from_priv(void *priv)
|
||||||
|
{
|
||||||
|
return container_of(priv, struct mmc_host, private);
|
||||||
|
}
|
||||||
|
|
||||||
#define mmc_host_is_spi(host) ((host)->caps & MMC_CAP_SPI)
|
#define mmc_host_is_spi(host) ((host)->caps & MMC_CAP_SPI)
|
||||||
|
|
||||||
#define mmc_dev(x) ((x)->parent)
|
#define mmc_dev(x) ((x)->parent)
|
||||||
|
Loading…
Reference in New Issue
Block a user