diff options
author | Jan Engelhardt <jengelh@gmx.de> | 2006-06-25 08:47:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-06-25 13:01:05 -0400 |
commit | a04ee14636fa339c4609766bd6173629d4f9026e (patch) | |
tree | 2a0e960d35f9cc586d128578adbf4a11aac45e40 /fs/openpromfs | |
parent | 515decdccf81cfbf5273d7f0085aea954ecd26c4 (diff) |
[PATCH] openpromfs: factorize out
"Move" "common code" out to PTR_NOD, which does the conversion from private
pointer to node number. This is to reduce potential casting/conversion errors
due to redundancy. (The naming PTR_NOD follows PTR_ERR, turning a pointer
into xyz.)
[akpm@osdl.org: cleanups]
Signed-off-by: Jan Engelhardt <jengelh@gmx.de>
Cc: "David S. Miller" <davem@davemloft.net>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'fs/openpromfs')
-rw-r--r-- | fs/openpromfs/inode.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/fs/openpromfs/inode.c b/fs/openpromfs/inode.c index 3bd2eeccb2ad..efc7c91128af 100644 --- a/fs/openpromfs/inode.c +++ b/fs/openpromfs/inode.c | |||
@@ -64,6 +64,11 @@ static int openpromfs_readdir(struct file *, void *, filldir_t); | |||
64 | static struct dentry *openpromfs_lookup(struct inode *, struct dentry *dentry, struct nameidata *nd); | 64 | static struct dentry *openpromfs_lookup(struct inode *, struct dentry *dentry, struct nameidata *nd); |
65 | static int openpromfs_unlink (struct inode *, struct dentry *dentry); | 65 | static int openpromfs_unlink (struct inode *, struct dentry *dentry); |
66 | 66 | ||
67 | static inline u16 ptr_nod(void *p) | ||
68 | { | ||
69 | return (long)p & 0xFFFF; | ||
70 | } | ||
71 | |||
67 | static ssize_t nodenum_read(struct file *file, char __user *buf, | 72 | static ssize_t nodenum_read(struct file *file, char __user *buf, |
68 | size_t count, loff_t *ppos) | 73 | size_t count, loff_t *ppos) |
69 | { | 74 | { |
@@ -95,9 +100,9 @@ static ssize_t property_read(struct file *filp, char __user *buf, | |||
95 | char buffer[64]; | 100 | char buffer[64]; |
96 | 101 | ||
97 | if (!filp->private_data) { | 102 | if (!filp->private_data) { |
98 | node = nodes[(u16)((long)inode->u.generic_ip)].node; | 103 | node = nodes[ptr_nod(inode->u.generic_ip)].node; |
99 | i = ((u32)(long)inode->u.generic_ip) >> 16; | 104 | i = ((u32)(long)inode->u.generic_ip) >> 16; |
100 | if ((u16)((long)inode->u.generic_ip) == aliases) { | 105 | if (ptr_nod(inode->u.generic_ip) == aliases) { |
101 | if (i >= aliases_nodes) | 106 | if (i >= aliases_nodes) |
102 | p = NULL; | 107 | p = NULL; |
103 | else | 108 | else |
@@ -111,7 +116,7 @@ static ssize_t property_read(struct file *filp, char __user *buf, | |||
111 | return -EIO; | 116 | return -EIO; |
112 | i = prom_getproplen (node, p); | 117 | i = prom_getproplen (node, p); |
113 | if (i < 0) { | 118 | if (i < 0) { |
114 | if ((u16)((long)inode->u.generic_ip) == aliases) | 119 | if (ptr_nod(inode->u.generic_ip) == aliases) |
115 | i = 0; | 120 | i = 0; |
116 | else | 121 | else |
117 | return -EIO; | 122 | return -EIO; |
@@ -540,8 +545,8 @@ int property_release (struct inode *inode, struct file *filp) | |||
540 | if (!op) | 545 | if (!op) |
541 | return 0; | 546 | return 0; |
542 | lock_kernel(); | 547 | lock_kernel(); |
543 | node = nodes[(u16)((long)inode->u.generic_ip)].node; | 548 | node = nodes[ptr_nod(inode->u.generic_ip)].node; |
544 | if ((u16)((long)inode->u.generic_ip) == aliases) { | 549 | if (ptr_nod(inode->u.generic_ip) == aliases) { |
545 | if ((op->flag & OPP_DIRTY) && (op->flag & OPP_STRING)) { | 550 | if ((op->flag & OPP_DIRTY) && (op->flag & OPP_STRING)) { |
546 | char *p = op->name; | 551 | char *p = op->name; |
547 | int i = (op->value - op->name) - strlen (op->name) - 1; | 552 | int i = (op->value - op->name) - strlen (op->name) - 1; |