From patchwork Sat May 16 15:36:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 11553593 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A068590 for ; Sat, 16 May 2020 15:38:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 86B0720756 for ; Sat, 16 May 2020 15:38:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Hvo9451S" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727918AbgEPPiB (ORCPT ); Sat, 16 May 2020 11:38:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45236 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727098AbgEPPhU (ORCPT ); Sat, 16 May 2020 11:37:20 -0400 Received: from mail-lf1-x142.google.com (mail-lf1-x142.google.com [IPv6:2a00:1450:4864:20::142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75A9BC061A0C; Sat, 16 May 2020 08:37:20 -0700 (PDT) Received: by mail-lf1-x142.google.com with SMTP id v5so4285771lfp.13; Sat, 16 May 2020 08:37:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xOq5yyY/u+0O8ZudKc0fLqZJ0PgNfXdMDM0w1gmW1jw=; b=Hvo9451ScIWr4K2i4TFKAfJ8Hiky01fRhOM/PddE10qCDyhNai+374jwqLZ2J3nfs2 p4OWzw9QrqZXo7s6npfHt5Alw65mJ9y08CSuIWyMuDBpum9inSTL8QUe7j5qhyD6o8Pq te+qSz/BQrDHrImbsGFaIfSsJkth/8yIEe5KECwITADdrGxxBXnoMj332SwXcUDnUdfW phHqcrAB/STUUcXItS+wcGF7NYpmQs9FQGMwYzECBje1d0h82O1FEr2/Ct/nwf64REDr q+HBH+9dJvTKa1yjSwKp+bBXG6Hy9UWfUcs9Sdo5wWIkQrHmdpEKXLxLGs3irtKOh2kx hq2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xOq5yyY/u+0O8ZudKc0fLqZJ0PgNfXdMDM0w1gmW1jw=; b=fV2KPqsiim6wyDEOSiadtxwTCYDo85CtZfWqJRYT8PByUmjDKWptuMpD/OFWRBRUtx Ukh4NmpRReQdIFeZPqJQHz1eK6yqGuvwTaGNSVJtK2/OQl1zT2xaWWyJwGjAszQfEPwM JOT0E4FRQTwtDejw5uZkhbHHNFJKGaPBpIX/nDgIq/2L10FbpuGOYeufgFJ5s3gQCWoL zJLu8sERPaUNeA0EoOYwPv4usaUNs672hd+K3BdbNsfBvyBt/49lUrQDvXKRma8jg4wX QTwHIQlXsNKzWfkJHj1CwAVgmWI2hj8GdN6aHn+uFqqzIsQGBLjVBzjuGjY8AQK8CYtG nyGw== X-Gm-Message-State: AOAM531DV/S6LCHm1/UpBSSivGKyvxfyCW3vFK2bUaSIdECCyYEetVK0 nIBe8P/wYxZ09goMREfhoja+O2E/ X-Google-Smtp-Source: ABdhPJynQ4R+mgLh+UneyxWsLqsBhBI616esT9RwgpBEsbBMIY5gXqS4hIYzOiak7k5TTs33aK8KSw== X-Received: by 2002:a05:6512:14c:: with SMTP id m12mr6008280lfo.165.1589643439009; Sat, 16 May 2020 08:37:19 -0700 (PDT) Received: from localhost.localdomain (ppp91-78-208-152.pppoe.mtu-net.ru. [91.78.208.152]) by smtp.gmail.com with ESMTPSA id a12sm2845356ljj.64.2020.05.16.08.37.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 May 2020 08:37:18 -0700 (PDT) From: Dmitry Osipenko To: Jens Axboe , Thierry Reding , Jonathan Hunter , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= , David Heidelberg , Peter Geis , Stephen Warren , Nicolas Chauvet , Ulf Hansson , Adrian Hunter , Billy Laws , =?utf-8?q?Nils_=C3=96stlund?= , Christoph Hellwig , Ard Biesheuvel , Davidlohr Bueso Cc: linux-tegra@vger.kernel.org, linux-block@vger.kernel.org, Andrey Danin , Gilles Grandou , Ryan Grachek , linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, Steve McIntyre , Randy Dunlap , linux-efi Subject: [PATCH v5 2/6] mmc: block: Add mmc_bdev_to_card() helper Date: Sat, 16 May 2020 18:36:40 +0300 Message-Id: <20200516153644.13748-3-digetx@gmail.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200516153644.13748-1-digetx@gmail.com> References: <20200516153644.13748-1-digetx@gmail.com> MIME-Version: 1.0 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org 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. There are also some other parts of struct mmc_card that are needed for the partition parser in order to calculate the eMMC offset and verify different things. This patch introduces new helper which takes block device for the input argument and returns the corresponding MMC card. Signed-off-by: Dmitry Osipenko --- drivers/mmc/core/block.c | 15 +++++++++++++++ include/linux/mmc/blkdev.h | 13 +++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 include/linux/mmc/blkdev.h diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c index c5367e2c8487..99298e888381 100644 --- a/drivers/mmc/core/block.c +++ b/drivers/mmc/core/block.c @@ -40,6 +40,7 @@ #include #include +#include #include #include #include @@ -305,6 +306,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/blkdev.h b/include/linux/mmc/blkdev.h new file mode 100644 index 000000000000..67608c58de70 --- /dev/null +++ b/include/linux/mmc/blkdev.h @@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * linux/include/linux/mmc/blkdev.h + */ +#ifndef LINUX_MMC_BLOCK_DEVICE_H +#define LINUX_MMC_BLOCK_DEVICE_H + +struct block_device; +struct mmc_card; + +struct mmc_card *mmc_bdev_to_card(struct block_device *bdev); + +#endif /* LINUX_MMC_BLOCK_DEVICE_H */