diff options
author | Bjorn Helgaas <bjorn.helgaas@hp.com> | 2008-04-28 18:34:16 -0400 |
---|---|---|
committer | Len Brown <len.brown@intel.com> | 2008-04-29 03:22:23 -0400 |
commit | 13575e81bb38fc797a5513ad1bd8e6fda17439b8 (patch) | |
tree | e1ac0d95a4225b9d26f736545664a70bc8770b59 /include | |
parent | 53052feb6ddd05cb2b5c6e89fb489bf83bbb6803 (diff) |
PNP: convert resource accessors to use pnp_get_resource(), not pnp_resource_table
This removes more direct references to pnp_resource_table.
Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/pnp.h | 145 |
1 files changed, 105 insertions, 40 deletions
diff --git a/include/linux/pnp.h b/include/linux/pnp.h index b5fd03854fa4..1640562f3ebc 100644 --- a/include/linux/pnp.h +++ b/include/linux/pnp.h | |||
@@ -27,46 +27,111 @@ struct pnp_dev; | |||
27 | */ | 27 | */ |
28 | struct resource *pnp_get_resource(struct pnp_dev *, unsigned int, unsigned int); | 28 | struct resource *pnp_get_resource(struct pnp_dev *, unsigned int, unsigned int); |
29 | 29 | ||
30 | /* Use these instead of directly reading pnp_dev to get resource information */ | 30 | static inline int pnp_resource_valid(struct resource *res) |
31 | #define pnp_port_start(dev,bar) ((dev)->res.port_resource[(bar)].start) | 31 | { |
32 | #define pnp_port_end(dev,bar) ((dev)->res.port_resource[(bar)].end) | 32 | if (res && !(res->flags & IORESOURCE_UNSET)) |
33 | #define pnp_port_flags(dev,bar) ((dev)->res.port_resource[(bar)].flags) | 33 | return 1; |
34 | #define pnp_port_valid(dev,bar) \ | 34 | return 0; |
35 | ((pnp_port_flags((dev),(bar)) & (IORESOURCE_IO | IORESOURCE_UNSET)) \ | 35 | } |
36 | == IORESOURCE_IO) | 36 | |
37 | #define pnp_port_len(dev,bar) \ | 37 | static inline resource_size_t pnp_resource_len(struct resource *res) |
38 | ((pnp_port_start((dev),(bar)) == 0 && \ | 38 | { |
39 | pnp_port_end((dev),(bar)) == \ | 39 | if (res->start == 0 && res->end == 0) |
40 | pnp_port_start((dev),(bar))) ? 0 : \ | 40 | return 0; |
41 | \ | 41 | return res->end - res->start + 1; |
42 | (pnp_port_end((dev),(bar)) - \ | 42 | } |
43 | pnp_port_start((dev),(bar)) + 1)) | 43 | |
44 | 44 | ||
45 | #define pnp_mem_start(dev,bar) ((dev)->res.mem_resource[(bar)].start) | 45 | static inline resource_size_t pnp_port_start(struct pnp_dev *dev, |
46 | #define pnp_mem_end(dev,bar) ((dev)->res.mem_resource[(bar)].end) | 46 | unsigned int bar) |
47 | #define pnp_mem_flags(dev,bar) ((dev)->res.mem_resource[(bar)].flags) | 47 | { |
48 | #define pnp_mem_valid(dev,bar) \ | 48 | return pnp_get_resource(dev, IORESOURCE_IO, bar)->start; |
49 | ((pnp_mem_flags((dev),(bar)) & (IORESOURCE_MEM | IORESOURCE_UNSET)) \ | 49 | } |
50 | == IORESOURCE_MEM) | 50 | |
51 | #define pnp_mem_len(dev,bar) \ | 51 | static inline resource_size_t pnp_port_end(struct pnp_dev *dev, |
52 | ((pnp_mem_start((dev),(bar)) == 0 && \ | 52 | unsigned int bar) |
53 | pnp_mem_end((dev),(bar)) == \ | 53 | { |
54 | pnp_mem_start((dev),(bar))) ? 0 : \ | 54 | return pnp_get_resource(dev, IORESOURCE_IO, bar)->end; |
55 | \ | 55 | } |
56 | (pnp_mem_end((dev),(bar)) - \ | 56 | |
57 | pnp_mem_start((dev),(bar)) + 1)) | 57 | static inline unsigned long pnp_port_flags(struct pnp_dev *dev, |
58 | 58 | unsigned int bar) | |
59 | #define pnp_irq(dev,bar) ((dev)->res.irq_resource[(bar)].start) | 59 | { |
60 | #define pnp_irq_flags(dev,bar) ((dev)->res.irq_resource[(bar)].flags) | 60 | return pnp_get_resource(dev, IORESOURCE_IO, bar)->flags; |
61 | #define pnp_irq_valid(dev,bar) \ | 61 | } |
62 | ((pnp_irq_flags((dev),(bar)) & (IORESOURCE_IRQ | IORESOURCE_UNSET)) \ | 62 | |
63 | == IORESOURCE_IRQ) | 63 | static inline int pnp_port_valid(struct pnp_dev *dev, unsigned int bar) |
64 | 64 | { | |
65 | #define pnp_dma(dev,bar) ((dev)->res.dma_resource[(bar)].start) | 65 | return pnp_resource_valid(pnp_get_resource(dev, IORESOURCE_IO, bar)); |
66 | #define pnp_dma_flags(dev,bar) ((dev)->res.dma_resource[(bar)].flags) | 66 | } |
67 | #define pnp_dma_valid(dev,bar) \ | 67 | |
68 | ((pnp_dma_flags((dev),(bar)) & (IORESOURCE_DMA | IORESOURCE_UNSET)) \ | 68 | static inline resource_size_t pnp_port_len(struct pnp_dev *dev, |
69 | == IORESOURCE_DMA) | 69 | unsigned int bar) |
70 | { | ||
71 | return pnp_resource_len(pnp_get_resource(dev, IORESOURCE_IO, bar)); | ||
72 | } | ||
73 | |||
74 | |||
75 | static inline resource_size_t pnp_mem_start(struct pnp_dev *dev, | ||
76 | unsigned int bar) | ||
77 | { | ||
78 | return pnp_get_resource(dev, IORESOURCE_MEM, bar)->start; | ||
79 | } | ||
80 | |||
81 | static inline resource_size_t pnp_mem_end(struct pnp_dev *dev, | ||
82 | unsigned int bar) | ||
83 | { | ||
84 | return pnp_get_resource(dev, IORESOURCE_MEM, bar)->end; | ||
85 | } | ||
86 | |||
87 | static inline unsigned long pnp_mem_flags(struct pnp_dev *dev, unsigned int bar) | ||
88 | { | ||
89 | return pnp_get_resource(dev, IORESOURCE_MEM, bar)->flags; | ||
90 | } | ||
91 | |||
92 | static inline int pnp_mem_valid(struct pnp_dev *dev, unsigned int bar) | ||
93 | { | ||
94 | return pnp_resource_valid(pnp_get_resource(dev, IORESOURCE_MEM, bar)); | ||
95 | } | ||
96 | |||
97 | static inline resource_size_t pnp_mem_len(struct pnp_dev *dev, | ||
98 | unsigned int bar) | ||
99 | { | ||
100 | return pnp_resource_len(pnp_get_resource(dev, IORESOURCE_MEM, bar)); | ||
101 | } | ||
102 | |||
103 | |||
104 | static inline resource_size_t pnp_irq(struct pnp_dev *dev, unsigned int bar) | ||
105 | { | ||
106 | return pnp_get_resource(dev, IORESOURCE_IRQ, bar)->start; | ||
107 | } | ||
108 | |||
109 | static inline unsigned long pnp_irq_flags(struct pnp_dev *dev, unsigned int bar) | ||
110 | { | ||
111 | return pnp_get_resource(dev, IORESOURCE_IRQ, bar)->flags; | ||
112 | } | ||
113 | |||
114 | static inline int pnp_irq_valid(struct pnp_dev *dev, unsigned int bar) | ||
115 | { | ||
116 | return pnp_resource_valid(pnp_get_resource(dev, IORESOURCE_IRQ, bar)); | ||
117 | } | ||
118 | |||
119 | |||
120 | static inline resource_size_t pnp_dma(struct pnp_dev *dev, unsigned int bar) | ||
121 | { | ||
122 | return pnp_get_resource(dev, IORESOURCE_DMA, bar)->start; | ||
123 | } | ||
124 | |||
125 | static inline unsigned long pnp_dma_flags(struct pnp_dev *dev, unsigned int bar) | ||
126 | { | ||
127 | return pnp_get_resource(dev, IORESOURCE_DMA, bar)->flags; | ||
128 | } | ||
129 | |||
130 | static inline int pnp_dma_valid(struct pnp_dev *dev, unsigned int bar) | ||
131 | { | ||
132 | return pnp_resource_valid(pnp_get_resource(dev, IORESOURCE_DMA, bar)); | ||
133 | } | ||
134 | |||
70 | 135 | ||
71 | #define PNP_PORT_FLAG_16BITADDR (1<<0) | 136 | #define PNP_PORT_FLAG_16BITADDR (1<<0) |
72 | #define PNP_PORT_FLAG_FIXED (1<<1) | 137 | #define PNP_PORT_FLAG_FIXED (1<<1) |