Thread (21 messages) 21 messages, 4 authors, 2021-08-20

Re: [PATCH v5 2/5] mmc: block: Support alternative_gpt_sector() operation

From: Christoph Hellwig <hch@infradead.org>
Date: 2021-08-18 05:30:44
Also in: linux-efi, linux-tegra

On Wed, Aug 18, 2021 at 03:55:44AM +0300, Dmitry Osipenko wrote:
+static int mmc_blk_alternative_gpt_sector(struct block_device *bdev,
+					  sector_t *sector)
+{
+	struct mmc_card *card = mmc_bdev_to_card(bdev);
+
+	if (!card)
+		return -ENODEV;
+
+	if (!card->host->ops->alternative_gpt_sector)
+		return -EOPNOTSUPP;
+
+	return card->host->ops->alternative_gpt_sector(card, sector);
+}
+
+static struct mmc_card *mmc_bdev_to_card(struct block_device *bdev)
+{
+	struct mmc_blk_data *md;
+
+	if (bdev->bd_disk->fops != &mmc_bdops)
+		return NULL;
No need for this check bow that it is only called through mmc_bdops.
+
+	md = mmc_blk_get(bdev->bd_disk);
+	if (!md)
+		return NULL;
+
+	return md->queue.card;
+}
This reference seems to never be dropped anywhere.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help