From patchwork Thu Nov 8 18:29:31 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasilis Liaskovitis X-Patchwork-Id: 1716851 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 42B643FCDE for ; Thu, 8 Nov 2012 18:30:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756626Ab2KHS3o (ORCPT ); Thu, 8 Nov 2012 13:29:44 -0500 Received: from mail-bk0-f46.google.com ([209.85.214.46]:61253 "EHLO mail-bk0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756623Ab2KHS3n (ORCPT ); Thu, 8 Nov 2012 13:29:43 -0500 Received: by mail-bk0-f46.google.com with SMTP id jk13so1346643bkc.19 for ; Thu, 08 Nov 2012 10:29:42 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=UemZS5t1XvnAn8l6rL8olJnJv+urjELfRKQQ36cbXiE=; b=hHzOSL/56QWfpcgOw1+qL8Ie+xNFp8DjfzY79A2e9ovfq0sa/vuOiUL5aK1VkzQ+Th 4pEZ2IgftxUJ5YyCUakTKLF32/AgDuW3khQ1pvpyeNWXvNNn3x5H1b2jcRCPKn1sTLW9 KJu5mbUFegeBOadKul8Xn5Wch+Vzi59EcV0S9SuGC9vRBSYK/lYhssA2FdFe9GRq2Z8I uI9pMaXUtr5NQP7R8XTmGFTrbVZpvWNhn33qNdpQiuZLsutsCt6mpwM5sulFWK//8Kwh aUzQ72Rn/Z1hycULA/9a5T+pWpdEqPyqCP57i9BXqVEm0N9E2iAjL8EIi3x3Is1SMAXH kSDw== Received: by 10.204.130.21 with SMTP id q21mr2580010bks.5.1352399382340; Thu, 08 Nov 2012 10:29:42 -0800 (PST) Received: from dhcp-192-168-178-175.ri.profitbricks.localdomain ([62.217.45.26]) by mx.google.com with ESMTPS id z22sm17670961bkw.2.2012.11.08.10.29.40 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 08 Nov 2012 10:29:41 -0800 (PST) From: Vasilis Liaskovitis To: linux-acpi@vger.kernel.org, isimatu.yasuaki@jp.fujitsu.com Cc: rjw@sisk.pl, wency@cn.fujitsu.com, lenb@kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, linux-mm@kvack.org, Vasilis Liaskovitis Subject: [RFC PATCH 3/3] acpi_memhotplug: Add prepare_remove operation Date: Thu, 8 Nov 2012 19:29:31 +0100 Message-Id: <1352399371-8015-4-git-send-email-vasilis.liaskovitis@profitbricks.com> X-Mailer: git-send-email 1.7.9 In-Reply-To: <1352399371-8015-1-git-send-email-vasilis.liaskovitis@profitbricks.com> References: <1352399371-8015-1-git-send-email-vasilis.liaskovitis@profitbricks.com> X-Gm-Message-State: ALoCoQlw4Dn2wdXSEcgahK54UkPq+1gJd2q5vyHcrKpEzD257h8FRJFoXv/0K+9CjAH+bFQrQNLT Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Offlining and removal of memory is now done in the prepare_remove callback, not in the remove callback. Signed-off-by: Vasilis Liaskovitis --- drivers/acpi/acpi_memhotplug.c | 22 ++++++++++++++++++++-- 1 files changed, 20 insertions(+), 2 deletions(-) diff --git a/drivers/acpi/acpi_memhotplug.c b/drivers/acpi/acpi_memhotplug.c index 7fcc844..9b734a5 100644 --- a/drivers/acpi/acpi_memhotplug.c +++ b/drivers/acpi/acpi_memhotplug.c @@ -54,6 +54,7 @@ MODULE_LICENSE("GPL"); static int acpi_memory_device_add(struct acpi_device *device); static int acpi_memory_device_remove(struct acpi_device *device, int type); +static int acpi_memory_device_prepare_remove(struct acpi_device *device); static const struct acpi_device_id memory_device_ids[] = { {ACPI_MEMORY_DEVICE_HID, 0}, @@ -68,6 +69,7 @@ static struct acpi_driver acpi_memory_device_driver = { .ops = { .add = acpi_memory_device_add, .remove = acpi_memory_device_remove, + .prepare_remove = acpi_memory_device_prepare_remove, }, }; @@ -499,6 +501,20 @@ static int acpi_memory_device_add(struct acpi_device *device) static int acpi_memory_device_remove(struct acpi_device *device, int type) { struct acpi_memory_device *mem_device = NULL; + + if (!device || !acpi_driver_data(device)) + return -EINVAL; + + mem_device = acpi_driver_data(device); + + kfree(mem_device); + + return 0; +} + +static int acpi_memory_device_prepare_remove(struct acpi_device *device) +{ + struct acpi_memory_device *mem_device = NULL; int result; if (!device || !acpi_driver_data(device)) @@ -506,12 +522,14 @@ static int acpi_memory_device_remove(struct acpi_device *device, int type) mem_device = acpi_driver_data(device); + /* + * offline and remove memory only when the memory device is + * ejected. + */ result = acpi_memory_remove_memory(mem_device); if (result) return result; - kfree(mem_device); - return 0; }