Commit 56b146d3 authored by Tobias Klauser's avatar Tobias Klauser Committed by Linus Torvalds

[PATCH] Last DMA_xBIT_MASK cleanups

These are the last conversions of pci_set_dma_mask(),
pci_set_consistent_dma_mask() and pci_dma_supported() to use DMA_xBIT_MASK
constants from linux/dma-mapping.h
Signed-off-by: default avatarTobias Klauser <tklauser@nuerscht.ch>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 31cc48bf
...@@ -194,7 +194,7 @@ document for how to handle this case. ...@@ -194,7 +194,7 @@ document for how to handle this case.
Finally, if your device can only drive the low 24-bits of Finally, if your device can only drive the low 24-bits of
address during PCI bus mastering you might do something like: address during PCI bus mastering you might do something like:
if (pci_set_dma_mask(pdev, 0x00ffffff)) { if (pci_set_dma_mask(pdev, DMA_24BIT_MASK)) {
printk(KERN_WARNING printk(KERN_WARNING
"mydev: 24-bit DMA addressing not available.\n"); "mydev: 24-bit DMA addressing not available.\n");
goto ignore_this_device; goto ignore_this_device;
...@@ -212,7 +212,7 @@ functions (for example a sound card provides playback and record ...@@ -212,7 +212,7 @@ functions (for example a sound card provides playback and record
functions) and the various different functions have _different_ functions) and the various different functions have _different_
DMA addressing limitations, you may wish to probe each mask and DMA addressing limitations, you may wish to probe each mask and
only provide the functionality which the machine can handle. It only provide the functionality which the machine can handle. It
is important that the last call to pci_set_dma_mask() be for the is important that the last call to pci_set_dma_mask() be for the
most specific mask. most specific mask.
Here is pseudo-code showing how this might be done: Here is pseudo-code showing how this might be done:
......
...@@ -1123,8 +1123,8 @@ ...@@ -1123,8 +1123,8 @@
if ((err = pci_enable_device(pci)) < 0) if ((err = pci_enable_device(pci)) < 0)
return err; return err;
/* check PCI availability (28bit DMA) */ /* check PCI availability (28bit DMA) */
if (pci_set_dma_mask(pci, 0x0fffffff) < 0 || if (pci_set_dma_mask(pci, DMA_28BIT_MASK) < 0 ||
pci_set_consistent_dma_mask(pci, 0x0fffffff) < 0) { pci_set_consistent_dma_mask(pci, DMA_28BIT_MASK) < 0) {
printk(KERN_ERR "error to set 28bit mask DMA\n"); printk(KERN_ERR "error to set 28bit mask DMA\n");
pci_disable_device(pci); pci_disable_device(pci);
return -ENXIO; return -ENXIO;
...@@ -1216,7 +1216,7 @@ ...@@ -1216,7 +1216,7 @@
The allocation of PCI resources is done in the The allocation of PCI resources is done in the
<function>probe()</function> function, and usually an extra <function>probe()</function> function, and usually an extra
<function>xxx_create()</function> function is written for this <function>xxx_create()</function> function is written for this
purpose. purpose.
</para> </para>
<para> <para>
...@@ -1225,7 +1225,7 @@ ...@@ -1225,7 +1225,7 @@
allocating resources. Also, you need to set the proper PCI DMA allocating resources. Also, you need to set the proper PCI DMA
mask to limit the accessed i/o range. In some cases, you might mask to limit the accessed i/o range. In some cases, you might
need to call <function>pci_set_master()</function> function, need to call <function>pci_set_master()</function> function,
too. too.
</para> </para>
<para> <para>
...@@ -1236,8 +1236,8 @@ ...@@ -1236,8 +1236,8 @@
<![CDATA[ <![CDATA[
if ((err = pci_enable_device(pci)) < 0) if ((err = pci_enable_device(pci)) < 0)
return err; return err;
if (pci_set_dma_mask(pci, 0x0fffffff) < 0 || if (pci_set_dma_mask(pci, DMA_28BIT_MASK) < 0 ||
pci_set_consistent_dma_mask(pci, 0x0fffffff) < 0) { pci_set_consistent_dma_mask(pci, DMA_28BIT_MASK) < 0) {
printk(KERN_ERR "error to set 28bit mask DMA\n"); printk(KERN_ERR "error to set 28bit mask DMA\n");
pci_disable_device(pci); pci_disable_device(pci);
return -ENXIO; return -ENXIO;
...@@ -1256,13 +1256,13 @@ ...@@ -1256,13 +1256,13 @@
functions. Unlike ALSA ver.0.5.x., there are no helpers for functions. Unlike ALSA ver.0.5.x., there are no helpers for
that. And these resources must be released in the destructor that. And these resources must be released in the destructor
function (see below). Also, on ALSA 0.9.x, you don't need to function (see below). Also, on ALSA 0.9.x, you don't need to
allocate (pseudo-)DMA for PCI like ALSA 0.5.x. allocate (pseudo-)DMA for PCI like ALSA 0.5.x.
</para> </para>
<para> <para>
Now assume that this PCI device has an I/O port with 8 bytes Now assume that this PCI device has an I/O port with 8 bytes
and an interrupt. Then struct <structname>mychip</structname> will have the and an interrupt. Then struct <structname>mychip</structname> will have the
following fields: following fields:
<informalexample> <informalexample>
<programlisting> <programlisting>
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/mutex.h> #include <linux/mutex.h>
#include <linux/dma-mapping.h>
#include "saa7134-reg.h" #include "saa7134-reg.h"
#include "saa7134.h" #include "saa7134.h"
...@@ -870,7 +871,7 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev, ...@@ -870,7 +871,7 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev,
pci_name(pci_dev), dev->pci_rev, pci_dev->irq, pci_name(pci_dev), dev->pci_rev, pci_dev->irq,
dev->pci_lat,pci_resource_start(pci_dev,0)); dev->pci_lat,pci_resource_start(pci_dev,0));
pci_set_master(pci_dev); pci_set_master(pci_dev);
if (!pci_dma_supported(pci_dev,0xffffffff)) { if (!pci_dma_supported(pci_dev, DMA_32BIT_MASK)) {
printk("%s: Oops: no 32bit PCI DMA ???\n",dev->name); printk("%s: Oops: no 32bit PCI DMA ???\n",dev->name);
err = -EIO; err = -EIO;
goto fail1; goto fail1;
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/dma-mapping.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <linux/delay.h> #include <linux/delay.h>
...@@ -619,9 +620,9 @@ static int ioc3_probe(struct pci_dev *pdev, const struct pci_device_id *pci_id) ...@@ -619,9 +620,9 @@ static int ioc3_probe(struct pci_dev *pdev, const struct pci_device_id *pci_id)
pci_set_master(pdev); pci_set_master(pdev);
#ifdef USE_64BIT_DMA #ifdef USE_64BIT_DMA
ret = pci_set_dma_mask(pdev, 0xffffffffffffffffULL); ret = pci_set_dma_mask(pdev, DMA_64BIT_MASK);
if (!ret) { if (!ret) {
ret = pci_set_consistent_dma_mask(pdev, 0xffffffffffffffffULL); ret = pci_set_consistent_dma_mask(pdev, DMA_64BIT_MASK);
if (ret < 0) { if (ret < 0) {
printk(KERN_WARNING "%s: Unable to obtain 64 bit DMA " printk(KERN_WARNING "%s: Unable to obtain 64 bit DMA "
"for consistent allocations\n", "for consistent allocations\n",
......
...@@ -21,7 +21,7 @@ enum dma_data_direction { ...@@ -21,7 +21,7 @@ enum dma_data_direction {
#define DMA_30BIT_MASK 0x000000003fffffffULL #define DMA_30BIT_MASK 0x000000003fffffffULL
#define DMA_29BIT_MASK 0x000000001fffffffULL #define DMA_29BIT_MASK 0x000000001fffffffULL
#define DMA_28BIT_MASK 0x000000000fffffffULL #define DMA_28BIT_MASK 0x000000000fffffffULL
#define DMA_24BIT_MASK 0x0000000000ffffffULL #define DMA_24BIT_MASK 0x0000000000ffffffULL
#include <asm/dma-mapping.h> #include <asm/dma-mapping.h>
......
...@@ -94,6 +94,7 @@ ...@@ -94,6 +94,7 @@
#include <linux/init.h> #include <linux/init.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/proc_fs.h> #include <linux/proc_fs.h>
#include <linux/dma-mapping.h>
#include "hwaccess.h" #include "hwaccess.h"
#include "8010.h" #include "8010.h"
...@@ -119,7 +120,7 @@ ...@@ -119,7 +120,7 @@
/* the emu10k1 _seems_ to only supports 29 bit (512MiB) bit bus master */ /* the emu10k1 _seems_ to only supports 29 bit (512MiB) bit bus master */
#define EMU10K1_DMA_MASK 0x1fffffff /* DMA buffer mask for pci_alloc_consist */ #define EMU10K1_DMA_MASK DMA_29BIT_MASK /* DMA buffer mask for pci_alloc_consist */
#ifndef PCI_VENDOR_ID_CREATIVE #ifndef PCI_VENDOR_ID_CREATIVE
#define PCI_VENDOR_ID_CREATIVE 0x1102 #define PCI_VENDOR_ID_CREATIVE 0x1102
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include <linux/init.h> #include <linux/init.h>
#include <linux/moduleparam.h> #include <linux/moduleparam.h>
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/dma-mapping.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/slab.h> #include <linux/slab.h>
...@@ -691,8 +692,8 @@ static int __devinit snd_als300_create(snd_card_t *card, ...@@ -691,8 +692,8 @@ static int __devinit snd_als300_create(snd_card_t *card,
if ((err = pci_enable_device(pci)) < 0) if ((err = pci_enable_device(pci)) < 0)
return err; return err;
if (pci_set_dma_mask(pci, 0x0fffffff) < 0 || if (pci_set_dma_mask(pci, DMA_28BIT_MASK) < 0 ||
pci_set_consistent_dma_mask(pci, 0x0fffffff) < 0) { pci_set_consistent_dma_mask(pci, DMA_28BIT_MASK) < 0) {
printk(KERN_ERR "error setting 28bit DMA mask\n"); printk(KERN_ERR "error setting 28bit DMA mask\n");
pci_disable_device(pci); pci_disable_device(pci);
return -ENXIO; return -ENXIO;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment