From: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
To: Simon Glass <sjg@chromium.org>
Cc: Patrick Delaunay <patrick.delaunay@foss.st.com>,
Ilias Apalodimas <ilias.apalodimas@linaro.org>,
u-boot@lists.denx.de,
Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Subject: [PATCH 1/1] blk: simplify blk_get_devnum_by_typename()
Date: Sat, 23 Oct 2021 16:06:47 +0200 [thread overview]
Message-ID: <20211023140647.7661-1-heinrich.schuchardt@canonical.com> (raw)
The block descriptor contains the if_type. There is no need to first look
up the uclass for the if_type and then to check the parent device's uclass
to know if the device has the correct if_type.
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
---
drivers/block/blk-uclass.c | 35 +----------------------------------
1 file changed, 1 insertion(+), 34 deletions(-)
diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-uclass.c
index 83682dcc18..b32067f957 100644
--- a/drivers/block/blk-uclass.c
+++ b/drivers/block/blk-uclass.c
@@ -33,22 +33,6 @@ static const char *if_typename_str[IF_TYPE_COUNT] = {
[IF_TYPE_PVBLOCK] = "pvblock",
};
-static enum uclass_id if_type_uclass_id[IF_TYPE_COUNT] = {
- [IF_TYPE_IDE] = UCLASS_IDE,
- [IF_TYPE_SCSI] = UCLASS_SCSI,
- [IF_TYPE_ATAPI] = UCLASS_INVALID,
- [IF_TYPE_USB] = UCLASS_MASS_STORAGE,
- [IF_TYPE_DOC] = UCLASS_INVALID,
- [IF_TYPE_MMC] = UCLASS_MMC,
- [IF_TYPE_SD] = UCLASS_INVALID,
- [IF_TYPE_SATA] = UCLASS_AHCI,
- [IF_TYPE_HOST] = UCLASS_ROOT,
- [IF_TYPE_NVME] = UCLASS_NVME,
- [IF_TYPE_EFI] = UCLASS_EFI,
- [IF_TYPE_VIRTIO] = UCLASS_VIRTIO,
- [IF_TYPE_PVBLOCK] = UCLASS_PVBLOCK,
-};
-
static enum if_type if_typename_to_iftype(const char *if_typename)
{
int i;
@@ -62,11 +46,6 @@ static enum if_type if_typename_to_iftype(const char *if_typename)
return IF_TYPE_UNKNOWN;
}
-static enum uclass_id if_type_to_uclass_id(enum if_type if_type)
-{
- return if_type_uclass_id[if_type];
-}
-
const char *blk_get_if_type_name(enum if_type if_type)
{
return if_typename_str[if_type];
@@ -93,7 +72,6 @@ struct blk_desc *blk_get_devnum_by_type(enum if_type if_type, int devnum)
*/
struct blk_desc *blk_get_devnum_by_typename(const char *if_typename, int devnum)
{
- enum uclass_id uclass_id;
enum if_type if_type;
struct udevice *dev;
struct uclass *uc;
@@ -105,12 +83,6 @@ struct blk_desc *blk_get_devnum_by_typename(const char *if_typename, int devnum)
if_typename);
return NULL;
}
- uclass_id = if_type_to_uclass_id(if_type);
- if (uclass_id == UCLASS_INVALID) {
- debug("%s: Unknown uclass for interface type'\n",
- if_typename_str[if_type]);
- return NULL;
- }
ret = uclass_get(UCLASS_BLK, &uc);
if (ret)
@@ -122,13 +94,8 @@ struct blk_desc *blk_get_devnum_by_typename(const char *if_typename, int devnum)
if_type, devnum, dev->name, desc->if_type, desc->devnum);
if (desc->devnum != devnum)
continue;
-
- /* Find out the parent device uclass */
- if (device_get_uclass_id(dev->parent) != uclass_id) {
- debug("%s: parent uclass %d, this dev %d\n", __func__,
- device_get_uclass_id(dev->parent), uclass_id);
+ if (desc->if_type != if_type)
continue;
- }
if (device_probe(dev))
return NULL;
--
2.32.0
next reply other threads:[~2021-10-23 14:07 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-23 14:06 Heinrich Schuchardt [this message]
2021-10-24 19:54 ` [PATCH 1/1] blk: simplify blk_get_devnum_by_typename() Simon Glass
2021-10-25 7:54 ` Heinrich Schuchardt
2021-10-25 8:00 ` Heinrich Schuchardt
2021-10-25 15:18 ` Simon Glass
2021-10-25 15:44 ` Heinrich Schuchardt
2021-10-25 17:29 ` Simon Glass
2021-10-25 18:41 ` Heinrich Schuchardt
2021-10-25 19:03 ` Simon Glass
2021-10-25 19:37 ` Heinrich Schuchardt
2021-10-25 19:45 ` Heinrich Schuchardt
2021-10-25 19:46 ` Simon Glass
2021-11-13 9:05 ` Heinrich Schuchardt
2021-10-25 15:46 ` Tom Rini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211023140647.7661-1-heinrich.schuchardt@canonical.com \
--to=heinrich.schuchardt@canonical.com \
--cc=ilias.apalodimas@linaro.org \
--cc=patrick.delaunay@foss.st.com \
--cc=sjg@chromium.org \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.