[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>
This commit is contained in:
parent
1b11d78cf8
commit
2d8331792e
|
@ -88,17 +88,14 @@ static struct w1_master * w1_alloc_dev(u32 id, int slave_count, int slave_ttl,
|
||||||
|
|
||||||
dev->groups = 1;
|
dev->groups = 1;
|
||||||
dev->seq = 1;
|
dev->seq = 1;
|
||||||
dev->nls = netlink_kernel_create(NETLINK_W1, 1, NULL, THIS_MODULE);
|
dev_init_netlink(dev);
|
||||||
if (!dev->nls) {
|
|
||||||
printk(KERN_ERR "Failed to create new netlink socket(%u) for w1 master %s.\n",
|
|
||||||
NETLINK_NFLOG, dev->dev.bus_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
err = device_register(&dev->dev);
|
err = device_register(&dev->dev);
|
||||||
if (err) {
|
if (err) {
|
||||||
printk(KERN_ERR "Failed to register master device. err=%d\n", err);
|
printk(KERN_ERR "Failed to register master device. err=%d\n", err);
|
||||||
if (dev->nls && dev->nls->sk_socket)
|
|
||||||
sock_release(dev->nls->sk_socket);
|
dev_fini_netlink(dev);
|
||||||
|
|
||||||
memset(dev, 0, sizeof(struct w1_master));
|
memset(dev, 0, sizeof(struct w1_master));
|
||||||
kfree(dev);
|
kfree(dev);
|
||||||
dev = NULL;
|
dev = NULL;
|
||||||
|
@ -107,11 +104,10 @@ static struct w1_master * w1_alloc_dev(u32 id, int slave_count, int slave_ttl,
|
||||||
return dev;
|
return dev;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void w1_free_dev(struct w1_master *dev)
|
void w1_free_dev(struct w1_master *dev)
|
||||||
{
|
{
|
||||||
device_unregister(&dev->dev);
|
device_unregister(&dev->dev);
|
||||||
if (dev->nls && dev->nls->sk_socket)
|
dev_fini_netlink(dev);
|
||||||
sock_release(dev->nls->sk_socket);
|
|
||||||
memset(dev, 0, sizeof(struct w1_master) + sizeof(struct w1_bus_master));
|
memset(dev, 0, sizeof(struct w1_master) + sizeof(struct w1_bus_master));
|
||||||
kfree(dev);
|
kfree(dev);
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,10 +57,36 @@ void w1_netlink_send(struct w1_master *dev, struct w1_netlink_msg *msg)
|
||||||
nlmsg_failure:
|
nlmsg_failure:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int dev_init_netlink(struct w1_master *dev)
|
||||||
|
{
|
||||||
|
dev->nls = netlink_kernel_create(NETLINK_W1, 1, NULL, THIS_MODULE);
|
||||||
|
if (!dev->nls) {
|
||||||
|
printk(KERN_ERR "Failed to create new netlink socket(%u) for w1 master %s.\n",
|
||||||
|
NETLINK_W1, dev->dev.bus_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void dev_fini_netlink(struct w1_master *dev)
|
||||||
|
{
|
||||||
|
if (dev->nls && dev->nls->sk_socket)
|
||||||
|
sock_release(dev->nls->sk_socket);
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
#warning Netlink support is disabled. Please compile with NET support enabled.
|
#warning Netlink support is disabled. Please compile with NET support enabled.
|
||||||
|
|
||||||
void w1_netlink_send(struct w1_master *dev, struct w1_netlink_msg *msg)
|
void w1_netlink_send(struct w1_master *dev, struct w1_netlink_msg *msg)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int dev_init_netlink(struct w1_master *dev)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void dev_fini_netlink(struct w1_master *dev)
|
||||||
|
{
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -52,6 +52,8 @@ struct w1_netlink_msg
|
||||||
#ifdef __KERNEL__
|
#ifdef __KERNEL__
|
||||||
|
|
||||||
void w1_netlink_send(struct w1_master *, struct w1_netlink_msg *);
|
void w1_netlink_send(struct w1_master *, struct w1_netlink_msg *);
|
||||||
|
int dev_init_netlink(struct w1_master *dev);
|
||||||
|
void dev_fini_netlink(struct w1_master *dev);
|
||||||
|
|
||||||
#endif /* __KERNEL__ */
|
#endif /* __KERNEL__ */
|
||||||
#endif /* __W1_NETLINK_H */
|
#endif /* __W1_NETLINK_H */
|
||||||
|
|
Loading…
Reference in New Issue