Re: [PATCH] posix-clock: drop code duplication using compat_ptr_ioctl

From: Thomas Weißschuh
Date: Mon Jan 20 2025 - 17:23:03 EST


Hi Cyrill,

On 2025-01-21 01:10:27+0300, Cyrill Gorcunov wrote:
> The posix_clock_compat_ioctl() is just a clone of posix_clock_ioctl(),
> drop the redundance.
>
> Signed-off-by: Cyrill Gorcunov <gorcunov@xxxxxxxxx>
> Cc: Anna-Maria Behnsen <anna-maria@xxxxxxxxxxxxx>
> Cc: Frederic Weisbecker <frederic@xxxxxxxxxx>
> Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
> ---
> kernel/time/posix-clock.c | 24 +-----------------------
> 1 file changed, 1 insertion(+), 23 deletions(-)
>
> Index: linux-tip.git/kernel/time/posix-clock.c
> ===================================================================
> --- linux-tip.git.orig/kernel/time/posix-clock.c
> +++ linux-tip.git/kernel/time/posix-clock.c
> @@ -90,26 +90,6 @@ static long posix_clock_ioctl(struct fil
> 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;
> @@ -173,9 +153,7 @@ static const struct file_operations posi
> .unlocked_ioctl = posix_clock_ioctl,
> .open = posix_clock_open,
> .release = posix_clock_release,
> -#ifdef CONFIG_COMPAT
> - .compat_ioctl = posix_clock_compat_ioctl,
> -#endif
> + .compat_ioctl = compat_ptr_ioctl,

This is not correct on s390. (It wasn't before either, though)
The improved patch below is in my personal queue, but I didn't get
around to actually testing and submitting it yet.

> };
>
> int posix_clock_register(struct posix_clock *clk, struct device *dev)