]> Git Repo - J-u-boot.git/blame - cmd/lsblk.c
rockchip: rk3399-gru: Include pinctrl and regulators in SPL
[J-u-boot.git] / cmd / lsblk.c
CommitLineData
e3697908
NF
1// SPDX-License-Identifier: GPL-2.0+
2/*
3 * (C) Copyright 2020
4 * Niel Fourie, DENX Software Engineering, [email protected].
5 */
6
b961d552
HS
7#include <blk.h>
8#include <command.h>
e3697908
NF
9#include <dm.h>
10
11static int do_lsblk(struct cmd_tbl *cmdtp, int flag, int argc, char * const argv[])
12{
13 struct driver *d = ll_entry_start(struct driver, driver);
14 const int n_ents = ll_entry_count(struct driver, driver);
15 struct driver *entry;
16 struct udevice *udev;
17 struct uclass *uc;
18 struct blk_desc *desc;
19 int ret, i;
20
21 ret = uclass_get(UCLASS_BLK, &uc);
22 if (ret) {
23 puts("Could not get BLK uclass.\n");
24 return CMD_RET_FAILURE;
25 }
26 puts("Block Driver Devices\n");
27 puts("-----------------------------\n");
28 for (entry = d; entry < d + n_ents; entry++) {
29 if (entry->id != UCLASS_BLK)
30 continue;
31 i = 0;
32 printf("%-20.20s", entry->name);
33 uclass_foreach_dev(udev, uc) {
34 if (udev->driver != entry)
35 continue;
caa4daa2 36 desc = dev_get_uclass_plat(udev);
e3697908 37 printf("%c %s %u", i ? ',' : ':',
8149b150 38 blk_get_uclass_name(desc->uclass_id),
e3697908
NF
39 desc->devnum);
40 i++;
41 }
42 if (!i)
43 puts(": <none>");
44 puts("\n");
45 }
46
47 return CMD_RET_SUCCESS;
48}
49
50U_BOOT_CMD(lsblk, 1, 0, do_lsblk, "list block drivers and devices",
51 "- display list of block device drivers and attached block devices"
52);
This page took 0.127724 seconds and 4 git commands to generate.