1<html><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968"><title>Some Hafta's</title><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"><link rel="home" href="index.html" title="Writing an ALSA Driver"><link rel="up" href="pci-resource.html" title="Chapter 4. PCI Resource Management"><link rel="prev" href="pci-resource.html" title="Chapter 4. PCI Resource Management"><link rel="next" href="pci-resource-resource-allocation.html" title="Resource Allocation"></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">Some Hafta's</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="pci-resource.html">Prev</a> </td><th width="60%" align="center">Chapter 4. PCI Resource Management</th><td width="20%" align="right"> <a accesskey="n" href="pci-resource-resource-allocation.html">Next</a></td></tr></table><hr></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="pci-resource-some-haftas"></a>Some Hafta's</h2></div></div></div><p> 2 The allocation of PCI resources is done in the 3 <code class="function">probe()</code> function, and usually an extra 4 <code class="function">xxx_create()</code> function is written for this 5 purpose. 6 </p><p> 7 In the case of PCI devices, you first have to call 8 the <code class="function">pci_enable_device()</code> function before 9 allocating resources. Also, you need to set the proper PCI DMA 10 mask to limit the accessed I/O range. In some cases, you might 11 need to call <code class="function">pci_set_master()</code> function, 12 too. 13 </p><p> 14 Suppose the 28bit mask, and the code to be added would be like: 15 16 </p><div class="informalexample"><pre class="programlisting"> 17 18 err = pci_enable_device(pci); 19 if (err < 0) 20 return err; 21 if (pci_set_dma_mask(pci, DMA_BIT_MASK(28)) < 0 || 22 pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(28)) < 0) { 23 printk(KERN_ERR "error to set 28bit mask DMA\n"); 24 pci_disable_device(pci); 25 return -ENXIO; 26 } 27 28 29 </pre></div><p> 30 </p></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="pci-resource.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="pci-resource.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="pci-resource-resource-allocation.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter 4. PCI Resource Management </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Resource Allocation</td></tr></table></div></body></html> 31