blob: cfaf5b73540bbc6b958ad7e5f15ea4822ab7c8d6 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * interface.c - contains everything related to the user interface
3 *
Jaroslav Kyselac1017a42007-10-15 09:50:19 +02004 * Some code, especially possible resource dumping is based on isapnp_proc.c (c) Jaroslav Kysela <perex@perex.cz>
Linus Torvalds1da177e2005-04-16 15:20:36 -07005 * Copyright 2002 Adam Belay <ambx1@neo.rr.com>
Bjorn Helgaas1f32ca32008-06-27 16:57:17 -06006 * Copyright (C) 2008 Hewlett-Packard Development Company, L.P.
7 * Bjorn Helgaas <bjorn.helgaas@hp.com>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 */
9
10#include <linux/pnp.h>
11#include <linux/string.h>
12#include <linux/errno.h>
13#include <linux/list.h>
14#include <linux/types.h>
15#include <linux/stat.h>
16#include <linux/ctype.h>
17#include <linux/slab.h>
Daniel Walkerb3bd86e2008-02-06 01:40:04 -080018#include <linux/mutex.h>
19
Linus Torvalds1da177e2005-04-16 15:20:36 -070020#include <asm/uaccess.h>
21
22#include "base.h"
23
24struct pnp_info_buffer {
25 char *buffer; /* pointer to begin of buffer */
26 char *curr; /* current position in buffer */
27 unsigned long size; /* current size */
28 unsigned long len; /* total length of buffer */
29 int stop; /* stop flag */
30 int error; /* error code */
31};
32
33typedef struct pnp_info_buffer pnp_info_buffer_t;
34
Bjorn Helgaas9dd78462007-07-26 10:41:20 -070035static int pnp_printf(pnp_info_buffer_t * buffer, char *fmt, ...)
Linus Torvalds1da177e2005-04-16 15:20:36 -070036{
37 va_list args;
38 int res;
39
40 if (buffer->stop || buffer->error)
41 return 0;
42 va_start(args, fmt);
43 res = vsnprintf(buffer->curr, buffer->len - buffer->size, fmt, args);
44 va_end(args);
45 if (buffer->size + res >= buffer->len) {
46 buffer->stop = 1;
47 return 0;
48 }
49 buffer->curr += res;
50 buffer->size += res;
51 return res;
52}
53
Bjorn Helgaas9dd78462007-07-26 10:41:20 -070054static void pnp_print_port(pnp_info_buffer_t * buffer, char *space,
55 struct pnp_port *port)
Linus Torvalds1da177e2005-04-16 15:20:36 -070056{
Bjorn Helgaas169aaff2008-06-27 16:57:06 -060057 pnp_printf(buffer, "%sport %#llx-%#llx, align %#llx, size %#llx, "
58 "%i-bit address decoding\n", space,
59 (unsigned long long) port->min,
60 (unsigned long long) port->max,
61 port->align ? ((unsigned long long) port->align - 1) : 0,
62 (unsigned long long) port->size,
Bjorn Helgaas08c9f262008-06-27 16:57:03 -060063 port->flags & IORESOURCE_IO_16BIT_ADDR ? 16 : 10);
Linus Torvalds1da177e2005-04-16 15:20:36 -070064}
65
Bjorn Helgaas9dd78462007-07-26 10:41:20 -070066static void pnp_print_irq(pnp_info_buffer_t * buffer, char *space,
67 struct pnp_irq *irq)
Linus Torvalds1da177e2005-04-16 15:20:36 -070068{
69 int first = 1, i;
70
71 pnp_printf(buffer, "%sirq ", space);
72 for (i = 0; i < PNP_IRQ_NR; i++)
Bjorn Helgaas7aefff52008-06-27 16:57:05 -060073 if (test_bit(i, irq->map.bits)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -070074 if (!first) {
75 pnp_printf(buffer, ",");
76 } else {
77 first = 0;
78 }
79 if (i == 2 || i == 9)
80 pnp_printf(buffer, "2/9");
81 else
82 pnp_printf(buffer, "%i", i);
83 }
Bjorn Helgaas7aefff52008-06-27 16:57:05 -060084 if (bitmap_empty(irq->map.bits, PNP_IRQ_NR))
Linus Torvalds1da177e2005-04-16 15:20:36 -070085 pnp_printf(buffer, "<none>");
86 if (irq->flags & IORESOURCE_IRQ_HIGHEDGE)
87 pnp_printf(buffer, " High-Edge");
88 if (irq->flags & IORESOURCE_IRQ_LOWEDGE)
89 pnp_printf(buffer, " Low-Edge");
90 if (irq->flags & IORESOURCE_IRQ_HIGHLEVEL)
91 pnp_printf(buffer, " High-Level");
92 if (irq->flags & IORESOURCE_IRQ_LOWLEVEL)
93 pnp_printf(buffer, " Low-Level");
Bjorn Helgaasd5ebde62008-06-27 16:57:14 -060094 if (irq->flags & IORESOURCE_IRQ_OPTIONAL)
95 pnp_printf(buffer, " (optional)");
Linus Torvalds1da177e2005-04-16 15:20:36 -070096 pnp_printf(buffer, "\n");
97}
98
Bjorn Helgaas9dd78462007-07-26 10:41:20 -070099static void pnp_print_dma(pnp_info_buffer_t * buffer, char *space,
100 struct pnp_dma *dma)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700101{
102 int first = 1, i;
103 char *s;
104
105 pnp_printf(buffer, "%sdma ", space);
106 for (i = 0; i < 8; i++)
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700107 if (dma->map & (1 << i)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108 if (!first) {
109 pnp_printf(buffer, ",");
110 } else {
111 first = 0;
112 }
113 pnp_printf(buffer, "%i", i);
114 }
115 if (!dma->map)
116 pnp_printf(buffer, "<none>");
117 switch (dma->flags & IORESOURCE_DMA_TYPE_MASK) {
118 case IORESOURCE_DMA_8BIT:
119 s = "8-bit";
120 break;
121 case IORESOURCE_DMA_8AND16BIT:
122 s = "8-bit&16-bit";
123 break;
124 default:
125 s = "16-bit";
126 }
127 pnp_printf(buffer, " %s", s);
128 if (dma->flags & IORESOURCE_DMA_MASTER)
129 pnp_printf(buffer, " master");
130 if (dma->flags & IORESOURCE_DMA_BYTE)
131 pnp_printf(buffer, " byte-count");
132 if (dma->flags & IORESOURCE_DMA_WORD)
133 pnp_printf(buffer, " word-count");
134 switch (dma->flags & IORESOURCE_DMA_SPEED_MASK) {
135 case IORESOURCE_DMA_TYPEA:
136 s = "type-A";
137 break;
138 case IORESOURCE_DMA_TYPEB:
139 s = "type-B";
140 break;
141 case IORESOURCE_DMA_TYPEF:
142 s = "type-F";
143 break;
144 default:
145 s = "compatible";
146 break;
147 }
148 pnp_printf(buffer, " %s\n", s);
149}
150
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700151static void pnp_print_mem(pnp_info_buffer_t * buffer, char *space,
152 struct pnp_mem *mem)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700153{
154 char *s;
155
Bjorn Helgaas169aaff2008-06-27 16:57:06 -0600156 pnp_printf(buffer, "%sMemory %#llx-%#llx, align %#llx, size %#llx",
157 space, (unsigned long long) mem->min,
158 (unsigned long long) mem->max,
159 (unsigned long long) mem->align,
160 (unsigned long long) mem->size);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700161 if (mem->flags & IORESOURCE_MEM_WRITEABLE)
162 pnp_printf(buffer, ", writeable");
163 if (mem->flags & IORESOURCE_MEM_CACHEABLE)
164 pnp_printf(buffer, ", cacheable");
165 if (mem->flags & IORESOURCE_MEM_RANGELENGTH)
166 pnp_printf(buffer, ", range-length");
167 if (mem->flags & IORESOURCE_MEM_SHADOWABLE)
168 pnp_printf(buffer, ", shadowable");
169 if (mem->flags & IORESOURCE_MEM_EXPANSIONROM)
170 pnp_printf(buffer, ", expansion ROM");
171 switch (mem->flags & IORESOURCE_MEM_TYPE_MASK) {
172 case IORESOURCE_MEM_8BIT:
173 s = "8-bit";
174 break;
175 case IORESOURCE_MEM_8AND16BIT:
176 s = "8-bit&16-bit";
177 break;
178 case IORESOURCE_MEM_32BIT:
179 s = "32-bit";
180 break;
181 default:
182 s = "16-bit";
183 }
184 pnp_printf(buffer, ", %s\n", s);
185}
186
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700187static void pnp_print_option(pnp_info_buffer_t * buffer, char *space,
Bjorn Helgaas1f32ca32008-06-27 16:57:17 -0600188 struct pnp_option *option)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700189{
Bjorn Helgaas1f32ca32008-06-27 16:57:17 -0600190 switch (option->type) {
191 case IORESOURCE_IO:
192 pnp_print_port(buffer, space, &option->u.port);
193 break;
194 case IORESOURCE_MEM:
195 pnp_print_mem(buffer, space, &option->u.mem);
196 break;
197 case IORESOURCE_IRQ:
198 pnp_print_irq(buffer, space, &option->u.irq);
199 break;
200 case IORESOURCE_DMA:
201 pnp_print_dma(buffer, space, &option->u.dma);
202 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700203 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700204}
205
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700206static ssize_t pnp_show_options(struct device *dmdev,
207 struct device_attribute *attr, char *buf)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700208{
209 struct pnp_dev *dev = to_pnp_dev(dmdev);
Bjorn Helgaasb72ee1f12008-06-27 16:57:02 -0600210 pnp_info_buffer_t *buffer;
Bjorn Helgaas1f32ca32008-06-27 16:57:17 -0600211 struct pnp_option *option;
212 int ret, dep = 0, set = 0;
213 char *indent;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700214
Bjorn Helgaasb72ee1f12008-06-27 16:57:02 -0600215 buffer = pnp_alloc(sizeof(pnp_info_buffer_t));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700216 if (!buffer)
217 return -ENOMEM;
218
219 buffer->len = PAGE_SIZE;
220 buffer->buffer = buf;
221 buffer->curr = buffer->buffer;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700222
Bjorn Helgaas1f32ca32008-06-27 16:57:17 -0600223 list_for_each_entry(option, &dev->options, list) {
224 if (pnp_option_is_dependent(option)) {
225 indent = " ";
226 if (!dep || pnp_option_set(option) != set) {
227 set = pnp_option_set(option);
228 dep = 1;
229 pnp_printf(buffer, "Dependent: %02i - "
230 "Priority %s\n", set,
231 pnp_option_priority_name(option));
232 }
233 } else {
234 dep = 0;
235 indent = "";
236 }
237 pnp_print_option(buffer, indent, option);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700238 }
Bjorn Helgaas1f32ca32008-06-27 16:57:17 -0600239
Linus Torvalds1da177e2005-04-16 15:20:36 -0700240 ret = (buffer->curr - buf);
241 kfree(buffer);
242 return ret;
243}
244
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700245static ssize_t pnp_show_current_resources(struct device *dmdev,
246 struct device_attribute *attr,
247 char *buf)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700248{
249 struct pnp_dev *dev = to_pnp_dev(dmdev);
Bjorn Helgaasb72ee1f12008-06-27 16:57:02 -0600250 pnp_info_buffer_t *buffer;
Bjorn Helgaasf61ed7e2008-06-27 16:57:00 -0600251 struct pnp_resource *pnp_res;
Bjorn Helgaas95ab3662008-04-28 16:34:26 -0600252 struct resource *res;
Bjorn Helgaasf61ed7e2008-06-27 16:57:00 -0600253 int ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700254
255 if (!dev)
256 return -EINVAL;
257
Bjorn Helgaasb72ee1f12008-06-27 16:57:02 -0600258 buffer = pnp_alloc(sizeof(pnp_info_buffer_t));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700259 if (!buffer)
260 return -ENOMEM;
Bjorn Helgaasb72ee1f12008-06-27 16:57:02 -0600261
Linus Torvalds1da177e2005-04-16 15:20:36 -0700262 buffer->len = PAGE_SIZE;
263 buffer->buffer = buf;
264 buffer->curr = buffer->buffer;
265
Bjorn Helgaasf61ed7e2008-06-27 16:57:00 -0600266 pnp_printf(buffer, "state = %s\n", dev->active ? "active" : "disabled");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700267
Bjorn Helgaasf61ed7e2008-06-27 16:57:00 -0600268 list_for_each_entry(pnp_res, &dev->resources, list) {
269 res = &pnp_res->res;
270
271 pnp_printf(buffer, pnp_resource_type_name(res));
272
273 if (res->flags & IORESOURCE_DISABLED) {
Bjorn Helgaasaee3ad82008-06-27 16:56:57 -0600274 pnp_printf(buffer, " disabled\n");
Bjorn Helgaasf61ed7e2008-06-27 16:57:00 -0600275 continue;
276 }
277
278 switch (pnp_resource_type(res)) {
279 case IORESOURCE_IO:
280 case IORESOURCE_MEM:
Bjorn Helgaas7e0e9c02010-03-05 10:47:57 -0700281 case IORESOURCE_BUS:
Bjorn Helgaasfa35b4922010-03-05 10:47:52 -0700282 pnp_printf(buffer, " %#llx-%#llx%s\n",
Bjorn Helgaasaee3ad82008-06-27 16:56:57 -0600283 (unsigned long long) res->start,
Bjorn Helgaasfa35b4922010-03-05 10:47:52 -0700284 (unsigned long long) res->end,
285 res->flags & IORESOURCE_WINDOW ?
286 " window" : "");
Bjorn Helgaasf61ed7e2008-06-27 16:57:00 -0600287 break;
288 case IORESOURCE_IRQ:
289 case IORESOURCE_DMA:
Bjorn Helgaasaee3ad82008-06-27 16:56:57 -0600290 pnp_printf(buffer, " %lld\n",
291 (unsigned long long) res->start);
Bjorn Helgaasf61ed7e2008-06-27 16:57:00 -0600292 break;
293 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700294 }
Bjorn Helgaasf61ed7e2008-06-27 16:57:00 -0600295
Linus Torvalds1da177e2005-04-16 15:20:36 -0700296 ret = (buffer->curr - buf);
297 kfree(buffer);
298 return ret;
299}
300
Bjorn Helgaasb72ee1f12008-06-27 16:57:02 -0600301static ssize_t pnp_set_current_resources(struct device *dmdev,
302 struct device_attribute *attr,
303 const char *ubuf, size_t count)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700304{
305 struct pnp_dev *dev = to_pnp_dev(dmdev);
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700306 char *buf = (void *)ubuf;
307 int retval = 0;
Bjorn Helgaascc8c2e32008-04-28 16:34:36 -0600308 resource_size_t start, end;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700309
310 if (dev->status & PNP_ATTACHED) {
311 retval = -EBUSY;
Bjorn Helgaasa05d0782007-10-16 23:31:10 -0700312 dev_info(&dev->dev, "in use; can't configure\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700313 goto done;
314 }
315
André Goddard Rosae7d28602009-12-14 18:01:06 -0800316 buf = skip_spaces(buf);
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700317 if (!strnicmp(buf, "disable", 7)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700318 retval = pnp_disable_dev(dev);
319 goto done;
320 }
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700321 if (!strnicmp(buf, "activate", 8)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700322 retval = pnp_activate_dev(dev);
323 goto done;
324 }
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700325 if (!strnicmp(buf, "fill", 4)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700326 if (dev->active)
327 goto done;
328 retval = pnp_auto_config_dev(dev);
329 goto done;
330 }
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700331 if (!strnicmp(buf, "auto", 4)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700332 if (dev->active)
333 goto done;
Bjorn Helgaasf4490002008-04-28 16:34:09 -0600334 pnp_init_resources(dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700335 retval = pnp_auto_config_dev(dev);
336 goto done;
337 }
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700338 if (!strnicmp(buf, "clear", 5)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700339 if (dev->active)
340 goto done;
Bjorn Helgaasf4490002008-04-28 16:34:09 -0600341 pnp_init_resources(dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700342 goto done;
343 }
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700344 if (!strnicmp(buf, "get", 3)) {
Daniel Walkerb3bd86e2008-02-06 01:40:04 -0800345 mutex_lock(&pnp_res_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700346 if (pnp_can_read(dev))
Bjorn Helgaas59284cb2008-04-28 16:34:05 -0600347 dev->protocol->get(dev);
Daniel Walkerb3bd86e2008-02-06 01:40:04 -0800348 mutex_unlock(&pnp_res_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700349 goto done;
350 }
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700351 if (!strnicmp(buf, "set", 3)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700352 if (dev->active)
353 goto done;
354 buf += 3;
Bjorn Helgaasf4490002008-04-28 16:34:09 -0600355 pnp_init_resources(dev);
Daniel Walkerb3bd86e2008-02-06 01:40:04 -0800356 mutex_lock(&pnp_res_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700357 while (1) {
André Goddard Rosae7d28602009-12-14 18:01:06 -0800358 buf = skip_spaces(buf);
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700359 if (!strnicmp(buf, "io", 2)) {
André Goddard Rosae7d28602009-12-14 18:01:06 -0800360 buf = skip_spaces(buf + 2);
Bjorn Helgaascc8c2e32008-04-28 16:34:36 -0600361 start = simple_strtoul(buf, &buf, 0);
André Goddard Rosae7d28602009-12-14 18:01:06 -0800362 buf = skip_spaces(buf);
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700363 if (*buf == '-') {
André Goddard Rosae7d28602009-12-14 18:01:06 -0800364 buf = skip_spaces(buf + 1);
Bjorn Helgaascc8c2e32008-04-28 16:34:36 -0600365 end = simple_strtoul(buf, &buf, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700366 } else
Bjorn Helgaascc8c2e32008-04-28 16:34:36 -0600367 end = start;
Bjorn Helgaas87e4acf2008-06-27 16:56:53 -0600368 pnp_add_io_resource(dev, start, end, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700369 continue;
370 }
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700371 if (!strnicmp(buf, "mem", 3)) {
André Goddard Rosae7d28602009-12-14 18:01:06 -0800372 buf = skip_spaces(buf + 3);
Bjorn Helgaasd6180f32008-04-28 16:34:37 -0600373 start = simple_strtoul(buf, &buf, 0);
André Goddard Rosae7d28602009-12-14 18:01:06 -0800374 buf = skip_spaces(buf);
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700375 if (*buf == '-') {
André Goddard Rosae7d28602009-12-14 18:01:06 -0800376 buf = skip_spaces(buf + 1);
Bjorn Helgaasd6180f32008-04-28 16:34:37 -0600377 end = simple_strtoul(buf, &buf, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700378 } else
Bjorn Helgaasd6180f32008-04-28 16:34:37 -0600379 end = start;
Bjorn Helgaas87e4acf2008-06-27 16:56:53 -0600380 pnp_add_mem_resource(dev, start, end, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700381 continue;
382 }
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700383 if (!strnicmp(buf, "irq", 3)) {
André Goddard Rosae7d28602009-12-14 18:01:06 -0800384 buf = skip_spaces(buf + 3);
Bjorn Helgaasdbddd032008-04-28 16:34:34 -0600385 start = simple_strtoul(buf, &buf, 0);
Bjorn Helgaas87e4acf2008-06-27 16:56:53 -0600386 pnp_add_irq_resource(dev, start, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700387 continue;
388 }
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700389 if (!strnicmp(buf, "dma", 3)) {
André Goddard Rosae7d28602009-12-14 18:01:06 -0800390 buf = skip_spaces(buf + 3);
Bjorn Helgaasdc16f5f2008-04-28 16:34:35 -0600391 start = simple_strtoul(buf, &buf, 0);
Bjorn Helgaas87e4acf2008-06-27 16:56:53 -0600392 pnp_add_dma_resource(dev, start, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700393 continue;
394 }
395 break;
396 }
Daniel Walkerb3bd86e2008-02-06 01:40:04 -0800397 mutex_unlock(&pnp_res_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700398 goto done;
399 }
Bjorn Helgaas1e0aa9a2007-08-15 10:32:08 -0600400
401done:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700402 if (retval < 0)
403 return retval;
404 return count;
405}
406
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700407static ssize_t pnp_show_current_ids(struct device *dmdev,
408 struct device_attribute *attr, char *buf)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700409{
410 char *str = buf;
411 struct pnp_dev *dev = to_pnp_dev(dmdev);
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700412 struct pnp_id *pos = dev->id;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700413
414 while (pos) {
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700415 str += sprintf(str, "%s\n", pos->id);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700416 pos = pos->next;
417 }
418 return (str - buf);
419}
420
Drew Moseley8a89efd2008-09-28 01:31:35 +0200421struct device_attribute pnp_interface_attrs[] = {
422 __ATTR(resources, S_IRUGO | S_IWUSR,
423 pnp_show_current_resources,
424 pnp_set_current_resources),
425 __ATTR(options, S_IRUGO, pnp_show_options, NULL),
426 __ATTR(id, S_IRUGO, pnp_show_current_ids, NULL),
427 __ATTR_NULL,
428};