From patchwork Wed Dec 12 23:17:22 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Toshi Kani X-Patchwork-Id: 1870891 Return-Path: X-Original-To: patchwork-linux-acpi@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id E6D8540DEA for ; Wed, 12 Dec 2012 23:28:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755339Ab2LLX2G (ORCPT ); Wed, 12 Dec 2012 18:28:06 -0500 Received: from g5t0009.atlanta.hp.com ([15.192.0.46]:7656 "EHLO g5t0009.atlanta.hp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755267Ab2LLX1f (ORCPT ); Wed, 12 Dec 2012 18:27:35 -0500 Received: from g5t0029.atlanta.hp.com (g5t0029.atlanta.hp.com [16.228.8.141]) by g5t0009.atlanta.hp.com (Postfix) with ESMTP id 737D3301C6; Wed, 12 Dec 2012 23:27:35 +0000 (UTC) Received: from misato.fc.hp.com (misato.fc.hp.com [16.71.12.41]) by g5t0029.atlanta.hp.com (Postfix) with ESMTP id 98F63201A3; Wed, 12 Dec 2012 23:27:34 +0000 (UTC) From: Toshi Kani To: rjw@sisk.pl, lenb@kernel.org, gregkh@linuxfoundation.org, akpm@linux-foundation.org Cc: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, bhelgaas@google.com, isimatu.yasuaki@jp.fujitsu.com, jiang.liu@huawei.com, wency@cn.fujitsu.com, guohanjun@huawei.com, yinghai@kernel.org, srivatsa.bhat@linux.vnet.ibm.com, Toshi Kani Subject: [RFC PATCH 10/11] cpu: Update sysfs cpu/online for hotplug framework Date: Wed, 12 Dec 2012 16:17:22 -0700 Message-Id: <1355354243-18657-11-git-send-email-toshi.kani@hp.com> X-Mailer: git-send-email 1.7.11.7 In-Reply-To: <1355354243-18657-1-git-send-email-toshi.kani@hp.com> References: <1355354243-18657-1-git-send-email-toshi.kani@hp.com> Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org 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 --- 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);