@@ -301,6 +301,20 @@ static ssize_t force_ro_store(struct device *dev, struct device_attribute *attr,
return ret;
}
+struct mmc_card *mmc_bdev_to_card(struct block_device *bdev)
+{
+ struct mmc_blk_data *md;
+
+ if (bdev->bd_disk->major != MMC_BLOCK_MAJOR)
+ return NULL;
+
+ md = mmc_blk_get(bdev->bd_disk);
+ if (!md)
+ return NULL;
+
+ return md->queue.card;
+}
+
static int mmc_blk_open(struct block_device *bdev, fmode_t mode)
{
struct mmc_blk_data *md = mmc_blk_get(bdev->bd_disk);
@@ -7,6 +7,7 @@
#ifndef LINUX_MMC_CARD_H
#define LINUX_MMC_CARD_H
+#include <linux/blkdev.h>
#include <linux/device.h>
#include <linux/mod_devicetable.h>
@@ -324,4 +325,6 @@ bool mmc_card_is_blockaddr(struct mmc_card *card);
#define mmc_card_sd(c) ((c)->type == MMC_TYPE_SD)
#define mmc_card_sdio(c) ((c)->type == MMC_TYPE_SDIO)
+struct mmc_card *mmc_bdev_to_card(struct block_device *bdev);
+
#endif /* LINUX_MMC_CARD_H */
NVIDIA Tegra Partition Table takes into account MMC card's BOOT_SIZE_MULT parameter, and thus, the partition parser needs to retrieve that EXT_CSD value from the block device. This patch introduces new helper which takes block device for the input argument and returns corresponding MMC card. Signed-off-by: Dmitry Osipenko <digetx@gmail.com> --- drivers/mmc/core/block.c | 14 ++++++++++++++ include/linux/mmc/card.h | 3 +++ 2 files changed, 17 insertions(+)