Message ID | 20230310181921.1437890-2-neeraj.sanjaykale@nxp.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | Add support for NXP bluetooth chipsets | expand |
Context | Check | Description |
---|---|---|
netdev/tree_selection | success | Not a local patch |
On Fri, Mar 10, 2023 at 11:49:19PM +0530, Neeraj Sanjay Kale wrote: > Adds serdev_device_break_ctl() and an implementation for ttyport. > This function simply calls the break_ctl in tty layer, which can > assert a break signal over UART-TX line, if the tty and the > underlying platform and UART peripheral supports this operation. > > Signed-off-by: Neeraj Sanjay Kale <neeraj.sanjaykale@nxp.com> > --- > v3: Add details to the commit message. (Greg KH) ... > diff --git a/include/linux/serdev.h b/include/linux/serdev.h > index 66f624fc618c..c065ef1c82f1 100644 > --- a/include/linux/serdev.h > +++ b/include/linux/serdev.h ... > @@ -255,6 +257,10 @@ static inline int serdev_device_set_tiocm(struct serdev_device *serdev, int set, > { > return -ENOTSUPP; > } > +static inline int serdev_device_break_ctl(struct serdev_device *serdev, int break_state) > +{ > + return -EOPNOTSUPP; Is the use of -EOPNOTSUPP intentional here? I see -ENOTSUPP is used elsewhere in this file. > +} > static inline int serdev_device_write(struct serdev_device *sdev, const unsigned char *buf, > size_t count, unsigned long timeout) > { > -- > 2.34.1 >
Hi Simon > > On Fri, Mar 10, 2023 at 11:49:19PM +0530, Neeraj Sanjay Kale wrote: > > Adds serdev_device_break_ctl() and an implementation for ttyport. > > This function simply calls the break_ctl in tty layer, which can > > assert a break signal over UART-TX line, if the tty and the underlying > > platform and UART peripheral supports this operation. > > > > Signed-off-by: Neeraj Sanjay Kale <neeraj.sanjaykale@nxp.com> > > --- > > v3: Add details to the commit message. (Greg KH) > > ... > > > diff --git a/include/linux/serdev.h b/include/linux/serdev.h index > > 66f624fc618c..c065ef1c82f1 100644 > > --- a/include/linux/serdev.h > > +++ b/include/linux/serdev.h > > ... > > > @@ -255,6 +257,10 @@ static inline int serdev_device_set_tiocm(struct > > serdev_device *serdev, int set, { > > return -ENOTSUPP; > > } > > +static inline int serdev_device_break_ctl(struct serdev_device > > +*serdev, int break_state) { > > + return -EOPNOTSUPP; > > Is the use of -EOPNOTSUPP intentional here? > I see -ENOTSUPP is used elsewhere in this file. I was suggested to use - EOPNOTSUPP instead of - ENOTSUPP by the check patch scripts and by Leon Romanovsky. https://patchwork.kernel.org/project/bluetooth/patch/20230130180504.2029440-2-neeraj.sanjaykale@nxp.com/ ENOTSUPP is not a standard error code and should be avoided in new patches. See: https://lore.kernel.org/netdev/20200510182252.GA411829@lunn.ch/ > > > +} > > static inline int serdev_device_write(struct serdev_device *sdev, const > unsigned char *buf, > > size_t count, unsigned long > > timeout) { > > -- > > 2.34.1 > > Thanks, Neeraj
On Sun, Mar 12, 2023 at 07:01:17AM +0000, Neeraj sanjay kale wrote: > Hi Simon > > > > > On Fri, Mar 10, 2023 at 11:49:19PM +0530, Neeraj Sanjay Kale wrote: > > > Adds serdev_device_break_ctl() and an implementation for ttyport. > > > This function simply calls the break_ctl in tty layer, which can > > > assert a break signal over UART-TX line, if the tty and the underlying > > > platform and UART peripheral supports this operation. > > > > > > Signed-off-by: Neeraj Sanjay Kale <neeraj.sanjaykale@nxp.com> > > > --- > > > v3: Add details to the commit message. (Greg KH) > > > > ... > > > > > diff --git a/include/linux/serdev.h b/include/linux/serdev.h index > > > 66f624fc618c..c065ef1c82f1 100644 > > > --- a/include/linux/serdev.h > > > +++ b/include/linux/serdev.h > > > > ... > > > > > @@ -255,6 +257,10 @@ static inline int serdev_device_set_tiocm(struct > > > serdev_device *serdev, int set, { > > > return -ENOTSUPP; > > > } > > > +static inline int serdev_device_break_ctl(struct serdev_device > > > +*serdev, int break_state) { > > > + return -EOPNOTSUPP; > > > > Is the use of -EOPNOTSUPP intentional here? > > I see -ENOTSUPP is used elsewhere in this file. > I was suggested to use - EOPNOTSUPP instead of - ENOTSUPP by the check patch scripts and by Leon Romanovsky. > https://patchwork.kernel.org/project/bluetooth/patch/20230130180504.2029440-2-neeraj.sanjaykale@nxp.com/ > > ENOTSUPP is not a standard error code and should be avoided in new patches. > See: https://lore.kernel.org/netdev/20200510182252.GA411829@lunn.ch/ Thanks. I agree that EOPNOTSUPP is preferable. But my question is if we chose to use it in this case, even if it is inconsistent with similar code in the same file/API. If so, then I have no objections.
Hi Simon > > > > > > On Fri, Mar 10, 2023 at 11:49:19PM +0530, Neeraj Sanjay Kale wrote: > > > > Adds serdev_device_break_ctl() and an implementation for ttyport. > > > > This function simply calls the break_ctl in tty layer, which can > > > > assert a break signal over UART-TX line, if the tty and the > > > > underlying platform and UART peripheral supports this operation. > > > > > > > > Signed-off-by: Neeraj Sanjay Kale <neeraj.sanjaykale@nxp.com> > > > > --- > > > > v3: Add details to the commit message. (Greg KH) > > > > > > ... > > > > > > > diff --git a/include/linux/serdev.h b/include/linux/serdev.h index > > > > 66f624fc618c..c065ef1c82f1 100644 > > > > --- a/include/linux/serdev.h > > > > +++ b/include/linux/serdev.h > > > > > > ... > > > > > > > @@ -255,6 +257,10 @@ static inline int > > > > serdev_device_set_tiocm(struct serdev_device *serdev, int set, { > > > > return -ENOTSUPP; > > > > } > > > > +static inline int serdev_device_break_ctl(struct serdev_device > > > > +*serdev, int break_state) { > > > > + return -EOPNOTSUPP; > > > > > > Is the use of -EOPNOTSUPP intentional here? > > > I see -ENOTSUPP is used elsewhere in this file. > > I was suggested to use - EOPNOTSUPP instead of - ENOTSUPP by the check > patch scripts and by Leon Romanovsky. > > https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpatc > > > hwork.kernel.org%2Fproject%2Fbluetooth%2Fpatch%2F20230130180504.202 > 944 > > 0-2- > neeraj.sanjaykale%40nxp.com%2F&data=05%7C01%7Cneeraj.sanjaykale%40 > > > nxp.com%7Cf2ae2c9ad3c243df2c1a08db232dc0f1%7C686ea1d3bc2b4c6fa92 > cd99c5 > > > c301635%7C0%7C0%7C638142451647332825%7CUnknown%7CTWFpbGZsb3 > d8eyJWIjoiM > > > C4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000 > %7C%7C > > %7C&sdata=6cF0gipe4kkwYI6txo0vs8vnmF8azCO6gxQ%2F6Tdyd%2Fw%3D > &reserved= > > 0 > > > > ENOTSUPP is not a standard error code and should be avoided in new > patches. > > See: > > https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore > > .kernel.org%2Fnetdev%2F20200510182252.GA411829%40lunn.ch%2F&data > =05%7C > > > 01%7Cneeraj.sanjaykale%40nxp.com%7Cf2ae2c9ad3c243df2c1a08db232dc0f > 1%7C > > > 686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C638142451647332825% > 7CUnknow > > > n%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1ha > WwiLC > > > JXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=wFgYY6VnZ8BBn6Wme8%2BYj > aJRy98qyPnUy > > XC8iCFCv5k%3D&reserved=0 > > Thanks. > > I agree that EOPNOTSUPP is preferable. > But my question is if we chose to use it in this case, even if it is inconsistent > with similar code in the same file/API. > If so, then I have no objections. No, it was just to satisfy the check patch error and Leon's comment. The driver is happy to check if the serdev returned success or not, and simply print the error code during driver debug. Do you think this should be reverted to ENOTSUPP to maintain consistency? Thanks, Neeraj
On Mon, Mar 13, 2023 at 04:19:59AM +0000, Neeraj sanjay kale wrote: > Hi Simon > > > > > > > > > On Fri, Mar 10, 2023 at 11:49:19PM +0530, Neeraj Sanjay Kale wrote: > > > > > Adds serdev_device_break_ctl() and an implementation for ttyport. > > > > > This function simply calls the break_ctl in tty layer, which can > > > > > assert a break signal over UART-TX line, if the tty and the > > > > > underlying platform and UART peripheral supports this operation. > > > > > > > > > > Signed-off-by: Neeraj Sanjay Kale <neeraj.sanjaykale@nxp.com> > > > > > --- > > > > > v3: Add details to the commit message. (Greg KH) > > > > > > > > ... > > > > > > > > > diff --git a/include/linux/serdev.h b/include/linux/serdev.h index > > > > > 66f624fc618c..c065ef1c82f1 100644 > > > > > --- a/include/linux/serdev.h > > > > > +++ b/include/linux/serdev.h > > > > > > > > ... > > > > > > > > > @@ -255,6 +257,10 @@ static inline int > > > > > serdev_device_set_tiocm(struct serdev_device *serdev, int set, { > > > > > return -ENOTSUPP; > > > > > } > > > > > +static inline int serdev_device_break_ctl(struct serdev_device > > > > > +*serdev, int break_state) { > > > > > + return -EOPNOTSUPP; > > > > > > > > Is the use of -EOPNOTSUPP intentional here? > > > > I see -ENOTSUPP is used elsewhere in this file. > > > I was suggested to use - EOPNOTSUPP instead of - ENOTSUPP by the check > > patch scripts and by Leon Romanovsky. > > > https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpatc > > > > > hwork.kernel.org%2Fproject%2Fbluetooth%2Fpatch%2F20230130180504.202 > > 944 > > > 0-2- > > neeraj.sanjaykale%40nxp.com%2F&data=05%7C01%7Cneeraj.sanjaykale%40 > > > > > nxp.com%7Cf2ae2c9ad3c243df2c1a08db232dc0f1%7C686ea1d3bc2b4c6fa92 > > cd99c5 > > > > > c301635%7C0%7C0%7C638142451647332825%7CUnknown%7CTWFpbGZsb3 > > d8eyJWIjoiM > > > > > C4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000 > > %7C%7C > > > %7C&sdata=6cF0gipe4kkwYI6txo0vs8vnmF8azCO6gxQ%2F6Tdyd%2Fw%3D > > &reserved= > > > 0 > > > > > > ENOTSUPP is not a standard error code and should be avoided in new > > patches. > > > See: > > > https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore > > > .kernel.org%2Fnetdev%2F20200510182252.GA411829%40lunn.ch%2F&data > > =05%7C > > > > > 01%7Cneeraj.sanjaykale%40nxp.com%7Cf2ae2c9ad3c243df2c1a08db232dc0f > > 1%7C > > > > > 686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C638142451647332825% > > 7CUnknow > > > > > n%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1ha > > WwiLC > > > > > JXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=wFgYY6VnZ8BBn6Wme8%2BYj > > aJRy98qyPnUy > > > XC8iCFCv5k%3D&reserved=0 > > > > Thanks. > > > > I agree that EOPNOTSUPP is preferable. > > But my question is if we chose to use it in this case, even if it is inconsistent > > with similar code in the same file/API. > > If so, then I have no objections. > > No, it was just to satisfy the check patch error and Leon's comment. The driver is happy to check if the serdev returned success or not, and simply print the error code during driver debug. > Do you think this should be reverted to ENOTSUPP to maintain consistency? My _opinion_, is that first prize would be converting existing instances of ENOTSUPP in this file to EOPNOTSUPP. And then use EOPNOTSUPP going forward. And that second prize would be for your patch to use ENOTSUPP. Because I think there is a value consistency. But I do see why you have done things the way you have. And I don't necessarily think it is wrong.
Hi Simon, > > > > > > diff --git a/include/linux/serdev.h b/include/linux/serdev.h > > > > > > index > > > > > > 66f624fc618c..c065ef1c82f1 100644 > > > > > > --- a/include/linux/serdev.h > > > > > > +++ b/include/linux/serdev.h > > > > > > > > > > ... > > > > > > > > > > > @@ -255,6 +257,10 @@ static inline int > > > > > > serdev_device_set_tiocm(struct serdev_device *serdev, int set, { > > > > > > return -ENOTSUPP; > > > > > > } > > > > > > +static inline int serdev_device_break_ctl(struct > > > > > > +serdev_device *serdev, int break_state) { > > > > > > + return -EOPNOTSUPP; > > > > > > > > > > Is the use of -EOPNOTSUPP intentional here? > > > > > I see -ENOTSUPP is used elsewhere in this file. > > > > I was suggested to use - EOPNOTSUPP instead of - ENOTSUPP by the > > > > check > > > patch scripts and by Leon Romanovsky. > > > > https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2F > > > > > patc%2F&data=05%7C01%7Cneeraj.sanjaykale%40nxp.com%7Cd6011072c88 > 94 > > > > > b141a3008db23bb5bc0%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0 > %7C6 > > > > > 38143059832335354%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwM > DAiLCJQ > > > > > IjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata > =k > > > > > gk6w%2Fn2d3rNx%2FXe1rLfN0U%2BeTBJTxztSRUEUW2Noqk%3D&reserved= > 0 > > > > > > > > hwork.kernel.org%2Fproject%2Fbluetooth%2Fpatch%2F20230130180504.202 > > > 944 > > > > 0-2- > > > > neeraj.sanjaykale%40nxp.com%2F&data=05%7C01%7Cneeraj.sanjaykale%40 > > > > > > > > nxp.com%7Cf2ae2c9ad3c243df2c1a08db232dc0f1%7C686ea1d3bc2b4c6fa92 > > > cd99c5 > > > > > > > > c301635%7C0%7C0%7C638142451647332825%7CUnknown%7CTWFpbGZsb3 > > > d8eyJWIjoiM > > > > > > > > C4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000 > > > %7C%7C > > > > %7C&sdata=6cF0gipe4kkwYI6txo0vs8vnmF8azCO6gxQ%2F6Tdyd%2Fw% > 3D > > > &reserved= > > > > 0 > > > > > > > > ENOTSUPP is not a standard error code and should be avoided in new > > > patches. > > > > See: > > > > https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2F > > > > > lore%2F&data=05%7C01%7Cneeraj.sanjaykale%40nxp.com%7Cd6011072c88 > 94 > > > > > b141a3008db23bb5bc0%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0 > %7C6 > > > > > 38143059832335354%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwM > DAiLCJQ > > > > > IjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata > =9 > > > > > wojVR7aEgzoeajvy%2FMAkSqAYGBkxrJZtyxlvIpeZ%2Bw%3D&reserved=0 > > > > .kernel.org%2Fnetdev%2F20200510182252.GA411829%40lunn.ch%2F& > data > > > =05%7C > > > > > > > > 01%7Cneeraj.sanjaykale%40nxp.com%7Cf2ae2c9ad3c243df2c1a08db232dc0f > > > 1%7C > > > > > > > > 686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C638142451647332825% > > > 7CUnknow > > > > > > > > n%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1ha > > > WwiLC > > > > > > > > JXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=wFgYY6VnZ8BBn6Wme8%2BYj > > > aJRy98qyPnUy > > > > XC8iCFCv5k%3D&reserved=0 > > > > > > Thanks. > > > > > > I agree that EOPNOTSUPP is preferable. > > > But my question is if we chose to use it in this case, even if it is > > > inconsistent with similar code in the same file/API. > > > If so, then I have no objections. > > > > No, it was just to satisfy the check patch error and Leon's comment. The > driver is happy to check if the serdev returned success or not, and simply > print the error code during driver debug. > > Do you think this should be reverted to ENOTSUPP to maintain consistency? > > My _opinion_, is that first prize would be converting existing instances of > ENOTSUPP in this file to EOPNOTSUPP. And then use EOPNOTSUPP going > forward. And that second prize would be for your patch to use ENOTSUPP. > Because I think there is a value consistency. > > But I do see why you have done things the way you have. > And I don't necessarily think it is wrong. When you put it that way, how can I say no to a first prize! :D I have replaced all instances of ENOTSUPP with EOPNOTSUPP in these 2 files after making sure none of the functions returning it has a check for ENOTSUPP. It seems most of the instances do not check for a return value anyways. Please check v9 patch for the changes. Thanks Neeraj
diff --git a/drivers/tty/serdev/core.c b/drivers/tty/serdev/core.c index 0180e1e4e75d..f2fdd6264e5d 100644 --- a/drivers/tty/serdev/core.c +++ b/drivers/tty/serdev/core.c @@ -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_break_ctl(struct serdev_device *serdev, int break_state) +{ + struct serdev_controller *ctrl = serdev->ctrl; + + if (!ctrl || !ctrl->ops->break_ctl) + return -EOPNOTSUPP; + + return ctrl->ops->break_ctl(ctrl, break_state); +} +EXPORT_SYMBOL_GPL(serdev_device_break_ctl); + 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..9888673744af 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_break_ctl(struct serdev_controller *ctrl, unsigned int break_state) +{ + struct serport *serport = serdev_controller_get_drvdata(ctrl); + struct tty_struct *tty = serport->tty; + + if (!tty->ops->break_ctl) + return -EOPNOTSUPP; + + return tty->ops->break_ctl(tty, break_state); +} + 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, + .break_ctl = ttyport_break_ctl, }; struct device *serdev_tty_port_register(struct tty_port *port, diff --git a/include/linux/serdev.h b/include/linux/serdev.h index 66f624fc618c..c065ef1c82f1 100644 --- a/include/linux/serdev.h +++ b/include/linux/serdev.h @@ -92,6 +92,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 (*break_ctl)(struct serdev_controller *ctrl, unsigned int break_state); }; /** @@ -202,6 +203,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_break_ctl(struct serdev_device *serdev, int break_state); 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 *); @@ -255,6 +257,10 @@ static inline int serdev_device_set_tiocm(struct serdev_device *serdev, int set, { return -ENOTSUPP; } +static inline int serdev_device_break_ctl(struct serdev_device *serdev, int break_state) +{ + return -EOPNOTSUPP; +} static inline int serdev_device_write(struct serdev_device *sdev, const unsigned char *buf, size_t count, unsigned long timeout) {
Adds serdev_device_break_ctl() and an implementation for ttyport. This function simply calls the break_ctl in tty layer, which can assert a break signal over UART-TX line, if the tty and the underlying platform and UART peripheral supports this operation. Signed-off-by: Neeraj Sanjay Kale <neeraj.sanjaykale@nxp.com> --- v3: Add details to the commit message. (Greg KH) --- drivers/tty/serdev/core.c | 11 +++++++++++ drivers/tty/serdev/serdev-ttyport.c | 12 ++++++++++++ include/linux/serdev.h | 6 ++++++ 3 files changed, 29 insertions(+)