aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/time
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/time')
-rw-r--r--kernel/time/clocksource.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/kernel/time/clocksource.c b/kernel/time/clocksource.c
index 6e9259a5d501..81afb3927ecc 100644
--- a/kernel/time/clocksource.c
+++ b/kernel/time/clocksource.c
@@ -363,15 +363,13 @@ void clocksource_unregister(struct clocksource *cs)
363static ssize_t 363static ssize_t
364sysfs_show_current_clocksources(struct sys_device *dev, char *buf) 364sysfs_show_current_clocksources(struct sys_device *dev, char *buf)
365{ 365{
366 char *curr = buf; 366 ssize_t count = 0;
367 367
368 spin_lock_irq(&clocksource_lock); 368 spin_lock_irq(&clocksource_lock);
369 curr += sprintf(curr, "%s ", curr_clocksource->name); 369 count = snprintf(buf, PAGE_SIZE, "%s\n", curr_clocksource->name);
370 spin_unlock_irq(&clocksource_lock); 370 spin_unlock_irq(&clocksource_lock);
371 371
372 curr += sprintf(curr, "\n"); 372 return count;
373
374 return curr - buf;
375} 373}
376 374
377/** 375/**
@@ -439,17 +437,20 @@ static ssize_t
439sysfs_show_available_clocksources(struct sys_device *dev, char *buf) 437sysfs_show_available_clocksources(struct sys_device *dev, char *buf)
440{ 438{
441 struct clocksource *src; 439 struct clocksource *src;
442 char *curr = buf; 440 ssize_t count = 0;
443 441
444 spin_lock_irq(&clocksource_lock); 442 spin_lock_irq(&clocksource_lock);
445 list_for_each_entry(src, &clocksource_list, list) { 443 list_for_each_entry(src, &clocksource_list, list) {
446 curr += sprintf(curr, "%s ", src->name); 444 count += snprintf(buf + count,
445 max((ssize_t)PAGE_SIZE - count, (ssize_t)0),
446 "%s ", src->name);
447 } 447 }
448 spin_unlock_irq(&clocksource_lock); 448 spin_unlock_irq(&clocksource_lock);
449 449
450 curr += sprintf(curr, "\n"); 450 count += snprintf(buf + count,
451 max((ssize_t)PAGE_SIZE - count, (ssize_t)0), "\n");
451 452
452 return curr - buf; 453 return count;
453} 454}
454 455
455/* 456/*