int retval;
retval = gb_debugfs_init();
- if (retval)
+ if (retval) {
+ pr_err("debugfs failed\n");
return retval;
+ }
retval = bus_register(&greybus_bus_type);
- if (retval)
+ if (retval) {
+ pr_err("bus_register failed\n");
goto error_bus;
+ }
retval = gb_thread_init();
- if (retval)
+ if (retval) {
+ pr_err("gb_thread_init failed\n");
goto error_thread;
+ }
// FIXME - more gb core init goes here
retval = gb_tty_init();
- if (retval)
+ if (retval) {
+ pr_err("gb_tty_init failed\n");
goto error_tty;
+ }
return 0;
* Heavily based on drivers/usb/class/cdc-acm.c and
* drivers/usb/serial/usb-serial.c.
*/
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/kernel.h>
#include <linux/errno.h>
#include <linux/kdev_t.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_NAME "ttyGB"
int retval = 0;
dev_t dev;
+#if 0
+
retval = alloc_chrdev_region(&dev, 0, GB_NUM_MINORS, GB_NAME);
- if (retval)
+ if (retval) {
+ pr_err("Can not allocate minors\n");
return retval;
+ }
+#endif
+
gb_tty_driver = tty_alloc_driver(GB_NUM_MINORS, 0);
if (IS_ERR(gb_tty_driver)) {
+ pr_err("Can not allocate tty driver\n");
retval = -ENOMEM;
goto fail_unregister_dev;
}
gb_tty_driver->driver_name = "gb";
gb_tty_driver->name = GB_NAME;
- gb_tty_driver->major = MAJOR(dev);
- gb_tty_driver->minor_start = MINOR(dev);
+ gb_tty_driver->major = 0;
+ gb_tty_driver->minor_start = 0;
gb_tty_driver->type = TTY_DRIVER_TYPE_SERIAL;
gb_tty_driver->subtype = SERIAL_TYPE_NORMAL;
gb_tty_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
tty_set_operations(gb_tty_driver, &gb_ops);
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;
+ }
+#if 0
retval = greybus_register(&tty_gb_driver);
- if (retval)
+ if (retval) {
+ pr_err("Can not register greybus driver.\n");
goto fail_unregister_gb_tty;
+ }
+#endif
return 0;
fail_put_gb_tty:
put_tty_driver(gb_tty_driver);
fail_unregister_dev:
- unregister_chrdev_region(dev, GB_NUM_MINORS);
+// unregister_chrdev_region(dev, GB_NUM_MINORS);
return retval;
}
{
int major = MAJOR(gb_tty_driver->major);
int minor = gb_tty_driver->minor_start;
- greybus_deregister(&tty_gb_driver);
+// greybus_deregister(&tty_gb_driver);
tty_unregister_driver(gb_tty_driver);
put_tty_driver(gb_tty_driver);
unregister_chrdev_region(MKDEV(major, minor), GB_NUM_MINORS);