aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pnp
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/pnp')
-rw-r--r--drivers/pnp/interface.c36
-rw-r--r--drivers/pnp/pnpbios/proc.c204
-rw-r--r--drivers/pnp/pnpbios/rsparser.c8
-rw-r--r--drivers/pnp/quirks.c13
-rw-r--r--drivers/pnp/resource.c10
-rw-r--r--drivers/pnp/support.c43
-rw-r--r--drivers/pnp/system.c14
7 files changed, 162 insertions, 166 deletions
diff --git a/drivers/pnp/interface.c b/drivers/pnp/interface.c
index c3f1c8e9d254..68b0c04987e4 100644
--- a/drivers/pnp/interface.c
+++ b/drivers/pnp/interface.c
@@ -310,8 +310,7 @@ static ssize_t pnp_set_current_resources(struct device *dmdev,
310 goto done; 310 goto done;
311 } 311 }
312 312
313 while (isspace(*buf)) 313 buf = skip_spaces(buf);
314 ++buf;
315 if (!strnicmp(buf, "disable", 7)) { 314 if (!strnicmp(buf, "disable", 7)) {
316 retval = pnp_disable_dev(dev); 315 retval = pnp_disable_dev(dev);
317 goto done; 316 goto done;
@@ -353,19 +352,13 @@ static ssize_t pnp_set_current_resources(struct device *dmdev,
353 pnp_init_resources(dev); 352 pnp_init_resources(dev);
354 mutex_lock(&pnp_res_mutex); 353 mutex_lock(&pnp_res_mutex);
355 while (1) { 354 while (1) {
356 while (isspace(*buf)) 355 buf = skip_spaces(buf);
357 ++buf;
358 if (!strnicmp(buf, "io", 2)) { 356 if (!strnicmp(buf, "io", 2)) {
359 buf += 2; 357 buf = skip_spaces(buf + 2);
360 while (isspace(*buf))
361 ++buf;
362 start = simple_strtoul(buf, &buf, 0); 358 start = simple_strtoul(buf, &buf, 0);
363 while (isspace(*buf)) 359 buf = skip_spaces(buf);
364 ++buf;
365 if (*buf == '-') { 360 if (*buf == '-') {
366 buf += 1; 361 buf = skip_spaces(buf + 1);
367 while (isspace(*buf))
368 ++buf;
369 end = simple_strtoul(buf, &buf, 0); 362 end = simple_strtoul(buf, &buf, 0);
370 } else 363 } else
371 end = start; 364 end = start;
@@ -373,16 +366,11 @@ static ssize_t pnp_set_current_resources(struct device *dmdev,
373 continue; 366 continue;
374 } 367 }
375 if (!strnicmp(buf, "mem", 3)) { 368 if (!strnicmp(buf, "mem", 3)) {
376 buf += 3; 369 buf = skip_spaces(buf + 3);
377 while (isspace(*buf))
378 ++buf;
379 start = simple_strtoul(buf, &buf, 0); 370 start = simple_strtoul(buf, &buf, 0);
380 while (isspace(*buf)) 371 buf = skip_spaces(buf);
381 ++buf;
382 if (*buf == '-') { 372 if (*buf == '-') {
383 buf += 1; 373 buf = skip_spaces(buf + 1);
384 while (isspace(*buf))
385 ++buf;
386 end = simple_strtoul(buf, &buf, 0); 374 end = simple_strtoul(buf, &buf, 0);
387 } else 375 } else
388 end = start; 376 end = start;
@@ -390,17 +378,13 @@ static ssize_t pnp_set_current_resources(struct device *dmdev,
390 continue; 378 continue;
391 } 379 }
392 if (!strnicmp(buf, "irq", 3)) { 380 if (!strnicmp(buf, "irq", 3)) {
393 buf += 3; 381 buf = skip_spaces(buf + 3);
394 while (isspace(*buf))
395 ++buf;
396 start = simple_strtoul(buf, &buf, 0); 382 start = simple_strtoul(buf, &buf, 0);
397 pnp_add_irq_resource(dev, start, 0); 383 pnp_add_irq_resource(dev, start, 0);
398 continue; 384 continue;
399 } 385 }
400 if (!strnicmp(buf, "dma", 3)) { 386 if (!strnicmp(buf, "dma", 3)) {
401 buf += 3; 387 buf = skip_spaces(buf + 3);
402 while (isspace(*buf))
403 ++buf;
404 start = simple_strtoul(buf, &buf, 0); 388 start = simple_strtoul(buf, &buf, 0);
405 pnp_add_dma_resource(dev, start, 0); 389 pnp_add_dma_resource(dev, start, 0);
406 continue; 390 continue;
diff --git a/drivers/pnp/pnpbios/proc.c b/drivers/pnp/pnpbios/proc.c
index b35d921bac6e..2d8ac43f78e8 100644
--- a/drivers/pnp/pnpbios/proc.c
+++ b/drivers/pnp/pnpbios/proc.c
@@ -24,6 +24,7 @@
24#include <linux/types.h> 24#include <linux/types.h>
25#include <linux/proc_fs.h> 25#include <linux/proc_fs.h>
26#include <linux/pnp.h> 26#include <linux/pnp.h>
27#include <linux/seq_file.h>
27#include <linux/init.h> 28#include <linux/init.h>
28 29
29#include <asm/uaccess.h> 30#include <asm/uaccess.h>
@@ -33,42 +34,65 @@
33static struct proc_dir_entry *proc_pnp = NULL; 34static struct proc_dir_entry *proc_pnp = NULL;
34static struct proc_dir_entry *proc_pnp_boot = NULL; 35static struct proc_dir_entry *proc_pnp_boot = NULL;
35 36
36static int proc_read_pnpconfig(char *buf, char **start, off_t pos, 37static int pnpconfig_proc_show(struct seq_file *m, void *v)
37 int count, int *eof, void *data)
38{ 38{
39 struct pnp_isa_config_struc pnps; 39 struct pnp_isa_config_struc pnps;
40 40
41 if (pnp_bios_isapnp_config(&pnps)) 41 if (pnp_bios_isapnp_config(&pnps))
42 return -EIO; 42 return -EIO;
43 return snprintf(buf, count, 43 seq_printf(m, "structure_revision %d\n"
44 "structure_revision %d\n" 44 "number_of_CSNs %d\n"
45 "number_of_CSNs %d\n" 45 "ISA_read_data_port 0x%x\n",
46 "ISA_read_data_port 0x%x\n", 46 pnps.revision, pnps.no_csns, pnps.isa_rd_data_port);
47 pnps.revision, pnps.no_csns, pnps.isa_rd_data_port); 47 return 0;
48} 48}
49 49
50static int proc_read_escdinfo(char *buf, char **start, off_t pos, 50static int pnpconfig_proc_open(struct inode *inode, struct file *file)
51 int count, int *eof, void *data) 51{
52 return single_open(file, pnpconfig_proc_show, NULL);
53}
54
55static const struct file_operations pnpconfig_proc_fops = {
56 .owner = THIS_MODULE,
57 .open = pnpconfig_proc_open,
58 .read = seq_read,
59 .llseek = seq_lseek,
60 .release = single_release,
61};
62
63static int escd_info_proc_show(struct seq_file *m, void *v)
52{ 64{
53 struct escd_info_struc escd; 65 struct escd_info_struc escd;
54 66
55 if (pnp_bios_escd_info(&escd)) 67 if (pnp_bios_escd_info(&escd))
56 return -EIO; 68 return -EIO;
57 return snprintf(buf, count, 69 seq_printf(m, "min_ESCD_write_size %d\n"
58 "min_ESCD_write_size %d\n"
59 "ESCD_size %d\n" 70 "ESCD_size %d\n"
60 "NVRAM_base 0x%x\n", 71 "NVRAM_base 0x%x\n",
61 escd.min_escd_write_size, 72 escd.min_escd_write_size,
62 escd.escd_size, escd.nv_storage_base); 73 escd.escd_size, escd.nv_storage_base);
74 return 0;
63} 75}
64 76
77static int escd_info_proc_open(struct inode *inode, struct file *file)
78{
79 return single_open(file, escd_info_proc_show, NULL);
80}
81
82static const struct file_operations escd_info_proc_fops = {
83 .owner = THIS_MODULE,
84 .open = escd_info_proc_open,
85 .read = seq_read,
86 .llseek = seq_lseek,
87 .release = single_release,
88};
89
65#define MAX_SANE_ESCD_SIZE (32*1024) 90#define MAX_SANE_ESCD_SIZE (32*1024)
66static int proc_read_escd(char *buf, char **start, off_t pos, 91static int escd_proc_show(struct seq_file *m, void *v)
67 int count, int *eof, void *data)
68{ 92{
69 struct escd_info_struc escd; 93 struct escd_info_struc escd;
70 char *tmpbuf; 94 char *tmpbuf;
71 int escd_size, escd_left_to_read, n; 95 int escd_size;
72 96
73 if (pnp_bios_escd_info(&escd)) 97 if (pnp_bios_escd_info(&escd))
74 return -EIO; 98 return -EIO;
@@ -76,7 +100,7 @@ static int proc_read_escd(char *buf, char **start, off_t pos,
76 /* sanity check */ 100 /* sanity check */
77 if (escd.escd_size > MAX_SANE_ESCD_SIZE) { 101 if (escd.escd_size > MAX_SANE_ESCD_SIZE) {
78 printk(KERN_ERR 102 printk(KERN_ERR
79 "PnPBIOS: proc_read_escd: ESCD size reported by BIOS escd_info call is too great\n"); 103 "PnPBIOS: %s: ESCD size reported by BIOS escd_info call is too great\n", __func__);
80 return -EFBIG; 104 return -EFBIG;
81 } 105 }
82 106
@@ -94,56 +118,75 @@ static int proc_read_escd(char *buf, char **start, off_t pos,
94 118
95 /* sanity check */ 119 /* sanity check */
96 if (escd_size > MAX_SANE_ESCD_SIZE) { 120 if (escd_size > MAX_SANE_ESCD_SIZE) {
97 printk(KERN_ERR "PnPBIOS: proc_read_escd: ESCD size reported by" 121 printk(KERN_ERR "PnPBIOS: %s: ESCD size reported by"
98 " BIOS read_escd call is too great\n"); 122 " BIOS read_escd call is too great\n", __func__);
99 kfree(tmpbuf); 123 kfree(tmpbuf);
100 return -EFBIG; 124 return -EFBIG;
101 } 125 }
102 126
103 escd_left_to_read = escd_size - pos; 127 seq_write(m, tmpbuf, escd_size);
104 if (escd_left_to_read < 0)
105 escd_left_to_read = 0;
106 if (escd_left_to_read == 0)
107 *eof = 1;
108 n = min(count, escd_left_to_read);
109 memcpy(buf, tmpbuf + pos, n);
110 kfree(tmpbuf); 128 kfree(tmpbuf);
111 *start = buf; 129 return 0;
112 return n;
113} 130}
114 131
115static int proc_read_legacyres(char *buf, char **start, off_t pos, 132static int escd_proc_open(struct inode *inode, struct file *file)
116 int count, int *eof, void *data) 133{
134 return single_open(file, escd_proc_show, NULL);
135}
136
137static const struct file_operations escd_proc_fops = {
138 .owner = THIS_MODULE,
139 .open = escd_proc_open,
140 .read = seq_read,
141 .llseek = seq_lseek,
142 .release = single_release,
143};
144
145static int pnp_legacyres_proc_show(struct seq_file *m, void *v)
117{ 146{
118 /* Assume that the following won't overflow the buffer */ 147 void *buf;
119 if (pnp_bios_get_stat_res(buf)) 148
149 buf = kmalloc(65536, GFP_KERNEL);
150 if (!buf)
151 return -ENOMEM;
152 if (pnp_bios_get_stat_res(buf)) {
153 kfree(buf);
120 return -EIO; 154 return -EIO;
155 }
156
157 seq_write(m, buf, 65536);
158 kfree(buf);
159 return 0;
160}
121 161
122 return count; // FIXME: Return actual length 162static int pnp_legacyres_proc_open(struct inode *inode, struct file *file)
163{
164 return single_open(file, pnp_legacyres_proc_show, NULL);
123} 165}
124 166
125static int proc_read_devices(char *buf, char **start, off_t pos, 167static const struct file_operations pnp_legacyres_proc_fops = {
126 int count, int *eof, void *data) 168 .owner = THIS_MODULE,
169 .open = pnp_legacyres_proc_open,
170 .read = seq_read,
171 .llseek = seq_lseek,
172 .release = single_release,
173};
174
175static int pnp_devices_proc_show(struct seq_file *m, void *v)
127{ 176{
128 struct pnp_bios_node *node; 177 struct pnp_bios_node *node;
129 u8 nodenum; 178 u8 nodenum;
130 char *p = buf;
131
132 if (pos >= 0xff)
133 return 0;
134 179
135 node = kzalloc(node_info.max_node_size, GFP_KERNEL); 180 node = kzalloc(node_info.max_node_size, GFP_KERNEL);
136 if (!node) 181 if (!node)
137 return -ENOMEM; 182 return -ENOMEM;
138 183
139 for (nodenum = pos; nodenum < 0xff;) { 184 for (nodenum = 0; nodenum < 0xff;) {
140 u8 thisnodenum = nodenum; 185 u8 thisnodenum = nodenum;
141 /* 26 = the number of characters per line sprintf'ed */ 186
142 if ((p - buf + 26) > count)
143 break;
144 if (pnp_bios_get_dev_node(&nodenum, PNPMODE_DYNAMIC, node)) 187 if (pnp_bios_get_dev_node(&nodenum, PNPMODE_DYNAMIC, node))
145 break; 188 break;
146 p += sprintf(p, "%02x\t%08x\t%02x:%02x:%02x\t%04x\n", 189 seq_printf(m, "%02x\t%08x\t%02x:%02x:%02x\t%04x\n",
147 node->handle, node->eisa_id, 190 node->handle, node->eisa_id,
148 node->type_code[0], node->type_code[1], 191 node->type_code[0], node->type_code[1],
149 node->type_code[2], node->flags); 192 node->type_code[2], node->flags);
@@ -153,20 +196,29 @@ static int proc_read_devices(char *buf, char **start, off_t pos,
153 "PnPBIOS: proc_read_devices:", 196 "PnPBIOS: proc_read_devices:",
154 (unsigned int)nodenum, 197 (unsigned int)nodenum,
155 (unsigned int)thisnodenum); 198 (unsigned int)thisnodenum);
156 *eof = 1;
157 break; 199 break;
158 } 200 }
159 } 201 }
160 kfree(node); 202 kfree(node);
161 if (nodenum == 0xff) 203 return 0;
162 *eof = 1; 204}
163 *start = (char *)((off_t) nodenum - pos); 205
164 return p - buf; 206static int pnp_devices_proc_open(struct inode *inode, struct file *file)
207{
208 return single_open(file, pnp_devices_proc_show, NULL);
165} 209}
166 210
167static int proc_read_node(char *buf, char **start, off_t pos, 211static const struct file_operations pnp_devices_proc_fops = {
168 int count, int *eof, void *data) 212 .owner = THIS_MODULE,
213 .open = pnp_devices_proc_open,
214 .read = seq_read,
215 .llseek = seq_lseek,
216 .release = single_release,
217};
218
219static int pnpbios_proc_show(struct seq_file *m, void *v)
169{ 220{
221 void *data = m->private;
170 struct pnp_bios_node *node; 222 struct pnp_bios_node *node;
171 int boot = (long)data >> 8; 223 int boot = (long)data >> 8;
172 u8 nodenum = (long)data; 224 u8 nodenum = (long)data;
@@ -180,14 +232,20 @@ static int proc_read_node(char *buf, char **start, off_t pos,
180 return -EIO; 232 return -EIO;
181 } 233 }
182 len = node->size - sizeof(struct pnp_bios_node); 234 len = node->size - sizeof(struct pnp_bios_node);
183 memcpy(buf, node->data, len); 235 seq_write(m, node->data, len);
184 kfree(node); 236 kfree(node);
185 return len; 237 return 0;
238}
239
240static int pnpbios_proc_open(struct inode *inode, struct file *file)
241{
242 return single_open(file, pnpbios_proc_show, PDE(inode)->data);
186} 243}
187 244
188static int proc_write_node(struct file *file, const char __user * buf, 245static ssize_t pnpbios_proc_write(struct file *file, const char __user *buf,
189 unsigned long count, void *data) 246 size_t count, loff_t *pos)
190{ 247{
248 void *data = PDE(file->f_path.dentry->d_inode)->data;
191 struct pnp_bios_node *node; 249 struct pnp_bios_node *node;
192 int boot = (long)data >> 8; 250 int boot = (long)data >> 8;
193 u8 nodenum = (long)data; 251 u8 nodenum = (long)data;
@@ -218,34 +276,33 @@ out:
218 return ret; 276 return ret;
219} 277}
220 278
279static const struct file_operations pnpbios_proc_fops = {
280 .owner = THIS_MODULE,
281 .open = pnpbios_proc_open,
282 .read = seq_read,
283 .llseek = seq_lseek,
284 .release = single_release,
285 .write = pnpbios_proc_write,
286};
287
221int pnpbios_interface_attach_device(struct pnp_bios_node *node) 288int pnpbios_interface_attach_device(struct pnp_bios_node *node)
222{ 289{
223 char name[3]; 290 char name[3];
224 struct proc_dir_entry *ent;
225 291
226 sprintf(name, "%02x", node->handle); 292 sprintf(name, "%02x", node->handle);
227 293
228 if (!proc_pnp) 294 if (!proc_pnp)
229 return -EIO; 295 return -EIO;
230 if (!pnpbios_dont_use_current_config) { 296 if (!pnpbios_dont_use_current_config) {
231 ent = create_proc_entry(name, 0, proc_pnp); 297 proc_create_data(name, 0644, proc_pnp, &pnpbios_proc_fops,
232 if (ent) { 298 (void *)(long)(node->handle));
233 ent->read_proc = proc_read_node;
234 ent->write_proc = proc_write_node;
235 ent->data = (void *)(long)(node->handle);
236 }
237 } 299 }
238 300
239 if (!proc_pnp_boot) 301 if (!proc_pnp_boot)
240 return -EIO; 302 return -EIO;
241 ent = create_proc_entry(name, 0, proc_pnp_boot); 303 if (proc_create_data(name, 0644, proc_pnp_boot, &pnpbios_proc_fops,
242 if (ent) { 304 (void *)(long)(node->handle + 0x100)))
243 ent->read_proc = proc_read_node;
244 ent->write_proc = proc_write_node;
245 ent->data = (void *)(long)(node->handle + 0x100);
246 return 0; 305 return 0;
247 }
248
249 return -EIO; 306 return -EIO;
250} 307}
251 308
@@ -262,14 +319,11 @@ int __init pnpbios_proc_init(void)
262 proc_pnp_boot = proc_mkdir("boot", proc_pnp); 319 proc_pnp_boot = proc_mkdir("boot", proc_pnp);
263 if (!proc_pnp_boot) 320 if (!proc_pnp_boot)
264 return -EIO; 321 return -EIO;
265 create_proc_read_entry("devices", 0, proc_pnp, proc_read_devices, NULL); 322 proc_create("devices", 0, proc_pnp, &pnp_devices_proc_fops);
266 create_proc_read_entry("configuration_info", 0, proc_pnp, 323 proc_create("configuration_info", 0, proc_pnp, &pnpconfig_proc_fops);
267 proc_read_pnpconfig, NULL); 324 proc_create("escd_info", 0, proc_pnp, &escd_info_proc_fops);
268 create_proc_read_entry("escd_info", 0, proc_pnp, proc_read_escdinfo, 325 proc_create("escd", S_IRUSR, proc_pnp, &escd_proc_fops);
269 NULL); 326 proc_create("legacy_device_resources", 0, proc_pnp, &pnp_legacyres_proc_fops);
270 create_proc_read_entry("escd", S_IRUSR, proc_pnp, proc_read_escd, NULL);
271 create_proc_read_entry("legacy_device_resources", 0, proc_pnp,
272 proc_read_legacyres, NULL);
273 327
274 return 0; 328 return 0;
275} 329}
diff --git a/drivers/pnp/pnpbios/rsparser.c b/drivers/pnp/pnpbios/rsparser.c
index 87b4f49a5251..a5135ebe5f07 100644
--- a/drivers/pnp/pnpbios/rsparser.c
+++ b/drivers/pnp/pnpbios/rsparser.c
@@ -191,7 +191,7 @@ static unsigned char *pnpbios_parse_allocated_resource_data(struct pnp_dev *dev,
191 return (unsigned char *)p; 191 return (unsigned char *)p;
192 break; 192 break;
193 193
194 default: /* an unkown tag */ 194 default: /* an unknown tag */
195len_err: 195len_err:
196 dev_err(&dev->dev, "unknown tag %#x length %d\n", 196 dev_err(&dev->dev, "unknown tag %#x length %d\n",
197 tag, len); 197 tag, len);
@@ -405,7 +405,7 @@ pnpbios_parse_resource_option_data(unsigned char *p, unsigned char *end,
405 case SMALL_TAG_END: 405 case SMALL_TAG_END:
406 return p + 2; 406 return p + 2;
407 407
408 default: /* an unkown tag */ 408 default: /* an unknown tag */
409len_err: 409len_err:
410 dev_err(&dev->dev, "unknown tag %#x length %d\n", 410 dev_err(&dev->dev, "unknown tag %#x length %d\n",
411 tag, len); 411 tag, len);
@@ -475,7 +475,7 @@ static unsigned char *pnpbios_parse_compatible_ids(unsigned char *p,
475 return (unsigned char *)p; 475 return (unsigned char *)p;
476 break; 476 break;
477 477
478 default: /* an unkown tag */ 478 default: /* an unknown tag */
479len_err: 479len_err:
480 dev_err(&dev->dev, "unknown tag %#x length %d\n", 480 dev_err(&dev->dev, "unknown tag %#x length %d\n",
481 tag, len); 481 tag, len);
@@ -744,7 +744,7 @@ static unsigned char *pnpbios_encode_allocated_resource_data(struct pnp_dev
744 return (unsigned char *)p; 744 return (unsigned char *)p;
745 break; 745 break;
746 746
747 default: /* an unkown tag */ 747 default: /* an unknown tag */
748len_err: 748len_err:
749 dev_err(&dev->dev, "unknown tag %#x length %d\n", 749 dev_err(&dev->dev, "unknown tag %#x length %d\n",
750 tag, len); 750 tag, len);
diff --git a/drivers/pnp/quirks.c b/drivers/pnp/quirks.c
index 8473fe5ed7ff..dfbd5a6cc58b 100644
--- a/drivers/pnp/quirks.c
+++ b/drivers/pnp/quirks.c
@@ -285,15 +285,10 @@ static void quirk_system_pci_resources(struct pnp_dev *dev)
285 * the PCI region, and that might prevent a PCI 285 * the PCI region, and that might prevent a PCI
286 * driver from requesting its resources. 286 * driver from requesting its resources.
287 */ 287 */
288 dev_warn(&dev->dev, "%s resource " 288 dev_warn(&dev->dev,
289 "(0x%llx-0x%llx) overlaps %s BAR %d " 289 "disabling %pR because it overlaps "
290 "(0x%llx-0x%llx), disabling\n", 290 "%s BAR %d %pR\n", res,
291 pnp_resource_type_name(res), 291 pci_name(pdev), i, &pdev->resource[i]);
292 (unsigned long long) pnp_start,
293 (unsigned long long) pnp_end,
294 pci_name(pdev), i,
295 (unsigned long long) pci_start,
296 (unsigned long long) pci_end);
297 res->flags |= IORESOURCE_DISABLED; 292 res->flags |= IORESOURCE_DISABLED;
298 } 293 }
299 } 294 }
diff --git a/drivers/pnp/resource.c b/drivers/pnp/resource.c
index ba9765427886..64d0596bafb5 100644
--- a/drivers/pnp/resource.c
+++ b/drivers/pnp/resource.c
@@ -517,7 +517,7 @@ struct pnp_resource *pnp_add_irq_resource(struct pnp_dev *dev, int irq,
517 res->start = irq; 517 res->start = irq;
518 res->end = irq; 518 res->end = irq;
519 519
520 pnp_dbg(&dev->dev, " add irq %d flags %#x\n", irq, flags); 520 pnp_dbg(&dev->dev, " add %pr\n", res);
521 return pnp_res; 521 return pnp_res;
522} 522}
523 523
@@ -538,7 +538,7 @@ struct pnp_resource *pnp_add_dma_resource(struct pnp_dev *dev, int dma,
538 res->start = dma; 538 res->start = dma;
539 res->end = dma; 539 res->end = dma;
540 540
541 pnp_dbg(&dev->dev, " add dma %d flags %#x\n", dma, flags); 541 pnp_dbg(&dev->dev, " add %pr\n", res);
542 return pnp_res; 542 return pnp_res;
543} 543}
544 544
@@ -562,8 +562,7 @@ struct pnp_resource *pnp_add_io_resource(struct pnp_dev *dev,
562 res->start = start; 562 res->start = start;
563 res->end = end; 563 res->end = end;
564 564
565 pnp_dbg(&dev->dev, " add io %#llx-%#llx flags %#x\n", 565 pnp_dbg(&dev->dev, " add %pr\n", res);
566 (unsigned long long) start, (unsigned long long) end, flags);
567 return pnp_res; 566 return pnp_res;
568} 567}
569 568
@@ -587,8 +586,7 @@ struct pnp_resource *pnp_add_mem_resource(struct pnp_dev *dev,
587 res->start = start; 586 res->start = start;
588 res->end = end; 587 res->end = end;
589 588
590 pnp_dbg(&dev->dev, " add mem %#llx-%#llx flags %#x\n", 589 pnp_dbg(&dev->dev, " add %pr\n", res);
591 (unsigned long long) start, (unsigned long long) end, flags);
592 return pnp_res; 590 return pnp_res;
593} 591}
594 592
diff --git a/drivers/pnp/support.c b/drivers/pnp/support.c
index 63087d5ce609..9585c1c1cc36 100644
--- a/drivers/pnp/support.c
+++ b/drivers/pnp/support.c
@@ -75,47 +75,14 @@ char *pnp_resource_type_name(struct resource *res)
75 75
76void dbg_pnp_show_resources(struct pnp_dev *dev, char *desc) 76void dbg_pnp_show_resources(struct pnp_dev *dev, char *desc)
77{ 77{
78 char buf[128];
79 int len;
80 struct pnp_resource *pnp_res; 78 struct pnp_resource *pnp_res;
81 struct resource *res;
82 79
83 if (list_empty(&dev->resources)) { 80 if (list_empty(&dev->resources))
84 pnp_dbg(&dev->dev, "%s: no current resources\n", desc); 81 pnp_dbg(&dev->dev, "%s: no current resources\n", desc);
85 return; 82 else {
86 } 83 pnp_dbg(&dev->dev, "%s: current resources:\n", desc);
87 84 list_for_each_entry(pnp_res, &dev->resources, list)
88 pnp_dbg(&dev->dev, "%s: current resources:\n", desc); 85 pnp_dbg(&dev->dev, "%pr\n", &pnp_res->res);
89 list_for_each_entry(pnp_res, &dev->resources, list) {
90 res = &pnp_res->res;
91 len = 0;
92
93 len += scnprintf(buf + len, sizeof(buf) - len, " %-3s ",
94 pnp_resource_type_name(res));
95
96 if (res->flags & IORESOURCE_DISABLED) {
97 pnp_dbg(&dev->dev, "%sdisabled\n", buf);
98 continue;
99 }
100
101 switch (pnp_resource_type(res)) {
102 case IORESOURCE_IO:
103 case IORESOURCE_MEM:
104 len += scnprintf(buf + len, sizeof(buf) - len,
105 "%#llx-%#llx flags %#lx",
106 (unsigned long long) res->start,
107 (unsigned long long) res->end,
108 res->flags);
109 break;
110 case IORESOURCE_IRQ:
111 case IORESOURCE_DMA:
112 len += scnprintf(buf + len, sizeof(buf) - len,
113 "%lld flags %#lx",
114 (unsigned long long) res->start,
115 res->flags);
116 break;
117 }
118 pnp_dbg(&dev->dev, "%s\n", buf);
119 } 86 }
120} 87}
121 88
diff --git a/drivers/pnp/system.c b/drivers/pnp/system.c
index 59b90922da8c..49c1720df59a 100644
--- a/drivers/pnp/system.c
+++ b/drivers/pnp/system.c
@@ -22,11 +22,11 @@ static const struct pnp_device_id pnp_dev_table[] = {
22 {"", 0} 22 {"", 0}
23}; 23};
24 24
25static void reserve_range(struct pnp_dev *dev, resource_size_t start, 25static void reserve_range(struct pnp_dev *dev, struct resource *r, int port)
26 resource_size_t end, int port)
27{ 26{
28 char *regionid; 27 char *regionid;
29 const char *pnpid = dev_name(&dev->dev); 28 const char *pnpid = dev_name(&dev->dev);
29 resource_size_t start = r->start, end = r->end;
30 struct resource *res; 30 struct resource *res;
31 31
32 regionid = kmalloc(16, GFP_KERNEL); 32 regionid = kmalloc(16, GFP_KERNEL);
@@ -48,10 +48,8 @@ static void reserve_range(struct pnp_dev *dev, resource_size_t start,
48 * example do reserve stuff they know about too, so we may well 48 * example do reserve stuff they know about too, so we may well
49 * have double reservations. 49 * have double reservations.
50 */ 50 */
51 dev_info(&dev->dev, "%s range 0x%llx-0x%llx %s reserved\n", 51 dev_info(&dev->dev, "%pR %s reserved\n", r,
52 port ? "ioport" : "iomem", 52 res ? "has been" : "could not be");
53 (unsigned long long) start, (unsigned long long) end,
54 res ? "has been" : "could not be");
55} 53}
56 54
57static void reserve_resources_of_dev(struct pnp_dev *dev) 55static void reserve_resources_of_dev(struct pnp_dev *dev)
@@ -77,14 +75,14 @@ static void reserve_resources_of_dev(struct pnp_dev *dev)
77 if (res->end < res->start) 75 if (res->end < res->start)
78 continue; /* invalid */ 76 continue; /* invalid */
79 77
80 reserve_range(dev, res->start, res->end, 1); 78 reserve_range(dev, res, 1);
81 } 79 }
82 80
83 for (i = 0; (res = pnp_get_resource(dev, IORESOURCE_MEM, i)); i++) { 81 for (i = 0; (res = pnp_get_resource(dev, IORESOURCE_MEM, i)); i++) {
84 if (res->flags & IORESOURCE_DISABLED) 82 if (res->flags & IORESOURCE_DISABLED)
85 continue; 83 continue;
86 84
87 reserve_range(dev, res->start, res->end, 0); 85 reserve_range(dev, res, 0);
88 } 86 }
89} 87}
90 88