[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>
This commit is contained in:
committed by
Linus Torvalds
parent
515decdccf
commit
a04ee14636
@@ -64,6 +64,11 @@ static int openpromfs_readdir(struct file *, void *, filldir_t);
|
|||||||
static struct dentry *openpromfs_lookup(struct inode *, struct dentry *dentry, struct nameidata *nd);
|
static struct dentry *openpromfs_lookup(struct inode *, struct dentry *dentry, struct nameidata *nd);
|
||||||
static int openpromfs_unlink (struct inode *, struct dentry *dentry);
|
static int openpromfs_unlink (struct inode *, struct dentry *dentry);
|
||||||
|
|
||||||
|
static inline u16 ptr_nod(void *p)
|
||||||
|
{
|
||||||
|
return (long)p & 0xFFFF;
|
||||||
|
}
|
||||||
|
|
||||||
static ssize_t nodenum_read(struct file *file, char __user *buf,
|
static ssize_t nodenum_read(struct file *file, char __user *buf,
|
||||||
size_t count, loff_t *ppos)
|
size_t count, loff_t *ppos)
|
||||||
{
|
{
|
||||||
@@ -95,9 +100,9 @@ static ssize_t property_read(struct file *filp, char __user *buf,
|
|||||||
char buffer[64];
|
char buffer[64];
|
||||||
|
|
||||||
if (!filp->private_data) {
|
if (!filp->private_data) {
|
||||||
node = nodes[(u16)((long)inode->u.generic_ip)].node;
|
node = nodes[ptr_nod(inode->u.generic_ip)].node;
|
||||||
i = ((u32)(long)inode->u.generic_ip) >> 16;
|
i = ((u32)(long)inode->u.generic_ip) >> 16;
|
||||||
if ((u16)((long)inode->u.generic_ip) == aliases) {
|
if (ptr_nod(inode->u.generic_ip) == aliases) {
|
||||||
if (i >= aliases_nodes)
|
if (i >= aliases_nodes)
|
||||||
p = NULL;
|
p = NULL;
|
||||||
else
|
else
|
||||||
@@ -111,7 +116,7 @@ static ssize_t property_read(struct file *filp, char __user *buf,
|
|||||||
return -EIO;
|
return -EIO;
|
||||||
i = prom_getproplen (node, p);
|
i = prom_getproplen (node, p);
|
||||||
if (i < 0) {
|
if (i < 0) {
|
||||||
if ((u16)((long)inode->u.generic_ip) == aliases)
|
if (ptr_nod(inode->u.generic_ip) == aliases)
|
||||||
i = 0;
|
i = 0;
|
||||||
else
|
else
|
||||||
return -EIO;
|
return -EIO;
|
||||||
@@ -540,8 +545,8 @@ int property_release (struct inode *inode, struct file *filp)
|
|||||||
if (!op)
|
if (!op)
|
||||||
return 0;
|
return 0;
|
||||||
lock_kernel();
|
lock_kernel();
|
||||||
node = nodes[(u16)((long)inode->u.generic_ip)].node;
|
node = nodes[ptr_nod(inode->u.generic_ip)].node;
|
||||||
if ((u16)((long)inode->u.generic_ip) == aliases) {
|
if (ptr_nod(inode->u.generic_ip) == aliases) {
|
||||||
if ((op->flag & OPP_DIRTY) && (op->flag & OPP_STRING)) {
|
if ((op->flag & OPP_DIRTY) && (op->flag & OPP_STRING)) {
|
||||||
char *p = op->name;
|
char *p = op->name;
|
||||||
int i = (op->value - op->name) - strlen (op->name) - 1;
|
int i = (op->value - op->name) - strlen (op->name) - 1;
|
||||||
|
Reference in New Issue
Block a user