aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pnp
diff options
context:
space:
mode:
authorAndré Goddard Rosa <andre.goddard@gmail.com>2009-12-14 21:01:06 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2009-12-15 11:53:32 -0500
commite7d2860b690d4f3bed6824757c540579638e3d1e (patch)
tree84268ee28893256fd6a6a7e1d4474f61dbee74e7 /drivers/pnp
parent84c95c9acf088c99d8793d78036b67faa5d0b851 (diff)
tree-wide: convert open calls to remove spaces to skip_spaces() lib function
Makes use of skip_spaces() defined in lib/string.c for removing leading spaces from strings all over the tree. It decreases lib.a code size by 47 bytes and reuses the function tree-wide: text data bss dec hex filename 64688 584 592 65864 10148 (TOTALS-BEFORE) 64641 584 592 65817 10119 (TOTALS-AFTER) Also, while at it, if we see (*str && isspace(*str)), we can be sure to remove the first condition (*str) as the second one (isspace(*str)) also evaluates to 0 whenever *str == 0, making it redundant. In other words, "a char equals zero is never a space". Julia Lawall tried the semantic patch (http://coccinelle.lip6.fr) below, and found occurrences of this pattern on 3 more files: drivers/leds/led-class.c drivers/leds/ledtrig-timer.c drivers/video/output.c @@ expression str; @@ ( // ignore skip_spaces cases while (*str && isspace(*str)) { \(str++;\|++str;\) } | - *str && isspace(*str) ) Signed-off-by: André Goddard Rosa <andre.goddard@gmail.com> Cc: Julia Lawall <julia@diku.dk> Cc: Martin Schwidefsky <schwidefsky@de.ibm.com> Cc: Jeff Dike <jdike@addtoit.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: "H. Peter Anvin" <hpa@zytor.com> Cc: Richard Purdie <rpurdie@rpsys.net> Cc: Neil Brown <neilb@suse.de> Cc: Kyle McMartin <kyle@mcmartin.ca> Cc: Henrique de Moraes Holschuh <hmh@hmh.eng.br> Cc: David Howells <dhowells@redhat.com> Cc: <linux-ext4@vger.kernel.org> Cc: Samuel Ortiz <samuel@sortiz.org> Cc: Patrick McHardy <kaber@trash.net> Cc: Takashi Iwai <tiwai@suse.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/pnp')
-rw-r--r--drivers/pnp/interface.c36
1 files changed, 10 insertions, 26 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;