From patchwork Sat Mar 27 21:20:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 410685 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham 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 38622C433DB for ; Sat, 27 Mar 2021 21:24:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0A34D601FD for ; Sat, 27 Mar 2021 21:24:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230449AbhC0VXq (ORCPT ); Sat, 27 Mar 2021 17:23:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52538 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230178AbhC0VX1 (ORCPT ); Sat, 27 Mar 2021 17:23:27 -0400 Received: from mail-lj1-x22c.google.com (mail-lj1-x22c.google.com [IPv6:2a00:1450:4864:20::22c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF8F6C0613B3; Sat, 27 Mar 2021 14:23:26 -0700 (PDT) Received: by mail-lj1-x22c.google.com with SMTP id s17so11457317ljc.5; Sat, 27 Mar 2021 14:23:26 -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=DYSgmhDDJeU60WZ2qkj3eYgQcVqlfr0Yv38NQkuYdoM=; b=duGQwc5aT3ZrdSRXFebNpJToMJ6rZyhUe54R3il99SAm9E3t1uc+KMSz5oaYIbHyFc lqZh/IrKc/7v//zT5KYtrsOqqmbGUQWN3fFn2GxcYt8OswzqiJlRlb3X4iDQSG7JV4fm MMya+HlqZCieqW5AICk+U3ya1/tLMgVGp2ii77GoUHAlZH7ePBj1q/8hHhIqiWE/reOq cobCTjOGYwp6Xf26VnkyDNHejskhVEW1PQKQN2ftPNPaFzDyDxhRcr9qByno9SXxOopV hJmP1PiQFjVgnEw2BPPxbwKI4Xz3OBbjLeI2vszR7K8KtPhHKE6r3Q/NVNckxXdN43JW LX4Q== 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=DYSgmhDDJeU60WZ2qkj3eYgQcVqlfr0Yv38NQkuYdoM=; b=lkhyYVL7GhZcgGGIJSAsKwitlXMOiSCLLwAe32V4e2ZPZnWH1M3tYYvPDPhvawS5BC QHhT/7QoiVnGzYN35UDpRAlylu/Pi9rKW/oHff3JRB2yeAacRDlkZ98idBv+eiKpNdMM erLNDN9h4XYmMYJZPNj5RXTHDqJo0m2Cv7UIVbch6dzGFqj6KR8oVIPOtZ9GsFO+63e2 kP1hQkoQhAIVDc5r9ZiB14R3VNAaXFzUuVC6V3uvB4plefG8GN2PeneDKstjUqAc0VCL HLirjHJWePcN/+hIWRSpQ8TPN+pPEfHCxGgHSTXaTE+HNQw9UmBPS5ckQhbtN46OtDn3 xf1g== X-Gm-Message-State: AOAM5304aLQA6pX96MNmH1H3ChNV6dxzxtYR2D2zb4c1wuZS8X8/7KWO t6rAE3o2xD/hd7Un3yrONsI= X-Google-Smtp-Source: ABdhPJw9ZU8ydYvThuoMbMN2MoKDQog6WsWizag6KBMfyHXWr0dLqRTVPLUxpxD4ryCW7tRP87rdrw== X-Received: by 2002:a2e:2d02:: with SMTP id t2mr12552119ljt.488.1616880205353; Sat, 27 Mar 2021 14:23:25 -0700 (PDT) Received: from localhost.localdomain (109-252-193-66.dynamic.spd-mgts.ru. [109.252.193.66]) by smtp.gmail.com with ESMTPSA id x7sm1300626lfe.182.2021.03.27.14.23.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Mar 2021 14:23:25 -0700 (PDT) From: Dmitry Osipenko To: Jens Axboe , Thierry Reding , Jonathan Hunter , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= , David Heidelberg , Peter Geis , Ulf Hansson , Adrian Hunter , Christoph Hellwig , Ard Biesheuvel , Davidlohr Bueso , Randy Dunlap , Ion Agorria , Svyatoslav Ryhel Cc: linux-tegra@vger.kernel.org, linux-block@vger.kernel.org, linux-efi Subject: [PATCH v1 2/3] mmc: block: Add mmc_bdev_to_card() helper Date: Sun, 28 Mar 2021 00:20:59 +0300 Message-Id: <20210327212100.3834-3-digetx@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210327212100.3834-1-digetx@gmail.com> References: <20210327212100.3834-1-digetx@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-efi@vger.kernel.org Add mmc_bdev_to_card() helper which is needed for finding EFI entry on EMMC of NVIDIA Tegra devices. 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 fe5892d30778..666066fd6037 100644 --- a/drivers/mmc/core/block.c +++ b/drivers/mmc/core/block.c @@ -40,6 +40,7 @@ #include #include +#include #include #include #include @@ -306,6 +307,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 */