diff mbox series

[v1,1/3] serdev: Add interface serdev_device_ioctl

Message ID 1635836707-29341-1-git-send-email-zijuhu@codeaurora.org (mailing list archive)
State Rejected
Headers show
Series [v1,1/3] serdev: Add interface serdev_device_ioctl | expand

Checks

Context Check Description
tedd_an/checkpatch fail [v1,1/3] serdev: Add interface serdev_device_ioctl\WARNING:ENOSYS: ENOSYS means 'invalid syscall nr' and nothing else #97: FILE: drivers/tty/serdev/core.c:415: + return -ENOSYS; WARNING:ENOSYS: ENOSYS means 'invalid syscall nr' and nothing else #120: FILE: drivers/tty/serdev/serdev-ttyport.c:256: + return -ENOSYS; WARNING:ENOSYS: ENOSYS means 'invalid syscall nr' and nothing else #164: FILE: include/linux/serdev.h:263: + return -ENOSYS; total: 0 errors, 3 warnings, 70 lines checked NOTE: For some of the reported defects, checkpatch may be able to mechanically convert to the typical style using --fix or --fix-inplace. /github/workspace/src/12597951.patch has style problems, please review. NOTE: Ignored message types: UNKNOWN_COMMIT_ID NOTE: If any of the errors are false positives, please report them to the maintainer, see CHECKPATCH in MAINTAINERS.
tedd_an/gitlint success Gitlint PASS
tedd_an/buildkernel success Build Kernel PASS
tedd_an/testrunnersetup success Test Runner Setup PASS
tedd_an/testrunnerl2cap-tester success Total: 40, Passed: 40 (100.0%), Failed: 0, Not Run: 0
tedd_an/testrunnerbnep-tester success Total: 1, Passed: 1 (100.0%), Failed: 0, Not Run: 0
tedd_an/testrunnermgmt-tester fail Total: 468, Passed: 463 (98.9%), Failed: 5, Not Run: 0
tedd_an/testrunnerrfcomm-tester success Total: 9, Passed: 9 (100.0%), Failed: 0, Not Run: 0
tedd_an/testrunnersco-tester success Total: 12, Passed: 12 (100.0%), Failed: 0, Not Run: 0
tedd_an/testrunnersmp-tester success Total: 8, Passed: 8 (100.0%), Failed: 0, Not Run: 0
tedd_an/testrunneruserchan-tester success Total: 4, Passed: 4 (100.0%), Failed: 0, Not Run: 0

Commit Message

Zijun Hu Nov. 2, 2021, 7:05 a.m. UTC
From: Zijun Hu <quic_zijuhu@quicinc.com>

For serdev_device which is mounted at virtual tty port, tty ioctl()
maybe be used to make serdev_device ready to talk with tty port, so
add interface serdev_device_ioctl().

Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
---
 drivers/tty/serdev/core.c           | 13 +++++++++++++
 drivers/tty/serdev/serdev-ttyport.c | 12 ++++++++++++
 include/linux/serdev.h              |  9 +++++++++
 3 files changed, 34 insertions(+)

Comments

Marcel Holtmann Nov. 2, 2021, 7:20 a.m. UTC | #1
Hi Zijun,

