projects
/
powerpc.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
libata: straighten out ATA_ID_* constants
[powerpc.git]
/
drivers
/
base
/
memory.c
diff --git
a/drivers/base/memory.c
b/drivers/base/memory.c
index
bc3ca6a
..
74b9679
100644
(file)
--- a/
drivers/base/memory.c
+++ b/
drivers/base/memory.c
@@
-13,8
+13,8
@@
#include <linux/sysdev.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/sysdev.h>
#include <linux/module.h>
#include <linux/init.h>
-#include <linux/sched.h> /* capable() */
#include <linux/topology.h>
#include <linux/topology.h>
+#include <linux/capability.h>
#include <linux/device.h>
#include <linux/memory.h>
#include <linux/kobject.h>
#include <linux/device.h>
#include <linux/memory.h>
#include <linux/kobject.h>
@@
-29,12
+29,12
@@
static struct sysdev_class memory_sysdev_class = {
set_kset_name(MEMORY_CLASS_NAME),
};
set_kset_name(MEMORY_CLASS_NAME),
};
-static c
har *memory_hotplug
_name(struct kset *kset, struct kobject *kobj)
+static c
onst char *memory_uevent
_name(struct kset *kset, struct kobject *kobj)
{
return MEMORY_CLASS_NAME;
}
{
return MEMORY_CLASS_NAME;
}
-static int memory_
hotplug
(struct kset *kset, struct kobject *kobj, char **envp,
+static int memory_
uevent
(struct kset *kset, struct kobject *kobj, char **envp,
int num_envp, char *buffer, int buffer_size)
{
int retval = 0;
int num_envp, char *buffer, int buffer_size)
{
int retval = 0;
@@
-42,28
+42,27
@@
static int memory_hotplug(struct kset *kset, struct kobject *kobj, char **envp,
return retval;
}
return retval;
}
-static struct kset_
hotplug_ops memory_hotplug
_ops = {
- .name = memory_
hotplug
_name,
- .
hotplug = memory_hotplug
,
+static struct kset_
uevent_ops memory_uevent
_ops = {
+ .name = memory_
uevent
_name,
+ .
uevent = memory_uevent
,
};
};
-static
struct notifier_block *memory_chain
;
+static
BLOCKING_NOTIFIER_HEAD(memory_chain)
;
-
static
int register_memory_notifier(struct notifier_block *nb)
+int register_memory_notifier(struct notifier_block *nb)
{
{
- return notifier_chain_register(&memory_chain, nb);
+ return
blocking_
notifier_chain_register(&memory_chain, nb);
}
}
-
static
void unregister_memory_notifier(struct notifier_block *nb)
+void unregister_memory_notifier(struct notifier_block *nb)
{
{
- notifier_chain_unregister(&memory_chain, nb);
+
blocking_
notifier_chain_unregister(&memory_chain, nb);
}
/*
* register_memory - Setup a sysfs device for a memory block
*/
}
/*
* register_memory - Setup a sysfs device for a memory block
*/
-static int
-register_memory(struct memory_block *memory, struct mem_section *section,
+int register_memory(struct memory_block *memory, struct mem_section *section,
struct node *root)
{
int error;
struct node *root)
{
int error;
@@
-141,7
+140,7
@@
static ssize_t show_mem_state(struct sys_device *dev, char *buf)
static inline int memory_notify(unsigned long val, void *v)
{
static inline int memory_notify(unsigned long val, void *v)
{
- return notifier_call_chain(&memory_chain, val, v);
+ return
blocking_
notifier_call_chain(&memory_chain, val, v);
}
/*
}
/*
@@
-291,9
+290,8
@@
static CLASS_ATTR(block_size_bytes, 0444, print_block_size, NULL);
static int block_size_init(void)
{
static int block_size_init(void)
{
- sysfs_create_file(&memory_sysdev_class.kset.kobj,
- &class_attr_block_size_bytes.attr);
- return 0;
+ return sysfs_create_file(&memory_sysdev_class.kset.kobj,
+ &class_attr_block_size_bytes.attr);
}
/*
}
/*
@@
-304,14
+302,16
@@
static int block_size_init(void)
*/
#ifdef CONFIG_ARCH_MEMORY_PROBE
static ssize_t
*/
#ifdef CONFIG_ARCH_MEMORY_PROBE
static ssize_t
-memory_probe_store(struct class *class, const char
__user
*buf, size_t count)
+memory_probe_store(struct class *class, const char *buf, size_t count)
{
u64 phys_addr;
{
u64 phys_addr;
+ int nid;
int ret;
phys_addr = simple_strtoull(buf, NULL, 0);
int ret;
phys_addr = simple_strtoull(buf, NULL, 0);
- ret = add_memory(phys_addr, PAGES_PER_SECTION << PAGE_SHIFT);
+ nid = memory_add_physaddr_to_nid(phys_addr);
+ ret = add_memory(nid, phys_addr, PAGES_PER_SECTION << PAGE_SHIFT);
if (ret)
count = ret;
if (ret)
count = ret;
@@
-322,12
+322,14
@@
static CLASS_ATTR(probe, 0700, NULL, memory_probe_store);
static int memory_probe_init(void)
{
static int memory_probe_init(void)
{
- sysfs_create_file(&memory_sysdev_class.kset.kobj,
- &class_attr_probe.attr);
- return 0;
+ return sysfs_create_file(&memory_sysdev_class.kset.kobj,
+ &class_attr_probe.attr);
}
#else
}
#else
-#define memory_probe_init(...) do {} while (0)
+static inline int memory_probe_init(void)
+{
+ return 0;
+}
#endif
/*
#endif
/*
@@
-430,9
+432,12
@@
int __init memory_dev_init(void)
{
unsigned int i;
int ret;
{
unsigned int i;
int ret;
+ int err;
- memory_sysdev_class.kset.
hotplug_ops = &memory_hotplug
_ops;
+ memory_sysdev_class.kset.
uevent_ops = &memory_uevent
_ops;
ret = sysdev_class_register(&memory_sysdev_class);
ret = sysdev_class_register(&memory_sysdev_class);
+ if (ret)
+ goto out;
/*
* Create entries for memory sections that were found
/*
* Create entries for memory sections that were found
@@
-441,11
+446,19
@@
int __init memory_dev_init(void)
for (i = 0; i < NR_MEM_SECTIONS; i++) {
if (!valid_section_nr(i))
continue;
for (i = 0; i < NR_MEM_SECTIONS; i++) {
if (!valid_section_nr(i))
continue;
- add_memory_block(0, __nr_to_section(i), MEM_ONLINE, 0);
+ err = add_memory_block(0, __nr_to_section(i), MEM_ONLINE, 0);
+ if (!ret)
+ ret = err;
}
}
- memory_probe_init();
- block_size_init();
-
+ err = memory_probe_init();
+ if (!ret)
+ ret = err;
+ err = block_size_init();
+ if (!ret)
+ ret = err;
+out:
+ if (ret)
+ printk(KERN_ERR "%s() failed: %d\n", __FUNCTION__, ret);
return ret;
}
return ret;
}