[patch] [Bug 10397] DMA-mapping.txt code examples have undeclared variables

Previous thread: tee question [OT] by Marc Perkel on Sunday, April 6, 2008 - 12:10 am. (3 messages)

Next thread: [patch] checkpatch: relax spacing and line length by Jan Engelhardt on Sunday, April 6, 2008 - 12:54 am. (33 messages)
To: <linux-kernel@...>, <linux-pci@...>
Date: Sunday, April 6, 2008 - 12:34 am

From: Matti Linnanvuori <mattilinnanvuori@yahoo.com>

Fix undeclared variables.

Signed-off-by: Matti Linnanvuori <mattilinnanvuori@yahoo.com>

---

--- linux-2.6/Documentation/DMA-mapping.txt 2008-03-23 09:01:06.304511500 +0200
+++ linux/Documentation/DMA-mapping.txt 2008-04-06 06:56:11.821314500 +0300
@@ -315,9 +315,9 @@

dma_addr_t dma_handle;

- cpu_addr = pci_alloc_consistent(dev, size, &dma_handle);
+ cpu_addr = pci_alloc_consistent(pdev, size, &dma_handle);

-where dev is a struct pci_dev *. You should pass NULL for PCI like buses
+where pdev is a struct pci_dev *. You should pass NULL for PCI like buses
where devices don't have struct pci_dev (like ISA, EISA). This may be
called in interrupt context.

@@ -354,9 +354,9 @@

To unmap and free such a DMA region, you call:

- pci_free_consistent(dev, size, cpu_addr, dma_handle);
+ pci_free_consistent(pdev, size, cpu_addr, dma_handle);

-where dev, size are the same as in the above call and cpu_addr and
+where pdev, size are the same as in the above call and cpu_addr and
dma_handle are the values pci_alloc_consistent returned to you.
This function may not be called in interrupt context.

@@ -371,9 +371,9 @@

struct pci_pool *pool;

- pool = pci_pool_create(name, dev, size, align, alloc);
+ pool = pci_pool_create(name, pdev, size, align, alloc);

-The "name" is for diagnostics (like a kmem_cache name); dev and size
+The "name" is for diagnostics (like a kmem_cache name); pdev and size
are as above. The device's hardware alignment requirement for this
type of data is "align" (which is expressed in bytes, and must be a
power of two). If your device has no boundary crossing restrictions,
@@ -472,11 +472,11 @@
void *addr = buffer->ptr;
size_t size = buffer->len;

- dma_handle = pci_map_single(dev, addr, size, direction);
+ dma_handle = pci_map_single(pdev, addr, size, direction);

and to unmap it:

- pci_unmap_single(dev, dma_handle, size, direction);
...

To: Matti Linnanvuori <mattilinnanvuori@...>
Cc: <linux-kernel@...>, <linux-pci@...>
Date: Sunday, April 6, 2008 - 2:51 am

Sorry? This changelog entry doesn't make sense to me since this patch
is for documentation and not a compiler error.

If you prefer them declared as C code, please try it this way:

+ struct pci_dev dev*;
+ size_t size;
dma_addr_t dma_handle;

cpu_addr = pci_alloc_consistent(dev, size, &dma_handle);

and delete the verbage (plain text) that defines the parameters.

If you are confusing "dev" with "struct device *" and want to change
all the references to "pdev", please do the above *and* write something
like the following in the changelog:
To avoid confusion with struct device, rename ...

thanks!
--

Previous thread: tee question [OT] by Marc Perkel on Sunday, April 6, 2008 - 12:10 am. (3 messages)

Next thread: [patch] checkpatch: relax spacing and line length by Jan Engelhardt on Sunday, April 6, 2008 - 12:54 am. (33 messages)