All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] posix-clock: Remove duplicate ioctl handler
@ 2025-01-25 10:20 Thomas Weißschuh
  2025-01-25 12:25 ` Cyrill Gorcunov
  2025-01-25 14:28 ` Arnd Bergmann
  0 siblings, 2 replies; 4+ messages in thread
From: Thomas Weißschuh @ 2025-01-25 10:20 UTC (permalink / raw)
  To: Anna-Maria Behnsen, Frederic Weisbecker, Thomas Gleixner
  Cc: linux-kernel, Richard Cochran, Arnd Bergmann, Cyrill Gorcunov,
	Thomas Weißschuh

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>


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] posix-clock: Remove duplicate ioctl handler
  2025-01-25 10:20 [PATCH] posix-clock: Remove duplicate ioctl handler Thomas Weißschuh
@ 2025-01-25 12:25 ` Cyrill Gorcunov
  2025-01-25 14:28 ` Arnd Bergmann
  1 sibling, 0 replies; 4+ messages in thread
From: Cyrill Gorcunov @ 2025-01-25 12:25 UTC (permalink / raw)
  To: Thomas Weißschuh
  Cc: Anna-Maria Behnsen, Frederic Weisbecker, Thomas Gleixner,
	linux-kernel, Richard Cochran, Arnd Bergmann

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>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] posix-clock: Remove duplicate ioctl handler
  2025-01-25 10:20 [PATCH] posix-clock: Remove duplicate ioctl handler Thomas Weißschuh
  2025-01-25 12:25 ` Cyrill Gorcunov
@ 2025-01-25 14:28 ` Arnd Bergmann
  2025-01-26 17:20   ` Thomas Weißschuh
  1 sibling, 1 reply; 4+ messages in thread
From: Arnd Bergmann @ 2025-01-25 14:28 UTC (permalink / raw)
  To: Thomas Weißschuh, Anna-Maria Gleixner, Frederic Weisbecker,
	Thomas Gleixner
  Cc: linux-kernel, Richard Cochran, Cyrill Gorcunov

On Sat, Jan 25, 2025, at 11:20, Thomas Weißschuh wrote:
>  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

I would remove the #ifdef/#endif as well here. I would also suggest
using compat_ptr_ioctl(), so on s390 the pointers get converted
correctly, even if it clears the upper bit on the integer arguments.

      Arnd

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] posix-clock: Remove duplicate ioctl handler
  2025-01-25 14:28 ` Arnd Bergmann
@ 2025-01-26 17:20   ` Thomas Weißschuh
  0 siblings, 0 replies; 4+ messages in thread
From: Thomas Weißschuh @ 2025-01-26 17:20 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Anna-Maria Gleixner, Frederic Weisbecker, Thomas Gleixner,
	linux-kernel, Richard Cochran, Cyrill Gorcunov

Hi Arnd,

On 2025-01-25 15:28:29+0100, Arnd Bergmann wrote:
> On Sat, Jan 25, 2025, at 11:20, Thomas Weißschuh wrote:
> >  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
> 
> I would remove the #ifdef/#endif as well here. I would also suggest
> using compat_ptr_ioctl(), so on s390 the pointers get converted
> correctly, even if it clears the upper bit on the integer arguments.

Using compat_ptr_ioctl() here will break the logic from the closely
related fix to the PTP ioctl handler [0].
There is no other posix_clock_file_operations implementer than PTP.

I can drop the #ifdef.


Thomas

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-01-26 17:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-25 10:20 [PATCH] posix-clock: Remove duplicate ioctl handler Thomas Weißschuh
2025-01-25 12:25 ` Cyrill Gorcunov
2025-01-25 14:28 ` Arnd Bergmann
2025-01-26 17:20   ` Thomas Weißschuh

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.