How can I list MMC partitions in a Linux driver?

ε祈祈猫儿з 提交于 2020-12-15 06:37:05

问题


I'm trying to read the U-Boot environment that is stored on eMMC, but I can't figure out how I can list the disks. The driver I'm creating is separated of the mmc device driver (/dev/mmcblk0p1).

I already found out that the partitions of mmcblk0 are struct mmc_part entries in struct mmc_card. Basically I'm searching for the mmc variant of __mtd_next_device.


EDIT 1:
I found out that I can get a block_device struct through bdget, but gendisk points to NULL.

struct block_device *my_bdevice;
struct gendisk *my_gdisk;
my_bdevice = bdget(179);
my_gdisk = part_to_disk(my_bdevice->bd_part);
if (!my_gdisk) goto end; // Goes to end..

回答1:


In my code above, my_bdevice = bdget(179); is wrong:

dev_t devt = blk_lookup_devt("mmcblk0", 0);
my_bdevice = bdget(devt);


来源:https://stackoverflow.com/questions/64877659/how-can-i-list-mmc-partitions-in-a-linux-driver

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!