From patchwork Wed Jul 18 10:11:14 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yasuaki Ishimatsu X-Patchwork-Id: 171630 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from ozlabs.org (localhost [IPv6:::1]) by ozlabs.org (Postfix) with ESMTP id 30A162C1009 for ; Wed, 18 Jul 2012 20:13:24 +1000 (EST) Received: from fgwmail6.fujitsu.co.jp (fgwmail6.fujitsu.co.jp [192.51.44.36]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 87AA12C0E30 for ; Wed, 18 Jul 2012 20:12:42 +1000 (EST) Received: from m4.gw.fujitsu.co.jp (unknown [10.0.50.74]) by fgwmail6.fujitsu.co.jp (Postfix) with ESMTP id D36E33EE0C1 for ; Wed, 18 Jul 2012 19:12:40 +0900 (JST) Received: from smail (m4 [127.0.0.1]) by outgoing.m4.gw.fujitsu.co.jp (Postfix) with ESMTP id E2BE645DE7C for ; Wed, 18 Jul 2012 19:12:39 +0900 (JST) Received: from s4.gw.fujitsu.co.jp (s4.gw.fujitsu.co.jp [10.0.50.94]) by m4.gw.fujitsu.co.jp (Postfix) with ESMTP id BDF5F45DE8D for ; Wed, 18 Jul 2012 19:12:36 +0900 (JST) Received: from s4.gw.fujitsu.co.jp (localhost.localdomain [127.0.0.1]) by s4.gw.fujitsu.co.jp (Postfix) with ESMTP id D4079EF803E for ; Wed, 18 Jul 2012 19:11:33 +0900 (JST) Received: from g01jpexchyt10.g01.fujitsu.local (g01jpexchyt10.g01.fujitsu.local [10.128.194.49]) by s4.gw.fujitsu.co.jp (Postfix) with ESMTP id 830B3EF803A for ; Wed, 18 Jul 2012 19:11:33 +0900 (JST) Received: from [127.0.0.1] (10.124.101.33) by g01jpexchyt10.g01.fujitsu.local (10.128.194.49) with Microsoft SMTP Server id 14.2.309.2; Wed, 18 Jul 2012 19:11:30 +0900 X-SecurityPolicyCheck: OK by SHieldMailChecker v1.7.4 Message-ID: <50068BC2.3040303@jp.fujitsu.com> Date: Wed, 18 Jul 2012 19:11:14 +0900 From: Yasuaki Ishimatsu User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:13.0) Gecko/20120614 Thunderbird/13.0.1 MIME-Version: 1.0 To: , , , Subject: [RFC PATCH v4 6/13] memory-hotplug : add memory_block_release References: <50068974.1070409@jp.fujitsu.com> In-Reply-To: <50068974.1070409@jp.fujitsu.com> Cc: len.brown@intel.com, wency@cn.fujitsu.com, paulus@samba.org, minchan.kim@gmail.com, kosaki.motohiro@jp.fujitsu.com, rientjes@google.com, cl@linux.com, akpm@linux-foundation.org, liuj97@gmail.com X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" When calling remove_memory_block(), the function shows following message at device_release(). Device 'memory528' does not have a release() function, it is broken and must be fixed. remove_memory_block() calls kfree(mem). I think it shouled be called from device_release(). So the patch implements memory_block_release() CC: David Rientjes CC: Jiang Liu CC: Len Brown CC: Benjamin Herrenschmidt CC: Paul Mackerras CC: Christoph Lameter Cc: Minchan Kim CC: Andrew Morton CC: KOSAKI Motohiro CC: Wen Congyang Signed-off-by: Yasuaki Ishimatsu --- drivers/base/memory.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) Index: linux-3.5-rc6/drivers/base/memory.c =================================================================== --- linux-3.5-rc6.orig/drivers/base/memory.c 2012-07-18 17:50:49.659368740 +0900 +++ linux-3.5-rc6/drivers/base/memory.c 2012-07-18 17:51:28.655881214 +0900 @@ -109,6 +109,15 @@ bool is_memblk_offline(unsigned long sta } EXPORT_SYMBOL(is_memblk_offline); +#define to_memory_block(device) container_of(device, struct memory_block, dev) + +static void release_memory_block(struct device *dev) +{ + struct memory_block *mem = to_memory_block(dev); + + kfree(mem); +} + /* * register_memory - Setup a sysfs device for a memory block */ @@ -119,6 +128,7 @@ int register_memory(struct memory_block memory->dev.bus = &memory_subsys; memory->dev.id = memory->start_section_nr / sections_per_block; + memory->dev.release = release_memory_block; error = device_register(&memory->dev); return error; @@ -669,7 +679,6 @@ int remove_memory_block(unsigned long no mem_remove_simple_file(mem, phys_device); mem_remove_simple_file(mem, removable); unregister_memory(mem); - kfree(mem); } else kobject_put(&mem->dev.kobj);