Skip to content

Commit fdc4e75

Browse files
mahathugstorulf
authored andcommitted
mmc: android-goldfish: Drop pointer to mmc_host from goldfish_mmc_host
The driver for android-goldfish uses a pointer to get from the private goldfish_mmc_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: Kamlesh Gurudasani <[email protected]> Signed-off-by: Ulf Hansson <[email protected]>
1 parent d1fdb6d commit fdc4e75

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

drivers/mmc/host/android-goldfish.c

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ struct goldfish_mmc_host {
113113
struct mmc_request *mrq;
114114
struct mmc_command *cmd;
115115
struct mmc_data *data;
116-
struct mmc_host *mmc;
117116
struct device *dev;
118117
unsigned char id; /* 16xx chips have 2 MMC blocks */
119118
void *virt_base;
@@ -175,7 +174,7 @@ goldfish_mmc_start_command(struct goldfish_mmc_host *host, struct mmc_command *c
175174
resptype = 3;
176175
break;
177176
default:
178-
dev_err(mmc_dev(host->mmc),
177+
dev_err(mmc_dev(mmc_from_priv(host)),
179178
"Invalid response type: %04x\n", mmc_resp_type(cmd));
180179
break;
181180
}
@@ -221,8 +220,8 @@ static void goldfish_mmc_xfer_done(struct goldfish_mmc_host *host,
221220
data->sg->length);
222221
}
223222
host->data->bytes_xfered += data->sg->length;
224-
dma_unmap_sg(mmc_dev(host->mmc), data->sg, host->sg_len,
225-
dma_data_dir);
223+
dma_unmap_sg(mmc_dev(mmc_from_priv(host)), data->sg,
224+
host->sg_len, dma_data_dir);
226225
}
227226

228227
host->data = NULL;
@@ -236,7 +235,7 @@ static void goldfish_mmc_xfer_done(struct goldfish_mmc_host *host,
236235

237236
if (!data->stop) {
238237
host->mrq = NULL;
239-
mmc_request_done(host->mmc, data->mrq);
238+
mmc_request_done(mmc_from_priv(host), data->mrq);
240239
return;
241240
}
242241

@@ -278,7 +277,7 @@ static void goldfish_mmc_cmd_done(struct goldfish_mmc_host *host,
278277

279278
if (host->data == NULL || cmd->error) {
280279
host->mrq = NULL;
281-
mmc_request_done(host->mmc, cmd->mrq);
280+
mmc_request_done(mmc_from_priv(host), cmd->mrq);
282281
}
283282
}
284283

@@ -313,7 +312,7 @@ static irqreturn_t goldfish_mmc_irq(int irq, void *dev_id)
313312
struct mmc_request *mrq = host->mrq;
314313
mrq->cmd->error = -ETIMEDOUT;
315314
host->mrq = NULL;
316-
mmc_request_done(host->mmc, mrq);
315+
mmc_request_done(mmc_from_priv(host), mrq);
317316
}
318317

319318
if (end_command)
@@ -339,12 +338,13 @@ static irqreturn_t goldfish_mmc_irq(int irq, void *dev_id)
339338
u32 state = GOLDFISH_MMC_READ(host, MMC_STATE);
340339
pr_info("%s: Card detect now %d\n", __func__,
341340
(state & MMC_STATE_INSERTED));
342-
mmc_detect_change(host->mmc, 0);
341+
mmc_detect_change(mmc_from_priv(host), 0);
343342
}
344343

345344
if (!end_command && !end_transfer && !state_changed && !cmd_timeout) {
346345
status = GOLDFISH_MMC_READ(host, MMC_INT_STATUS);
347-
dev_info(mmc_dev(host->mmc),"spurious irq 0x%04x\n", status);
346+
dev_info(mmc_dev(mmc_from_priv(host)), "spurious irq 0x%04x\n",
347+
status);
348348
if (status != 0) {
349349
GOLDFISH_MMC_WRITE(host, MMC_INT_STATUS, status);
350350
GOLDFISH_MMC_WRITE(host, MMC_INT_ENABLE, 0);
@@ -383,7 +383,7 @@ static void goldfish_mmc_prepare_data(struct goldfish_mmc_host *host,
383383

384384
dma_data_dir = mmc_get_dma_dir(data);
385385

386-
host->sg_len = dma_map_sg(mmc_dev(host->mmc), data->sg,
386+
host->sg_len = dma_map_sg(mmc_dev(mmc_from_priv(host)), data->sg,
387387
sg_len, dma_data_dir);
388388
host->dma_done = 0;
389389
host->dma_in_use = 1;
@@ -461,7 +461,6 @@ static int goldfish_mmc_probe(struct platform_device *pdev)
461461
}
462462

463463
host = mmc_priv(mmc);
464-
host->mmc = mmc;
465464

466465
pr_err("mmc: Mapping %lX to %lX\n", (long)res->start, (long)res->end);
467466
host->reg_base = ioremap(res->start, resource_size(res));
@@ -508,8 +507,7 @@ static int goldfish_mmc_probe(struct platform_device *pdev)
508507

509508
ret = device_create_file(&pdev->dev, &dev_attr_cover_switch);
510509
if (ret)
511-
dev_warn(mmc_dev(host->mmc),
512-
"Unable to create sysfs attributes\n");
510+
dev_warn(mmc_dev(mmc), "Unable to create sysfs attributes\n");
513511

514512
GOLDFISH_MMC_WRITE(host, MMC_SET_BUFFER, host->phys_base);
515513
GOLDFISH_MMC_WRITE(host, MMC_INT_ENABLE,
@@ -525,22 +523,23 @@ static int goldfish_mmc_probe(struct platform_device *pdev)
525523
dma_alloc_failed:
526524
iounmap(host->reg_base);
527525
ioremap_failed:
528-
mmc_free_host(host->mmc);
526+
mmc_free_host(mmc);
529527
err_alloc_host_failed:
530528
return ret;
531529
}
532530

533531
static int goldfish_mmc_remove(struct platform_device *pdev)
534532
{
535533
struct goldfish_mmc_host *host = platform_get_drvdata(pdev);
534+
struct mmc_host *mmc = mmc_from_priv(host);
536535

537536
BUG_ON(host == NULL);
538537

539-
mmc_remove_host(host->mmc);
538+
mmc_remove_host(mmc);
540539
free_irq(host->irq, host);
541540
dma_free_coherent(&pdev->dev, BUFFER_SIZE, host->virt_base, host->phys_base);
542541
iounmap(host->reg_base);
543-
mmc_free_host(host->mmc);
542+
mmc_free_host(mmc);
544543
return 0;
545544
}
546545

0 commit comments

Comments
 (0)