1<html><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&#160;3.&#160;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 bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><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>&#160;</td><th width="60%" align="center">Chapter&#160;3.&#160;Writing your own kernel module</th><td width="20%" align="right">&#160;<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 name="using_uio_pdrv"></a>Using uio_pdrv for platform devices</h2></div></div></div><p>
2	In many cases, UIO drivers for platform devices can be handled in a
3	generic way. In the same place where you define your
4	<code class="varname">struct platform_device</code>, you simply also implement
5	your interrupt handler and fill your
6	<code class="varname">struct uio_info</code>. A pointer to this
7	<code class="varname">struct uio_info</code> is then used as
8	<code class="varname">platform_data</code> for your platform device.
9	</p><p>
10	You also need to set up an array of <code class="varname">struct resource</code>
11	containing addresses and sizes of your memory mappings. This
12	information is passed to the driver using the
13	<code class="varname">.resource</code> and <code class="varname">.num_resources</code>
14	elements of <code class="varname">struct platform_device</code>.
15	</p><p>
16	You now have to set the <code class="varname">.name</code> element of
17	<code class="varname">struct platform_device</code> to
18	<code class="varname">"uio_pdrv"</code> to use the generic UIO platform device
19	driver. This driver will fill the <code class="varname">mem[]</code> array
20	according to the resources given, and register the device.
21	</p><p>
22	The advantage of this approach is that you only have to edit a file
23	you need to edit anyway. You do not have to create an extra driver.
24	</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>&#160;</td><td width="20%" align="center"><a accesskey="u" href="custom_kernel_module.html">Up</a></td><td width="40%" align="right">&#160;<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&#160;</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">&#160;Using uio_pdrv_genirq for platform devices</td></tr></table></div></body></html>
25