> For serdev_device which is mounted at virtual tty port, tty ioctl()
> maybe be used to make serdev_device ready to talk with tty port, so
> add interface serdev_device_ioctl().
> 
> Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
> ---
> drivers/tty/serdev/core.c           | 13 +++++++++++++
> drivers/tty/serdev/serdev-ttyport.c | 12 ++++++++++++
> include/linux/serdev.h              |  9 +++++++++
> 3 files changed, 34 insertions(+)
> 
> diff --git a/drivers/tty/serdev/core.c b/drivers/tty/serdev/core.c
> index f1324fe99378..dee934203277 100644
> --- a/drivers/tty/serdev/core.c
> +++ b/drivers/tty/serdev/core.c
> @@ -405,6 +405,19 @@ int serdev_device_set_tiocm(struct serdev_device *serdev, int set, int clear)
> }
> EXPORT_SYMBOL_GPL(serdev_device_set_tiocm);
> 
> +int serdev_device_ioctl(struct serdev_device *serdev, unsigned int cmd, unsigned long arg)
> +{
> +	struct serdev_controller *ctrl = serdev->ctrl;
> +
> +	if (!ctrl)
> +		return -ENOTTY;
> +	else if	(!ctrl->ops->ioctl)
> +		return -ENOSYS;
> +	else
> +		return ctrl->ops->ioctl(ctrl, cmd, arg);
> +}
> +EXPORT_SYMBOL_GPL(serdev_device_ioctl);
> +
> static int serdev_drv_probe(struct device *dev)
> {
> 	const struct serdev_device_driver *sdrv = to_serdev_device_driver(dev->driver);
> diff --git a/drivers/tty/serdev/serdev-ttyport.c b/drivers/tty/serdev/serdev-ttyport.c
> index d367803e2044..66afad1eb1b7 100644
> --- a/drivers/tty/serdev/serdev-ttyport.c
> +++ b/drivers/tty/serdev/serdev-ttyport.c
> @@ -247,6 +247,17 @@ static int ttyport_set_tiocm(struct serdev_controller *ctrl, unsigned int set, u
> 	return tty->ops->tiocmset(tty, set, clear);
> }
> 
> +static int ttyport_ioctl(struct serdev_controller *ctrl, unsigned int cmd, unsigned long arg)
> +{
> +	struct serport *serport = serdev_controller_get_drvdata(ctrl);
> +	struct tty_struct *tty = serport->tty;
> +
> +	if (!tty->ops->ioctl)
> +		return -ENOSYS;
> +
> +	return tty->ops->ioctl(tty, cmd, arg);
> +}
> +
> static const struct serdev_controller_ops ctrl_ops = {
> 	.write_buf = ttyport_write_buf,
> 	.write_flush = ttyport_write_flush,
> @@ -259,6 +270,7 @@ static const struct serdev_controller_ops ctrl_ops = {
> 	.wait_until_sent = ttyport_wait_until_sent,
> 	.get_tiocm = ttyport_get_tiocm,
> 	.set_tiocm = ttyport_set_tiocm,
> +	.ioctl = ttyport_ioctl,
> };
> 
> struct device *serdev_tty_port_register(struct tty_port *port,
> diff --git a/include/linux/serdev.h b/include/linux/serdev.h
> index 3368c261ab62..5804201fafb2 100644
> --- a/include/linux/serdev.h
> +++ b/include/linux/serdev.h
> @@ -91,6 +91,7 @@ struct serdev_controller_ops {
> 	void (*wait_until_sent)(struct serdev_controller *, long);
> 	int (*get_tiocm)(struct serdev_controller *);
> 	int (*set_tiocm)(struct serdev_controller *, unsigned int, unsigned int);
> +	int (*ioctl)(struct serdev_controller *ctrl, unsigned int cmd, unsigned long arg);
> };

I thought the conclusion was not do this and instead have a proper Bluetooth driver. So please drop this patch.

Regards

Marcel
Greg KH Nov. 2, 2021, 7:32 a.m. UTC | #2
On Tue, Nov 02, 2021 at 03:05:07PM +0800, Zijun Hu wrote:
> From: Zijun Hu <quic_zijuhu@quicinc.com>
> 
> For serdev_device which is mounted at virtual tty port, tty ioctl()
> maybe be used to make serdev_device ready to talk with tty port, so
> add interface serdev_device_ioctl().
> 
> Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
> ---
>  drivers/tty/serdev/core.c           | 13 +++++++++++++
>  drivers/tty/serdev/serdev-ttyport.c | 12 ++++++++++++
>  include/linux/serdev.h              |  9 +++++++++
>  3 files changed, 34 insertions(+)

Why did I only recieve patch 1/3 here?  Where are the rest of them?

And as Marcel said, I though we stated that this change was NOT needed
at all.  What driver needs special ioctls for bluetooth that is not
already handled by the bluetooth layer?

thanks,

greg k-h
diff mbox series

Patch

diff --git a/drivers/tty/serdev/core.c b/drivers/tty/serdev/core.c
index f1324fe99378..dee934203277 100644
--- a/drivers/tty/serdev/core.c
+++ b/drivers/tty/serdev/core.c
@@ -405,6 +405,19 @@  int serdev_device_set_tiocm(struct serdev_device *serdev, int set, int clear)
 }
 EXPORT_SYMBOL_GPL(serdev_device_set_tiocm);
 
+int serdev_device_ioctl(struct serdev_device *serdev, unsigned int cmd, unsigned long arg)
+{
+	struct serdev_controller *ctrl = serdev->ctrl;
+
+	if (!ctrl)
+		return -ENOTTY;
+	else if	(!ctrl->ops->ioctl)
+		return -ENOSYS;
+	else
+		return ctrl->ops->ioctl(ctrl, cmd, arg);
+}
+EXPORT_SYMBOL_GPL(serdev_device_ioctl);
+
 static int serdev_drv_probe(struct device *dev)
 {
 	const struct serdev_device_driver *sdrv = to_serdev_device_driver(dev->driver);
diff --git a/drivers/tty/serdev/serdev-ttyport.c b/drivers/tty/serdev/serdev-ttyport.c
index d367803e2044..66afad1eb1b7 100644
--- a/drivers/tty/serdev/serdev-ttyport.c
+++ b/drivers/tty/serdev/serdev-ttyport.c
@@ -247,6 +247,17 @@  static int ttyport_set_tiocm(struct serdev_controller *ctrl, unsigned int set, u
 	return tty->ops->tiocmset(tty, set, clear);
 }
 
+static int ttyport_ioctl(struct serdev_controller *ctrl, unsigned int cmd, unsigned long arg)
+{
+	struct serport *serport = serdev_controller_get_drvdata(ctrl);
+	struct tty_struct *tty = serport->tty;
+
+	if (!tty->ops->ioctl)
+		return -ENOSYS;
+
+	return tty->ops->ioctl(tty, cmd, arg);
+}
+
 static const struct serdev_controller_ops ctrl_ops = {
 	.write_buf = ttyport_write_buf,
 	.write_flush = ttyport_write_flush,
@@ -259,6 +270,7 @@  static const struct serdev_controller_ops ctrl_ops = {
 	.wait_until_sent = ttyport_wait_until_sent,
 	.get_tiocm = ttyport_get_tiocm,
 	.set_tiocm = ttyport_set_tiocm,
+	.ioctl = ttyport_ioctl,
 };
 
 struct device *serdev_tty_port_register(struct tty_port *port,
diff --git a/include/linux/serdev.h b/include/linux/serdev.h
index 3368c261ab62..5804201fafb2 100644
--- a/include/linux/serdev.h
+++ b/include/linux/serdev.h
@@ -91,6 +91,7 @@  struct serdev_controller_ops {
 	void (*wait_until_sent)(struct serdev_controller *, long);
 	int (*get_tiocm)(struct serdev_controller *);
 	int (*set_tiocm)(struct serdev_controller *, unsigned int, unsigned int);
+	int (*ioctl)(struct serdev_controller *ctrl, unsigned int cmd, unsigned long arg);
 };
 
 /**
@@ -201,6 +202,7 @@  int serdev_device_write_buf(struct serdev_device *, const unsigned char *, size_
 void serdev_device_wait_until_sent(struct serdev_device *, long);
 int serdev_device_get_tiocm(struct serdev_device *);
 int serdev_device_set_tiocm(struct serdev_device *, int, int);
+int serdev_device_ioctl(struct serdev_device *serdev, unsigned int cmd, unsigned long arg);
 void serdev_device_write_wakeup(struct serdev_device *);
 int serdev_device_write(struct serdev_device *, const unsigned char *, size_t, long);
 void serdev_device_write_flush(struct serdev_device *);
@@ -254,6 +256,13 @@  static inline int serdev_device_set_tiocm(struct serdev_device *serdev, int set,
 {
 	return -ENOTSUPP;
 }
+
+static inline int serdev_device_ioctl(struct serdev_device *serdev,
+				      unsigned int cmd, unsigned long arg)
+{
+	return -ENOSYS;
+}
+
 static inline int serdev_device_write(struct serdev_device *sdev, const unsigned char *buf,
 				      size_t count, unsigned long timeout)
 {