Re: [PATCH 18/19] serdev: ttydev: Serdev driver that creates an standard TTY port

2018-06-06 Thread Ricardo Ribalda Delgado
On Wed, Jun 6, 2018 at 11:55 AM Andy Shevchenko
 wrote:
> >
> > https://github.com/ribalda/linux/tree/serdev2
>
> n _is_ default. So, just remove a line.
>

Done. Thanks!

> --
> With Best Regards,
> Andy Shevchenko



-- 
Ricardo Ribalda


Re: [PATCH 18/19] serdev: ttydev: Serdev driver that creates an standard TTY port

2018-06-06 Thread Ricardo Ribalda Delgado
On Wed, Jun 6, 2018 at 11:55 AM Andy Shevchenko
 wrote:
> >
> > https://github.com/ribalda/linux/tree/serdev2
>
> n _is_ default. So, just remove a line.
>

Done. Thanks!

> --
> With Best Regards,
> Andy Shevchenko



-- 
Ricardo Ribalda


Re: [PATCH 18/19] serdev: ttydev: Serdev driver that creates an standard TTY port

2018-06-06 Thread Andy Shevchenko
On Wed, Jun 6, 2018 at 10:47 AM, Ricardo Ribalda Delgado
 wrote:
> Hi Andy,
> On Wed, Jun 6, 2018 at 8:58 AM Ricardo Ribalda Delgado
>  wrote:

> I have defaulted the module to n as you suggested. You can take a look
> to the patches that I plan to submit tomorrow at:
>
> https://github.com/ribalda/linux/tree/serdev2

n _is_ default. So, just remove a line.

-- 
With Best Regards,
Andy Shevchenko


Re: [PATCH 18/19] serdev: ttydev: Serdev driver that creates an standard TTY port

2018-06-06 Thread Andy Shevchenko
On Wed, Jun 6, 2018 at 10:47 AM, Ricardo Ribalda Delgado
 wrote:
> Hi Andy,
> On Wed, Jun 6, 2018 at 8:58 AM Ricardo Ribalda Delgado
>  wrote:

> I have defaulted the module to n as you suggested. You can take a look
> to the patches that I plan to submit tomorrow at:
>
> https://github.com/ribalda/linux/tree/serdev2

n _is_ default. So, just remove a line.

-- 
With Best Regards,
Andy Shevchenko


Re: [PATCH 18/19] serdev: ttydev: Serdev driver that creates an standard TTY port

2018-06-06 Thread Ricardo Ribalda Delgado
Hi Andy,
On Wed, Jun 6, 2018 at 8:58 AM Ricardo Ribalda Delgado
 wrote:
>
> Hi Andy
> On Tue, Jun 5, 2018 at 3:42 PM Andy Shevchenko
>  wrote:
> >
> > On Tue, May 29, 2018 at 4:10 PM, Ricardo Ribalda Delgado
> >  wrote:
> > > Standard TTY port that can be loaded/unloaded via serdev sysfs. This
> > > serdev driver can only be used by serdev controllers that are compatible
> > > with ttyport.
> >
> > > +config SERIAL_DEV_CTRL_TTYDEV
> > > +   tristate "TTY port dynamically loaded by the Serial Device Bus"
> > > +   help
> > > + Say Y here if you want to create a bridge driver between the 
> > > Serial
> > > + device bus and the TTY chardevice. This driver can be 
> > > dynamically
> > > + loaded/unloaded by the Serial Device Bus.
> > > +
> > > + If unsure, say Y.
> > > +   depends on SERIAL_DEV_CTRL_TTYPORT
> >
> > > +   default m
> >
> > Hmm... Can't we survive w/o this by default?
>
> If this module is not available and serdev is enabled the user would
> miss his /dev/ttyS* nodes, so I rather leave this on.

Sorry, brain fart. This is exactly what #if
IS_ENABLED(CONFIG_SERIAL_DEV_CTRL_TTYDEV) prevents.

