[PATCH] posix-clock: Remove duplicate ioctl handler

Thomas Weißschuh posted 1 patch 1 year ago
There is a newer version of this series
kernel/time/posix-clock.c | 22 +---------------------
1 file changed, 1 insertion(+), 21 deletions(-)
[PATCH] posix-clock: Remove duplicate ioctl handler
Posted by Thomas Weißschuh 1 year ago
The normal and compat ioctl handlers are identical,
which is fine as compat ioctls are detected and handled dynamically [0].
The duplicate definition however is unnecessary.
Just reuse the regular ioctl handler also for compat ioctls.

[0] https://lore.kernel.org/lkml/20250125-posix-clock-compat_ioctl-v2-1-11c865c500eb@weissschuh.net/

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
 kernel/time/posix-clock.c | 22 +---------------------
 1 file changed, 1 insertion(+), 21 deletions(-)

diff --git a/kernel/time/posix-clock.c b/kernel/time/posix-clock.c
index 1af0bb2cc45c0aab843f77eb156992de469c8fb9..353dddea0dd0cb2b0b76b5d5c5c2e4c232006c37 100644
--- a/kernel/time/posix-clock.c
+++ b/kernel/time/posix-clock.c
@@ -90,26 +90,6 @@ static long posix_clock_ioctl(struct file *fp,
 	return err;
 }
 
-#ifdef CONFIG_COMPAT
-static long posix_clock_compat_ioctl(struct file *fp,
-				     unsigned int cmd, unsigned long arg)
-{
-	struct posix_clock_context *pccontext = fp->private_data;
-	struct posix_clock *clk = get_posix_clock(fp);
-	int err = -ENOTTY;
-
-	if (!clk)
-		return -ENODEV;
-
-	if (clk->ops.ioctl)
-		err = clk->ops.ioctl(pccontext, cmd, arg);
-
-	put_posix_clock(clk);
-
-	return err;
-}
-#endif
-
 static int posix_clock_open(struct inode *inode, struct file *fp)
 {
 	int err;
@@ -174,7 +154,7 @@ static const struct file_operations posix_clock_file_operations = {
 	.open		= posix_clock_open,
 	.release	= posix_clock_release,
 #ifdef CONFIG_COMPAT
-	.compat_ioctl	= posix_clock_compat_ioctl,
+	.compat_ioctl	= posix_clock_ioctl,
 #endif
 };
 

---
base-commit: b46c89c08f4146e7987fc355941a93b12e2c03ef
change-id: 20250125-posix-clock-compat-cleanup-c2b8d0aefa31

Best regards,
-- 
Thomas Weißschuh <linux@weissschuh.net>

Re: [PATCH] posix-clock: Remove duplicate ioctl handler
Posted by Cyrill Gorcunov 1 year ago
On Sat, Jan 25, 2025 at 11:20:49AM +0100, Thomas Weißschuh wrote:
> The normal and compat ioctl handlers are identical,
> which is fine as compat ioctls are detected and handled dynamically [0].
> The duplicate definition however is unnecessary.
> Just reuse the regular ioctl handler also for compat ioctls.
> 
> [0] https://lore.kernel.org/lkml/20250125-posix-clock-compat_ioctl-v2-1-11c865c500eb@weissschuh.net/
> 
> Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Reviewed-by: Cyrill Gorcunov <gorcunov@gmail.com>