From patchwork Wed Jan 19 01:42:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1581600 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=DxrHKaOd; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JdpP35VfLz9sPC for ; Wed, 19 Jan 2022 12:45:11 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 32D2E8380F; Wed, 19 Jan 2022 02:44:25 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="DxrHKaOd"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D41D3837E1; Wed, 19 Jan 2022 02:43:56 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-io1-xd32.google.com (mail-io1-xd32.google.com [IPv6:2607:f8b0:4864:20::d32]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id B9F34837CC for ; Wed, 19 Jan 2022 02:43:48 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd32.google.com with SMTP id f24so1033769ioc.0 for ; Tue, 18 Jan 2022 17:43:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=CeQ4TznH5ulNgatYTr4CgoePHEto85uHOBv7OxAtLGg=; b=DxrHKaOd0uDsGRNs1+Ln+j9BpEpgmc+lYhE6x0ZaHt05o0k16v19LDyVmdUoJn5Qu5 fm8YLnzzS47i7/4bfdXFb21x7XM3usmlx6JvlCaayVo0vvDus7YEj4lUsuZBHkvoiFye lmQjucx+FQIkw/nqlM/lQ1RkCd4+X+Jxi6fAA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=CeQ4TznH5ulNgatYTr4CgoePHEto85uHOBv7OxAtLGg=; b=7b7/PGqjwryzyBp+iwu+LXS/o6tZiGySMXeMQcPhgwrvw7X1F5PNOYlipipGrQnTr3 Ly7aYAFpl5MXcqi2ib2q+EXdUa0QlPxn46TlIGSUu3Eu8unQwAOwZ5mhfYNRQoZuswaU wYEfxal+3If5vb/DDWlM/1jCTl0rrs9TubuMZwkl+Ral+FMXGx26vhFfgfxK6T6BMufk 5AZWDvioNaqcxzEY2fnayYBt0WKK8Nh9m/A4N7TE9dEFffrlddtOo4G5ERYhIdTybare cqFVisv84ZkBVubvc33ulNjhQzVXgj7l1ruYac6n3j/7Ybj1AV3lxju8tcN2XF9W377E Z0Tw== X-Gm-Message-State: AOAM532teZS5W9dxB9qgS/XNU+cG83KlhK65TQiP0Litq+iAesIH4jyi nB69jiyPiLc7wtmmgXhn9/4AV/p9tWw5UQ== X-Google-Smtp-Source: ABdhPJxzxuK3xfpXUdx0CYBrZOl8y+i7F+1tRu7S6/hxtiJ6fPPiKAt0008LtwUoD44IZxj4/rcDAA== X-Received: by 2002:a05:6638:2a7:: with SMTP id d7mr12865916jaq.93.1642556627352; Tue, 18 Jan 2022 17:43:47 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id j18sm10546314ila.86.2022.01.18.17.43.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jan 2022 17:43:47 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Ilias Apalodimas , Daniel Schwierzeck , Dennis Gilmore , Steffen Jaeckel , Lukas Auer , Michal Simek , Tom Rini , Heinrich Schuchardt , Simon Glass , Marek Vasut , Pavel Herrmann Subject: [PATCH v3 09/31] dm: blk: Add a function to return the device type Date: Tue, 18 Jan 2022 18:42:53 -0700 Message-Id: <20220118184259.v3.9.I6a05dc4317e457af31d5f1dc9df5848a521a2374@changeid> X-Mailer: git-send-email 2.34.1.703.g22d0c6ccf7-goog In-Reply-To: <20220119014315.1938157-1-sjg@chromium.org> References: <20220119014315.1938157-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean Use the uclass name to get the device type for a block device. Signed-off-by: Simon Glass --- (no changes since v1) drivers/block/blk-uclass.c | 8 ++++++++ include/blk.h | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-uclass.c index a055387570a..cfc34417a27 100644 --- a/drivers/block/blk-uclass.c +++ b/drivers/block/blk-uclass.c @@ -509,6 +509,14 @@ int blk_get_from_parent(struct udevice *parent, struct udevice **devp) return 0; } +const char *blk_get_devtype(struct udevice *dev) +{ + struct udevice *parent = dev_get_parent(dev); + + return uclass_get_name(device_get_uclass_id(parent)); +}; + + int blk_find_max_devnum(enum if_type if_type) { struct udevice *dev; diff --git a/include/blk.h b/include/blk.h index 133204a82e1..e88948e4c32 100644 --- a/include/blk.h +++ b/include/blk.h @@ -433,6 +433,14 @@ int blk_select_hwpart(struct udevice *dev, int hwpart); */ int blk_get_from_parent(struct udevice *parent, struct udevice **devp); +/** + * blk_get_devtype() - Get the device type of a block device + * + * @dev: Block device to check + * @return device tree, i.e. the uclass name of its parent, e.g. "mmc" + */ +const char *blk_get_devtype(struct udevice *dev); + /** * blk_get_by_device() - Get the block device descriptor for the given device * @dev: Instance of a storage device