I have defaulted the module to n as you suggested. You can take a look
to the patches that I plan to submit tomorrow at:

https://github.com/ribalda/linux/tree/serdev2

>
> >
> > > +static int __init ttydev_serdev_init(void)
> > > +{
> > > +   return serdev_device_driver_register(_serdev_driver);
> > > +}
> > > +module_init(ttydev_serdev_init);
> > > +
> > > +static void __exit ttydev_serdev_exit(void)
> > > +{
> > > +   return serdev_device_driver_unregister(_serdev_driver);
> > > +}
> > > +module_exit(ttydev_serdev_exit);
> >
> > Isn't above is just a macro in serdev.h?
> > I.e. module_serdev_device_driver().
>
> ACK, thanks!
> >
> > --
> > With Best Regards,
> > Andy Shevchenko
>
> Best regards
>
> --
> Ricardo Ribalda



-- 
Ricardo Ribalda


Re: [PATCH 18/19] serdev: ttydev: Serdev driver that creates an standard TTY port

2018-06-06 Thread Ricardo Ribalda Delgado
Hi Andy,
On Wed, Jun 6, 2018 at 8:58 AM Ricardo Ribalda Delgado
 wrote:
>
> Hi Andy
> On Tue, Jun 5, 2018 at 3:42 PM Andy Shevchenko
>  wrote:
> >
> > On Tue, May 29, 2018 at 4:10 PM, Ricardo Ribalda Delgado
> >  wrote:
> > > Standard TTY port that can be loaded/unloaded via serdev sysfs. This
> > > serdev driver can only be used by serdev controllers that are compatible
> > > with ttyport.
> >
> > > +config SERIAL_DEV_CTRL_TTYDEV
> > > +   tristate "TTY port dynamically loaded by the Serial Device Bus"
> > > +   help
> > > + Say Y here if you want to create a bridge driver between the 
> > > Serial
> > > + device bus and the TTY chardevice. This driver can be 
> > > dynamically
> > > + loaded/unloaded by the Serial Device Bus.
> > > +
> > > + If unsure, say Y.
> > > +   depends on SERIAL_DEV_CTRL_TTYPORT
> >
> > > +   default m
> >
> > Hmm... Can't we survive w/o this by default?
>
> If this module is not available and serdev is enabled the user would
> miss his /dev/ttyS* nodes, so I rather leave this on.

Sorry, brain fart. This is exactly what #if
IS_ENABLED(CONFIG_SERIAL_DEV_CTRL_TTYDEV) prevents.

I have defaulted the module to n as you suggested. You can take a look
to the patches that I plan to submit tomorrow at:

https://github.com/ribalda/linux/tree/serdev2

>
> >
> > > +static int __init ttydev_serdev_init(void)
> > > +{
> > > +   return serdev_device_driver_register(_serdev_driver);
> > > +}
> > > +module_init(ttydev_serdev_init);
> > > +
> > > +static void __exit ttydev_serdev_exit(void)
> > > +{
> > > +   return serdev_device_driver_unregister(_serdev_driver);
> > > +}
> > > +module_exit(ttydev_serdev_exit);
> >
> > Isn't above is just a macro in serdev.h?
> > I.e. module_serdev_device_driver().
>
> ACK, thanks!
> >
> > --
> > With Best Regards,
> > Andy Shevchenko
>
> Best regards
>
> --
> Ricardo Ribalda



-- 
Ricardo Ribalda


Re: [PATCH 18/19] serdev: ttydev: Serdev driver that creates an standard TTY port

2018-06-06 Thread Ricardo Ribalda Delgado
Hi Andy
On Tue, Jun 5, 2018 at 3:42 PM Andy Shevchenko
 wrote:
