[Devel,2/6] proc connector: introduce get_cdev() helper

Submitted by Stanislav Kinsburskiy on Aug. 15, 2017, 12:41 p.m.

Details

Message ID 20170815124159.22445.33116.stgit@localhost.localdomain
State New
Series "proc connector: containerize on per-net basis"
Headers show

Commit Message

Stanislav Kinsburskiy Aug. 15, 2017, 12:41 p.m.
This is a precursor helper, which will hide all the containerization magic.

Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>
---
 drivers/connector/connector.c |   20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

Patch hide | download patch | download mbox

diff --git a/drivers/connector/connector.c b/drivers/connector/connector.c
index d0b678f..833aea4 100644
--- a/drivers/connector/connector.c
+++ b/drivers/connector/connector.c
@@ -65,6 +65,12 @@  static int cn_already_initialized;
  * a new message.
  *
  */
+
+static struct cn_dev *get_cdev(void)
+{
+	return &cdev;
+}
+
 int cn_netlink_send(struct cn_msg *msg, u32 __group, gfp_t gfp_mask)
 {
 	struct cn_callback_entry *__cbq;
@@ -72,7 +78,7 @@  int cn_netlink_send(struct cn_msg *msg, u32 __group, gfp_t gfp_mask)
 	struct sk_buff *skb;
 	struct nlmsghdr *nlh;
 	struct cn_msg *data;
-	struct cn_dev *dev = &cdev;
+	struct cn_dev *dev = get_cdev();
 	u32 group = 0;
 	int found = 0;
 
@@ -125,7 +131,7 @@  EXPORT_SYMBOL_GPL(cn_netlink_send);
 static int cn_call_callback(struct sk_buff *skb)
 {
 	struct cn_callback_entry *i, *cbq = NULL;
-	struct cn_dev *dev = &cdev;
+	struct cn_dev *dev = get_cdev();
 	struct cn_msg *msg = nlmsg_data(nlmsg_hdr(skb));
 	struct netlink_skb_parms *nsp = &NETLINK_CB(skb);
 	int err = -ENODEV;
@@ -192,7 +198,7 @@  int cn_add_callback(struct cb_id *id, const char *name,
 				     struct netlink_skb_parms *))
 {
 	int err;
-	struct cn_dev *dev = &cdev;
+	struct cn_dev *dev = get_cdev();
 
 	if (!cn_already_initialized)
 		return -EAGAIN;
@@ -215,7 +221,7 @@  EXPORT_SYMBOL_GPL(cn_add_callback);
  */
 void cn_del_callback(struct cb_id *id)
 {
-	struct cn_dev *dev = &cdev;
+	struct cn_dev *dev = get_cdev();
 
 	cn_queue_del_callback(dev->cbdev, id);
 }
@@ -223,7 +229,7 @@  EXPORT_SYMBOL_GPL(cn_del_callback);
 
 static int cn_proc_show(struct seq_file *m, void *v)
 {
-	struct cn_queue_dev *dev = cdev.cbdev;
+	struct cn_queue_dev *dev = get_cdev()->cbdev;
 	struct cn_callback_entry *cbq;
 
 	seq_printf(m, "Name            ID\n");
@@ -371,7 +377,7 @@  static struct cn_dev cdev = {
 
 static int cn_init(void)
 {
-	struct cn_dev *dev = &cdev;
+	struct cn_dev *dev = get_cdev();
 	struct netlink_kernel_cfg cfg = {
 		.groups	= CN_NETLINK_USERS + 0xf,
 		.input	= dev->input,
@@ -398,7 +404,7 @@  static int cn_init(void)
 
 static void cn_fini(void)
 {
-	struct cn_dev *dev = &cdev;
+	struct cn_dev *dev = get_cdev();
 
 	cn_already_initialized = 0;