aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/xen/balloon.c27
1 files changed, 12 insertions, 15 deletions
diff --git a/drivers/xen/balloon.c b/drivers/xen/balloon.c
index d4427cb86979..cdec2d843e4c 100644
--- a/drivers/xen/balloon.c
+++ b/drivers/xen/balloon.c
@@ -60,7 +60,7 @@
60 60
61#define PAGES2KB(_p) ((_p)<<(PAGE_SHIFT-10)) 61#define PAGES2KB(_p) ((_p)<<(PAGE_SHIFT-10))
62 62
63#define BALLOON_CLASS_NAME "memory" 63#define BALLOON_CLASS_NAME "xen_memory"
64 64
65struct balloon_stats { 65struct balloon_stats {
66 /* We aim for 'current allocation' == 'target allocation'. */ 66 /* We aim for 'current allocation' == 'target allocation'. */
@@ -588,12 +588,13 @@ static void balloon_release_driver_page(struct page *page)
588} 588}
589 589
590 590
591#define BALLOON_SHOW(name, format, args...) \ 591#define BALLOON_SHOW(name, format, args...) \
592 static ssize_t show_##name(struct sys_device *dev, \ 592 static ssize_t show_##name(struct sys_device *dev, \
593 char *buf) \ 593 struct sysdev_attribute *attr, \
594 { \ 594 char *buf) \
595 return sprintf(buf, format, ##args); \ 595 { \
596 } \ 596 return sprintf(buf, format, ##args); \
597 } \
597 static SYSDEV_ATTR(name, S_IRUGO, show_##name, NULL) 598 static SYSDEV_ATTR(name, S_IRUGO, show_##name, NULL)
598 599
599BALLOON_SHOW(current_kb, "%lu\n", PAGES2KB(balloon_stats.current_pages)); 600BALLOON_SHOW(current_kb, "%lu\n", PAGES2KB(balloon_stats.current_pages));
@@ -604,7 +605,8 @@ BALLOON_SHOW(hard_limit_kb,
604 (balloon_stats.hard_limit!=~0UL) ? PAGES2KB(balloon_stats.hard_limit) : 0); 605 (balloon_stats.hard_limit!=~0UL) ? PAGES2KB(balloon_stats.hard_limit) : 0);
605BALLOON_SHOW(driver_kb, "%lu\n", PAGES2KB(balloon_stats.driver_pages)); 606BALLOON_SHOW(driver_kb, "%lu\n", PAGES2KB(balloon_stats.driver_pages));
606 607
607static ssize_t show_target_kb(struct sys_device *dev, char *buf) 608static ssize_t show_target_kb(struct sys_device *dev, struct sysdev_attribute *attr,
609 char *buf)
608{ 610{
609 return sprintf(buf, "%lu\n", PAGES2KB(balloon_stats.target_pages)); 611 return sprintf(buf, "%lu\n", PAGES2KB(balloon_stats.target_pages));
610} 612}
@@ -614,19 +616,14 @@ static ssize_t store_target_kb(struct sys_device *dev,
614 const char *buf, 616 const char *buf,
615 size_t count) 617 size_t count)
616{ 618{
617 char memstring[64], *endchar; 619 char *endchar;
618 unsigned long long target_bytes; 620 unsigned long long target_bytes;
619 621
620 if (!capable(CAP_SYS_ADMIN)) 622 if (!capable(CAP_SYS_ADMIN))
621 return -EPERM; 623 return -EPERM;
622 624
623 if (count <= 1) 625 target_bytes = memparse(buf, &endchar);
624 return -EBADMSG; /* runt */
625 if (count > sizeof(memstring))
626 return -EFBIG; /* too long */
627 strcpy(memstring, buf);
628 626
629 target_bytes = memparse(memstring, &endchar);
630 balloon_set_new_target(target_bytes >> PAGE_SHIFT); 627 balloon_set_new_target(target_bytes >> PAGE_SHIFT);
631 628
632 return count; 629 return count;