linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH/RFC] add proc_dir_entry fields to device_node
@ 2003-10-03 16:22 Nathan Lynch
  2003-10-04  7:55 ` Benjamin Herrenschmidt
  0 siblings, 1 reply; 4+ messages in thread
From: Nathan Lynch @ 2003-10-03 16:22 UTC (permalink / raw)
  To: linuxppc-dev

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

Hi-

I am doing some ppc64 work to enable dynamic addition and removal of
nodes in /proc/device-tree.  It seems that recording a node's directory
and symlinks (if any) in the device_node is the easiest way to assure
that a node is cleaned up properly after deletion.

I need to add a few lines to fs/proc/proc_devtree.c::add_node() to
record the proc entries for each node as it is processed.  These will
refer to fields that do not yet exist in ppc's device_node.  I propose
adding these fields to ppc's device_node (patch attached).  If that
comment in prom.h about breaking BootX is still valid, there are
alternatives, but they would likely involve ifdefs and macros.

I have attached the proposed changes in separate patches against linus
2.5 bk.  The proc_devtree patch is for illustration purposes -- the
patch I submit to lkml will make add_node() extern and place its
declaration in the proper header.

Comments?

Nathan

[-- Attachment #2: ppc_device_node.patch --]
[-- Type: text/plain, Size: 680 bytes --]

diff -Nru a/include/asm-ppc/prom.h b/include/asm-ppc/prom.h
--- a/include/asm-ppc/prom.h	Fri Oct  3 10:57:25 2003
+++ b/include/asm-ppc/prom.h	Fri Oct  3 10:57:25 2003
@@ -9,6 +9,7 @@
 #define _PPC_PROM_H

 #include <linux/config.h>
+#include <linux/proc_fs.h>

 typedef void *phandle;
 typedef void *ihandle;
@@ -57,6 +58,9 @@
 	struct	device_node *sibling;
 	struct	device_node *next;	/* next device of same type */
 	struct	device_node *allnext;	/* next in list of all nodes */
+	struct  proc_dir_entry *pde;       /* node's directory */
+	struct  proc_dir_entry *name_link; /* name symlink */
+	struct  proc_dir_entry *addr_link; /* address symlink */
 };

 struct prom_args;

[-- Attachment #3: proc_devtree.patch --]
[-- Type: text/plain, Size: 662 bytes --]

diff -Nru a/fs/proc/proc_devtree.c b/fs/proc/proc_devtree.c
--- a/fs/proc/proc_devtree.c	Fri Oct  3 11:05:05 2003
+++ b/fs/proc/proc_devtree.c	Fri Oct  3 11:05:05 2003
@@ -53,6 +53,7 @@
 	int l;
 	struct proc_dir_entry *list, **lastp, *al;

+	np->pde = de;
 	lastp = &list;
 	for (pp = np->properties; pp != 0; pp = pp->next) {
 		/*
@@ -102,6 +103,7 @@
 			al = proc_symlink(child->name, de, ent->name);
 			if (al == 0)
 				break;
+			child->name_link = al;
 			*lastp = al;
 			lastp = &al->next;
 		}
@@ -112,6 +114,7 @@
 		al = proc_symlink(at, de, ent->name);
 		if (al == 0)
 			break;
+		child->addr_link = al;
 		*lastp = al;
 		lastp = &al->next;
 	}

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH/RFC] add proc_dir_entry fields to device_node
  2003-10-03 16:22 [PATCH/RFC] add proc_dir_entry fields to device_node Nathan Lynch
@ 2003-10-04  7:55 ` Benjamin Herrenschmidt
  2003-10-06 19:12   ` Nathan Lynch
  0 siblings, 1 reply; 4+ messages in thread
From: Benjamin Herrenschmidt @ 2003-10-04  7:55 UTC (permalink / raw)
  To: Nathan Lynch; +Cc: linuxppc-dev list


On Fri, 2003-10-03 at 18:22, Nathan Lynch wrote:
> Hi-
>
> I am doing some ppc64 work to enable dynamic addition and removal of
> nodes in /proc/device-tree.  It seems that recording a node's directory
> and symlinks (if any) in the device_node is the easiest way to assure
> that a node is cleaned up properly after deletion.
>
> I need to add a few lines to fs/proc/proc_devtree.c::add_node() to
> record the proc entries for each node as it is processed.  These will
> refer to fields that do not yet exist in ppc's device_node.  I propose
> adding these fields to ppc's device_node (patch attached).  If that
> comment in prom.h about breaking BootX is still valid, there are
> alternatives, but they would likely involve ifdefs and macros.

The comment is valid. You cannot change the format of struct
device_node on ppc32 without breaking BootX booting :(

The solution to this is to finally break it by having a conversion
step between the BootX-passed device-tree and the in-kernel one

Ben


** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH/RFC] add proc_dir_entry fields to device_node
  2003-10-04  7:55 ` Benjamin Herrenschmidt