>
> On Tue, May 29, 2018 at 4:10 PM, Ricardo Ribalda Delgado
>  wrote:
> > Standard TTY port that can be loaded/unloaded via serdev sysfs. This
> > serdev driver can only be used by serdev controllers that are compatible
> > with ttyport.
>
> > +config SERIAL_DEV_CTRL_TTYDEV
> > +   tristate "TTY port dynamically loaded by the Serial Device Bus"
> > +   help
> > + Say Y here if you want to create a bridge driver between the 
> > Serial
> > + device bus and the TTY chardevice. This driver can be dynamically
> > + loaded/unloaded by the Serial Device Bus.
> > +
> > + If unsure, say Y.
> > +   depends on SERIAL_DEV_CTRL_TTYPORT
>
> > +   default m
>
> Hmm... Can't we survive w/o this by default?

If this module is not available and serdev is enabled the user would
miss his /dev/ttyS* nodes, so I rather leave this on.

>
> > +static int __init ttydev_serdev_init(void)
> > +{
> > +   return serdev_device_driver_register(_serdev_driver);
> > +}
> > +module_init(ttydev_serdev_init);
> > +
> > +static void __exit ttydev_serdev_exit(void)
> > +{
> > +   return serdev_device_driver_unregister(_serdev_driver);
> > +}
> > +module_exit(ttydev_serdev_exit);
>
> Isn't above is just a macro in serdev.h?
> I.e. module_serdev_device_driver().

ACK, thanks!
>
> --
> With Best Regards,
> Andy Shevchenko

Best regards

-- 
Ricardo Ribalda


Re: [PATCH 18/19] serdev: ttydev: Serdev driver that creates an standard TTY port

2018-06-06 Thread Ricardo Ribalda Delgado
Hi Andy
On Tue, Jun 5, 2018 at 3:42 PM Andy Shevchenko
 wrote:
>
> On Tue, May 29, 2018 at 4:10 PM, Ricardo Ribalda Delgado
>  wrote:
> > Standard TTY port that can be loaded/unloaded via serdev sysfs. This
> > serdev driver can only be used by serdev controllers that are compatible
> > with ttyport.
>
> > +config SERIAL_DEV_CTRL_TTYDEV
> > +   tristate "TTY port dynamically loaded by the Serial Device Bus"
> > +   help
> > + Say Y here if you want to create a bridge driver between the 
> > Serial
> > + device bus and the TTY chardevice. This driver can be dynamically
> > + loaded/unloaded by the Serial Device Bus.
> > +
> > + If unsure, say Y.
> > +   depends on SERIAL_DEV_CTRL_TTYPORT
>
> > +   default m
>
> Hmm... Can't we survive w/o this by default?

If this module is not available and serdev is enabled the user would
miss his /dev/ttyS* nodes, so I rather leave this on.

>
> > +static int __init ttydev_serdev_init(void)
> > +{
> > +   return serdev_device_driver_register(_serdev_driver);
> > +}
> > +module_init(ttydev_serdev_init);
> > +
> > +static void __exit ttydev_serdev_exit(void)
> > +{
> > +   return serdev_device_driver_unregister(_serdev_driver);
> > +}
> > +module_exit(ttydev_serdev_exit);
>
> Isn't above is just a macro in serdev.h?
> I.e. module_serdev_device_driver().

ACK, thanks!
>
> --
> With Best Regards,
> Andy Shevchenko

Best regards

-- 
Ricardo Ribalda


Re: [PATCH 18/19] serdev: ttydev: Serdev driver that creates an standard TTY port

2018-06-05 Thread Andy Shevchenko
On Tue, May 29, 2018 at 4:10 PM, Ricardo Ribalda Delgado
 wrote:
> Standard TTY port that can be loaded/unloaded via serdev sysfs. This
> serdev driver can only be used by serdev controllers that are compatible
> with ttyport.

