Commit 10fbcf4c authored by Kay Sievers's avatar Kay Sievers Committed by Greg Kroah-Hartman

convert 'memory' sysdev_class to a regular subsystem

This moves the 'memory sysdev_class' over to a regular 'memory' subsystem
and converts the devices to regular devices. The sysdev drivers are
implemented as subsystem interfaces now.

After all sysdev classes are ported to regular driver core entities, the
sysdev implementation will be entirely removed from the kernel.
Signed-off-by: default avatarKay Sievers <kay.sievers@vrfy.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 8a25a2fd
...@@ -592,7 +592,7 @@ static void register_nodes(void) ...@@ -592,7 +592,7 @@ static void register_nodes(void)
int sysfs_add_device_to_node(struct device *dev, int nid) int sysfs_add_device_to_node(struct device *dev, int nid)
{ {
struct node *node = &node_devices[nid]; struct node *node = &node_devices[nid];
return sysfs_create_link(&node->sysdev.kobj, &dev->kobj, return sysfs_create_link(&node->dev.kobj, &dev->kobj,
kobject_name(&dev->kobj)); kobject_name(&dev->kobj));
} }
EXPORT_SYMBOL_GPL(sysfs_add_device_to_node); EXPORT_SYMBOL_GPL(sysfs_add_device_to_node);
...@@ -600,7 +600,7 @@ EXPORT_SYMBOL_GPL(sysfs_add_device_to_node); ...@@ -600,7 +600,7 @@ EXPORT_SYMBOL_GPL(sysfs_add_device_to_node);
void sysfs_remove_device_from_node(struct device *dev, int nid) void sysfs_remove_device_from_node(struct device *dev, int nid)
{ {
struct node *node = &node_devices[nid]; struct node *node = &node_devices[nid];
sysfs_remove_link(&node->sysdev.kobj, kobject_name(&dev->kobj)); sysfs_remove_link(&node->dev.kobj, kobject_name(&dev->kobj));
} }
EXPORT_SYMBOL_GPL(sysfs_remove_device_from_node); EXPORT_SYMBOL_GPL(sysfs_remove_device_from_node);
......
This diff is collapsed.
This diff is collapsed.
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
#ifndef _LINUX_MEMORY_H_ #ifndef _LINUX_MEMORY_H_
#define _LINUX_MEMORY_H_ #define _LINUX_MEMORY_H_
#include <linux/sysdev.h>
#include <linux/node.h> #include <linux/node.h>
#include <linux/compiler.h> #include <linux/compiler.h>
#include <linux/mutex.h> #include <linux/mutex.h>
...@@ -38,7 +37,7 @@ struct memory_block { ...@@ -38,7 +37,7 @@ struct memory_block {
int phys_device; /* to which fru does this belong? */ int phys_device; /* to which fru does this belong? */
void *hw; /* optional pointer to fw/hw data */ void *hw; /* optional pointer to fw/hw data */
int (*phys_callback)(struct memory_block *); int (*phys_callback)(struct memory_block *);
struct sys_device sysdev; struct device dev;
}; };
int arch_get_memory_phys_device(unsigned long start_pfn); int arch_get_memory_phys_device(unsigned long start_pfn);
......
...@@ -14,12 +14,12 @@ ...@@ -14,12 +14,12 @@
#ifndef _LINUX_NODE_H_ #ifndef _LINUX_NODE_H_
#define _LINUX_NODE_H_ #define _LINUX_NODE_H_
#include <linux/sysdev.h> #include <linux/device.h>
#include <linux/cpumask.h> #include <linux/cpumask.h>
#include <linux/workqueue.h> #include <linux/workqueue.h>
struct node { struct node {
struct sys_device sysdev; struct device dev;
#if defined(CONFIG_MEMORY_HOTPLUG_SPARSE) && defined(CONFIG_HUGETLBFS) #if defined(CONFIG_MEMORY_HOTPLUG_SPARSE) && defined(CONFIG_HUGETLBFS)
struct work_struct node_work; struct work_struct node_work;
...@@ -80,6 +80,6 @@ static inline void register_hugetlbfs_with_node(node_registration_func_t reg, ...@@ -80,6 +80,6 @@ static inline void register_hugetlbfs_with_node(node_registration_func_t reg,
} }
#endif #endif
#define to_node(sys_device) container_of(sys_device, struct node, sysdev) #define to_node(device) container_of(device, struct node, dev)
#endif /* _LINUX_NODE_H_ */ #endif /* _LINUX_NODE_H_ */
...@@ -721,23 +721,23 @@ int sysctl_extfrag_handler(struct ctl_table *table, int write, ...@@ -721,23 +721,23 @@ int sysctl_extfrag_handler(struct ctl_table *table, int write,
} }
#if defined(CONFIG_SYSFS) && defined(CONFIG_NUMA) #if defined(CONFIG_SYSFS) && defined(CONFIG_NUMA)
ssize_t sysfs_compact_node(struct sys_device *dev, ssize_t sysfs_compact_node(struct device *dev,
struct sysdev_attribute *attr, struct device_attribute *attr,
const char *buf, size_t count) const char *buf, size_t count)
{ {
compact_node(dev->id); compact_node(dev->id);
return count; return count;
} }
static SYSDEV_ATTR(compact, S_IWUSR, NULL, sysfs_compact_node); static DEVICE_ATTR(compact, S_IWUSR, NULL, sysfs_compact_node);
int compaction_register_node(struct node *node) int compaction_register_node(struct node *node)
{ {
return sysdev_create_file(&node->sysdev, &attr_compact); return device_create_file(&node->dev, &dev_attr_compact);
} }
void compaction_unregister_node(struct node *node) void compaction_unregister_node(struct node *node)
{ {
return sysdev_remove_file(&node->sysdev, &attr_compact); return device_remove_file(&node->dev, &dev_attr_compact);
} }
#endif /* CONFIG_SYSFS && CONFIG_NUMA */ #endif /* CONFIG_SYSFS && CONFIG_NUMA */
...@@ -1591,9 +1591,9 @@ static void __init hugetlb_sysfs_init(void) ...@@ -1591,9 +1591,9 @@ static void __init hugetlb_sysfs_init(void)
/* /*
* node_hstate/s - associate per node hstate attributes, via their kobjects, * node_hstate/s - associate per node hstate attributes, via their kobjects,
* with node sysdevs in node_devices[] using a parallel array. The array * with node devices in node_devices[] using a parallel array. The array
* index of a node sysdev or _hstate == node id. * index of a node device or _hstate == node id.
* This is here to avoid any static dependency of the node sysdev driver, in * This is here to avoid any static dependency of the node device driver, in
* the base kernel, on the hugetlb module. * the base kernel, on the hugetlb module.
*/ */
struct node_hstate { struct node_hstate {
...@@ -1603,7 +1603,7 @@ struct node_hstate { ...@@ -1603,7 +1603,7 @@ struct node_hstate {
struct node_hstate node_hstates[MAX_NUMNODES]; struct node_hstate node_hstates[MAX_NUMNODES];
/* /*
* A subset of global hstate attributes for node sysdevs * A subset of global hstate attributes for node devices
*/ */
static struct attribute *per_node_hstate_attrs[] = { static struct attribute *per_node_hstate_attrs[] = {
&nr_hugepages_attr.attr, &nr_hugepages_attr.attr,
...@@ -1617,7 +1617,7 @@ static struct attribute_group per_node_hstate_attr_group = { ...@@ -1617,7 +1617,7 @@ static struct attribute_group per_node_hstate_attr_group = {
}; };
/* /*
* kobj_to_node_hstate - lookup global hstate for node sysdev hstate attr kobj. * kobj_to_node_hstate - lookup global hstate for node device hstate attr kobj.
* Returns node id via non-NULL nidp. * Returns node id via non-NULL nidp.
*/ */
static struct hstate *kobj_to_node_hstate(struct kobject *kobj, int *nidp) static struct hstate *kobj_to_node_hstate(struct kobject *kobj, int *nidp)
...@@ -1640,13 +1640,13 @@ static struct hstate *kobj_to_node_hstate(struct kobject *kobj, int *nidp) ...@@ -1640,13 +1640,13 @@ static struct hstate *kobj_to_node_hstate(struct kobject *kobj, int *nidp)
} }
/* /*
* Unregister hstate attributes from a single node sysdev. * Unregister hstate attributes from a single node device.
* No-op if no hstate attributes attached. * No-op if no hstate attributes attached.
*/ */
void hugetlb_unregister_node(struct node *node) void hugetlb_unregister_node(struct node *node)
{ {
struct hstate *h; struct hstate *h;
struct node_hstate *nhs = &node_hstates[node->sysdev.id]; struct node_hstate *nhs = &node_hstates[node->dev.id];
if (!nhs->hugepages_kobj) if (!nhs->hugepages_kobj)
return; /* no hstate attributes */ return; /* no hstate attributes */
...@@ -1662,7 +1662,7 @@ void hugetlb_unregister_node(struct node *node) ...@@ -1662,7 +1662,7 @@ void hugetlb_unregister_node(struct node *node)
} }
/* /*
* hugetlb module exit: unregister hstate attributes from node sysdevs * hugetlb module exit: unregister hstate attributes from node devices
* that have them. * that have them.
*/ */
static void hugetlb_unregister_all_nodes(void) static void hugetlb_unregister_all_nodes(void)
...@@ -1670,7 +1670,7 @@ static void hugetlb_unregister_all_nodes(void) ...@@ -1670,7 +1670,7 @@ static void hugetlb_unregister_all_nodes(void)
int nid; int nid;
/* /*
* disable node sysdev registrations. * disable node device registrations.
*/ */
register_hugetlbfs_with_node(NULL, NULL); register_hugetlbfs_with_node(NULL, NULL);
...@@ -1682,20 +1682,20 @@ static void hugetlb_unregister_all_nodes(void) ...@@ -1682,20 +1682,20 @@ static void hugetlb_unregister_all_nodes(void)
} }
/* /*
* Register hstate attributes for a single node sysdev. * Register hstate attributes for a single node device.
* No-op if attributes already registered. * No-op if attributes already registered.
*/ */
void hugetlb_register_node(struct node *node) void hugetlb_register_node(struct node *node)
{ {
struct hstate *h; struct hstate *h;
struct node_hstate *nhs = &node_hstates[node->sysdev.id]; struct node_hstate *nhs = &node_hstates[node->dev.id];
int err; int err;
if (nhs->hugepages_kobj) if (nhs->hugepages_kobj)
return; /* already allocated */ return; /* already allocated */
nhs->hugepages_kobj = kobject_create_and_add("hugepages", nhs->hugepages_kobj = kobject_create_and_add("hugepages",
&node->sysdev.kobj); &node->dev.kobj);
if (!nhs->hugepages_kobj) if (!nhs->hugepages_kobj)
return; return;
...@@ -1706,7 +1706,7 @@ void hugetlb_register_node(struct node *node) ...@@ -1706,7 +1706,7 @@ void hugetlb_register_node(struct node *node)
if (err) { if (err) {
printk(KERN_ERR "Hugetlb: Unable to add hstate %s" printk(KERN_ERR "Hugetlb: Unable to add hstate %s"
" for node %d\n", " for node %d\n",
h->name, node->sysdev.id); h->name, node->dev.id);
hugetlb_unregister_node(node); hugetlb_unregister_node(node);
break; break;
} }
...@@ -1715,8 +1715,8 @@ void hugetlb_register_node(struct node *node) ...@@ -1715,8 +1715,8 @@ void hugetlb_register_node(struct node *node)
/* /*
* hugetlb init time: register hstate attributes for all registered node * hugetlb init time: register hstate attributes for all registered node
* sysdevs of nodes that have memory. All on-line nodes should have * devices of nodes that have memory. All on-line nodes should have
* registered their associated sysdev by this time. * registered their associated device by this time.
*/ */
static void hugetlb_register_all_nodes(void) static void hugetlb_register_all_nodes(void)
{ {
...@@ -1724,12 +1724,12 @@ static void hugetlb_register_all_nodes(void) ...@@ -1724,12 +1724,12 @@ static void hugetlb_register_all_nodes(void)
for_each_node_state(nid, N_HIGH_MEMORY) { for_each_node_state(nid, N_HIGH_MEMORY) {
struct node *node = &node_devices[nid]; struct node *node = &node_devices[nid];
if (node->sysdev.id == nid) if (node->dev.id == nid)
hugetlb_register_node(node); hugetlb_register_node(node);
} }
/* /*
* Let the node sysdev driver know we're here so it can * Let the node device driver know we're here so it can
* [un]register hstate attributes on node hotplug. * [un]register hstate attributes on node hotplug.
*/ */
register_hugetlbfs_with_node(hugetlb_register_node, register_hugetlbfs_with_node(hugetlb_register_node,
......
...@@ -3475,16 +3475,16 @@ int scan_unevictable_handler(struct ctl_table *table, int write, ...@@ -3475,16 +3475,16 @@ int scan_unevictable_handler(struct ctl_table *table, int write,
* a specified node's per zone unevictable lists for evictable pages. * a specified node's per zone unevictable lists for evictable pages.
*/ */
static ssize_t read_scan_unevictable_node(struct sys_device *dev, static ssize_t read_scan_unevictable_node(struct device *dev,
struct sysdev_attribute *attr, struct device_attribute *attr,
char *buf) char *buf)
{ {
warn_scan_unevictable_pages(); warn_scan_unevictable_pages();
return sprintf(buf, "0\n"); /* always zero; should fit... */ return sprintf(buf, "0\n"); /* always zero; should fit... */
} }
static ssize_t write_scan_unevictable_node(struct sys_device *dev, static ssize_t write_scan_unevictable_node(struct device *dev,
struct sysdev_attribute *attr, struct device_attribute *attr,
const char *buf, size_t count) const char *buf, size_t count)
{ {
warn_scan_unevictable_pages(); warn_scan_unevictable_pages();
...@@ -3492,17 +3492,17 @@ static ssize_t write_scan_unevictable_node(struct sys_device *dev, ...@@ -3492,17 +3492,17 @@ static ssize_t write_scan_unevictable_node(struct sys_device *dev,
} }
static SYSDEV_ATTR(scan_unevictable_pages, S_IRUGO | S_IWUSR, static DEVICE_ATTR(scan_unevictable_pages, S_IRUGO | S_IWUSR,
read_scan_unevictable_node, read_scan_unevictable_node,
write_scan_unevictable_node); write_scan_unevictable_node);
int scan_unevictable_register_node(struct node *node) int scan_unevictable_register_node(struct node *node)
{ {
return sysdev_create_file(&node->sysdev, &attr_scan_unevictable_pages); return device_create_file(&node->dev, &dev_attr_scan_unevictable_pages);
} }
void scan_unevictable_unregister_node(struct node *node) void scan_unevictable_unregister_node(struct node *node)
{ {
sysdev_remove_file(&node->sysdev, &attr_scan_unevictable_pages); device_remove_file(&node->dev, &dev_attr_scan_unevictable_pages);
} }
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment