How to read /dev/mmcblk0p** data in kernel?

hello,i have generated two additional partition in nx emmc,and i write data file using dd command to my partition.
and then i want to read this file from my partition,such as /dev/mmcblk0p**,in kernel space,
is it right to do this? and how to do?
i use flip_open to open “/dev/mmcblk0p**” in my kernel driver code,but it open failed,why?

is any help?

hello lmmhu,

please examine the partition labels, for example, $ ls -al /dev/disk/by-partlabel
for your reference, there’s kernel APIs to use of_property_read_string() or of_get_named_gpio() to fetch property from kernel-dtb (device tree) layer.
thanks

i set my partition in "/Linux_for_Tegra/bootloader/t186ref/cfg/ ",partition name is mytestpartition,and filename is mytest.bin.such as follow:

<partition name="mytestpartition" type="data">
        <allocation_policy> sequential </allocation_policy>
        <filesystem_type> basic </filesystem_type>
        <size>4194304</size>
        <file_system_attribute> 0 </file_system_attribute>
        <allocation_attribute> 8 </allocation_attribute>
        <percent_reserved> 0 </percent_reserved>
        <filename>mytest.bin </filename>
    </partition>

so,i flash the emmc,and i found my partition in “/dev/disk/by-partition/mytestpartition”,and cat the partition,can read my file data of “mytest.bin”.
when ls -al /dev/disk/by-partlabel,i found mytestpartition is soft link to “/dev/mmcblk0p11”
my focus is :i want to read my partition file data to set camera parameter in my camera driver,so how to do it ? is any reference?

is it necessary to write a driver for my emmc partition?

hello lmmhu,

camera driver usually use device tree to store hardware specific settings.
for example,
you’ll see kernel function to parse device tree settings,
$L4T_Sources/r32.5/Linux_for_Tegra/source/public/kernel/nvidia/drivers/media/i2c/imx185.c

static struct camera_common_pdata *imx185_parse_dt(struct tegracam_device *tc_dev)
{
...
        gpio = of_get_named_gpio(np, "reset-gpios", 0);

there’s definition in DT as following,
$L4T_Sources/r32.5/Linux_for_Tegra/source/public/hardware/nvidia/platform/t18x/common/kernel-dts/t18x-common-platforms/tegra186-quill-camera-imx185-a00.dtsi

                                imx185_a@1a {
                                        reset-gpios = <&tegra_main_gpio CAM0_RST_L GPIO_ACTIVE_HIGH>;

in addition,
it’s the compatible property to match the driver and device tree.
for example,
you must have exactly same string definition for both sources. i.e. compatible = "nvidia,imx185";
thanks

yes,i knew the way,but it’s not meet my requirement.
i want to my camera driver compatible with different manufacturers based on a config file,more than modify device tree,and rebuild kernel,that’s too complicated.
in another word, how to preset userdata in the specific partition,and can read the userdata in kernel driver?

yes,i knew the way,but it’s not meet my requirement.
i want to my camera driver compatible with different manufacturers based on a config file,more than modify device tree,and rebuild kernel,that’s too complicated.
in another word, how to preset userdata in the specific partition,and can read the userdata in kernel driver?

hello lmmhu,

please refer to developer guide, Device Registration, it enable plugin-manger to do so.

sorry, I don’t have experience to read that besides device tree partition.