> +config SERIAL_DEV_CTRL_TTYDEV
> +   tristate "TTY port dynamically loaded by the Serial Device Bus"
> +   help
> + Say Y here if you want to create a bridge driver between the Serial
> + device bus and the TTY chardevice. This driver can be dynamically
> + loaded/unloaded by the Serial Device Bus.
> +
> + If unsure, say Y.
> +   depends on SERIAL_DEV_CTRL_TTYPORT

> +   default m

Hmm... Can't we survive w/o this by default?

> +static int __init ttydev_serdev_init(void)
> +{
> +   return serdev_device_driver_register(_serdev_driver);
> +}
> +module_init(ttydev_serdev_init);
> +
> +static void __exit ttydev_serdev_exit(void)
> +{
> +   return serdev_device_driver_unregister(_serdev_driver);
> +}
> +module_exit(ttydev_serdev_exit);

Isn't above is just a macro in serdev.h?
I.e. module_serdev_device_driver().

-- 
With Best Regards,
Andy Shevchenko


Re: [PATCH 18/19] serdev: ttydev: Serdev driver that creates an standard TTY port

2018-06-05 Thread Andy Shevchenko
On Tue, May 29, 2018 at 4:10 PM, Ricardo Ribalda Delgado
 wrote:
> Standard TTY port that can be loaded/unloaded via serdev sysfs. This
> serdev driver can only be used by serdev controllers that are compatible
> with ttyport.

> +config SERIAL_DEV_CTRL_TTYDEV
> +   tristate "TTY port dynamically loaded by the Serial Device Bus"
> +   help
> + Say Y here if you want to create a bridge driver between the Serial
> + device bus and the TTY chardevice. This driver can be dynamically
> + loaded/unloaded by the Serial Device Bus.
> +
> + If unsure, say Y.
> +   depends on SERIAL_DEV_CTRL_TTYPORT

> +   default m

Hmm... Can't we survive w/o this by default?

> +static int __init ttydev_serdev_init(void)
> +{
> +   return serdev_device_driver_register(_serdev_driver);
> +}
> +module_init(ttydev_serdev_init);
> +
> +static void __exit ttydev_serdev_exit(void)
> +{
> +   return serdev_device_driver_unregister(_serdev_driver);
> +}
> +module_exit(ttydev_serdev_exit);

Isn't above is just a macro in serdev.h?
I.e. module_serdev_device_driver().

-- 
With Best Regards,
Andy Shevchenko


[PATCH 18/19] serdev: ttydev: Serdev driver that creates an standard TTY port

2018-05-29 Thread Ricardo Ribalda Delgado
Standard TTY port that can be loaded/unloaded via serdev sysfs. This
serdev driver can only be used by serdev controllers that are compatible
with ttyport.

Cc: Rob Herring 
Cc: Johan Hovold 
Cc: Greg Kroah-Hartman 
Cc: Jiri Slaby 
Signed-off-by: Ricardo Ribalda Delgado 
---
 drivers/tty/serdev/Kconfig | 11 +
 drivers/tty/serdev/Makefile|  2 +
 drivers/tty/serdev/serdev-ttydev.c | 70 ++
 3 files changed, 83 insertions(+)
 create mode 100644 drivers/tty/serdev/serdev-ttydev.c

diff --git a/drivers/tty/serdev/Kconfig b/drivers/tty/serdev/Kconfig
index 1dbc8352e027..d19bf689a424 100644
--- a/drivers/tty/serdev/Kconfig
+++ b/drivers/tty/serdev/Kconfig
@@ -21,4 +21,15 @@ config SERIAL_DEV_CTRL_TTYPORT
depends on SERIAL_DEV_BUS != m
default y
 
+config SERIAL_DEV_CTRL_TTYDEV
+   tristate "TTY port dynamically loaded by the Serial Device Bus"
+   help
+ Say Y here if you want to create a bridge driver between the Serial
+ device bus and the TTY chardevice. This driver can be dynamically
+ loaded/unloaded by the Serial Device Bus.
+
+ If unsure, say Y.
+   depends on SERIAL_DEV_CTRL_TTYPORT
+   default m
+
 endif
