[PATCH 08/12] devfs: only check for ioctl function when needed

Sascha Hauer s.hauer at pengutronix.de
Mon Jul 5 09:16:31 EDT 2010


Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 fs/devfs.c |   15 +++++++--------
 1 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/fs/devfs.c b/fs/devfs.c
index 9ce9117..7019c8d 100644
--- a/fs/devfs.c
+++ b/fs/devfs.c
@@ -193,6 +193,8 @@ static int partition_ioctl(struct cdev *cdev, int request, void *buf)
 			user->eccsize	= 0;
 			return 0;
 		}
+		if (!cdev->ops->ioctl)
+			return -EINVAL;
 		return cdev->ops->ioctl(cdev, request, buf);
 	default:
 		return -EINVAL;
@@ -202,17 +204,14 @@ static int partition_ioctl(struct cdev *cdev, int request, void *buf)
 static int devfs_ioctl(struct device_d *_dev, FILE *f, int request, void *buf)
 {
 	struct cdev *cdev = f->inode;
-	int ret = -EINVAL;
+
+	if (cdev->flags & DEVFS_IS_PARTITION)
+		return partition_ioctl(cdev, request, buf);
 
 	if (!cdev->ops->ioctl)
-		goto out;
+		return -EINVAL;
 
-	if (cdev->flags & DEVFS_IS_PARTITION)
-		ret = partition_ioctl(cdev, request, buf);
-	else
-		ret = cdev->ops->ioctl(cdev, request, buf);
-out:
-	return ret;
+	return cdev->ops->ioctl(cdev, request, buf);
 }
 
 static int devfs_truncate(struct device_d *dev, FILE *f, ulong size)
-- 
1.7.1




More information about the barebox mailing list