From: Greg Kroah-Hartman Date: Sun, 31 Aug 2014 20:54:59 +0000 (-0700) Subject: greybus: register the bus with the driver core and add framework for debugfs files. X-Git-Tag: v4.14-rc1~2366^2~378^2~21^2~2166 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=27fb83109a3901767cbabafeba617d74f70fcbdc;p=platform%2Fkernel%2Flinux-rpi.git greybus: register the bus with the driver core and add framework for debugfs files. --- diff --git a/drivers/staging/greybus/Makefile b/drivers/staging/greybus/Makefile index 29ba1da..3badfef 100644 --- a/drivers/staging/greybus/Makefile +++ b/drivers/staging/greybus/Makefile @@ -1,4 +1,4 @@ -greybus-y := core.o gbuf.o i2c-gb.o gpio-gb.o sdio-gb.o uart-gb.o +greybus-y := core.o gbuf.o debugfs.o i2c-gb.o gpio-gb.o sdio-gb.o uart-gb.o obj-m += greybus.o obj-m += es1-ap-usb.o diff --git a/drivers/staging/greybus/core.c b/drivers/staging/greybus/core.c index b1a5b88..143882a 100644 --- a/drivers/staging/greybus/core.c +++ b/drivers/staging/greybus/core.c @@ -86,7 +86,7 @@ static int greybus_uevent(struct device *dev, struct kobj_uevent_env *env) return 0; } -struct bus_type greybus_bus_type = { +static struct bus_type greybus_bus_type = { .name = "greybus", .match = greybus_device_match, .uevent = greybus_uevent, @@ -199,16 +199,36 @@ static int __init gb_init(void) { int retval; - retval = gb_tty_init(); + retval = greybus_debugfs_init(); if (retval) return retval; + retval = bus_register(&greybus_bus_type); + if (retval) + goto error_bus; + + // FIXME - more gb core init goes here + + retval = gb_tty_init(); + if (retval) + goto error_tty; + return 0; + +error_tty: + bus_unregister(&greybus_bus_type); + +error_bus: + greybus_debugfs_cleanup(); + + return retval; } static void __exit gb_exit(void) { gb_tty_exit(); + bus_unregister(&greybus_bus_type); + greybus_debugfs_cleanup(); } module_init(gb_init); diff --git a/drivers/staging/greybus/debugfs.c b/drivers/staging/greybus/debugfs.c new file mode 100644 index 0000000..097b32d --- /dev/null +++ b/drivers/staging/greybus/debugfs.c @@ -0,0 +1,34 @@ +/* + * Greybus debugfs code + * + * Copyright 2014 Google Inc. + * + * Released under the GPLv2 only. + */ + +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + +#include +#include +#include +#include +#include +#include + +#include "greybus.h" + +static struct dentry *gb_debug_root; + +int greybus_debugfs_init(void) +{ + gb_debug_root = debugfs_create_dir("greybus", NULL); + if (!gb_debug_root) + return -ENOENT; + + return 0; +} + +void greybus_debugfs_cleanup(void) +{ + debugfs_remove_recursive(gb_debug_root); +} diff --git a/drivers/staging/greybus/greybus.h b/drivers/staging/greybus/greybus.h index 2440342a..7ce8c6e 100644 --- a/drivers/staging/greybus/greybus.h +++ b/drivers/staging/greybus/greybus.h @@ -174,10 +174,10 @@ void greybus_deregister(struct greybus_driver *driver); #define module_greybus_driver(__greybus_driver) \ module_driver(__greybus_driver, greybus_register, greybus_deregister) -extern struct bus_type greybus_bus_type; - int greybus_disabled(void); +int greybus_debugfs_init(void); +void greybus_debugfs_cleanup(void); #endif /* __KERNEL__ */ #endif /* __LINUX_GREYBUS_H */