diff --git a/drivers/tty/serdev/Makefile b/drivers/tty/serdev/Makefile
index 0cbdb9444d9d..5c807b77d12d 100644
--- a/drivers/tty/serdev/Makefile
+++ b/drivers/tty/serdev/Makefile
@@ -3,3 +3,5 @@ serdev-objs := core.o
 obj-$(CONFIG_SERIAL_DEV_BUS) += serdev.o
 
 obj-$(CONFIG_SERIAL_DEV_CTRL_TTYPORT) += serdev-ttyport.o
+
+obj-$(CONFIG_SERIAL_DEV_CTRL_TTYDEV) += serdev-ttydev.o
diff --git a/drivers/tty/serdev/serdev-ttydev.c 
b/drivers/tty/serdev/serdev-ttydev.c
new file mode 100644
index ..66479d6534dd
--- /dev/null
+++ b/drivers/tty/serdev/serdev-ttydev.c
@@ -0,0 +1,70 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2018 Ricardo Ribalda 
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "serport.h"
+
+static int ttydev_serdev_probe(struct serdev_device *serdev)
+{
+   struct serdev_controller *ctrl = serdev->ctrl;
+   struct serport *serport;
+   struct device *dev;
+
+   if (!ctrl->is_ttyport)
+   return -ENODEV;
+
+   serport = serdev_controller_get_drvdata(ctrl);
+
+   dev = tty_register_device_attr(serport->tty_drv, serport->tty_idx,
+   >dev, NULL, NULL);
+
+   return dev ? 0 : PTR_ERR(dev);
+}
+
+static void ttydev_serdev_remove(struct serdev_device *serdev)
+{
+   struct serdev_controller *ctrl = serdev->ctrl;
+   struct serport *serport;
+
+   serport = serdev_controller_get_drvdata(ctrl);
+   tty_unregister_device(serport->tty_drv, serport->tty_idx);
+}
+
+static const struct serdev_device_id ttydev_serdev_id[] = {
+   { "ttydev", },
+   { "ttydev_serdev", },
+   {}
+};
+MODULE_DEVICE_TABLE(serdev, ttydev_serdev_id);
+
+static struct serdev_device_driver ttydev_serdev_driver = {
+   .probe = ttydev_serdev_probe,
+   .remove = ttydev_serdev_remove,
+   .driver = {
+   .name = "ttydev_serdev",
+   },
+   .id_table = ttydev_serdev_id,
+};
+
+static int __init ttydev_serdev_init(void)
+{
+   return serdev_device_driver_register(_serdev_driver);
+}
+module_init(ttydev_serdev_init);
+
+static void __exit ttydev_serdev_exit(void)
+{
+   return serdev_device_driver_unregister(_serdev_driver);
+}
+module_exit(ttydev_serdev_exit);
+
+MODULE_AUTHOR("Ricardo Ribalda ");
+MODULE_LICENSE("GPL v2");
+MODULE_DESCRIPTION("Serdev to ttydev module");
-- 
2.17.0



[PATCH 18/19] serdev: ttydev: Serdev driver that creates an standard TTY port

2018-05-29 Thread Ricardo Ribalda Delgado
Standard TTY port that can be loaded/unloaded via serdev sysfs. This
serdev driver can only be used by serdev controllers that are compatible
with ttyport.

Cc: Rob Herring 
Cc: Johan Hovold 
Cc: Greg Kroah-Hartman 
Cc: Jiri Slaby 
Signed-off-by: Ricardo Ribalda Delgado 
---
 drivers/tty/serdev/Kconfig | 11 +
 drivers/tty/serdev/Makefile|  2 +
 drivers/tty/serdev/serdev-ttydev.c | 70 ++
 3 files changed, 83 insertions(+)
 create mode 100644 drivers/tty/serdev/serdev-ttydev.c

