<?xml version="1.0" encoding="ANSI_X3.4-1968" standalone="no"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968" /><title>Using uio_pdrv for platform devices</title><meta name="generator" content="DocBook XSL Stylesheets V1.78.1" /><link rel="home" href="index.html" title="The Userspace I/O HOWTO" /><link rel="up" href="custom_kernel_module.html" title="Chapter 3. Writing your own kernel module" /><link rel="prev" href="adding_irq_handler.html" title="Adding an interrupt handler" /><link rel="next" href="using_uio_pdrv_genirq.html" title="Using uio_pdrv_genirq for platform devices" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Using uio_pdrv for platform devices</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="adding_irq_handler.html">Prev</a> </td><th width="60%" align="center">Chapter 3. Writing your own kernel module</th><td width="20%" align="right"> <a accesskey="n" href="using_uio_pdrv_genirq.html">Next</a></td></tr></table><hr /></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="using_uio_pdrv"></a>Using uio_pdrv for platform devices</h2></div></div></div><p> In many cases, UIO drivers for platform devices can be handled in a generic way. In the same place where you define your <code class="varname">struct platform_device</code>, you simply also implement your interrupt handler and fill your <code class="varname">struct uio_info</code>. A pointer to this <code class="varname">struct uio_info</code> is then used as <code class="varname">platform_data</code> for your platform device. </p><p> You also need to set up an array of <code class="varname">struct resource</code> containing addresses and sizes of your memory mappings. This information is passed to the driver using the <code class="varname">.resource</code> and <code class="varname">.num_resources</code> elements of <code class="varname">struct platform_device</code>. </p><p> You now have to set the <code class="varname">.name</code> element of <code class="varname">struct platform_device</code> to <code class="varname">"uio_pdrv"</code> to use the generic UIO platform device driver. This driver will fill the <code class="varname">mem[]</code> array according to the resources given, and register the device. </p><p> The advantage of this approach is that you only have to edit a file you need to edit anyway. You do not have to create an extra driver. </p></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="adding_irq_handler.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="custom_kernel_module.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="using_uio_pdrv_genirq.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Adding an interrupt handler </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Using uio_pdrv_genirq for platform devices</td></tr></table></div></body></html>