diff options
Diffstat (limited to 'drivers/pnp/support.c')
-rw-r--r-- | drivers/pnp/support.c | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/drivers/pnp/support.c b/drivers/pnp/support.c index 0ad42db94884..bbf78ef4ba02 100644 --- a/drivers/pnp/support.c +++ b/drivers/pnp/support.c | |||
@@ -2,6 +2,8 @@ | |||
2 | * support.c - standard functions for the use of pnp protocol drivers | 2 | * support.c - standard functions for the use of pnp protocol drivers |
3 | * | 3 | * |
4 | * Copyright 2003 Adam Belay <ambx1@neo.rr.com> | 4 | * Copyright 2003 Adam Belay <ambx1@neo.rr.com> |
5 | * Copyright (C) 2008 Hewlett-Packard Development Company, L.P. | ||
6 | * Bjorn Helgaas <bjorn.helgaas@hp.com> | ||
5 | */ | 7 | */ |
6 | 8 | ||
7 | #include <linux/module.h> | 9 | #include <linux/module.h> |
@@ -117,3 +119,93 @@ void dbg_pnp_show_resources(struct pnp_dev *dev, char *desc) | |||
117 | } | 119 | } |
118 | #endif | 120 | #endif |
119 | } | 121 | } |
122 | |||
123 | char *pnp_option_priority_name(struct pnp_option *option) | ||
124 | { | ||
125 | switch (pnp_option_priority(option)) { | ||
126 | case PNP_RES_PRIORITY_PREFERRED: | ||
127 | return "preferred"; | ||
128 | case PNP_RES_PRIORITY_ACCEPTABLE: | ||
129 | return "acceptable"; | ||
130 | case PNP_RES_PRIORITY_FUNCTIONAL: | ||
131 | return "functional"; | ||
132 | } | ||
133 | return "invalid"; | ||
134 | } | ||
135 | |||
136 | void dbg_pnp_show_option(struct pnp_dev *dev, struct pnp_option *option) | ||
137 | { | ||
138 | #ifdef DEBUG | ||
139 | char buf[128]; | ||
140 | int len = 0, i; | ||
141 | struct pnp_port *port; | ||
142 | struct pnp_mem *mem; | ||
143 | struct pnp_irq *irq; | ||
144 | struct pnp_dma *dma; | ||
145 | |||
146 | if (pnp_option_is_dependent(option)) | ||
147 | len += snprintf(buf + len, sizeof(buf) - len, | ||
148 | " dependent set %d (%s) ", | ||
149 | pnp_option_set(option), | ||
150 | pnp_option_priority_name(option)); | ||
151 | else | ||
152 | len += snprintf(buf + len, sizeof(buf) - len, " independent "); | ||
153 | |||
154 | switch (option->type) { | ||
155 | case IORESOURCE_IO: | ||
156 | port = &option->u.port; | ||
157 | len += snprintf(buf + len, sizeof(buf) - len, "io min %#llx " | ||
158 | "max %#llx align %lld size %lld flags %#x", | ||
159 | (unsigned long long) port->min, | ||
160 | (unsigned long long) port->max, | ||
161 | (unsigned long long) port->align, | ||
162 | (unsigned long long) port->size, port->flags); | ||
163 | break; | ||
164 | case IORESOURCE_MEM: | ||
165 | mem = &option->u.mem; | ||
166 | len += snprintf(buf + len, sizeof(buf) - len, "mem min %#llx " | ||
167 | "max %#llx align %lld size %lld flags %#x", | ||
168 | (unsigned long long) mem->min, | ||
169 | (unsigned long long) mem->max, | ||
170 | (unsigned long long) mem->align, | ||
171 | (unsigned long long) mem->size, mem->flags); | ||
172 | break; | ||
173 | case IORESOURCE_IRQ: | ||
174 | irq = &option->u.irq; | ||
175 | len += snprintf(buf + len, sizeof(buf) - len, "irq"); | ||
176 | if (bitmap_empty(irq->map.bits, PNP_IRQ_NR)) | ||
177 | len += snprintf(buf + len, sizeof(buf) - len, | ||
178 | " <none>"); | ||
179 | else { | ||
180 | for (i = 0; i < PNP_IRQ_NR; i++) | ||
181 | if (test_bit(i, irq->map.bits)) | ||
182 | len += snprintf(buf + len, | ||
183 | sizeof(buf) - len, | ||
184 | " %d", i); | ||
185 | } | ||
186 | len += snprintf(buf + len, sizeof(buf) - len, " flags %#x", | ||
187 | irq->flags); | ||
188 | if (irq->flags & IORESOURCE_IRQ_OPTIONAL) | ||
189 | len += snprintf(buf + len, sizeof(buf) - len, | ||
190 | " (optional)"); | ||
191 | break; | ||
192 | case IORESOURCE_DMA: | ||
193 | dma = &option->u.dma; | ||
194 | len += snprintf(buf + len, sizeof(buf) - len, "dma"); | ||
195 | if (!dma->map) | ||
196 | len += snprintf(buf + len, sizeof(buf) - len, | ||
197 | " <none>"); | ||
198 | else { | ||
199 | for (i = 0; i < 8; i++) | ||
200 | if (dma->map & (1 << i)) | ||
201 | len += snprintf(buf + len, | ||
202 | sizeof(buf) - len, | ||
203 | " %d", i); | ||
204 | } | ||
205 | len += snprintf(buf + len, sizeof(buf) - len, " (bitmask %#x) " | ||
206 | "flags %#x", dma->map, dma->flags); | ||
207 | break; | ||
208 | } | ||
209 | dev_dbg(&dev->dev, "%s\n", buf); | ||
210 | #endif | ||
211 | } | ||