1 // SPDX-License-Identifier: GPL-2.0+
4 * Niel Fourie, DENX Software Engineering, lusus@denx.de.
12 static int do_lsblk(struct cmd_tbl *cmdtp, int flag, int argc, char * const argv[])
14 struct driver *d = ll_entry_start(struct driver, driver);
15 const int n_ents = ll_entry_count(struct driver, driver);
19 struct blk_desc *desc;
22 ret = uclass_get(UCLASS_BLK, &uc);
24 puts("Could not get BLK uclass.\n");
25 return CMD_RET_FAILURE;
27 puts("Block Driver Devices\n");
28 puts("-----------------------------\n");
29 for (entry = d; entry < d + n_ents; entry++) {
30 if (entry->id != UCLASS_BLK)
33 printf("%-20.20s", entry->name);
34 uclass_foreach_dev(udev, uc) {
35 if (udev->driver != entry)
37 desc = dev_get_uclass_plat(udev);
38 printf("%c %s %u", i ? ',' : ':',
39 blk_get_uclass_name(desc->uclass_id),
48 return CMD_RET_SUCCESS;
51 U_BOOT_CMD(lsblk, 1, 0, do_lsblk, "list block drivers and devices",
52 "- display list of block device drivers and attached block devices"