All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] change memoryX->phys_device from number to symlink [2/2] acpi func
@ 2006-02-17  6:45 KAMEZAWA Hiroyuki
  0 siblings, 0 replies; only message in thread
From: KAMEZAWA Hiroyuki @ 2006-02-17  6:45 UTC (permalink / raw)
  To: Linux Kernel Mailing List; +Cc: Dave Hansen, gregkh, lhms, Yasunori Goto

[-- Attachment #1: Type: text/plain, Size: 0 bytes --]



[-- Attachment #2: physdevice_symlink_02.patch --]
[-- Type: text/x-patch, Size: 2611 bytes --]

This patch add phys_device symbolic link support to acpi memory hotplug.
This will help shell script for memory hotplug.

example)
%readlink /sys/devices/system/memory/memory10/phys_device
../../../../firmware/acpi/namespace/ACPI/_SB/LSB1/MEM3


Signed-Off-By: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>


Index: testtree/drivers/acpi/acpi_memhotplug.c
===================================================================
--- testtree.orig/drivers/acpi/acpi_memhotplug.c	2006-02-17 15:07:53.000000000 +0900
+++ testtree/drivers/acpi/acpi_memhotplug.c	2006-02-17 15:08:30.000000000 +0900
@@ -30,6 +30,7 @@
 #include <linux/init.h>
 #include <linux/types.h>
 #include <linux/memory_hotplug.h>
+#include <linux/memory.h>
 #include <acpi/acpi_drivers.h>
 
 #define ACPI_MEMORY_DEVICE_COMPONENT		0x08000000UL
@@ -180,6 +181,19 @@
 	return_VALUE(0);
 }
 
+static acpi_status acpi_memory_link_name(struct acpi_memory_device *mem_device)
+{
+	struct acpi_device *device = NULL;
+	acpi_status status;
+	int ret;
+	status = acpi_bus_get_device(mem_device->handle, &device);
+	if (ACPI_FAILURE(status))
+		return status;
+	ret = attach_device_to_memsection(mem_device->start_addr,
+					mem_device->end_addr, &device->kobj);
+	return_VALUE(ret);
+}
+
 static int acpi_memory_enable_device(struct acpi_memory_device *mem_device)
 {
 	int result;
@@ -206,7 +220,8 @@
 		mem_device->state = MEMORY_INVALID_STATE;
 		return result;
 	}
-
+	/* link to /sys/devices/system/memory/memoryX  */
+	result = acpi_memory_link_name(mem_device);
 	return result;
 }
 
@@ -471,6 +486,22 @@
 	return_ACPI_STATUS(status);
 }
 
+static acpi_status __init acpi_memory_link_name_cb(acpi_handle handle, u32 level,
+						  void *ctxt, void **retv)
+{
+	acpi_status status;
+	struct acpi_memory_device *mem_device;
+	status = is_memory_device(handle);
+	if (ACPI_FAILURE(status))
+		return_ACPI_STATUS(AE_OK); /* continue */
+	if (acpi_memory_get_device(handle, &mem_device)) {
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
+				  "Error in finding driver data\n"));
+		return_ACPI_STATUS(AE_OK); /* continue */
+	}
+	return acpi_memory_link_name(mem_device);
+}
+
 static int __init acpi_memory_device_init(void)
 {
 	int result;
@@ -494,6 +525,16 @@
 		return_VALUE(-ENODEV);
 	}
 
+	status = acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
+				     ACPI_UINT32_MAX,
+				     acpi_memory_link_name_cb,
+				     NULL, NULL);
+	if (ACPI_FAILURE(status)) {
+		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "walk_namespace failed\n"));
+		acpi_bus_unregister_driver(&acpi_memory_device_driver);
+		return_VALUE(-ENODEV);
+	}
+
 	return_VALUE(0);
 }
 

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2006-02-17  6:45 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-02-17  6:45 [PATCH] change memoryX->phys_device from number to symlink [2/2] acpi func KAMEZAWA Hiroyuki

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.