diff options
Diffstat (limited to 'drivers/pnp/interface.c')
-rw-r--r-- | drivers/pnp/interface.c | 217 |
1 files changed, 123 insertions, 94 deletions
diff --git a/drivers/pnp/interface.c b/drivers/pnp/interface.c index ac9fcd499f3f..fe6684e13e82 100644 --- a/drivers/pnp/interface.c +++ b/drivers/pnp/interface.c | |||
@@ -3,7 +3,6 @@ | |||
3 | * | 3 | * |
4 | * Some code, especially possible resource dumping is based on isapnp_proc.c (c) Jaroslav Kysela <perex@suse.cz> | 4 | * Some code, especially possible resource dumping is based on isapnp_proc.c (c) Jaroslav Kysela <perex@suse.cz> |
5 | * Copyright 2002 Adam Belay <ambx1@neo.rr.com> | 5 | * Copyright 2002 Adam Belay <ambx1@neo.rr.com> |
6 | * | ||
7 | */ | 6 | */ |
8 | 7 | ||
9 | #include <linux/pnp.h> | 8 | #include <linux/pnp.h> |
@@ -29,7 +28,7 @@ struct pnp_info_buffer { | |||
29 | 28 | ||
30 | typedef struct pnp_info_buffer pnp_info_buffer_t; | 29 | typedef struct pnp_info_buffer pnp_info_buffer_t; |
31 | 30 | ||
32 | static int pnp_printf(pnp_info_buffer_t * buffer, char *fmt,...) | 31 | static int pnp_printf(pnp_info_buffer_t * buffer, char *fmt, ...) |
33 | { | 32 | { |
34 | va_list args; | 33 | va_list args; |
35 | int res; | 34 | int res; |
@@ -48,14 +47,18 @@ static int pnp_printf(pnp_info_buffer_t * buffer, char *fmt,...) | |||
48 | return res; | 47 | return res; |
49 | } | 48 | } |
50 | 49 | ||
51 | static void pnp_print_port(pnp_info_buffer_t *buffer, char *space, struct pnp_port *port) | 50 | static void pnp_print_port(pnp_info_buffer_t * buffer, char *space, |
51 | struct pnp_port *port) | ||
52 | { | 52 | { |
53 | pnp_printf(buffer, "%sport 0x%x-0x%x, align 0x%x, size 0x%x, %i-bit address decoding\n", | 53 | pnp_printf(buffer, |
54 | space, port->min, port->max, port->align ? (port->align-1) : 0, port->size, | 54 | "%sport 0x%x-0x%x, align 0x%x, size 0x%x, %i-bit address decoding\n", |
55 | port->flags & PNP_PORT_FLAG_16BITADDR ? 16 : 10); | 55 | space, port->min, port->max, |
56 | port->align ? (port->align - 1) : 0, port->size, | ||
57 | port->flags & PNP_PORT_FLAG_16BITADDR ? 16 : 10); | ||
56 | } | 58 | } |
57 | 59 | ||
58 | static void pnp_print_irq(pnp_info_buffer_t *buffer, char *space, struct pnp_irq *irq) | 60 | static void pnp_print_irq(pnp_info_buffer_t * buffer, char *space, |
61 | struct pnp_irq *irq) | ||
59 | { | 62 | { |
60 | int first = 1, i; | 63 | int first = 1, i; |
61 | 64 | ||
@@ -85,14 +88,15 @@ static void pnp_print_irq(pnp_info_buffer_t *buffer, char *space, struct pnp_irq | |||
85 | pnp_printf(buffer, "\n"); | 88 | pnp_printf(buffer, "\n"); |
86 | } | 89 | } |
87 | 90 | ||
88 | static void pnp_print_dma(pnp_info_buffer_t *buffer, char *space, struct pnp_dma *dma) | 91 | static void pnp_print_dma(pnp_info_buffer_t * buffer, char *space, |
92 | struct pnp_dma *dma) | ||
89 | { | 93 | { |
90 | int first = 1, i; | 94 | int first = 1, i; |
91 | char *s; | 95 | char *s; |
92 | 96 | ||
93 | pnp_printf(buffer, "%sdma ", space); | 97 | pnp_printf(buffer, "%sdma ", space); |
94 | for (i = 0; i < 8; i++) | 98 | for (i = 0; i < 8; i++) |
95 | if (dma->map & (1<<i)) { | 99 | if (dma->map & (1 << i)) { |
96 | if (!first) { | 100 | if (!first) { |
97 | pnp_printf(buffer, ","); | 101 | pnp_printf(buffer, ","); |
98 | } else { | 102 | } else { |
@@ -136,12 +140,13 @@ static void pnp_print_dma(pnp_info_buffer_t *buffer, char *space, struct pnp_dma | |||
136 | pnp_printf(buffer, " %s\n", s); | 140 | pnp_printf(buffer, " %s\n", s); |
137 | } | 141 | } |
138 | 142 | ||
139 | static void pnp_print_mem(pnp_info_buffer_t *buffer, char *space, struct pnp_mem *mem) | 143 | static void pnp_print_mem(pnp_info_buffer_t * buffer, char *space, |
144 | struct pnp_mem *mem) | ||
140 | { | 145 | { |
141 | char *s; | 146 | char *s; |
142 | 147 | ||
143 | pnp_printf(buffer, "%sMemory 0x%x-0x%x, align 0x%x, size 0x%x", | 148 | pnp_printf(buffer, "%sMemory 0x%x-0x%x, align 0x%x, size 0x%x", |
144 | space, mem->min, mem->max, mem->align, mem->size); | 149 | space, mem->min, mem->max, mem->align, mem->size); |
145 | if (mem->flags & IORESOURCE_MEM_WRITEABLE) | 150 | if (mem->flags & IORESOURCE_MEM_WRITEABLE) |
146 | pnp_printf(buffer, ", writeable"); | 151 | pnp_printf(buffer, ", writeable"); |
147 | if (mem->flags & IORESOURCE_MEM_CACHEABLE) | 152 | if (mem->flags & IORESOURCE_MEM_CACHEABLE) |
@@ -168,7 +173,7 @@ static void pnp_print_mem(pnp_info_buffer_t *buffer, char *space, struct pnp_mem | |||
168 | pnp_printf(buffer, ", %s\n", s); | 173 | pnp_printf(buffer, ", %s\n", s); |
169 | } | 174 | } |
170 | 175 | ||
171 | static void pnp_print_option(pnp_info_buffer_t *buffer, char *space, | 176 | static void pnp_print_option(pnp_info_buffer_t * buffer, char *space, |
172 | struct pnp_option *option, int dep) | 177 | struct pnp_option *option, int dep) |
173 | { | 178 | { |
174 | char *s; | 179 | char *s; |
@@ -179,19 +184,19 @@ static void pnp_print_option(pnp_info_buffer_t *buffer, char *space, | |||
179 | 184 | ||
180 | if (dep) { | 185 | if (dep) { |
181 | switch (option->priority) { | 186 | switch (option->priority) { |
182 | case PNP_RES_PRIORITY_PREFERRED: | 187 | case PNP_RES_PRIORITY_PREFERRED: |
183 | s = "preferred"; | 188 | s = "preferred"; |
184 | break; | 189 | break; |
185 | case PNP_RES_PRIORITY_ACCEPTABLE: | 190 | case PNP_RES_PRIORITY_ACCEPTABLE: |
186 | s = "acceptable"; | 191 | s = "acceptable"; |
187 | break; | 192 | break; |
188 | case PNP_RES_PRIORITY_FUNCTIONAL: | 193 | case PNP_RES_PRIORITY_FUNCTIONAL: |
189 | s = "functional"; | 194 | s = "functional"; |
190 | break; | 195 | break; |
191 | default: | 196 | default: |
192 | s = "invalid"; | 197 | s = "invalid"; |
193 | } | 198 | } |
194 | pnp_printf(buffer, "Dependent: %02i - Priority %s\n",dep, s); | 199 | pnp_printf(buffer, "Dependent: %02i - Priority %s\n", dep, s); |
195 | } | 200 | } |
196 | 201 | ||
197 | for (port = option->port; port; port = port->next) | 202 | for (port = option->port; port; port = port->next) |
@@ -204,16 +209,16 @@ static void pnp_print_option(pnp_info_buffer_t *buffer, char *space, | |||
204 | pnp_print_mem(buffer, space, mem); | 209 | pnp_print_mem(buffer, space, mem); |
205 | } | 210 | } |
206 | 211 | ||
207 | 212 | static ssize_t pnp_show_options(struct device *dmdev, | |
208 | static ssize_t pnp_show_options(struct device *dmdev, struct device_attribute *attr, char *buf) | 213 | struct device_attribute *attr, char *buf) |
209 | { | 214 | { |
210 | struct pnp_dev *dev = to_pnp_dev(dmdev); | 215 | struct pnp_dev *dev = to_pnp_dev(dmdev); |
211 | struct pnp_option * independent = dev->independent; | 216 | struct pnp_option *independent = dev->independent; |
212 | struct pnp_option * dependent = dev->dependent; | 217 | struct pnp_option *dependent = dev->dependent; |
213 | int ret, dep = 1; | 218 | int ret, dep = 1; |
214 | 219 | ||
215 | pnp_info_buffer_t *buffer = (pnp_info_buffer_t *) | 220 | pnp_info_buffer_t *buffer = (pnp_info_buffer_t *) |
216 | pnp_alloc(sizeof(pnp_info_buffer_t)); | 221 | pnp_alloc(sizeof(pnp_info_buffer_t)); |
217 | if (!buffer) | 222 | if (!buffer) |
218 | return -ENOMEM; | 223 | return -ENOMEM; |
219 | 224 | ||
@@ -223,7 +228,7 @@ static ssize_t pnp_show_options(struct device *dmdev, struct device_attribute *a | |||
223 | if (independent) | 228 | if (independent) |
224 | pnp_print_option(buffer, "", independent, 0); | 229 | pnp_print_option(buffer, "", independent, 0); |
225 | 230 | ||
226 | while (dependent){ | 231 | while (dependent) { |
227 | pnp_print_option(buffer, " ", dependent, dep); | 232 | pnp_print_option(buffer, " ", dependent, dep); |
228 | dependent = dependent->next; | 233 | dependent = dependent->next; |
229 | dep++; | 234 | dep++; |
@@ -233,10 +238,11 @@ static ssize_t pnp_show_options(struct device *dmdev, struct device_attribute *a | |||
233 | return ret; | 238 | return ret; |
234 | } | 239 | } |
235 | 240 | ||
236 | static DEVICE_ATTR(options,S_IRUGO,pnp_show_options,NULL); | 241 | static DEVICE_ATTR(options, S_IRUGO, pnp_show_options, NULL); |
237 | 242 | ||
238 | 243 | static ssize_t pnp_show_current_resources(struct device *dmdev, | |
239 | static ssize_t pnp_show_current_resources(struct device *dmdev, struct device_attribute *attr, char *buf) | 244 | struct device_attribute *attr, |
245 | char *buf) | ||
240 | { | 246 | { |
241 | struct pnp_dev *dev = to_pnp_dev(dmdev); | 247 | struct pnp_dev *dev = to_pnp_dev(dmdev); |
242 | int i, ret; | 248 | int i, ret; |
@@ -252,52 +258,56 @@ static ssize_t pnp_show_current_resources(struct device *dmdev, struct device_at | |||
252 | buffer->buffer = buf; | 258 | buffer->buffer = buf; |
253 | buffer->curr = buffer->buffer; | 259 | buffer->curr = buffer->buffer; |
254 | 260 | ||
255 | pnp_printf(buffer,"state = "); | 261 | pnp_printf(buffer, "state = "); |
256 | if (dev->active) | 262 | if (dev->active) |
257 | pnp_printf(buffer,"active\n"); | 263 | pnp_printf(buffer, "active\n"); |
258 | else | 264 | else |
259 | pnp_printf(buffer,"disabled\n"); | 265 | pnp_printf(buffer, "disabled\n"); |
260 | 266 | ||
261 | for (i = 0; i < PNP_MAX_PORT; i++) { | 267 | for (i = 0; i < PNP_MAX_PORT; i++) { |
262 | if (pnp_port_valid(dev, i)) { | 268 | if (pnp_port_valid(dev, i)) { |
263 | pnp_printf(buffer,"io"); | 269 | pnp_printf(buffer, "io"); |
264 | if (pnp_port_flags(dev, i) & IORESOURCE_DISABLED) | 270 | if (pnp_port_flags(dev, i) & IORESOURCE_DISABLED) |
265 | pnp_printf(buffer," disabled\n"); | 271 | pnp_printf(buffer, " disabled\n"); |
266 | else | 272 | else |
267 | pnp_printf(buffer," 0x%llx-0x%llx\n", | 273 | pnp_printf(buffer, " 0x%llx-0x%llx\n", |
268 | (unsigned long long)pnp_port_start(dev, i), | 274 | (unsigned long long) |
269 | (unsigned long long)pnp_port_end(dev, i)); | 275 | pnp_port_start(dev, i), |
276 | (unsigned long long)pnp_port_end(dev, | ||
277 | i)); | ||
270 | } | 278 | } |
271 | } | 279 | } |
272 | for (i = 0; i < PNP_MAX_MEM; i++) { | 280 | for (i = 0; i < PNP_MAX_MEM; i++) { |
273 | if (pnp_mem_valid(dev, i)) { | 281 | if (pnp_mem_valid(dev, i)) { |
274 | pnp_printf(buffer,"mem"); | 282 | pnp_printf(buffer, "mem"); |
275 | if (pnp_mem_flags(dev, i) & IORESOURCE_DISABLED) | 283 | if (pnp_mem_flags(dev, i) & IORESOURCE_DISABLED) |
276 | pnp_printf(buffer," disabled\n"); | 284 | pnp_printf(buffer, " disabled\n"); |
277 | else | 285 | else |
278 | pnp_printf(buffer," 0x%llx-0x%llx\n", | 286 | pnp_printf(buffer, " 0x%llx-0x%llx\n", |
279 | (unsigned long long)pnp_mem_start(dev, i), | 287 | (unsigned long long) |
280 | (unsigned long long)pnp_mem_end(dev, i)); | 288 | pnp_mem_start(dev, i), |
289 | (unsigned long long)pnp_mem_end(dev, | ||
290 | i)); | ||
281 | } | 291 | } |
282 | } | 292 | } |
283 | for (i = 0; i < PNP_MAX_IRQ; i++) { | 293 | for (i = 0; i < PNP_MAX_IRQ; i++) { |
284 | if (pnp_irq_valid(dev, i)) { | 294 | if (pnp_irq_valid(dev, i)) { |
285 | pnp_printf(buffer,"irq"); | 295 | pnp_printf(buffer, "irq"); |
286 | if (pnp_irq_flags(dev, i) & IORESOURCE_DISABLED) | 296 | if (pnp_irq_flags(dev, i) & IORESOURCE_DISABLED) |
287 | pnp_printf(buffer," disabled\n"); | 297 | pnp_printf(buffer, " disabled\n"); |
288 | else | 298 | else |
289 | pnp_printf(buffer," %lld\n", | 299 | pnp_printf(buffer, " %lld\n", |
290 | (unsigned long long)pnp_irq(dev, i)); | 300 | (unsigned long long)pnp_irq(dev, i)); |
291 | } | 301 | } |
292 | } | 302 | } |
293 | for (i = 0; i < PNP_MAX_DMA; i++) { | 303 | for (i = 0; i < PNP_MAX_DMA; i++) { |
294 | if (pnp_dma_valid(dev, i)) { | 304 | if (pnp_dma_valid(dev, i)) { |
295 | pnp_printf(buffer,"dma"); | 305 | pnp_printf(buffer, "dma"); |
296 | if (pnp_dma_flags(dev, i) & IORESOURCE_DISABLED) | 306 | if (pnp_dma_flags(dev, i) & IORESOURCE_DISABLED) |
297 | pnp_printf(buffer," disabled\n"); | 307 | pnp_printf(buffer, " disabled\n"); |
298 | else | 308 | else |
299 | pnp_printf(buffer," %lld\n", | 309 | pnp_printf(buffer, " %lld\n", |
300 | (unsigned long long)pnp_dma(dev, i)); | 310 | (unsigned long long)pnp_dma(dev, i)); |
301 | } | 311 | } |
302 | } | 312 | } |
303 | ret = (buffer->curr - buf); | 313 | ret = (buffer->curr - buf); |
@@ -308,55 +318,57 @@ static ssize_t pnp_show_current_resources(struct device *dmdev, struct device_at | |||
308 | extern struct semaphore pnp_res_mutex; | 318 | extern struct semaphore pnp_res_mutex; |
309 | 319 | ||
310 | static ssize_t | 320 | static ssize_t |
311 | pnp_set_current_resources(struct device * dmdev, struct device_attribute *attr, const char * ubuf, size_t count) | 321 | pnp_set_current_resources(struct device *dmdev, struct device_attribute *attr, |
322 | const char *ubuf, size_t count) | ||
312 | { | 323 | { |
313 | struct pnp_dev *dev = to_pnp_dev(dmdev); | 324 | struct pnp_dev *dev = to_pnp_dev(dmdev); |
314 | char *buf = (void *)ubuf; | 325 | char *buf = (void *)ubuf; |
315 | int retval = 0; | 326 | int retval = 0; |
316 | 327 | ||
317 | if (dev->status & PNP_ATTACHED) { | 328 | if (dev->status & PNP_ATTACHED) { |
318 | retval = -EBUSY; | 329 | retval = -EBUSY; |
319 | pnp_info("Device %s cannot be configured because it is in use.", dev->dev.bus_id); | 330 | pnp_info("Device %s cannot be configured because it is in use.", |
331 | dev->dev.bus_id); | ||
320 | goto done; | 332 | goto done; |
321 | } | 333 | } |
322 | 334 | ||
323 | while (isspace(*buf)) | 335 | while (isspace(*buf)) |
324 | ++buf; | 336 | ++buf; |
325 | if (!strnicmp(buf,"disable",7)) { | 337 | if (!strnicmp(buf, "disable", 7)) { |
326 | retval = pnp_disable_dev(dev); | 338 | retval = pnp_disable_dev(dev); |
327 | goto done; | 339 | goto done; |
328 | } | 340 | } |
329 | if (!strnicmp(buf,"activate",8)) { | 341 | if (!strnicmp(buf, "activate", 8)) { |
330 | retval = pnp_activate_dev(dev); | 342 | retval = pnp_activate_dev(dev); |
331 | goto done; | 343 | goto done; |
332 | } | 344 | } |
333 | if (!strnicmp(buf,"fill",4)) { | 345 | if (!strnicmp(buf, "fill", 4)) { |
334 | if (dev->active) | 346 | if (dev->active) |
335 | goto done; | 347 | goto done; |
336 | retval = pnp_auto_config_dev(dev); | 348 | retval = pnp_auto_config_dev(dev); |
337 | goto done; | 349 | goto done; |
338 | } | 350 | } |
339 | if (!strnicmp(buf,"auto",4)) { | 351 | if (!strnicmp(buf, "auto", 4)) { |
340 | if (dev->active) | 352 | if (dev->active) |
341 | goto done; | 353 | goto done; |
342 | pnp_init_resource_table(&dev->res); | 354 | pnp_init_resource_table(&dev->res); |
343 | retval = pnp_auto_config_dev(dev); | 355 | retval = pnp_auto_config_dev(dev); |
344 | goto done; | 356 | goto done; |
345 | } | 357 | } |
346 | if (!strnicmp(buf,"clear",5)) { | 358 | if (!strnicmp(buf, "clear", 5)) { |
347 | if (dev->active) | 359 | if (dev->active) |
348 | goto done; | 360 | goto done; |
349 | pnp_init_resource_table(&dev->res); | 361 | pnp_init_resource_table(&dev->res); |
350 | goto done; | 362 | goto done; |
351 | } | 363 | } |
352 | if (!strnicmp(buf,"get",3)) { | 364 | if (!strnicmp(buf, "get", 3)) { |
353 | down(&pnp_res_mutex); | 365 | down(&pnp_res_mutex); |
354 | if (pnp_can_read(dev)) | 366 | if (pnp_can_read(dev)) |
355 | dev->protocol->get(dev, &dev->res); | 367 | dev->protocol->get(dev, &dev->res); |
356 | up(&pnp_res_mutex); | 368 | up(&pnp_res_mutex); |
357 | goto done; | 369 | goto done; |
358 | } | 370 | } |
359 | if (!strnicmp(buf,"set",3)) { | 371 | if (!strnicmp(buf, "set", 3)) { |
360 | int nport = 0, nmem = 0, nirq = 0, ndma = 0; | 372 | int nport = 0, nmem = 0, nirq = 0, ndma = 0; |
361 | if (dev->active) | 373 | if (dev->active) |
362 | goto done; | 374 | goto done; |
@@ -366,65 +378,77 @@ pnp_set_current_resources(struct device * dmdev, struct device_attribute *attr, | |||
366 | while (1) { | 378 | while (1) { |
367 | while (isspace(*buf)) | 379 | while (isspace(*buf)) |
368 | ++buf; | 380 | ++buf; |
369 | if (!strnicmp(buf,"io",2)) { | 381 | if (!strnicmp(buf, "io", 2)) { |
370 | buf += 2; | 382 | buf += 2; |
371 | while (isspace(*buf)) | 383 | while (isspace(*buf)) |
372 | ++buf; | 384 | ++buf; |
373 | dev->res.port_resource[nport].start = simple_strtoul(buf,&buf,0); | 385 | dev->res.port_resource[nport].start = |
386 | simple_strtoul(buf, &buf, 0); | ||
374 | while (isspace(*buf)) | 387 | while (isspace(*buf)) |
375 | ++buf; | 388 | ++buf; |
376 | if(*buf == '-') { | 389 | if (*buf == '-') { |
377 | buf += 1; | 390 | buf += 1; |
378 | while (isspace(*buf)) | 391 | while (isspace(*buf)) |
379 | ++buf; | 392 | ++buf; |
380 | dev->res.port_resource[nport].end = simple_strtoul(buf,&buf,0); | 393 | dev->res.port_resource[nport].end = |
394 | simple_strtoul(buf, &buf, 0); | ||
381 | } else | 395 | } else |
382 | dev->res.port_resource[nport].end = dev->res.port_resource[nport].start; | 396 | dev->res.port_resource[nport].end = |
383 | dev->res.port_resource[nport].flags = IORESOURCE_IO; | 397 | dev->res.port_resource[nport].start; |
398 | dev->res.port_resource[nport].flags = | ||
399 | IORESOURCE_IO; | ||
384 | nport++; | 400 | nport++; |
385 | if (nport >= PNP_MAX_PORT) | 401 | if (nport >= PNP_MAX_PORT) |
386 | break; | 402 | break; |
387 | continue; | 403 | continue; |
388 | } | 404 | } |
389 | if (!strnicmp(buf,"mem",3)) { | 405 | if (!strnicmp(buf, "mem", 3)) { |
390 | buf += 3; | 406 | buf += 3; |
391 | while (isspace(*buf)) | 407 | while (isspace(*buf)) |
392 | ++buf; | 408 | ++buf; |
393 | dev->res.mem_resource[nmem].start = simple_strtoul(buf,&buf,0); | 409 | dev->res.mem_resource[nmem].start = |
410 | simple_strtoul(buf, &buf, 0); | ||
394 | while (isspace(*buf)) | 411 | while (isspace(*buf)) |
395 | ++buf; | 412 | ++buf; |
396 | if(*buf == '-') { | 413 | if (*buf == '-') { |
397 | buf += 1; | 414 | buf += 1; |
398 | while (isspace(*buf)) | 415 | while (isspace(*buf)) |
399 | ++buf; | 416 | ++buf; |
400 | dev->res.mem_resource[nmem].end = simple_strtoul(buf,&buf,0); | 417 | dev->res.mem_resource[nmem].end = |
418 | simple_strtoul(buf, &buf, 0); | ||
401 | } else | 419 | } else |
402 | dev->res.mem_resource[nmem].end = dev->res.mem_resource[nmem].start; | 420 | dev->res.mem_resource[nmem].end = |
403 | dev->res.mem_resource[nmem].flags = IORESOURCE_MEM; | 421 | dev->res.mem_resource[nmem].start; |
422 | dev->res.mem_resource[nmem].flags = | ||
423 | IORESOURCE_MEM; | ||
404 | nmem++; | 424 | nmem++; |
405 | if (nmem >= PNP_MAX_MEM) | 425 | if (nmem >= PNP_MAX_MEM) |
406 | break; | 426 | break; |
407 | continue; | 427 | continue; |
408 | } | 428 | } |
409 | if (!strnicmp(buf,"irq",3)) { | 429 | if (!strnicmp(buf, "irq", 3)) { |
410 | buf += 3; | 430 | buf += 3; |
411 | while (isspace(*buf)) | 431 | while (isspace(*buf)) |
412 | ++buf; | 432 | ++buf; |
413 | dev->res.irq_resource[nirq].start = | 433 | dev->res.irq_resource[nirq].start = |
414 | dev->res.irq_resource[nirq].end = simple_strtoul(buf,&buf,0); | 434 | dev->res.irq_resource[nirq].end = |
415 | dev->res.irq_resource[nirq].flags = IORESOURCE_IRQ; | 435 | simple_strtoul(buf, &buf, 0); |
436 | dev->res.irq_resource[nirq].flags = | ||
437 | IORESOURCE_IRQ; | ||
416 | nirq++; | 438 | nirq++; |
417 | if (nirq >= PNP_MAX_IRQ) | 439 | if (nirq >= PNP_MAX_IRQ) |
418 | break; | 440 | break; |
419 | continue; | 441 | continue; |
420 | } | 442 | } |
421 | if (!strnicmp(buf,"dma",3)) { | 443 | if (!strnicmp(buf, "dma", 3)) { |
422 | buf += 3; | 444 | buf += 3; |
423 | while (isspace(*buf)) | 445 | while (isspace(*buf)) |
424 | ++buf; | 446 | ++buf; |
425 | dev->res.dma_resource[ndma].start = | 447 | dev->res.dma_resource[ndma].start = |
426 | dev->res.dma_resource[ndma].end = simple_strtoul(buf,&buf,0); | 448 | dev->res.dma_resource[ndma].end = |
427 | dev->res.dma_resource[ndma].flags = IORESOURCE_DMA; | 449 | simple_strtoul(buf, &buf, 0); |
450 | dev->res.dma_resource[ndma].flags = | ||
451 | IORESOURCE_DMA; | ||
428 | ndma++; | 452 | ndma++; |
429 | if (ndma >= PNP_MAX_DMA) | 453 | if (ndma >= PNP_MAX_DMA) |
430 | break; | 454 | break; |
@@ -435,45 +459,50 @@ pnp_set_current_resources(struct device * dmdev, struct device_attribute *attr, | |||
435 | up(&pnp_res_mutex); | 459 | up(&pnp_res_mutex); |
436 | goto done; | 460 | goto done; |
437 | } | 461 | } |
438 | done: | 462 | done: |
439 | if (retval < 0) | 463 | if (retval < 0) |
440 | return retval; | 464 | return retval; |
441 | return count; | 465 | return count; |
442 | } | 466 | } |
443 | 467 | ||
444 | static DEVICE_ATTR(resources,S_IRUGO | S_IWUSR, | 468 | static DEVICE_ATTR(resources, S_IRUGO | S_IWUSR, |
445 | pnp_show_current_resources,pnp_set_current_resources); | 469 | pnp_show_current_resources, pnp_set_current_resources); |
446 | 470 | ||
447 | static ssize_t pnp_show_current_ids(struct device *dmdev, struct device_attribute *attr, char *buf) | 471 | static ssize_t pnp_show_current_ids(struct device *dmdev, |
472 | struct device_attribute *attr, char *buf) | ||
448 | { | 473 | { |
449 | char *str = buf; | 474 | char *str = buf; |
450 | struct pnp_dev *dev = to_pnp_dev(dmdev); | 475 | struct pnp_dev *dev = to_pnp_dev(dmdev); |
451 | struct pnp_id * pos = dev->id; | 476 | struct pnp_id *pos = dev->id; |
452 | 477 | ||
453 | while (pos) { | 478 | while (pos) { |
454 | str += sprintf(str,"%s\n", pos->id); | 479 | str += sprintf(str, "%s\n", pos->id); |
455 | pos = pos->next; | 480 | pos = pos->next; |
456 | } | 481 | } |
457 | return (str - buf); | 482 | return (str - buf); |
458 | } | 483 | } |
459 | 484 | ||
460 | static DEVICE_ATTR(id,S_IRUGO,pnp_show_current_ids,NULL); | 485 | static DEVICE_ATTR(id, S_IRUGO, pnp_show_current_ids, NULL); |
461 | 486 | ||
462 | int pnp_interface_attach_device(struct pnp_dev *dev) | 487 | int pnp_interface_attach_device(struct pnp_dev *dev) |
463 | { | 488 | { |
464 | int rc = device_create_file(&dev->dev,&dev_attr_options); | 489 | int rc = device_create_file(&dev->dev, &dev_attr_options); |
465 | if (rc) goto err; | 490 | |
466 | rc = device_create_file(&dev->dev,&dev_attr_resources); | 491 | if (rc) |
467 | if (rc) goto err_opt; | 492 | goto err; |
468 | rc = device_create_file(&dev->dev,&dev_attr_id); | 493 | rc = device_create_file(&dev->dev, &dev_attr_resources); |
469 | if (rc) goto err_res; | 494 | if (rc) |
495 | goto err_opt; | ||
496 | rc = device_create_file(&dev->dev, &dev_attr_id); | ||
497 | if (rc) | ||
498 | goto err_res; | ||
470 | 499 | ||
471 | return 0; | 500 | return 0; |
472 | 501 | ||
473 | err_res: | 502 | err_res: |
474 | device_remove_file(&dev->dev,&dev_attr_resources); | 503 | device_remove_file(&dev->dev, &dev_attr_resources); |
475 | err_opt: | 504 | err_opt: |
476 | device_remove_file(&dev->dev,&dev_attr_options); | 505 | device_remove_file(&dev->dev, &dev_attr_options); |
477 | err: | 506 | err: |
478 | return rc; | 507 | return rc; |
479 | } | 508 | } |