mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-27 00:51:35 +00:00
power: cmm - convert sysdev_class to a regular subsystem
After all sysdev classes are ported to regular driver core entities, the sysdev implementation will be entirely removed from the kernel. Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: Paul Mackerras <paulus@samba.org> Cc: Prarit Bhargava <prarit@redhat.com> Signed-off-by: Kay Sievers <kay.sievers@vrfy.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
parent
3fbacffbe9
commit
6c9d290952
1 changed files with 34 additions and 33 deletions
|
@ -33,7 +33,7 @@
|
||||||
#include <linux/sched.h>
|
#include <linux/sched.h>
|
||||||
#include <linux/stringify.h>
|
#include <linux/stringify.h>
|
||||||
#include <linux/swap.h>
|
#include <linux/swap.h>
|
||||||
#include <linux/sysdev.h>
|
#include <linux/device.h>
|
||||||
#include <asm/firmware.h>
|
#include <asm/firmware.h>
|
||||||
#include <asm/hvcall.h>
|
#include <asm/hvcall.h>
|
||||||
#include <asm/mmu.h>
|
#include <asm/mmu.h>
|
||||||
|
@ -65,7 +65,7 @@ static unsigned int oom_kb = CMM_OOM_KB;
|
||||||
static unsigned int cmm_debug = CMM_DEBUG;
|
static unsigned int cmm_debug = CMM_DEBUG;
|
||||||
static unsigned int cmm_disabled = CMM_DISABLE;
|
static unsigned int cmm_disabled = CMM_DISABLE;
|
||||||
static unsigned long min_mem_mb = CMM_MIN_MEM_MB;
|
static unsigned long min_mem_mb = CMM_MIN_MEM_MB;
|
||||||
static struct sys_device cmm_sysdev;
|
static struct device cmm_dev;
|
||||||
|
|
||||||
MODULE_AUTHOR("Brian King <brking@linux.vnet.ibm.com>");
|
MODULE_AUTHOR("Brian King <brking@linux.vnet.ibm.com>");
|
||||||
MODULE_DESCRIPTION("IBM System p Collaborative Memory Manager");
|
MODULE_DESCRIPTION("IBM System p Collaborative Memory Manager");
|
||||||
|
@ -347,25 +347,25 @@ static int cmm_thread(void *dummy)
|
||||||
}
|
}
|
||||||
|
|
||||||
#define CMM_SHOW(name, format, args...) \
|
#define CMM_SHOW(name, format, args...) \
|
||||||
static ssize_t show_##name(struct sys_device *dev, \
|
static ssize_t show_##name(struct device *dev, \
|
||||||
struct sysdev_attribute *attr, \
|
struct device_attribute *attr, \
|
||||||
char *buf) \
|
char *buf) \
|
||||||
{ \
|
{ \
|
||||||
return sprintf(buf, format, ##args); \
|
return sprintf(buf, format, ##args); \
|
||||||
} \
|
} \
|
||||||
static SYSDEV_ATTR(name, S_IRUGO, show_##name, NULL)
|
static DEVICE_ATTR(name, S_IRUGO, show_##name, NULL)
|
||||||
|
|
||||||
CMM_SHOW(loaned_kb, "%lu\n", PAGES2KB(loaned_pages));
|
CMM_SHOW(loaned_kb, "%lu\n", PAGES2KB(loaned_pages));
|
||||||
CMM_SHOW(loaned_target_kb, "%lu\n", PAGES2KB(loaned_pages_target));
|
CMM_SHOW(loaned_target_kb, "%lu\n", PAGES2KB(loaned_pages_target));
|
||||||
|
|
||||||
static ssize_t show_oom_pages(struct sys_device *dev,
|
static ssize_t show_oom_pages(struct device *dev,
|
||||||
struct sysdev_attribute *attr, char *buf)
|
struct device_attribute *attr, char *buf)
|
||||||
{
|
{
|
||||||
return sprintf(buf, "%lu\n", PAGES2KB(oom_freed_pages));
|
return sprintf(buf, "%lu\n", PAGES2KB(oom_freed_pages));
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t store_oom_pages(struct sys_device *dev,
|
static ssize_t store_oom_pages(struct device *dev,
|
||||||
struct sysdev_attribute *attr,
|
struct device_attribute *attr,
|
||||||
const char *buf, size_t count)
|
const char *buf, size_t count)
|
||||||
{
|
{
|
||||||
unsigned long val = simple_strtoul (buf, NULL, 10);
|
unsigned long val = simple_strtoul (buf, NULL, 10);
|
||||||
|
@ -379,17 +379,18 @@ static ssize_t store_oom_pages(struct sys_device *dev,
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SYSDEV_ATTR(oom_freed_kb, S_IWUSR| S_IRUGO,
|
static DEVICE_ATTR(oom_freed_kb, S_IWUSR | S_IRUGO,
|
||||||
show_oom_pages, store_oom_pages);
|
show_oom_pages, store_oom_pages);
|
||||||
|
|
||||||
static struct sysdev_attribute *cmm_attrs[] = {
|
static struct device_attribute *cmm_attrs[] = {
|
||||||
&attr_loaned_kb,
|
&dev_attr_loaned_kb,
|
||||||
&attr_loaned_target_kb,
|
&dev_attr_loaned_target_kb,
|
||||||
&attr_oom_freed_kb,
|
&dev_attr_oom_freed_kb,
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct sysdev_class cmm_sysdev_class = {
|
static struct bus_type cmm_subsys = {
|
||||||
.name = "cmm",
|
.name = "cmm",
|
||||||
|
.dev_name = "cmm",
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -398,21 +399,21 @@ static struct sysdev_class cmm_sysdev_class = {
|
||||||
* Return value:
|
* Return value:
|
||||||
* 0 on success / other on failure
|
* 0 on success / other on failure
|
||||||
**/
|
**/
|
||||||
static int cmm_sysfs_register(struct sys_device *sysdev)
|
static int cmm_sysfs_register(struct device *dev)
|
||||||
{
|
{
|
||||||
int i, rc;
|
int i, rc;
|
||||||
|
|
||||||
if ((rc = sysdev_class_register(&cmm_sysdev_class)))
|
if ((rc = subsys_system_register(&cmm_subsys, NULL)))
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
sysdev->id = 0;
|
dev->id = 0;
|
||||||
sysdev->cls = &cmm_sysdev_class;
|
dev->bus = &cmm_subsys;
|
||||||
|
|
||||||
if ((rc = sysdev_register(sysdev)))
|
if ((rc = device_register(dev)))
|
||||||
goto class_unregister;
|
goto subsys_unregister;
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(cmm_attrs); i++) {
|
for (i = 0; i < ARRAY_SIZE(cmm_attrs); i++) {
|
||||||
if ((rc = sysdev_create_file(sysdev, cmm_attrs[i])))
|
if ((rc = device_create_file(dev, cmm_attrs[i])))
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -420,10 +421,10 @@ static int cmm_sysfs_register(struct sys_device *sysdev)
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
while (--i >= 0)
|
while (--i >= 0)
|
||||||
sysdev_remove_file(sysdev, cmm_attrs[i]);
|
device_remove_file(dev, cmm_attrs[i]);
|
||||||
sysdev_unregister(sysdev);
|
device_unregister(dev);
|
||||||
class_unregister:
|
subsys_unregister:
|
||||||
sysdev_class_unregister(&cmm_sysdev_class);
|
bus_unregister(&cmm_subsys);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -431,14 +432,14 @@ class_unregister:
|
||||||
* cmm_unregister_sysfs - Unregister from sysfs
|
* cmm_unregister_sysfs - Unregister from sysfs
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
static void cmm_unregister_sysfs(struct sys_device *sysdev)
|
static void cmm_unregister_sysfs(struct device *dev)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(cmm_attrs); i++)
|
for (i = 0; i < ARRAY_SIZE(cmm_attrs); i++)
|
||||||
sysdev_remove_file(sysdev, cmm_attrs[i]);
|
device_remove_file(dev, cmm_attrs[i]);
|
||||||
sysdev_unregister(sysdev);
|
device_unregister(dev);
|
||||||
sysdev_class_unregister(&cmm_sysdev_class);
|
bus_unregister(&cmm_subsys);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -657,7 +658,7 @@ static int cmm_init(void)
|
||||||
if ((rc = register_reboot_notifier(&cmm_reboot_nb)))
|
if ((rc = register_reboot_notifier(&cmm_reboot_nb)))
|
||||||
goto out_oom_notifier;
|
goto out_oom_notifier;
|
||||||
|
|
||||||
if ((rc = cmm_sysfs_register(&cmm_sysdev)))
|
if ((rc = cmm_sysfs_register(&cmm_dev)))
|
||||||
goto out_reboot_notifier;
|
goto out_reboot_notifier;
|
||||||
|
|
||||||
if (register_memory_notifier(&cmm_mem_nb) ||
|
if (register_memory_notifier(&cmm_mem_nb) ||
|
||||||
|
@ -678,7 +679,7 @@ static int cmm_init(void)
|
||||||
out_unregister_notifier:
|
out_unregister_notifier:
|
||||||
unregister_memory_notifier(&cmm_mem_nb);
|
unregister_memory_notifier(&cmm_mem_nb);
|
||||||
unregister_memory_isolate_notifier(&cmm_mem_isolate_nb);
|
unregister_memory_isolate_notifier(&cmm_mem_isolate_nb);
|
||||||
cmm_unregister_sysfs(&cmm_sysdev);
|
cmm_unregister_sysfs(&cmm_dev);
|
||||||
out_reboot_notifier:
|
out_reboot_notifier:
|
||||||
unregister_reboot_notifier(&cmm_reboot_nb);
|
unregister_reboot_notifier(&cmm_reboot_nb);
|
||||||
out_oom_notifier:
|
out_oom_notifier:
|
||||||
|
@ -701,7 +702,7 @@ static void cmm_exit(void)
|
||||||
unregister_memory_notifier(&cmm_mem_nb);
|
unregister_memory_notifier(&cmm_mem_nb);
|
||||||
unregister_memory_isolate_notifier(&cmm_mem_isolate_nb);
|
unregister_memory_isolate_notifier(&cmm_mem_isolate_nb);
|
||||||
cmm_free_pages(loaned_pages);
|
cmm_free_pages(loaned_pages);
|
||||||
cmm_unregister_sysfs(&cmm_sysdev);
|
cmm_unregister_sysfs(&cmm_dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue