public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH V1 1/1] Serial: core: Add compat ioctl support
@ 2022-12-22  4:49 Viken Dadhaniya
  2022-12-22  5:49 ` Greg KH
  0 siblings, 1 reply; 4+ messages in thread
From: Viken Dadhaniya @ 2022-12-22  4:49 UTC (permalink / raw)
  To: gregkh, jirislaby, linux-serial, linux-kernel
  Cc: quic_msavaliy, quic_vnivarth, quic_vtanuku, quic_arandive,
	Viken Dadhaniya

Current serial core driver doesn't support compat_ioctl
due to which 32-bit application is not able to send
ioctls to driver on a 64-bit platform.

Added compat_ioctl support in serial core to handle
ioctls from 32-bit applications on a 64-bit platform.

Signed-off-by: Viken Dadhaniya <quic_vdadhani@quicinc.com>
---
 drivers/tty/serial/serial_core.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index b9fbbee598b8..5ffa0798db3b 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -1601,6 +1601,22 @@ uart_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg)
 	return ret;
 }
 
+/**
+ * uart_compat_ioctl: uart compat IOCTL function.
+ * @tty: pointer to tty structure.
+ * @cmd: command code passed by user-space.
+ * @arg: argument  passed by user-space.
+ *
+ * This function will call normal uart IOCTL.
+ *
+ * Return: 0 for success, Negative number for error condition.
+ */
+static long
+uart_compat_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg)
+{
+	return (long)uart_ioctl(tty, cmd, arg);
+};
+
 static void uart_set_ldisc(struct tty_struct *tty)
 {
 	struct uart_state *state = tty->driver_data;
@@ -2670,6 +2686,7 @@ static const struct tty_operations uart_ops = {
 	.chars_in_buffer= uart_chars_in_buffer,
 	.flush_buffer	= uart_flush_buffer,
 	.ioctl		= uart_ioctl,
+	.compat_ioctl   = uart_compat_ioctl,
 	.throttle	= uart_throttle,
 	.unthrottle	= uart_unthrottle,
 	.send_xchar	= uart_send_xchar,
-- 
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member 
of Code Aurora Forum, hosted by The Linux Foundation


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

end of thread, other threads:[~2023-01-25 12:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-22  4:49 [PATCH V1 1/1] Serial: core: Add compat ioctl support Viken Dadhaniya
2022-12-22  5:49 ` Greg KH
2023-01-25 11:27   ` Viken Dadhaniya
2023-01-25 12:22     ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox