[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200224231841.26550-3-digetx@gmail.com>
Date: Tue, 25 Feb 2020 02:18:40 +0300
From: Dmitry Osipenko <digetx@...il.com>
To: Jens Axboe <axboe@...nel.dk>,
Thierry Reding <thierry.reding@...il.com>,
Jonathan Hunter <jonathanh@...dia.com>,
Michał Mirosław <mirq-linux@...e.qmqm.pl>,
David Heidelberg <david@...t.cz>,
Peter Geis <pgwipeout@...il.com>,
Stephen Warren <swarren@...dotorg.org>,
Nicolas Chauvet <kwizart@...il.com>,
Ulf Hansson <ulf.hansson@...aro.org>,
Adrian Hunter <adrian.hunter@...el.com>,
Billy Laws <blaws05@...il.com>
Cc: linux-tegra@...r.kernel.org, linux-block@...r.kernel.org,
Andrey Danin <danindrey@...l.ru>,
Gilles Grandou <gilles@...ndou.net>,
Ryan Grachek <ryan@...ted.us>, linux-mmc@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH v1 2/3] mmc: block: Add mmc_bdev_to_card() helper
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@...il.com>
---
drivers/mmc/core/block.c | 14 ++++++++++++++
include/linux/mmc/card.h | 3 +++
2 files changed, 17 insertions(+)
diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c
index 663d87924e5e..5d853450c764 100644
--- a/drivers/mmc/core/block.c
+++ b/drivers/mmc/core/block.c
@@ -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);
diff --git a/include/linux/mmc/card.h b/include/linux/mmc/card.h
index 90b1d83ce675..daccb0cc25f8 100644
--- a/include/linux/mmc/card.h
+++ b/include/linux/mmc/card.h
@@ -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 */
--
2.24.0
Powered by blists - more mailing lists