Commit 6217eaae authored by Jeffy Chen's avatar Jeffy Chen Committed by chrome-bot
Browse files

mmc: add block_mmc_is_bdev_owned



Add block_mmc_is_bdev_owned and set it in all MMC drivers.

BUG=b:63407238
TEST=build and boot

Change-Id: I4bd69be559275ad4a92e7a89d8dfb607819c883f
Signed-off-by: default avatarJeffy Chen <jeffy.chen@rock-chips.com>
Reviewed-on: https://chromium-review.googlesource.com/652088

Reviewed-by: default avatarJulius Werner <jwerner@chromium.org>
parent 618a044b
......@@ -404,13 +404,6 @@ static int dwmci_update(BlockDevCtrlrOps *me)
return 0;
}
static int dwmmc_is_bdev_owned(BlockDevCtrlrOps *me, BlockDev *bdev)
{
DwmciHost *host = container_of(me, DwmciHost, mmc.ctrlr.ops);
return (&host->mmc.media->dev == bdev);
}
DwmciHost *new_dwmci_host(uintptr_t ioaddr, uint32_t src_hz,
int bus_width, int removable,
GpioOps *card_detect, uint32_t clksel_val)
......@@ -418,7 +411,7 @@ DwmciHost *new_dwmci_host(uintptr_t ioaddr, uint32_t src_hz,
DwmciHost *ctrlr = xzalloc(sizeof(*ctrlr));
ctrlr->mmc.ctrlr.ops.update = &dwmci_update;
ctrlr->mmc.ctrlr.ops.is_bdev_owned = &dwmmc_is_bdev_owned;
ctrlr->mmc.ctrlr.ops.is_bdev_owned = block_mmc_is_bdev_owned;
ctrlr->mmc.ctrlr.need_update = 1;
......
......@@ -739,6 +739,7 @@ QcomMmcHost *new_qcom_mmc_host(unsigned slot, uint32_t base, int bus_width)
new_host->instance = slot;
new_host->mci_base = (uint8_t *)base;
new_host->mmc.ctrlr.ops.is_bdev_owned = block_mmc_is_bdev_owned;
new_host->mmc.ctrlr.ops.update = qcom_mmc_update;
new_host->mmc.ctrlr.need_update = 1;
new_host->mmc.set_ios = &mmc_boot_set_ios;
......
......@@ -1330,3 +1330,10 @@ cleanup:
free(buffer);
return ret;
}
int block_mmc_is_bdev_owned(BlockDevCtrlrOps *me, BlockDev *bdev)
{
MmcCtrlr *mmc_ctrlr = container_of(me, MmcCtrlr, ctrlr.ops);
return &mmc_ctrlr->media->dev == bdev;
}
......@@ -323,6 +323,7 @@ lba_t block_mmc_write(BlockDevOps *me, lba_t start, lba_t count,
lba_t block_mmc_erase(BlockDevOps *me, lba_t start, lba_t count);
lba_t block_mmc_fill_write(BlockDevOps *me, lba_t start, lba_t count,
uint32_t fill_pattern);
int block_mmc_is_bdev_owned(BlockDevCtrlrOps *me, BlockDev *bdev);
// Debug functions.
extern int __mmc_debug, __mmc_trace;
......
......@@ -461,6 +461,7 @@ MtkMmcHost *new_mtk_mmc_host(uintptr_t ioaddr, uint32_t src_hz, uint32_t max_fre
assert((max_freq <= MtkMmcMaxFreq) && (max_freq >= MtkMmcMinFreq));
ctrlr->mmc.ctrlr.ops.is_bdev_owned = block_mmc_is_bdev_owned;
ctrlr->mmc.ctrlr.ops.update = &mtk_mmc_update;
ctrlr->mmc.ctrlr.need_update = 1;
......
......@@ -531,6 +531,7 @@ Mvmap2315MmcHost *new_mvmap2315_mmc_host(uintptr_t ioaddr,
{
Mvmap2315MmcHost *ctrlr = xzalloc(sizeof(*ctrlr));
ctrlr->mmc.ctrlr.ops.is_bdev_owned = block_mmc_is_bdev_owned;
ctrlr->mmc.ctrlr.ops.update = &mvmap2315_mmc_update;
ctrlr->mmc.ctrlr.need_update = 1;
......
......@@ -520,6 +520,7 @@ MshciHost *new_mshci_host(uintptr_t ioaddr, uint32_t src_hz, int bus_width,
{
MshciHost *ctrlr = xzalloc(sizeof(*ctrlr));
ctrlr->mmc.ctrlr.ops.is_bdev_owned = block_mmc_is_bdev_owned;
ctrlr->mmc.ctrlr.ops.update = &s5p_mshc_update;
ctrlr->mmc.ctrlr.need_update = 1;
......
......@@ -831,6 +831,7 @@ void add_sdhci(SdhciHost *host)
host->mmc_ctrlr.send_cmd = &sdhci_send_command;
host->mmc_ctrlr.set_ios = &sdhci_set_ios;
host->mmc_ctrlr.ctrlr.ops.is_bdev_owned = block_mmc_is_bdev_owned;
host->mmc_ctrlr.ctrlr.ops.update = &sdhci_update;
host->mmc_ctrlr.ctrlr.need_update = 1;
......
......@@ -573,21 +573,14 @@ static int tegra_mmc_update(BlockDevCtrlrOps *me)
return 0;
}
static int tegra_is_bdev_owned(BlockDevCtrlrOps *me, BlockDev *bdev)
{
TegraMmcHost *host = container_of(me, TegraMmcHost, mmc.ctrlr.ops);
return (&host->mmc.media->dev == bdev);
}
TegraMmcHost *new_tegra_mmc_host(uintptr_t ioaddr, int bus_width,
int removable, GpioOps *card_detect,
GpioOps *enable_power)
{
TegraMmcHost *ctrlr = xzalloc(sizeof(*ctrlr));
ctrlr->mmc.ctrlr.ops.is_bdev_owned = block_mmc_is_bdev_owned;
ctrlr->mmc.ctrlr.ops.update = &tegra_mmc_update;
ctrlr->mmc.ctrlr.ops.is_bdev_owned = &tegra_is_bdev_owned;
ctrlr->mmc.ctrlr.need_update = 1;
ctrlr->mmc.voltages = TegraMmcVoltages;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment