kernel device block get by path fail on builtin

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

kernel device block get by path fail on builtin

282 Views
ciaran_lequeux
Contributor I

have a module who open mmc blockdevice, inspired of block2mtd.c driver on linux 5.1. It works successfully when my driver is as module and "modprobe" after kernel started. But it fail when my driver is as built-in. The mmc is correctly mounted with the good name. And traces of mmc mount appears before the timeout off my driver.

Did you have any idea why he did'nt see the emmc ? I have see there are different namespace ?

A part of my code :

int i;
int timeout = 10;
const fmode_t mode = FMODE_READ | FMODE_WRITE;

struct block_device *bdev;
bdev = blkdev_get_by_path("/dev/mmcblk0", mode, NULL);


for (i = 0; IS_ERR(bdev) && i <= timeout; i++) {
    dev_t devt;

printk("Try...\n");
    if (i)
        msleep(1000);
    wait_for_device_probe();

    devt = name_to_dev_t("/dev/mmcblk0");
    if (!devt)
        continue;
    bdev = blkdev_get_by_dev(devt, mode, NULL);
}

if (IS_ERR(bdev)) {
    pr_err("error: cannot open device %s\n", "/dev/mmcblk0");
    return -1;
}
else
{
   printk("Open MMC OK !\n");

Sorry i can't post full boot log (it's for my work).

If CONFIG_MODULES=y and CONFIG_MYDRIVER=m

..
..
mmc1: new high speed SDHC card at address b368

mmcblk0: mmc1:b368 3.73 GiB
..
modprobe mydriver
..
Open MMC OK !
..
..

If # CONFIG_MODULES is not set and CONFIG_MYDRIVER=y

Try...
Try...
Try...
Try...
mmc1: new high speed SDHC card at address b368
Try...
mmcblk0: mmc1:b368 3.73 GiB
Try...
Try...
Try...
Try...
Try...
Try...
Try...
Try...
error: cannot open device /dev/mmcblk0

 

0 Kudos
Reply
0 Replies