aboutsummaryrefslogtreecommitdiffstats
path: root/dbus.patch
blob: 01152d8f4c78eadd476daa068bfda4f25e83cd34 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
---
 drivers/char/Kconfig  |    3 ++
 drivers/char/Makefile |    1 
 drivers/char/dbus.c   |   57 ++++++++++++++++++++++++++++++++++++++++++++++++++
 include/linux/dbus.h  |   15 +++++++++++++
 4 files changed, 76 insertions(+)

--- a/drivers/char/Kconfig
+++ b/drivers/char/Kconfig
@@ -604,5 +604,8 @@ config TILE_SROM
 	  device appear much like a simple EEPROM, and knows
 	  how to partition a single ROM for multiple purposes.
 
+config DBUS
+	tristate "Kernel DBUS provider"
+
 endmenu
 
--- a/drivers/char/Makefile
+++ b/drivers/char/Makefile
@@ -62,3 +62,4 @@ obj-$(CONFIG_JS_RTC)		+= js-rtc.o
 js-rtc-y = rtc.o
 
 obj-$(CONFIG_TILE_SROM)		+= tile-srom.o
+obj-$(CONFIG_DBUS)		+= dbus.o
--- /dev/null
+++ b/drivers/char/dbus.c
@@ -0,0 +1,57 @@
+/*
+ * dbus - in kernel dbus functionality
+ *
+ * Copyright (C) 2012 Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+ * Copyright (C) 2012 Linux Foundation
+ *
+ * This file is released under the GPLv2 only.
+ */
+
+#include <linux/types.h>
+#include <linux/mutex.h>
+#include <linux/idr.h>
+#include <linux/module.h>
+#include <linux/dbus.h>
+
+static DEFINE_MUTEX(minor_lock);
+static DEFINE_IDR(minor_idr);
+
+static int minor_get(void)
+{
+	int minor = -ENOMEM;
+	int retval;
+
+	mutex_lock(&minor_lock);
+	if (idr_pre_get(&minor_idr, GFP_KERNEL) == 0)
+		goto exit;
+	retval = idr_get_new(&minor_idr, NULL, &minor);
+	if (retval < 0) {
+		minor = retval;
+		if (retval == -EAGAIN)
+			minor = -ENOMEM;
+	}
+exit:
+	mutex_unlock(&minor_lock);
+	return minor;
+}
+
+static void minor_free(int minor)
+{
+	mutex_lock(&minor_lock);
+	idr_remove(&minor_idr, minor);
+	mutex_unlock(&minor_lock);
+}
+
+static int dbus_init(void)
+{
+	return 0;
+}
+
+static void dbus_exit(void)
+{
+}
+
+module_init(dbus_init);
+module_exit(dbus_exit);
+
+MODULE_LICENSE("GPLv2");
--- /dev/null
+++ b/include/linux/dbus.h
@@ -0,0 +1,15 @@
+/*
+ * dbus.h - user/kernel dbus api
+ *
+ * Copyright (C) 2012 Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+ * Copyright (C) 2012 Linux Foundation
+ *
+ * Released under the GPLv2 only.
+ */
+
+#ifndef __DBUS_H
+#define __DBUS_H
+
+
+
+#endif	/* __DBUS_H */