Commit 168db1cd authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

greybus: tty driver fixes to get init working properly

parent 082570b0
...@@ -508,22 +508,30 @@ static int __init gb_init(void) ...@@ -508,22 +508,30 @@ static int __init gb_init(void)
int retval; int retval;
retval = gb_debugfs_init(); retval = gb_debugfs_init();
if (retval) if (retval) {
pr_err("debugfs failed\n");
return retval; return retval;
}
retval = bus_register(&greybus_bus_type); retval = bus_register(&greybus_bus_type);
if (retval) if (retval) {
pr_err("bus_register failed\n");
goto error_bus; goto error_bus;
}
retval = gb_thread_init(); retval = gb_thread_init();
if (retval) if (retval) {
pr_err("gb_thread_init failed\n");
goto error_thread; goto error_thread;
}
// FIXME - more gb core init goes here // FIXME - more gb core init goes here
retval = gb_tty_init(); retval = gb_tty_init();
if (retval) if (retval) {
pr_err("gb_tty_init failed\n");
goto error_tty; goto error_tty;
}
return 0; return 0;
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
* Heavily based on drivers/usb/class/cdc-acm.c and * Heavily based on drivers/usb/class/cdc-acm.c and
* drivers/usb/serial/usb-serial.c. * drivers/usb/serial/usb-serial.c.
*/ */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/errno.h> #include <linux/errno.h>
...@@ -27,7 +28,7 @@ ...@@ -27,7 +28,7 @@
#include <linux/kdev_t.h> #include <linux/kdev_t.h>
#include "greybus.h" #include "greybus.h"
#define GB_TTY_MAJOR 180 /* FIXME use a real number!!! */ #define GB_TTY_MAJOR 230 /* FIXME use a real number!!! */
#define GB_NUM_MINORS 255 /* 255 is enough for anyone... */ #define GB_NUM_MINORS 255 /* 255 is enough for anyone... */
#define GB_NAME "ttyGB" #define GB_NAME "ttyGB"
...@@ -473,20 +474,27 @@ int __init gb_tty_init(void) ...@@ -473,20 +474,27 @@ int __init gb_tty_init(void)
int retval = 0; int retval = 0;
dev_t dev; dev_t dev;
#if 0
retval = alloc_chrdev_region(&dev, 0, GB_NUM_MINORS, GB_NAME); retval = alloc_chrdev_region(&dev, 0, GB_NUM_MINORS, GB_NAME);
if (retval) if (retval) {
pr_err("Can not allocate minors\n");
return retval; return retval;
}
#endif
gb_tty_driver = tty_alloc_driver(GB_NUM_MINORS, 0); gb_tty_driver = tty_alloc_driver(GB_NUM_MINORS, 0);
if (IS_ERR(gb_tty_driver)) { if (IS_ERR(gb_tty_driver)) {
pr_err("Can not allocate tty driver\n");
retval = -ENOMEM; retval = -ENOMEM;
goto fail_unregister_dev; goto fail_unregister_dev;
} }
gb_tty_driver->driver_name = "gb"; gb_tty_driver->driver_name = "gb";
gb_tty_driver->name = GB_NAME; gb_tty_driver->name = GB_NAME;
gb_tty_driver->major = MAJOR(dev); gb_tty_driver->major = 0;
gb_tty_driver->minor_start = MINOR(dev); gb_tty_driver->minor_start = 0;
gb_tty_driver->type = TTY_DRIVER_TYPE_SERIAL; gb_tty_driver->type = TTY_DRIVER_TYPE_SERIAL;
gb_tty_driver->subtype = SERIAL_TYPE_NORMAL; gb_tty_driver->subtype = SERIAL_TYPE_NORMAL;
gb_tty_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV; gb_tty_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
...@@ -495,12 +503,18 @@ int __init gb_tty_init(void) ...@@ -495,12 +503,18 @@ int __init gb_tty_init(void)
tty_set_operations(gb_tty_driver, &gb_ops); tty_set_operations(gb_tty_driver, &gb_ops);
retval = tty_register_driver(gb_tty_driver); retval = tty_register_driver(gb_tty_driver);
if (retval) if (retval) {
pr_err("Can not register tty driver: %d\n", retval);
goto fail_put_gb_tty; goto fail_put_gb_tty;
}
#if 0
retval = greybus_register(&tty_gb_driver); retval = greybus_register(&tty_gb_driver);
if (retval) if (retval) {
pr_err("Can not register greybus driver.\n");
goto fail_unregister_gb_tty; goto fail_unregister_gb_tty;
}
#endif
return 0; return 0;
...@@ -509,7 +523,7 @@ int __init gb_tty_init(void) ...@@ -509,7 +523,7 @@ int __init gb_tty_init(void)
fail_put_gb_tty: fail_put_gb_tty:
put_tty_driver(gb_tty_driver); put_tty_driver(gb_tty_driver);
fail_unregister_dev: fail_unregister_dev:
unregister_chrdev_region(dev, GB_NUM_MINORS); // unregister_chrdev_region(dev, GB_NUM_MINORS);
return retval; return retval;
} }
...@@ -517,7 +531,7 @@ void __exit gb_tty_exit(void) ...@@ -517,7 +531,7 @@ void __exit gb_tty_exit(void)
{ {
int major = MAJOR(gb_tty_driver->major); int major = MAJOR(gb_tty_driver->major);
int minor = gb_tty_driver->minor_start; int minor = gb_tty_driver->minor_start;
greybus_deregister(&tty_gb_driver); // greybus_deregister(&tty_gb_driver);
tty_unregister_driver(gb_tty_driver); tty_unregister_driver(gb_tty_driver);
put_tty_driver(gb_tty_driver); put_tty_driver(gb_tty_driver);
unregister_chrdev_region(MKDEV(major, minor), GB_NUM_MINORS); unregister_chrdev_region(MKDEV(major, minor), GB_NUM_MINORS);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment