Skip to content

Commit c58ccf2

Browse files
l1kstorulf
authored andcommitted
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 <[email protected]> Cc: Frank Pavlic <[email protected]> Cc: Alexander Graf <[email protected]> Reviewed-by: Alexander Graf <[email protected]> Signed-off-by: Ulf Hansson <[email protected]>
1 parent e5c1e63 commit c58ccf2

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

drivers/mmc/host/bcm2835.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,6 @@ struct bcm2835_host {
148148
void __iomem *ioaddr;
149149
u32 phys_addr;
150150

151-
struct mmc_host *mmc;
152151
struct platform_device *pdev;
153152

154153
int clock; /* Current clock speed */
@@ -618,7 +617,7 @@ static void bcm2835_finish_request(struct bcm2835_host *host)
618617
"failed to terminate DMA (%d)\n", err);
619618
}
620619

621-
mmc_request_done(host->mmc, mrq);
620+
mmc_request_done(mmc_from_priv(host), mrq);
622621
}
623622

624623
static
@@ -837,7 +836,7 @@ static void bcm2835_timeout(struct work_struct *work)
837836
dev_err(dev, "timeout waiting for hardware interrupt.\n");
838837
bcm2835_dumpregs(host);
839838

840-
bcm2835_reset(host->mmc);
839+
bcm2835_reset(mmc_from_priv(host));
841840

842841
if (host->data) {
843842
host->data->error = -ETIMEDOUT;
@@ -1100,6 +1099,7 @@ static void bcm2835_dma_complete_work(struct work_struct *work)
11001099

11011100
static void bcm2835_set_clock(struct bcm2835_host *host, unsigned int clock)
11021101
{
1102+
struct mmc_host *mmc = mmc_from_priv(host);
11031103
int div;
11041104

11051105
/* 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)
11431143
div = SDCDIV_MAX_CDIV;
11441144

11451145
clock = host->max_clk / (div + 2);
1146-
host->mmc->actual_clock = clock;
1146+
mmc->actual_clock = clock;
11471147

11481148
/* Calibrate some delays */
11491149

11501150
host->ns_per_fifo_word = (1000000000 / clock) *
1151-
((host->mmc->caps & MMC_CAP_4_BIT_DATA) ? 8 : 32);
1151+
((mmc->caps & MMC_CAP_4_BIT_DATA) ? 8 : 32);
11521152

11531153
host->cdiv = div;
11541154
writel(host->cdiv, host->ioaddr + SDCDIV);
11551155

11561156
/* Set the timeout to 500ms */
1157-
writel(host->mmc->actual_clock / 2, host->ioaddr + SDTOUT);
1157+
writel(mmc->actual_clock / 2, host->ioaddr + SDTOUT);
11581158
}
11591159

11601160
static void bcm2835_request(struct mmc_host *mmc, struct mmc_request *mrq)
@@ -1264,7 +1264,7 @@ static const struct mmc_host_ops bcm2835_ops = {
12641264

12651265
static int bcm2835_add_host(struct bcm2835_host *host)
12661266
{
1267-
struct mmc_host *mmc = host->mmc;
1267+
struct mmc_host *mmc = mmc_from_priv(host);
12681268
struct device *dev = &host->pdev->dev;
12691269
char pio_limit_string[20];
12701270
int ret;
@@ -1370,7 +1370,6 @@ static int bcm2835_probe(struct platform_device *pdev)
13701370

13711371
mmc->ops = &bcm2835_ops;
13721372
host = mmc_priv(mmc);
1373-
host->mmc = mmc;
13741373
host->pdev = pdev;
13751374
spin_lock_init(&host->lock);
13761375

@@ -1441,8 +1440,9 @@ static int bcm2835_probe(struct platform_device *pdev)
14411440
static int bcm2835_remove(struct platform_device *pdev)
14421441
{
14431442
struct bcm2835_host *host = platform_get_drvdata(pdev);
1443+
struct mmc_host *mmc = mmc_from_priv(host);
14441444

1445-
mmc_remove_host(host->mmc);
1445+
mmc_remove_host(mmc);
14461446

14471447
writel(SDVDD_POWER_OFF, host->ioaddr + SDVDD);
14481448

@@ -1454,7 +1454,7 @@ static int bcm2835_remove(struct platform_device *pdev)
14541454
if (host->dma_chan_rxtx)
14551455
dma_release_channel(host->dma_chan_rxtx);
14561456

1457-
mmc_free_host(host->mmc);
1457+
mmc_free_host(mmc);
14581458
platform_set_drvdata(pdev, NULL);
14591459

14601460
return 0;

include/linux/mmc/host.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,11 @@ static inline void *mmc_priv(struct mmc_host *host)
478478
return (void *)host->private;
479479
}
480480

481+
static inline struct mmc_host *mmc_from_priv(void *priv)
482+
{
483+
return container_of(priv, struct mmc_host, private);
484+
}
485+
481486
#define mmc_host_is_spi(host) ((host)->caps & MMC_CAP_SPI)
482487

483488
#define mmc_dev(x) ((x)->parent)

0 commit comments

Comments
 (0)