From patchwork Mon Feb 24 23:18: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: 11402099 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 A54BC159A for ; Mon, 24 Feb 2020 23:22:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8553522525 for ; Mon, 24 Feb 2020 23:22:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="L/QD2NWl" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728578AbgBXXWQ (ORCPT ); Mon, 24 Feb 2020 18:22:16 -0500 Received: from mail-lf1-f68.google.com ([209.85.167.68]:39199 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728601AbgBXXWP (ORCPT ); Mon, 24 Feb 2020 18:22:15 -0500 Received: by mail-lf1-f68.google.com with SMTP id n30so7318717lfh.6; Mon, 24 Feb 2020 15:22:13 -0800 (PST) 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=0WbwisyovPdHh7n4bXAVF0naVkmF9FhNybnanTU/DvE=; b=L/QD2NWlOoATb3n4pe/WkpwegJ+eSQdE69qR5elj74A01FRPVQeTbbZaUvbB2T3aRK XeuZrQq2UrK/jCsxi1FENcbGh3gTrieDZSgypUWGCBdPuqhJm7NkSoMFjvaFvvYy+fo5 CnoJ0e2ldWNZ8Z/wpoPJL64nTzvlNMVhIU9iTWlQR+4WR2u3Mv34U2Q34GkebPyLdeU3 16ffg4vzu8ajfSJPMmHBr3tWJKObFFiy3PtyaVQ2uhVxmXa0ZQ1zYGMiWYZHQWyobs+u iSohkTigTMhiqitHrB/JWg7YD6/Q0ifjNk/uNwghpNGa/pd9p+0o+WEsiD5IN9k0Uyu8 ePqQ== 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=0WbwisyovPdHh7n4bXAVF0naVkmF9FhNybnanTU/DvE=; b=kGufi6nys0cJMsAU2tQmSLB3iPon5qNhKbUzr6CN2hbvaE1TrivaVCy1VQIMZ6ILCK KWjnaFIYT7oqy2iF+yEZnJavq3prdAnKLQzgW7xqyujc4brp2YfU8oa8Ljhi6bEdJl7t eIWf9yAZ+Q4luRRY5eSuncM7Y7vzni9mzx/U1dZ5vvp5/JoNnzKhDbkI2b6+eSd7KgVu lCuyKtkOIA58L+yL2QK4RdQQDFT5ncY/WxVRbjsuiIVhVgwJIJ0B8IpDSci25QCjcQjz EUtbKFQ+o6exGEIu2cVXGlkcbDW0q40fl00hKz87L5RniuSzf2JRkSWQxfp56MogF8t5 W9oA== X-Gm-Message-State: APjAAAW4TYekV1ECMXOh3WCUfHpEvRs6slC2ZYxmUwUy0I+P4YAIYOMn ACHpAe5DYxTDp2Y69YTFU6s= X-Google-Smtp-Source: APXvYqxafMZRO9DsBweskGBjWJG4F055WbsYEBgXwBngwRHxDKevzJcykEixDVZfgY/3AbhgNCtnqA== X-Received: by 2002:ac2:5106:: with SMTP id q6mr12758402lfb.54.1582586532904; Mon, 24 Feb 2020 15:22:12 -0800 (PST) Received: from localhost.localdomain (79-139-233-37.dynamic.spd-mgts.ru. [79.139.233.37]) by smtp.gmail.com with ESMTPSA id r10sm8154071ljk.9.2020.02.24.15.22.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Feb 2020 15:22:12 -0800 (PST) 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 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 Subject: [PATCH v1 2/3] mmc: block: Add mmc_bdev_to_card() helper Date: Tue, 25 Feb 2020 02:18:40 +0300 Message-Id: <20200224231841.26550-3-digetx@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200224231841.26550-1-digetx@gmail.com> References: <20200224231841.26550-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. This patch introduces new helper which takes block device for the input argument and returns corresponding MMC card. Signed-off-by: Dmitry Osipenko Reported-by: kbuild test robot --- 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 #include #include @@ -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 */