lkml.org 
[lkml]   [2012]   [Dec]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[RFC PATCH 10/11] cpu: Update sysfs cpu/online for hotplug framework
Date
Changed store_online() to request a cpu online or offline
operation by calling hp_submit_req(). It sets a target cpu
device information with hp_add_dev_info() before making the
request.

Signed-off-by: Toshi Kani <toshi.kani@hp.com>
---
drivers/base/cpu.c | 40 ++++++++++++++++++++++++++++------------
1 file changed, 28 insertions(+), 12 deletions(-)

diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c
index 3870231..dc50d17 100644
--- a/drivers/base/cpu.c
+++ b/drivers/base/cpu.c
@@ -41,27 +41,43 @@ static ssize_t __ref store_online(struct device *dev,
const char *buf, size_t count)
{
struct cpu *cpu = container_of(dev, struct cpu, dev);
- ssize_t ret;
+ struct hp_request *hp_req;
+ struct hp_device *hp_dev;
+ enum hp_operation operation;
+ ssize_t ret = count;

- cpu_hotplug_driver_lock();
switch (buf[0]) {
case '0':
- ret = cpu_down(cpu->dev.id);
- if (!ret)
- kobject_uevent(&dev->kobj, KOBJ_OFFLINE);
+ operation = HP_ONLINE_DEL;
break;
case '1':
- ret = cpu_up(cpu->dev.id);
- if (!ret)
- kobject_uevent(&dev->kobj, KOBJ_ONLINE);
+ operation = HP_ONLINE_ADD;
break;
default:
- ret = -EINVAL;
+ return -EINVAL;
+ }
+
+ hp_req = hp_alloc_request(operation);
+ if (!hp_req)
+ return -ENOMEM;
+
+ hp_dev = kzalloc(sizeof(*hp_dev), GFP_KERNEL);
+ if (!hp_dev) {
+ kfree(hp_req);
+ return -ENOMEM;
+ }
+
+ hp_dev->device = dev;
+ hp_dev->class = HP_CLS_CPU;
+ hp_dev->data.cpu.cpu_id = cpu->dev.id;
+ hp_add_dev_info(hp_req, hp_dev);
+
+ if (hp_submit_req(hp_req)) {
+ kfree(hp_dev);
+ kfree(hp_req);
+ return -EINVAL;
}
- cpu_hotplug_driver_unlock();

- if (ret >= 0)
- ret = count;
return ret;
}
static DEVICE_ATTR(online, 0644, show_online, store_online);
--
1.7.11.7


\
 
 \ /
  Last update: 2012-12-13 02:01    [W:0.083 / U:1.336 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site