diff options
author | Paul Mundt <lethal@linux-sh.org> | 2012-01-11 23:11:43 -0500 |
---|---|---|
committer | Paul Mundt <lethal@linux-sh.org> | 2012-01-11 23:11:43 -0500 |
commit | b1bdd255661369cb6eb90b6e181169b5e6d0f9b6 (patch) | |
tree | 17d15f3a6dc5bdd6205070dbef0e339421b13d25 /lib | |
parent | 9d14070f656addddce3d63fd483de46930b51850 (diff) | |
parent | c1537b4863da620f12f5b42ece61bf65314148ed (diff) |
Merge branch 'sh/nommu' into sh-latest
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Kconfig | 7 | ||||
-rw-r--r-- | lib/Makefile | 1 | ||||
-rw-r--r-- | lib/btree.c | 1 | ||||
-rw-r--r-- | lib/crc32.c | 21 | ||||
-rw-r--r-- | lib/iomap.c | 38 | ||||
-rw-r--r-- | lib/pci_iomap.c | 48 | ||||
-rw-r--r-- | lib/swiotlb.c | 5 |
7 files changed, 73 insertions, 48 deletions
diff --git a/lib/Kconfig b/lib/Kconfig index f34be6417d71..7f6b8bca8c25 100644 --- a/lib/Kconfig +++ b/lib/Kconfig | |||
@@ -19,6 +19,13 @@ config RATIONAL | |||
19 | config GENERIC_FIND_FIRST_BIT | 19 | config GENERIC_FIND_FIRST_BIT |
20 | bool | 20 | bool |
21 | 21 | ||
22 | config GENERIC_PCI_IOMAP | ||
23 | bool | ||
24 | |||
25 | config GENERIC_IOMAP | ||
26 | bool | ||
27 | select GENERIC_PCI_IOMAP | ||
28 | |||
22 | config CRC_CCITT | 29 | config CRC_CCITT |
23 | tristate "CRC-CCITT functions" | 30 | tristate "CRC-CCITT functions" |
24 | help | 31 | help |
diff --git a/lib/Makefile b/lib/Makefile index c0ffaaff6534..884ed376164d 100644 --- a/lib/Makefile +++ b/lib/Makefile | |||
@@ -33,6 +33,7 @@ endif | |||
33 | 33 | ||
34 | lib-$(CONFIG_HOTPLUG) += kobject_uevent.o | 34 | lib-$(CONFIG_HOTPLUG) += kobject_uevent.o |
35 | obj-$(CONFIG_GENERIC_IOMAP) += iomap.o | 35 | obj-$(CONFIG_GENERIC_IOMAP) += iomap.o |
36 | obj-$(CONFIG_GENERIC_PCI_IOMAP) += pci_iomap.o | ||
36 | obj-$(CONFIG_HAS_IOMEM) += iomap_copy.o devres.o | 37 | obj-$(CONFIG_HAS_IOMEM) += iomap_copy.o devres.o |
37 | obj-$(CONFIG_CHECK_SIGNATURE) += check_signature.o | 38 | obj-$(CONFIG_CHECK_SIGNATURE) += check_signature.o |
38 | obj-$(CONFIG_DEBUG_LOCKING_API_SELFTESTS) += locking-selftest.o | 39 | obj-$(CONFIG_DEBUG_LOCKING_API_SELFTESTS) += locking-selftest.o |
diff --git a/lib/btree.c b/lib/btree.c index 2a34392bcecc..e5ec1e9c1aa5 100644 --- a/lib/btree.c +++ b/lib/btree.c | |||
@@ -357,6 +357,7 @@ miss: | |||
357 | } | 357 | } |
358 | return NULL; | 358 | return NULL; |
359 | } | 359 | } |
360 | EXPORT_SYMBOL_GPL(btree_get_prev); | ||
360 | 361 | ||
361 | static int getpos(struct btree_geo *geo, unsigned long *node, | 362 | static int getpos(struct btree_geo *geo, unsigned long *node, |
362 | unsigned long *key) | 363 | unsigned long *key) |
diff --git a/lib/crc32.c b/lib/crc32.c index a6e633a48cea..4b35d2b4437c 100644 --- a/lib/crc32.c +++ b/lib/crc32.c | |||
@@ -51,20 +51,21 @@ static inline u32 | |||
51 | crc32_body(u32 crc, unsigned char const *buf, size_t len, const u32 (*tab)[256]) | 51 | crc32_body(u32 crc, unsigned char const *buf, size_t len, const u32 (*tab)[256]) |
52 | { | 52 | { |
53 | # ifdef __LITTLE_ENDIAN | 53 | # ifdef __LITTLE_ENDIAN |
54 | # define DO_CRC(x) crc = tab[0][(crc ^ (x)) & 255] ^ (crc >> 8) | 54 | # define DO_CRC(x) crc = t0[(crc ^ (x)) & 255] ^ (crc >> 8) |
55 | # define DO_CRC4 crc = tab[3][(crc) & 255] ^ \ | 55 | # define DO_CRC4 crc = t3[(crc) & 255] ^ \ |
56 | tab[2][(crc >> 8) & 255] ^ \ | 56 | t2[(crc >> 8) & 255] ^ \ |
57 | tab[1][(crc >> 16) & 255] ^ \ | 57 | t1[(crc >> 16) & 255] ^ \ |
58 | tab[0][(crc >> 24) & 255] | 58 | t0[(crc >> 24) & 255] |
59 | # else | 59 | # else |
60 | # define DO_CRC(x) crc = tab[0][((crc >> 24) ^ (x)) & 255] ^ (crc << 8) | 60 | # define DO_CRC(x) crc = t0[((crc >> 24) ^ (x)) & 255] ^ (crc << 8) |
61 | # define DO_CRC4 crc = tab[0][(crc) & 255] ^ \ | 61 | # define DO_CRC4 crc = t0[(crc) & 255] ^ \ |
62 | tab[1][(crc >> 8) & 255] ^ \ | 62 | t1[(crc >> 8) & 255] ^ \ |
63 | tab[2][(crc >> 16) & 255] ^ \ | 63 | t2[(crc >> 16) & 255] ^ \ |
64 | tab[3][(crc >> 24) & 255] | 64 | t3[(crc >> 24) & 255] |
65 | # endif | 65 | # endif |
66 | const u32 *b; | 66 | const u32 *b; |
67 | size_t rem_len; | 67 | size_t rem_len; |
68 | const u32 *t0=tab[0], *t1=tab[1], *t2=tab[2], *t3=tab[3]; | ||
68 | 69 | ||
69 | /* Align it */ | 70 | /* Align it */ |
70 | if (unlikely((long)buf & 3 && len)) { | 71 | if (unlikely((long)buf & 3 && len)) { |
diff --git a/lib/iomap.c b/lib/iomap.c index 5dbcb4b2d864..ada922a808e6 100644 --- a/lib/iomap.c +++ b/lib/iomap.c | |||
@@ -242,45 +242,11 @@ EXPORT_SYMBOL(ioport_unmap); | |||
242 | #endif /* CONFIG_HAS_IOPORT */ | 242 | #endif /* CONFIG_HAS_IOPORT */ |
243 | 243 | ||
244 | #ifdef CONFIG_PCI | 244 | #ifdef CONFIG_PCI |
245 | /** | 245 | /* Hide the details if this is a MMIO or PIO address space and just do what |
246 | * pci_iomap - create a virtual mapping cookie for a PCI BAR | 246 | * you expect in the correct way. */ |
247 | * @dev: PCI device that owns the BAR | ||
248 | * @bar: BAR number | ||
249 | * @maxlen: length of the memory to map | ||
250 | * | ||
251 | * Using this function you will get a __iomem address to your device BAR. | ||
252 | * You can access it using ioread*() and iowrite*(). These functions hide | ||
253 | * the details if this is a MMIO or PIO address space and will just do what | ||
254 | * you expect from them in the correct way. | ||
255 | * | ||
256 | * @maxlen specifies the maximum length to map. If you want to get access to | ||
257 | * the complete BAR without checking for its length first, pass %0 here. | ||
258 | * */ | ||
259 | void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen) | ||
260 | { | ||
261 | resource_size_t start = pci_resource_start(dev, bar); | ||
262 | resource_size_t len = pci_resource_len(dev, bar); | ||
263 | unsigned long flags = pci_resource_flags(dev, bar); | ||
264 | |||
265 | if (!len || !start) | ||
266 | return NULL; | ||
267 | if (maxlen && len > maxlen) | ||
268 | len = maxlen; | ||
269 | if (flags & IORESOURCE_IO) | ||
270 | return ioport_map(start, len); | ||
271 | if (flags & IORESOURCE_MEM) { | ||
272 | if (flags & IORESOURCE_CACHEABLE) | ||
273 | return ioremap(start, len); | ||
274 | return ioremap_nocache(start, len); | ||
275 | } | ||
276 | /* What? */ | ||
277 | return NULL; | ||
278 | } | ||
279 | |||
280 | void pci_iounmap(struct pci_dev *dev, void __iomem * addr) | 247 | void pci_iounmap(struct pci_dev *dev, void __iomem * addr) |
281 | { | 248 | { |
282 | IO_COND(addr, /* nothing */, iounmap(addr)); | 249 | IO_COND(addr, /* nothing */, iounmap(addr)); |
283 | } | 250 | } |
284 | EXPORT_SYMBOL(pci_iomap); | ||
285 | EXPORT_SYMBOL(pci_iounmap); | 251 | EXPORT_SYMBOL(pci_iounmap); |
286 | #endif /* CONFIG_PCI */ | 252 | #endif /* CONFIG_PCI */ |
diff --git a/lib/pci_iomap.c b/lib/pci_iomap.c new file mode 100644 index 000000000000..4b0fdc22e688 --- /dev/null +++ b/lib/pci_iomap.c | |||
@@ -0,0 +1,48 @@ | |||
1 | /* | ||
2 | * Implement the default iomap interfaces | ||
3 | * | ||
4 | * (C) Copyright 2004 Linus Torvalds | ||
5 | */ | ||
6 | #include <linux/pci.h> | ||
7 | #include <linux/io.h> | ||
8 | |||
9 | #include <linux/export.h> | ||
10 | |||
11 | #ifdef CONFIG_PCI | ||
12 | /** | ||
13 | * pci_iomap - create a virtual mapping cookie for a PCI BAR | ||
14 | * @dev: PCI device that owns the BAR | ||
15 | * @bar: BAR number | ||
16 | * @maxlen: length of the memory to map | ||
17 | * | ||
18 | * Using this function you will get a __iomem address to your device BAR. | ||
19 | * You can access it using ioread*() and iowrite*(). These functions hide | ||
20 | * the details if this is a MMIO or PIO address space and will just do what | ||
21 | * you expect from them in the correct way. | ||
22 | * | ||
23 | * @maxlen specifies the maximum length to map. If you want to get access to | ||
24 | * the complete BAR without checking for its length first, pass %0 here. | ||
25 | * */ | ||
26 | void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen) | ||
27 | { | ||
28 | resource_size_t start = pci_resource_start(dev, bar); | ||
29 | resource_size_t len = pci_resource_len(dev, bar); | ||
30 | unsigned long flags = pci_resource_flags(dev, bar); | ||
31 | |||
32 | if (!len || !start) | ||
33 | return NULL; | ||
34 | if (maxlen && len > maxlen) | ||
35 | len = maxlen; | ||
36 | if (flags & IORESOURCE_IO) | ||
37 | return ioport_map(start, len); | ||
38 | if (flags & IORESOURCE_MEM) { | ||
39 | if (flags & IORESOURCE_CACHEABLE) | ||
40 | return ioremap(start, len); | ||
41 | return ioremap_nocache(start, len); | ||
42 | } | ||
43 | /* What? */ | ||
44 | return NULL; | ||
45 | } | ||
46 | |||
47 | EXPORT_SYMBOL(pci_iomap); | ||
48 | #endif /* CONFIG_PCI */ | ||
diff --git a/lib/swiotlb.c b/lib/swiotlb.c index 99093b396145..058935ef3975 100644 --- a/lib/swiotlb.c +++ b/lib/swiotlb.c | |||
@@ -110,11 +110,11 @@ setup_io_tlb_npages(char *str) | |||
110 | __setup("swiotlb=", setup_io_tlb_npages); | 110 | __setup("swiotlb=", setup_io_tlb_npages); |
111 | /* make io_tlb_overflow tunable too? */ | 111 | /* make io_tlb_overflow tunable too? */ |
112 | 112 | ||
113 | unsigned long swioltb_nr_tbl(void) | 113 | unsigned long swiotlb_nr_tbl(void) |
114 | { | 114 | { |
115 | return io_tlb_nslabs; | 115 | return io_tlb_nslabs; |
116 | } | 116 | } |
117 | 117 | EXPORT_SYMBOL_GPL(swiotlb_nr_tbl); | |
118 | /* Note that this doesn't work with highmem page */ | 118 | /* Note that this doesn't work with highmem page */ |
119 | static dma_addr_t swiotlb_virt_to_bus(struct device *hwdev, | 119 | static dma_addr_t swiotlb_virt_to_bus(struct device *hwdev, |
120 | volatile void *address) | 120 | volatile void *address) |
@@ -321,6 +321,7 @@ void __init swiotlb_free(void) | |||
321 | free_bootmem_late(__pa(io_tlb_start), | 321 | free_bootmem_late(__pa(io_tlb_start), |
322 | PAGE_ALIGN(io_tlb_nslabs << IO_TLB_SHIFT)); | 322 | PAGE_ALIGN(io_tlb_nslabs << IO_TLB_SHIFT)); |
323 | } | 323 | } |
324 | io_tlb_nslabs = 0; | ||
324 | } | 325 | } |
325 | 326 | ||
326 | static int is_swiotlb_buffer(phys_addr_t paddr) | 327 | static int is_swiotlb_buffer(phys_addr_t paddr) |