Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

kernel doc for internal.h, add handle.h, move some things around to b…

…ecome static
  • Loading branch information...
commit 675d4b314b826266c83ab0d4c597217830204a56 1 parent 1ca937b
@kaysievers kaysievers authored
View
4 bus.c
@@ -1,7 +1,7 @@
/*
* Copyright (C) 2013 Kay Sievers
* Copyright (C) 2013 Greg Kroah-Hartman <gregkh@linuxfoundation.org>
- * Copyright (C) 2013 Daniel Mack
+ * Copyright (C) 2013 Daniel Mack <daniel@zonque.org>
* Copyright (C) 2013 Linux Foundation
*
* kdbus is free software; you can redistribute it and/or modify it under
@@ -10,8 +10,6 @@
* your option) any later version.
*/
-#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
-
#include <linux/module.h>
#include <linux/device.h>
#include <linux/fs.h>
View
1  bus.h
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2013 Kay Sievers
* Copyright (C) 2013 Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+ * Copyright (C) 2013 Daniel Mack <daniel@zonque.org>
* Copyright (C) 2013 Linux Foundation
*
* kdbus is free software; you can redistribute it and/or modify it under
View
4 connection.c
@@ -1,8 +1,8 @@
/*
* Copyright (C) 2013 Kay Sievers
* Copyright (C) 2013 Greg Kroah-Hartman <gregkh@linuxfoundation.org>
- * Copyright (C) 2013 Linux Foundation
* Copyright (C) 2013 Daniel Mack <daniel@zonque.org>
+ * Copyright (C) 2013 Linux Foundation
*
* kdbus is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the
@@ -10,8 +10,6 @@
* your option) any later version.
*/
-#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
-
#include <linux/module.h>
#include <linux/device.h>
#include <linux/idr.h>
View
2  connection.h
@@ -1,8 +1,8 @@
/*
* Copyright (C) 2013 Kay Sievers
* Copyright (C) 2013 Greg Kroah-Hartman <gregkh@linuxfoundation.org>
- * Copyright (C) 2013 Linux Foundation
* Copyright (C) 2013 Daniel Mack <daniel@zonque.org>
+ * Copyright (C) 2013 Linux Foundation
*
* kdbus is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the
View
8 endpoint.c
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2013 Kay Sievers
* Copyright (C) 2013 Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+ * Copyright (C) 2013 Daniel Mack <daniel@zonque.org>
* Copyright (C) 2013 Linux Foundation
*
* kdbus is free software; you can redistribute it and/or modify it under
@@ -9,8 +10,6 @@
* your option) any later version.
*/
-#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
-
#include <linux/module.h>
#include <linux/device.h>
#include <linux/idr.h>
@@ -43,6 +42,11 @@ static char *kdbus_devnode_ep(struct device *dev, umode_t *mode,
return NULL;
}
+static void kdbus_dev_release(struct device *dev)
+{
+ kfree(dev);
+}
+
static struct device_type kdbus_devtype_ep = {
.name = "ep",
.release = kdbus_dev_release,
View
1  endpoint.h
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2013 Kay Sievers
* Copyright (C) 2013 Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+ * Copyright (C) 2013 Daniel Mack <daniel@zonque.org>
* Copyright (C) 2013 Linux Foundation
*
* kdbus is free software; you can redistribute it and/or modify it under
View
4 handle.c
@@ -1,8 +1,8 @@
/*
* Copyright (C) 2013 Kay Sievers
* Copyright (C) 2013 Greg Kroah-Hartman <gregkh@linuxfoundation.org>
- * Copyright (C) 2013 Linux Foundation
* Copyright (C) 2013 Daniel Mack <daniel@zonque.org>
+ * Copyright (C) 2013 Linux Foundation
*
* kdbus is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the
@@ -10,8 +10,6 @@
* your option) any later version.
*/
-#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
-
#include <linux/module.h>
#include <linux/device.h>
#include <linux/idr.h>
View
17 handle.h
@@ -0,0 +1,17 @@
+/*
+ * Copyright (C) 2013 Kay Sievers
+ * Copyright (C) 2013 Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+ * Copyright (C) 2013 Daniel Mack <daniel@zonque.org>
+ * Copyright (C) 2013 Linux Foundation
+ *
+ * kdbus is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at
+ * your option) any later version.
+ */
+
+#ifndef __KDBUS_HANDLE_H
+#define __KDBUS_HANDLE_H
+
+extern const struct file_operations kdbus_device_ops;
+#endif
View
49 internal.h
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2013 Kay Sievers
* Copyright (C) 2013 Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+ * Copyright (C) 2013 Daniel Mack <daniel@zonque.org>
* Copyright (C) 2013 Linux Foundation
*
* kdbus is free software; you can redistribute it and/or modify it under
@@ -12,9 +13,9 @@
#ifndef __KDBUS_INTERNAL_H
#define __KDBUS_INTERNAL_H
-//#include <uapi/kdbus/kdbus.h>
#include "kdbus.h"
+/* limits enforced by the interfaces */
#define KDBUS_MSG_MAX_SIZE SZ_8K /* maximum size of message header and items */
#define KDBUS_MSG_MAX_ITEMS 128 /* maximum number of message items */
#define KDBUS_MSG_MAX_FDS 256 /* maximum number of passed file descriptors */
@@ -33,13 +34,14 @@
#define KDBUS_CONN_MAX_NAMES 64 /* maximum number of well-known names */
#define KDBUS_CONN_MAX_ALLOCATED_BYTES SZ_64K /* maximum number of allocated bytes on the bus */
-/* exported addresses are 64bit */
+/* all exported addresses are 64 bit */
#define KDBUS_PTR(addr) ((void __user *)(uintptr_t)(addr))
-/* exported sizes are 64bit and data aligned to 64 bit */
+/* all exported sizes are 64 bit and data aligned to 64 bit */
#define KDBUS_ALIGN8(s) ALIGN((s), 8)
#define KDBUS_IS_ALIGNED8(s) (IS_ALIGNED(s, 8))
+/* generic access and iterators over a stream of items/parts */
#define KDBUS_PART_HEADER_SIZE sizeof(KDBUS_PART_HEADER)
#define KDBUS_PART_SIZE(s) KDBUS_ALIGN8(KDBUS_PART_HEADER_SIZE + (s))
#define KDBUS_PART_NEXT(part) \
@@ -56,34 +58,57 @@
#define KDBUS_MSG_HEADER_SIZE offsetof(struct kdbus_msg, items)
-/* read 64bit .size in struct */
+/**
+ * kdbus_size_get_user - read the size variable from user memory
+ * @_s: Size variable
+ * @_b: Buffer to read from
+ * @_t: Structure "size" is embedded in
+ *
+ * Returns: the result of copy_from_user()
+ */
#define kdbus_size_get_user(_s, _b, _t) \
({ \
u64 __user *_sz = (void __user *)(_b) + offsetof(typeof(_t), size); \
copy_from_user(_s, _sz, sizeof(__u64)); \
})
-/* set 64bit .offset in struct */
+/**
+ * kdbus_offset_set_user - write the offset variable to user memory
+ * @_s: Offset variable
+ * @_b: Buffer to write to
+ * @_t: Structure "offset" is embedded in
+ *
+ * Returns: the result of copy_to_user()
+ */
#define kdbus_offset_set_user(_s, _b, _t) \
({ \
u64 __user *_sz = (void __user *)(_b) + offsetof(typeof(_t), offset); \
copy_to_user(_sz, _s, sizeof(__u64)); \
})
+/**
+ * kdbus_validate_nul - check the validity of a sized string
+ * @s: String
+ * @l: Length of string
+ *
+ * Validate that a given string matches the given size, and the
+ * string is \0 terminated.
+ *
+ * Returns: true if the given string is valid
+ */
static inline bool kdbus_validate_nul(const char *s, size_t l)
{
return l > 0 && memchr(s, '\0', l) == s + l - 1;
}
+/**
+ * kdbus_str_hash - calculate a hash
+ * @str: String
+ *
+ * Returns: hash value
+ */
static inline unsigned int kdbus_str_hash(const char *str)
{
return full_name_hash(str, strlen(str));
}
-
-extern const struct file_operations kdbus_device_ops;
-extern struct bus_type kdbus_subsys;
-void kdbus_dev_release(struct device *dev);
-extern struct mutex kdbus_subsys_lock;
-extern struct idr kdbus_ns_major_idr;
-extern struct kdbus_ns *kdbus_ns_init;
#endif
View
21 main.c
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2013 Kay Sievers
* Copyright (C) 2013 Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+ * Copyright (C) 2013 Daniel Mack <daniel@zonque.org>
* Copyright (C) 2013 Linux Foundation
*
* kdbus is free software; you can redistribute it and/or modify it under
@@ -9,8 +10,6 @@
* your option) any later version.
*/
-#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
-
#include <linux/module.h>
#include <linux/device.h>
#include <linux/idr.h>
@@ -25,22 +24,6 @@
#include "internal.h"
#include "namespace.h"
-/* kdbus sysfs subsystem */
-struct bus_type kdbus_subsys = {
- .name = "kdbus",
-};
-
-/* kdbus initial namespace */
-struct kdbus_ns *kdbus_ns_init;
-
-/* map of majors to namespaces */
-DEFINE_IDR(kdbus_ns_major_idr);
-
-void kdbus_dev_release(struct device *dev)
-{
- kfree(dev);
-}
-
static int __init kdbus_init(void)
{
int ret;
@@ -60,7 +43,7 @@ static int __init kdbus_init(void)
return ret;
}
- pr_info("initialized\n");
+ pr_info("kdbus initialized\n");
return 0;
}
View
2  match.c
@@ -10,8 +10,6 @@
* your option) any later version.
*/
-#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
-
#include <linux/fs.h>
#include <linux/slab.h>
#include <linux/sched.h>
View
1  match.h
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2013 Kay Sievers
* Copyright (C) 2013 Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+ * Copyright (C) 2013 Daniel Mack <daniel@zonque.org>
* Copyright (C) 2013 Linux Foundation
*
* kdbus is free software; you can redistribute it and/or modify it under
View
4 memfd.c
@@ -1,8 +1,8 @@
/*
* Copyright (C) 2013 Kay Sievers
* Copyright (C) 2013 Greg Kroah-Hartman <gregkh@linuxfoundation.org>
- * Copyright (C) 2013 Linux Foundation
* Copyright (C) 2013 Daniel Mack <daniel@zonque.org>
+ * Copyright (C) 2013 Linux Foundation
*
* kdbus is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the
@@ -10,8 +10,6 @@
* your option) any later version.
*/
-#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
-
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/sizes.h>
View
2  memfd.h
@@ -1,8 +1,8 @@
/*
* Copyright (C) 2013 Kay Sievers
* Copyright (C) 2013 Greg Kroah-Hartman <gregkh@linuxfoundation.org>
- * Copyright (C) 2013 Linux Foundation
* Copyright (C) 2013 Daniel Mack <daniel@zonque.org>
+ * Copyright (C) 2013 Linux Foundation
*
* kdbus is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the
View
2  message.c
@@ -10,8 +10,6 @@
* your option) any later version.
*/
-#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
-
#include <linux/module.h>
#include <linux/device.h>
#include <linux/idr.h>
View
1  message.h
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2013 Kay Sievers
* Copyright (C) 2013 Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+ * Copyright (C) 2013 Daniel Mack <daniel@zonque.org>
* Copyright (C) 2013 Linux Foundation
*
* kdbus is free software; you can redistribute it and/or modify it under
View
2  metadata.c
@@ -10,8 +10,6 @@
* your option) any later version.
*/
-#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
-
#include <linux/slab.h>
#include <linux/file.h>
#include <linux/sched.h>
View
1  metadata.h
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2013 Kay Sievers
* Copyright (C) 2013 Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+ * Copyright (C) 2013 Daniel Mack <daniel@zonque.org>
* Copyright (C) 2013 Linux Foundation
*
* kdbus is free software; you can redistribute it and/or modify it under
View
2  names.c
@@ -10,8 +10,6 @@
* your option) any later version.
*/
-#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
-
#include <linux/module.h>
#include <linux/device.h>
#include <linux/idr.h>
View
1  names.h
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2013 Kay Sievers
* Copyright (C) 2013 Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+ * Copyright (C) 2013 Daniel Mack <daniel@zonque.org>
* Copyright (C) 2013 Linux Foundation
*
* kdbus is free software; you can redistribute it and/or modify it under
View
24 namespace.c
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2013 Kay Sievers
* Copyright (C) 2013 Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+ * Copyright (C) 2013 Daniel Mack <daniel@zonque.org>
* Copyright (C) 2013 Linux Foundation
*
* kdbus is free software; you can redistribute it and/or modify it under
@@ -9,8 +10,6 @@
* your option) any later version.
*/
-#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
-
#include <linux/module.h>
#include <linux/device.h>
#include <linux/idr.h>
@@ -22,18 +21,30 @@
#include <linux/sizes.h>
#include <uapi/linux/major.h>
+#include "handle.h"
#include "namespace.h"
#include "bus.h"
/* global list of all namespaces */
static LIST_HEAD(namespace_list);
-/* namespace list lock */
-DEFINE_MUTEX(kdbus_subsys_lock);
+/* map of majors to namespaces */
+static DEFINE_IDR(kdbus_ns_major_idr);
/* next namespace id sequence number */
static u64 kdbus_ns_id_next;
+/* kdbus initial namespace */
+struct kdbus_ns *kdbus_ns_init;
+
+/* kdbus subsystem lock */
+static DEFINE_MUTEX(kdbus_subsys_lock);
+
+/* kdbus sysfs subsystem */
+struct bus_type kdbus_subsys = {
+ .name = "kdbus",
+};
+
/* control nodes are world accessible */
static char *kdbus_devnode_control(struct device *dev, umode_t *mode,
kuid_t *uid, kgid_t *gid)
@@ -46,6 +57,11 @@ static char *kdbus_devnode_control(struct device *dev, umode_t *mode,
return NULL;
}
+static void kdbus_dev_release(struct device *dev)
+{
+ kfree(dev);
+}
+
static struct device_type kdbus_devtype_control = {
.name = "control",
.release = kdbus_dev_release,
View
4 namespace.h
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2013 Kay Sievers
* Copyright (C) 2013 Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+ * Copyright (C) 2013 Daniel Mack <daniel@zonque.org>
* Copyright (C) 2013 Linux Foundation
*
* kdbus is free software; you can redistribute it and/or modify it under
@@ -58,6 +59,9 @@ struct kdbus_ns {
struct list_head bus_list;
};
+extern struct kdbus_ns *kdbus_ns_init;
+extern struct bus_type kdbus_subsys;
+
struct kdbus_ns *kdbus_ns_ref(struct kdbus_ns *ns);
void kdbus_ns_unref(struct kdbus_ns *ns);
void kdbus_ns_disconnect(struct kdbus_ns *ns);
View
2  notify.c
@@ -10,8 +10,6 @@
* your option) any later version.
*/
-#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
-
#include <linux/module.h>
#include <linux/device.h>
#include <linux/idr.h>
View
1  notify.h
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2013 Kay Sievers
* Copyright (C) 2013 Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+ * Copyright (C) 2013 Daniel Mack <daniel@zonque.org>
* Copyright (C) 2013 Linux Foundation
*
* kdbus is free software; you can redistribute it and/or modify it under
View
2  policy.c
@@ -10,8 +10,6 @@
* your option) any later version.
*/
-#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
-
#include <linux/module.h>
#include <linux/device.h>
#include <linux/idr.h>
View
1  policy.h
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2013 Kay Sievers
* Copyright (C) 2013 Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+ * Copyright (C) 2013 Daniel Mack <daniel@zonque.org>
* Copyright (C) 2013 Linux Foundation
*
* kdbus is free software; you can redistribute it and/or modify it under
View
4 pool.c
@@ -1,8 +1,8 @@
/*
* Copyright (C) 2013 Kay Sievers
* Copyright (C) 2013 Greg Kroah-Hartman <gregkh@linuxfoundation.org>
- * Copyright (C) 2013 Linux Foundation
* Copyright (C) 2013 Daniel Mack <daniel@zonque.org>
+ * Copyright (C) 2013 Linux Foundation
*
* kdbus is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the
@@ -10,8 +10,6 @@
* your option) any later version.
*/
-#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
-
#include <linux/module.h>
#include <linux/fs.h>
#include <linux/slab.h>
View
2  pool.h
@@ -1,8 +1,8 @@
/*
* Copyright (C) 2013 Kay Sievers
* Copyright (C) 2013 Greg Kroah-Hartman <gregkh@linuxfoundation.org>
- * Copyright (C) 2013 Linux Foundation
* Copyright (C) 2013 Daniel Mack <daniel@zonque.org>
+ * Copyright (C) 2013 Linux Foundation
*
* kdbus is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the
Please sign in to comment.
Something went wrong with that request. Please try again.