Using uio_dmem_genirq for platform devices

In addition to statically allocated memory ranges, they may also be a desire to use dynamically allocated regions in a user space driver. In particular, being able to access memory made available through the dma-mapping API, may be particularly useful. The uio_dmem_genirq driver provides a way to accomplish this.

This driver is used in a similar manner to the "uio_pdrv_genirq" driver with respect to interrupt configuration and handling.

Set the .name element of struct platform_device to "uio_dmem_genirq" to use this driver.

When using this driver, fill in the .platform_data element of struct platform_device, which is of type struct uio_dmem_genirq_pdata and which contains the following elements:

The dynamic regions defined in the platform data will be appended to the mem[] array after the platform device resources, which implies that the total number of static and dynamic memory regions cannot exceed MAX_UIO_MAPS.

The dynamic memory regions will be allocated when the UIO device file, /dev/uioX is opened. Similar to static memory resources, the memory region information for dynamic regions is then visible via sysfs at /sys/class/uio/uioX/maps/mapY/*. The dynamic memory regions will be freed when the UIO device file is closed. When no processes are holding the device file open, the address returned to userspace is ~0.