How does request io memory region works

m silverstri michael.j.silverstri at gmail.com
Wed Jan 29 02:47:23 EST 2014


I am trying to understand the following driver code. In the probe
function, i think it tries to map memory region for the driver so that
the driver can access the hardware register. Please correct me if I am
wrong. My question is where does it specifies the address of the
registers for the driver to map from? And how much it should map?

https://android.googlesource.com/kernel/exynos/+/a6a1de6334417e0800440cdf971270df6f90b2fa/drivers/media/video/exynos/jpeg/jpeg_dev.c

/* memory region */
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res) {
        jpeg_err("failed to get jpeg memory region resource\n");
        ret = -ENOENT;
        goto err_res;
}

res = request_mem_region(res->start, resource_size(res),
                        pdev->name);
if (!res) {
        jpeg_err("failed to request jpeg io memory region\n");
        ret = -ENOMEM;
        goto err_region;
}

/* ioremap */
dev->reg_base = ioremap(res->start, resource_size(res));
if (!dev->reg_base) {
        jpeg_err("failed to remap jpeg io region\n");
        ret = -ENOENT;
        goto err_map;
}



More information about the Kernelnewbies mailing list