diff --git a/drivers/tty/serdev/Kconfig b/drivers/tty/serdev/Kconfig
index 1dbc8352e027..d19bf689a424 100644
--- a/drivers/tty/serdev/Kconfig
+++ b/drivers/tty/serdev/Kconfig
@@ -21,4 +21,15 @@ config SERIAL_DEV_CTRL_TTYPORT
depends on SERIAL_DEV_BUS != m
default y
 
+config SERIAL_DEV_CTRL_TTYDEV
+   tristate "TTY port dynamically loaded by the Serial Device Bus"
+   help
+ Say Y here if you want to create a bridge driver between the Serial
+ device bus and the TTY chardevice. This driver can be dynamically
+ loaded/unloaded by the Serial Device Bus.
+
+ If unsure, say Y.
+   depends on SERIAL_DEV_CTRL_TTYPORT
+   default m
+
 endif
diff --git a/drivers/tty/serdev/Makefile b/drivers/tty/serdev/Makefile
index 0cbdb9444d9d..5c807b77d12d 100644
--- a/drivers/tty/serdev/Makefile
+++ b/drivers/tty/serdev/Makefile
@@ -3,3 +3,5 @@ serdev-objs := core.o
 obj-$(CONFIG_SERIAL_DEV_BUS) += serdev.o
 
 obj-$(CONFIG_SERIAL_DEV_CTRL_TTYPORT) += serdev-ttyport.o
+
+obj-$(CONFIG_SERIAL_DEV_CTRL_TTYDEV) += serdev-ttydev.o
diff --git a/drivers/tty/serdev/serdev-ttydev.c 
b/drivers/tty/serdev/serdev-ttydev.c
new file mode 100644
index ..66479d6534dd
--- /dev/null
+++ b/drivers/tty/serdev/serdev-ttydev.c
@@ -0,0 +1,70 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2018 Ricardo Ribalda 
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "serport.h"
+
+static int ttydev_serdev_probe(struct serdev_device *serdev)
+{
+   struct serdev_controller *ctrl = serdev->ctrl;
+   struct serport *serport;
+   struct device *dev;
+
+   if (!ctrl->is_ttyport)
+   return -ENODEV;
+
+   serport = serdev_controller_get_drvdata(ctrl);
+
+   dev = tty_register_device_attr(serport->tty_drv, serport->tty_idx,
+   >dev, NULL, NULL);
+
+   return dev ? 0 : PTR_ERR(dev);
+}
+
+static void ttydev_serdev_remove(struct serdev_device *serdev)
+{
+   struct serdev_controller *ctrl = serdev->ctrl;
+   struct serport *serport;
+
+   serport = serdev_controller_get_drvdata(ctrl);
+   tty_unregister_device(serport->tty_drv, serport->tty_idx);
+}
+
+static const struct serdev_device_id ttydev_serdev_id[] = {
+   { "ttydev", },
+   { "ttydev_serdev", },
+   {}
+};
+MODULE_DEVICE_TABLE(serdev, ttydev_serdev_id);
+
+static struct serdev_device_driver ttydev_serdev_driver = {
+   .probe = ttydev_serdev_probe,
+   .remove = ttydev_serdev_remove,
+   .driver = {
+   .name = "ttydev_serdev",
+   },
+   .id_table = ttydev_serdev_id,
+};
+
+static int __init ttydev_serdev_init(void)
+{
+   return serdev_device_driver_register(_serdev_driver);
+}
+module_init(ttydev_serdev_init);
+
+static void __exit ttydev_serdev_exit(void)
+{
+   return serdev_device_driver_unregister(_serdev_driver);
+}
+module_exit(ttydev_serdev_exit);
+
+MODULE_AUTHOR("Ricardo Ribalda ");
+MODULE_LICENSE("GPL v2");
+MODULE_DESCRIPTION("Serdev to ttydev module");
-- 
2.17.0