serdev: Add interface serdev_device_ioctl
Subsystems (3)
PATCH 1/1 serdev: Add interface serdev_device_ioctl
From: Zijun Hu <[email protected]>
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().
--- drivers/tty/serdev/core.c | 11 +++++++++++ drivers/tty/serdev/serdev-ttyport.c | 12 ++++++++++++ include/linux/serdev.h | 9 +++++++++ 3 files changed, 32 insertions(+)
drivers/tty/serdev/core.c +11 -0
@@ -405,6 +405,17 @@ 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 || !ctrl->ops->ioctl) +return -EOPNOTSUPP ; + +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);
drivers/tty/serdev/serdev-ttyport.c +12 -0
@@ -247,6 +247,17 @@ static int ttyport_set_tiocm(struct serdev_controller *ctrl, unsigned int set, ureturn 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 -EOPNOTSUPP ; + +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,
include/linux/serdev.h +9 -0
@@ -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 -EOPNOTSUPP ; +} +static inline int serdev_device_write (struct serdev_device *sdev,const unsigned char *buf,size_t count,unsigned long timeout) {
Signature · 1 line
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
Greg KH
maintainerQuoted 18 lines · Zijun Hu
From: Zijun Hu <[email protected]>
For
serdev_devicewhich is mounted at virtual tty port, ttyioctl()maybe be used to makeserdev_deviceready to talk with tty port, so add interfaceserdev_device_ioctl().Signed-off-by Zijun Hu <[email protected]>--- drivers/tty/serdev/core.c | 11 +++++++++++ drivers/tty/serdev/serdev-ttyport.c | 12 ++++++++++++ include/linux/serdev.h | 9 +++++++++ 3 files changed, 32 insertions(+)drivers/tty/serdev/core.c +0
-0
drivers/tty/serdev/core.c int serdev_device_set_tiocm(struct serdev_device *serdev, int set, int clear) · line 413
Quoted 9 lines
drivers/tty/serdev/core.c +6
-0@@ -405,6 +405,17 @@ 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 || !ctrl->ops->ioctl) +return -EOPNOTSUPP ;
Wrong error for returning that an ioctl is not handled :(
Anyway, what in-tree driver needs this functionality? Why does serdev need any ioctl commands?
thanks,
greg k-h
Quoted 22 lines · Greg KH
Quoted 21 lines · Zijun Hu
From: Zijun Hu <[email protected]>
For
serdev_devicewhich is mounted at virtual tty port, ttyioctl()maybe be used to makeserdev_deviceready to talk with tty port, so add interfaceserdev_device_ioctl().Signed-off-by Zijun Hu <[email protected]>--- drivers/tty/serdev/core.c | 11 +++++++++++ drivers/tty/serdev/serdev-ttyport.c | 12 ++++++++++++ include/linux/serdev.h | 9 +++++++++ 3 files changed, 32 insertions(+)drivers/tty/serdev/core.c +0
-0@@ -405,6 +405,17 @@ int serdev_device_set_tiocm(struct serdev_device *serdev, int set, int clear) }EXPORT_SYMBOL_GPL (serdev_device_set_tiocm);
Quoted 8 lines
drivers/tty/serdev/core.c int serdev_device_set_tiocm(struct serdev_device *serdev, int set, int clear) · line 413
Quoted 6 lines
drivers/tty/serdev/core.c +6
-0+int serdev_device_ioctl (struct serdev_device *serdev,unsigned int cmd,unsigned long arg) +{ +struct serdev_controller *ctrl = serdev->ctrl; + +if (!ctrl || !ctrl->ops->ioctl) +return -EOPNOTSUPP ;Wrong error for returning that an ioctl is not handled :(
checkpatch.pl always reports below WARNING when i use ENOTSUPP as present interfaces do. so i change error code to EOPNOTSUPP.
#28: FILE: drivers/tty/serdev/core.c:412:
+ return -ENOTSUPP;
WARNING: ENOTSUPP is not a SUSV4 error code, prefer EOPNOTSUPP
Quoted 4 lines
Anyway, what in-tree driver needs this functionality? Why does serdev need any ioctl commands?
i am developing driver for a special bluetooth controller which is integrated within SOC, and it does not connect with the BT HOST with UART as normal controller do, but it has very similar features as the BT controller with UART I/F. it is mounted on a virtual serial port driven by a tty driver developed. but it need to call tty ioctl to make the special BT controller ready to talk with tty port. so i add this interface.
as you known, the main purpose of ioctl is to achieve MISC and irregular control. so it is useful for these irregular devices.
thanks
Quoted 4 lines
thanks,
greg k-h
Greg KH
maintainerQuoted 33 lines · Zijun Hu
Quoted 22 lines · Greg KH
Quoted 21 lines · Zijun Hu
From: Zijun Hu <[email protected]>
For
serdev_devicewhich is mounted at virtual tty port, ttyioctl()maybe be used to makeserdev_deviceready to talk with tty port, so add interfaceserdev_device_ioctl().Signed-off-by Zijun Hu <[email protected]>--- drivers/tty/serdev/core.c | 11 +++++++++++ drivers/tty/serdev/serdev-ttyport.c | 12 ++++++++++++ include/linux/serdev.h | 9 +++++++++ 3 files changed, 32 insertions(+)drivers/tty/serdev/core.c +0
-0@@ -405,6 +405,17 @@ int serdev_device_set_tiocm(struct serdev_device *serdev, int set, int clear) }EXPORT_SYMBOL_GPL (serdev_device_set_tiocm);Quoted 8 lines
drivers/tty/serdev/core.c int serdev_device_set_tiocm(struct serdev_device *serdev, int set, int clear) · line 413
Quoted 6 lines
drivers/tty/serdev/core.c +6
-0+int serdev_device_ioctl (struct serdev_device *serdev,unsigned int cmd,unsigned long arg) +{ +struct serdev_controller *ctrl = serdev->ctrl; + +if (!ctrl || !ctrl->ops->ioctl) +return -EOPNOTSUPP ;Wrong error for returning that an ioctl is not handled :(
Quoted 7 lines
checkpatch.pl always reports below WARNING when i use ENOTSUPP as present interfaces do. so i change error code to EOPNOTSUPP.
#28: FILE:
drivers/tty/serdev/core.c:412:
+ return-ENOTSUPP;WARNING: ENOTSUPP is not a SUSV4 error code, prefer EOPNOTSUPP
Both of them are not the correct error to return when an ioctl is not supported.
Quoted 8 lines
Quoted 3 lines
Anyway, what in-tree driver needs this functionality? Why does serdev need any ioctl commands?
i am developing driver for a special bluetooth controller which is integrated within SOC, and it does not connect with the BT HOST with UART as normal controller do, but it has very similar features as the BT controller with UART I/F. it is mounted on a virtual serial port driven by a tty driver developed. but it need to call tty ioctl to make the special BT controller ready to talk with tty port. so i add this interface.
Please submit this change when you submit your driver that uses it at the same time so we can review them all at once. We do not add apis that are not used in the kernel tree.
Quoted 2 lines
as you known, the main purpose of ioctl is to achieve MISC and irregular control. so it is useful for these irregular devices.
For tty devices, "custom" ioctls are not ok, use the standard tty commands and you should be fine for everything you need to do.
If not, then perhaps your design is incorrect?
thanks,
greg k-h
Quoted 37 lines · Greg KH
Quoted 36 lines · Zijun Hu
Quoted 22 lines · Greg KH
Quoted 21 lines · Zijun Hu
From: Zijun Hu <[email protected]>
For
serdev_devicewhich is mounted at virtual tty port, ttyioctl()maybe be used to makeserdev_deviceready to talk with tty port, so add interfaceserdev_device_ioctl().Signed-off-by Zijun Hu <[email protected]>--- drivers/tty/serdev/core.c | 11 +++++++++++ drivers/tty/serdev/serdev-ttyport.c | 12 ++++++++++++ include/linux/serdev.h | 9 +++++++++ 3 files changed, 32 insertions(+)drivers/tty/serdev/core.c +0
-0@@ -405,6 +405,17 @@ int serdev_device_set_tiocm(struct serdev_device *serdev, int set, int clear) }EXPORT_SYMBOL_GPL (serdev_device_set_tiocm);Quoted 8 lines
drivers/tty/serdev/core.c int serdev_device_set_tiocm(struct serdev_device *serdev, int set, int clear) · line 413
Quoted 6 lines
drivers/tty/serdev/core.c +6
-0+int serdev_device_ioctl (struct serdev_device *serdev,unsigned int cmd,unsigned long arg) +{ +struct serdev_controller *ctrl = serdev->ctrl; + +if (!ctrl || !ctrl->ops->ioctl) +return -EOPNOTSUPP ;Wrong error for returning that an ioctl is not handled :(
checkpatch.pl always reports below WARNING when i use ENOTSUPP as present interfaces do. so i change error code to EOPNOTSUPP.
Quoted 8 lines
Quoted 4 lines
#28: FILE:
drivers/tty/serdev/core.c:412:
+ return-ENOTSUPP;WARNING: ENOTSUPP is not a SUSV4 error code, prefer EOPNOTSUPP
Both of them are not the correct error to return when an ioctl is not supported.
is ENODEV okay?
Quoted 9 lines
Quoted 8 lines
Quoted 3 lines
Anyway, what in-tree driver needs this functionality? Why does serdev need any ioctl commands?
i am developing driver for a special bluetooth controller which is integrated within SOC, and it does not connect with the BT HOST with UART as normal controller do, but it has very similar features as the BT controller with UART I/F. it is mounted on a virtual serial port driven by a tty driver developed. but it need to call tty ioctl to make the special BT controller ready to talk with tty port. so i add this interface.
Quoted 4 lines
Please submit this change when you submit your driver that uses it at the same time so we can review them all at once. We do not add apis that are not used in the kernel tree.
okay
Quoted 8 lines
Quoted 2 lines
as you known, the main purpose of ioctl is to achieve MISC and irregular control. so it is useful for these irregular devices.
For tty devices, "custom" ioctls are not ok, use the standard tty commands and you should be fine for everything you need to do.
If not, then perhaps your design is incorrect?
i just want to refer bt_ioctl within https://source.codeaurora.org/quic/qsdk/oss/kernel/linux-ipq-5.4/tree/drivers/soc/qcom/bt_tty.c?h=NHSS.QSDK.11.5.0.5.r2
by serdev. so add this interface.
are there any other good solution to advise?
thanks
Quoted 4 lines
thanks,
greg k-h
Greg KH
maintainerQuoted 43 lines · Zijun Hu
Quoted 40 lines · Greg KH
Quoted 39 lines · Zijun Hu
Quoted 22 lines · Greg KH
Quoted 21 lines · Zijun Hu
From: Zijun Hu <[email protected]>
For
serdev_devicewhich is mounted at virtual tty port, ttyioctl()maybe be used to makeserdev_deviceready to talk with tty port, so add interfaceserdev_device_ioctl().Signed-off-by Zijun Hu <[email protected]>--- drivers/tty/serdev/core.c | 11 +++++++++++ drivers/tty/serdev/serdev-ttyport.c | 12 ++++++++++++ include/linux/serdev.h | 9 +++++++++ 3 files changed, 32 insertions(+)drivers/tty/serdev/core.c +0
-0@@ -405,6 +405,17 @@ int serdev_device_set_tiocm(struct serdev_device *serdev, int set, int clear) }EXPORT_SYMBOL_GPL (serdev_device_set_tiocm);Quoted 8 lines
drivers/tty/serdev/core.c int serdev_device_set_tiocm(struct serdev_device *serdev, int set, int clear) · line 413
Quoted 6 lines
drivers/tty/serdev/core.c +6
-0+int serdev_device_ioctl (struct serdev_device *serdev,unsigned int cmd,unsigned long arg) +{ +struct serdev_controller *ctrl = serdev->ctrl; + +if (!ctrl || !ctrl->ops->ioctl) +return -EOPNOTSUPP ;Wrong error for returning that an ioctl is not handled :(
checkpatch.pl always reports below WARNING when i use ENOTSUPP as present interfaces do. so i change error code to EOPNOTSUPP.
#28: FILE:
drivers/tty/serdev/core.c:412:
+ return-ENOTSUPP;
Quoted 6 lines
Quoted 5 lines
Quoted 1 line
WARNING: ENOTSUPP is not a SUSV4 error code, prefer EOPNOTSUPP
Both of them are not the correct error to return when an ioctl is not supported.
is ENODEV okay?
No, -ENOTTY is the correct one as per the documentation, right?
Quoted 17 lines
Quoted 9 lines
Quoted 8 lines
Quoted 3 lines
Anyway, what in-tree driver needs this functionality? Why does serdev need any ioctl commands?
i am developing driver for a special bluetooth controller which is integrated within SOC, and it does not connect with the BT HOST with UART as normal controller do, but it has very similar features as the BT controller with UART I/F. it is mounted on a virtual serial port driven by a tty driver developed. but it need to call tty ioctl to make the special BT controller ready to talk with tty port. so i add this interface.
Quoted 4 lines
Please submit this change when you submit your driver that uses it at the same time so we can review them all at once. We do not add apis that are not used in the kernel tree.
okay
Quoted 3 lines
Quoted 2 lines
as you known, the main purpose of ioctl is to achieve MISC and irregular control. so it is useful for these irregular devices.
Quoted 7 lines
Quoted 5 lines
For tty devices, "custom" ioctls are not ok, use the standard tty commands and you should be fine for everything you need to do.
If not, then perhaps your design is incorrect?
i just want to refer
bt_ioctlwithin https://source.codeaurora.org/quic/qsdk/oss/kernel/linux-ipq-5.4/tree/drivers/soc/qcom/bt_tty.c?h=NHSS.QSDK.11.5.0.5.r2
by serdev. so add this interface.
The 5.4 kernel is not relevant here, so I do not understand.
Quoted 1 line
are there any other good solution to advise?
Why not work with the bluetooth developers on this?
thanks,
greg k-h
Marcel Holtmann
maintainerHi Greg,
Quoted 64 lines
Quoted 33 lines
Quoted 33 lines
Quoted 33 lines
Quoted 19 lines
Quoted 19 lines
For
serdev_devicewhich is mounted at virtual tty port, ttyioctl()maybe be used to makeserdev_deviceready to talk with tty port, so add interfaceserdev_device_ioctl().Signed-off-by Zijun Hu <[email protected]>---
drivers/tty/serdev/core.c | 11 +++++++++++ drivers/tty/serdev/serdev-ttyport.c | 12 ++++++++++++ include/linux/serdev.h | 9 +++++++++ 3 files changed, 32 insertions(+)drivers/tty/serdev/core.c +0
-0@@ -405,6 +405,17 @@ int serdev_device_set_tiocm(struct serdev_device *serdev, int set, int clear) }EXPORT_SYMBOL_GPL (serdev_device_set_tiocm);Quoted 8 lines
drivers/tty/serdev/core.c int serdev_device_set_tiocm(struct serdev_device *serdev, int set, int clear) · line 413
Quoted 6 lines
drivers/tty/serdev/core.c +6
-0+int serdev_device_ioctl (struct serdev_device *serdev,unsigned int cmd,unsigned long arg) +{ +struct serdev_controller *ctrl = serdev->ctrl; + +if (!ctrl || !ctrl->ops->ioctl) +return -EOPNOTSUPP ;Wrong error for returning that an ioctl is not handled :(
checkpatch.pl always reports below WARNING when i use ENOTSUPP as present interfaces do. so i change error code to EOPNOTSUPP.
#28: FILE:
drivers/tty/serdev/core.c:412:
+ return-ENOTSUPP;Quoted 6 lines
Quoted 5 lines
Quoted 1 line
WARNING: ENOTSUPP is not a SUSV4 error code, prefer EOPNOTSUPP
Both of them are not the correct error to return when an ioctl is not supported.
is ENODEV okay?
No,
-ENOTTYis the correct one as per the documentation, right?Quoted 22 lines
Quoted 9 lines
Quoted 8 lines
Quoted 3 lines
Anyway, what in-tree driver needs this functionality? Why does serdev need any ioctl commands?
i am developing driver for a special bluetooth controller which is integrated within SOC, and it does not connect with the BT HOST with UART as normal controller do, but it has very similar features as the BT controller with UART I/F. it is mounted on a virtual serial port driven by a tty driver developed. but it need to call tty ioctl to make the special BT controller ready to talk with tty port. so i add this interface.
Quoted 4 lines
Please submit this change when you submit your driver that uses it at the same time so we can review them all at once. We do not add apis that are not used in the kernel tree.
okay
Quoted 8 lines
Quoted 2 lines
as you known, the main purpose of ioctl is to achieve MISC and irregular control. so it is useful for these irregular devices.
For tty devices, "custom" ioctls are not ok, use the standard tty commands and you should be fine for everything you need to do.
If not, then perhaps your design is incorrect?
Quoted 8 lines
Quoted 2 lines
i just want to refer
bt_ioctlwithin https://source.codeaurora.org/quic/qsdk/oss/kernel/linux-ipq-5.4/tree/drivers/soc/qcom/bt_tty.c?h=NHSS.QSDK.11.5.0.5.r2
by serdev. so add this interface.The 5.4 kernel is not relevant here, so I do not understand.
Quoted 1 line
are there any other good solution to advise?
Why not work with the bluetooth developers on this?
if this is just to have some hackish Bluetooth driver, then NAK from my side. Since we have serdev, we have no need for, or requirements for any ioctl anymore. If such thing is needed, it is a bad design.
Regards
Marcel
Greg KH
maintainerQuoted 69 lines · Marcel Holtmann
Hi Greg,
Quoted 67 lines
Quoted 33 lines
Quoted 33 lines
Quoted 33 lines
Quoted 19 lines
Quoted 19 lines
For
serdev_devicewhich is mounted at virtual tty port, ttyioctl()maybe be used to makeserdev_deviceready to talk with tty port, so add interfaceserdev_device_ioctl().Signed-off-by Zijun Hu <[email protected]>---
drivers/tty/serdev/core.c | 11 +++++++++++ drivers/tty/serdev/serdev-ttyport.c | 12 ++++++++++++ include/linux/serdev.h | 9 +++++++++ 3 files changed, 32 insertions(+)drivers/tty/serdev/core.c +0
-0@@ -405,6 +405,17 @@ int serdev_device_set_tiocm(struct serdev_device *serdev, int set, int clear) }EXPORT_SYMBOL_GPL (serdev_device_set_tiocm);Quoted 8 lines
drivers/tty/serdev/core.c int serdev_device_set_tiocm(struct serdev_device *serdev, int set, int clear) · line 413
Quoted 6 lines
drivers/tty/serdev/core.c +6
-0+int serdev_device_ioctl (struct serdev_device *serdev,unsigned int cmd,unsigned long arg) +{ +struct serdev_controller *ctrl = serdev->ctrl; + +if (!ctrl || !ctrl->ops->ioctl) +return -EOPNOTSUPP ;Wrong error for returning that an ioctl is not handled :(
checkpatch.pl always reports below WARNING when i use ENOTSUPP as present interfaces do. so i change error code to EOPNOTSUPP.
#28: FILE:
drivers/tty/serdev/core.c:412:
+ return-ENOTSUPP;Quoted 6 lines
Quoted 5 lines
Quoted 1 line
WARNING: ENOTSUPP is not a SUSV4 error code, prefer EOPNOTSUPP
Both of them are not the correct error to return when an ioctl is not supported.
is ENODEV okay?
No,
-ENOTTYis the correct one as per the documentation, right?Quoted 24 lines
Quoted 9 lines
Quoted 8 lines
Quoted 3 lines
Anyway, what in-tree driver needs this functionality? Why does serdev need any ioctl commands?
i am developing driver for a special bluetooth controller which is integrated within SOC, and it does not connect with the BT HOST with UART as normal controller do, but it has very similar features as the BT controller with UART I/F. it is mounted on a virtual serial port driven by a tty driver developed. but it need to call tty ioctl to make the special BT controller ready to talk with tty port. so i add this interface.
Quoted 4 lines
Please submit this change when you submit your driver that uses it at the same time so we can review them all at once. We do not add apis that are not used in the kernel tree.
okay
Quoted 8 lines
Quoted 2 lines
as you known, the main purpose of ioctl is to achieve MISC and irregular control. so it is useful for these irregular devices.
For tty devices, "custom" ioctls are not ok, use the standard tty commands and you should be fine for everything you need to do.
If not, then perhaps your design is incorrect?
i just want to refer
bt_ioctlwithin https://source.codeaurora.org/quic/qsdk/oss/kernel/linux-ipq-5.4/tree/drivers/soc/qcom/bt_tty.c?h=NHSS.QSDK.11.5.0.5.r2
by serdev. so add this interface.
Quoted 7 lines
Quoted 5 lines
The 5.4 kernel is not relevant here, so I do not understand.
Quoted 1 line
are there any other good solution to advise?
Why not work with the bluetooth developers on this?
if this is just to have some hackish Bluetooth driver, then NAK from my side. Since we have serdev, we have no need for, or requirements for any ioctl anymore. If such thing is needed, it is a bad design.
Thanks for the confirmation, seems sane to me!
Zijun, please fix up your driver and submit it to be merged and all should be fine, no need for any custom ioctls.
thanks,
greg k-h
Quoted 74 lines · Greg KH
Quoted 73 lines · Marcel Holtmann
Hi Greg,
Quoted 71 lines
Quoted 33 lines
Quoted 33 lines
Quoted 33 lines
Quoted 19 lines
Quoted 19 lines
For
serdev_devicewhich is mounted at virtual tty port, ttyioctl()maybe be used to makeserdev_deviceready to talk with tty port, so add interfaceserdev_device_ioctl().Signed-off-by Zijun Hu <[email protected]>---
drivers/tty/serdev/core.c | 11 +++++++++++ drivers/tty/serdev/serdev-ttyport.c | 12 ++++++++++++ include/linux/serdev.h | 9 +++++++++ 3 files changed, 32 insertions(+)drivers/tty/serdev/core.c +0
-0@@ -405,6 +405,17 @@ int serdev_device_set_tiocm(struct serdev_device *serdev, int set, int clear) }EXPORT_SYMBOL_GPL (serdev_device_set_tiocm);Quoted 8 lines
drivers/tty/serdev/core.c int serdev_device_set_tiocm(struct serdev_device *serdev, int set, int clear) · line 413
Quoted 6 lines
drivers/tty/serdev/core.c +6
-0+int serdev_device_ioctl (struct serdev_device *serdev,unsigned int cmd,unsigned long arg) +{ +struct serdev_controller *ctrl = serdev->ctrl; + +if (!ctrl || !ctrl->ops->ioctl) +return -EOPNOTSUPP ;Wrong error for returning that an ioctl is not handled :(
checkpatch.pl always reports below WARNING when i use ENOTSUPP as present interfaces do. so i change error code to EOPNOTSUPP.
#28: FILE:
drivers/tty/serdev/core.c:412:
+ return-ENOTSUPP;Quoted 6 lines
Quoted 5 lines
Quoted 1 line
WARNING: ENOTSUPP is not a SUSV4 error code, prefer EOPNOTSUPP
Both of them are not the correct error to return when an ioctl is not supported.
is ENODEV okay?
No,
-ENOTTYis the correct one as per the documentation, right?Quoted 17 lines
Quoted 9 lines
Quoted 8 lines
Quoted 3 lines
Anyway, what in-tree driver needs this functionality? Why does serdev need any ioctl commands?
i am developing driver for a special bluetooth controller which is integrated within SOC, and it does not connect with the BT HOST with UART as normal controller do, but it has very similar features as the BT controller with UART I/F. it is mounted on a virtual serial port driven by a tty driver developed. but it need to call tty ioctl to make the special BT controller ready to talk with tty port. so i add this interface.
Quoted 4 lines
Please submit this change when you submit your driver that uses it at the same time so we can review them all at once. We do not add apis that are not used in the kernel tree.
okay
Quoted 3 lines
Quoted 2 lines
as you known, the main purpose of ioctl is to achieve MISC and irregular control. so it is useful for these irregular devices.
Quoted 7 lines
Quoted 5 lines
For tty devices, "custom" ioctls are not ok, use the standard tty commands and you should be fine for everything you need to do.
If not, then perhaps your design is incorrect?
i just want to refer
bt_ioctlwithin https://source.codeaurora.org/quic/qsdk/oss/kernel/linux-ipq-5.4/tree/drivers/soc/qcom/bt_tty.c?h=NHSS.QSDK.11.5.0.5.r2
by serdev. so add this interface.The 5.4 kernel is not relevant here, so I do not understand.
Quoted 1 line
are there any other good solution to advise?
Quoted 9 lines
Quoted 3 lines
Quoted 1 line
Why not work with the bluetooth developers on this?
if this is just to have some hackish Bluetooth driver, then NAK from my side. Since we have serdev, we have no need for, or requirements for any ioctl anymore. If such thing is needed, it is a bad design.
Thanks for the confirmation, seems sane to me!
Zijun, please fix up your driver and submit it to be merged and all should be fine, no need for any custom ioctls.
thank you Greg, i have submitted all changes to support the special BT controller, certainly, it includes this serdev change.
Quoted 4 lines
thanks,
greg k-h