@ 2003-10-06 19:12   ` Nathan Lynch
  2003-10-06 19:40     ` Benjamin Herrenschmidt
  0 siblings, 1 reply; 4+ messages in thread
From: Nathan Lynch @ 2003-10-06 19:12 UTC (permalink / raw)
  To: Benjamin Herrenschmidt; +Cc: linuxppc-dev list

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

> The comment is valid. You cannot change the format of struct
> device_node on ppc32 without breaking BootX booting :(
>
> The solution to this is to finally break it by having a conversion
> step between the BootX-passed device-tree and the in-kernel one

What about something like this as a short term solution?  The ppc64
versions of the macros would store the proc_dir_entry pointers in the
device nodes as they are added, e.g.

#define set_node_proc_entry(node,entry) node->pde = entry
#define set_node_name_link(node,entry) node->name_link = entry
#define set_node_addr_link(node,entry) node->addr_link = entry

while the ppc versions are no-ops.  This would preserve source
compatibility while keeping us from breaking BootX.

Separate patches against kernel.org 2.6.0-test6 attached.

Nathan

[-- Attachment #2: proc_devtree.patch --]
[-- Type: text/plain, Size: 714 bytes --]

diff -ur a/fs/proc/proc_devtree.c b/fs/proc/proc_devtree.c
--- a/fs/proc/proc_devtree.c	2003-09-27 19:50:38.000000000 -0500
+++ b/fs/proc/proc_devtree.c	2003-10-06 12:46:21.000000000 -0500
@@ -53,6 +53,7 @@
 	int l;
 	struct proc_dir_entry *list, **lastp, *al;

+	set_node_proc_entry(np, de);
 	lastp = &list;
 	for (pp = np->properties; pp != 0; pp = pp->next) {
 		/*
@@ -102,6 +103,7 @@
 			al = proc_symlink(child->name, de, ent->name);
 			if (al == 0)
 				break;
+			set_node_name_link(child, al);
 			*lastp = al;
 			lastp = &al->next;
 		}
@@ -112,6 +114,7 @@
 		al = proc_symlink(at, de, ent->name);
 		if (al == 0)
 			break;
+		set_node_addr_link(child, al);
 		*lastp = al;
 		lastp = &al->next;
 	}

[-- Attachment #3: ppc_device_node.patch --]
[-- Type: text/plain, Size: 552 bytes --]

diff -ur a/include/asm-ppc/prom.h b/include/asm-ppc/prom.h
--- a/include/asm-ppc/prom.h	2003-09-27 19:50:38.000000000 -0500
+++ b/include/asm-ppc/prom.h	2003-10-06 12:43:12.000000000 -0500
@@ -59,6 +59,11 @@
 	struct	device_node *allnext;	/* next in list of all nodes */
 };

+/* for compatibility with ppc64 */
+#define set_node_proc_entry(node,entry) do { } while(0)
+#define set_node_name_link(node,entry) do { } while(0)
+#define set_node_addr_link(node,entry) do { } while(0)
+
 struct prom_args;
 typedef void (*prom_entry)(struct prom_args *);


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH/RFC] add proc_dir_entry fields to device_node
  2003-10-06 19:12   ` Nathan Lynch
@ 2003-10-06 19:40     ` Benjamin Herrenschmidt
  0 siblings, 0 replies; 4+ messages in thread
From: Benjamin Herrenschmidt @ 2003-10-06 19:40 UTC (permalink / raw)
  To: Nathan Lynch; +Cc: linuxppc-dev list


> while the ppc versions are no-ops.  This would preserve source
> compatibility while keeping us from breaking BootX.
>
> Separate patches against kernel.org 2.6.0-test6 attached.

go on. I don't have much time to work on this right now. I hope
I'll be able to move us away from BootX format later this year

Ben.


** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2003-10-06 19:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-10-03 16:22 [PATCH/RFC] add proc_dir_entry fields to device_node Nathan Lynch
2003-10-04  7:55 ` Benjamin Herrenschmidt
2003-10-06 19:12   ` Nathan Lynch
2003-10-06 19:40     ` Benjamin Herrenschmidt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).