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: 210922 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5F229C433E0 for ; Sat, 16 May 2020 15:38:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3E01A20727 for ; Sat, 16 May 2020 15:38:10 +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 S1727822AbgEPPiB (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-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@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 */