aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorEvgeniy Polyakov <johnpol@2ka.mipt.ru>2005-07-27 05:10:11 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2005-09-08 17:41:25 -0400
commit2d8331792ea3f5ccfd147288afba148537337019 (patch)
tree7d144ae862363a5fd6bfa031cca04a42cc79d879 /drivers
parent1b11d78cf87a7014f96e5b7fa2e1233cc8081a00 (diff)
[PATCH] W1: w1_netlink: New init/fini netlink callbacks.
They are guarded with NETLINK_DISABLE compile time options, so if CONFIG_NET is disabled, no linking errors occur. Bug noticed by Adrian Bunk <bunk@stusta.de>. Signed-off-by: Evgeniy Polyakov <johnpol@2ka.mipt.ru> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/w1/w1_int.c16
-rw-r--r--drivers/w1/w1_netlink.c26
-rw-r--r--drivers/w1/w1_netlink.h2
3 files changed, 34 insertions, 10 deletions
diff --git a/drivers/w1/w1_int.c b/drivers/w1/w1_int.c
index 498ad505fa5f..2a538d012194 100644
--- a/drivers/w1/w1_int.c
+++ b/drivers/w1/w1_int.c
@@ -88,17 +88,14 @@ static struct w1_master * w1_alloc_dev(u32 id, int slave_count, int slave_ttl,
88 88
89 dev->groups = 1; 89 dev->groups = 1;
90 dev->seq = 1; 90 dev->seq = 1;
91 dev->nls = netlink_kernel_create(NETLINK_W1, 1, NULL, THIS_MODULE); 91 dev_init_netlink(dev);
92 if (!dev->nls) {
93 printk(KERN_ERR "Failed to create new netlink socket(%u) for w1 master %s.\n",
94 NETLINK_NFLOG, dev->dev.bus_id);
95 }
96 92
97 err = device_register(&dev->dev); 93 err = device_register(&dev->dev);
98 if (err) { 94 if (err) {
99 printk(KERN_ERR "Failed to register master device. err=%d\n", err); 95 printk(KERN_ERR "Failed to register master device. err=%d\n", err);
100 if (dev->nls && dev->nls->sk_socket) 96
101 sock_release(dev->nls->sk_socket); 97 dev_fini_netlink(dev);
98
102 memset(dev, 0, sizeof(struct w1_master)); 99 memset(dev, 0, sizeof(struct w1_master));
103 kfree(dev); 100 kfree(dev);
104 dev = NULL; 101 dev = NULL;
@@ -107,11 +104,10 @@ static struct w1_master * w1_alloc_dev(u32 id, int slave_count, int slave_ttl,
107 return dev; 104 return dev;
108} 105}
109 106
110static void w1_free_dev(struct w1_master *dev) 107void w1_free_dev(struct w1_master *dev)
111{ 108{
112 device_unregister(&dev->dev); 109 device_unregister(&dev->dev);
113 if (dev->nls && dev->nls->sk_socket) 110 dev_fini_netlink(dev);
114 sock_release(dev->nls->sk_socket);
115 memset(dev, 0, sizeof(struct w1_master) + sizeof(struct w1_bus_master)); 111 memset(dev, 0, sizeof(struct w1_master) + sizeof(struct w1_bus_master));
116 kfree(dev); 112 kfree(dev);
117} 113}
diff --git a/drivers/w1/w1_netlink.c b/drivers/w1/w1_netlink.c
index e7b774423dd6..328645da7972 100644
--- a/drivers/w1/w1_netlink.c
+++ b/drivers/w1/w1_netlink.c
@@ -57,10 +57,36 @@ void w1_netlink_send(struct w1_master *dev, struct w1_netlink_msg *msg)
57nlmsg_failure: 57nlmsg_failure:
58 return; 58 return;
59} 59}
60
61int dev_init_netlink(struct w1_master *dev)
62{
63 dev->nls = netlink_kernel_create(NETLINK_W1, 1, NULL, THIS_MODULE);
64 if (!dev->nls) {
65 printk(KERN_ERR "Failed to create new netlink socket(%u) for w1 master %s.\n",
66 NETLINK_W1, dev->dev.bus_id);
67 }
68
69 return 0;
70}
71
72void dev_fini_netlink(struct w1_master *dev)
73{
74 if (dev->nls && dev->nls->sk_socket)
75 sock_release(dev->nls->sk_socket);
76}
60#else 77#else
61#warning Netlink support is disabled. Please compile with NET support enabled. 78#warning Netlink support is disabled. Please compile with NET support enabled.
62 79
63void w1_netlink_send(struct w1_master *dev, struct w1_netlink_msg *msg) 80void w1_netlink_send(struct w1_master *dev, struct w1_netlink_msg *msg)
64{ 81{
65} 82}
83
84int dev_init_netlink(struct w1_master *dev)
85{
86 return 0;
87}
88
89void dev_fini_netlink(struct w1_master *dev)
90{
91}
66#endif 92#endif
diff --git a/drivers/w1/w1_netlink.h b/drivers/w1/w1_netlink.h
index 8615756946df..eb0c8b3152c8 100644
--- a/drivers/w1/w1_netlink.h
+++ b/drivers/w1/w1_netlink.h
@@ -52,6 +52,8 @@ struct w1_netlink_msg
52#ifdef __KERNEL__ 52#ifdef __KERNEL__
53 53
54void w1_netlink_send(struct w1_master *, struct w1_netlink_msg *); 54void w1_netlink_send(struct w1_master *, struct w1_netlink_msg *);
55int dev_init_netlink(struct w1_master *dev);
56void dev_fini_netlink(struct w1_master *dev);
55 57
56#endif /* __KERNEL__ */ 58#endif /* __KERNEL__ */
57#endif /* __W1_NETLINK_H */ 59#endif /* __W1_NETLINK_H */