From: Greg KH <gregkh@suse.de>
To: linux-kernel@vger.kernel.org
Cc: johnpol@2ka.mipt.ru
Subject: [PATCH] W1: w1_netlink: New init/fini netlink callbacks.
Date: Thu, 8 Sep 2005 15:22:40 -0700 [thread overview]
Message-ID: <11262181602327@kroah.com> (raw)
In-Reply-To: <20050905214431.GA5897@kroah.com>
[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>
---
commit 2d8331792ea3f5ccfd147288afba148537337019
tree 7d144ae862363a5fd6bfa031cca04a42cc79d879
parent 1b11d78cf87a7014f96e5b7fa2e1233cc8081a00
author Evgeniy Polyakov <johnpol@2ka.mipt.ru> Wed, 27 Jul 2005 13:10:11 +0400
committer Greg Kroah-Hartman <gregkh@suse.de> Thu, 08 Sep 2005 14:41:25 -0700
drivers/w1/w1_int.c | 16 ++++++----------
drivers/w1/w1_netlink.c | 26 ++++++++++++++++++++++++++
drivers/w1/w1_netlink.h | 2 ++
3 files changed, 34 insertions(+), 10 deletions(-)
diff --git a/drivers/w1/w1_int.c b/drivers/w1/w1_int.c
--- a/drivers/w1/w1_int.c
+++ b/drivers/w1/w1_int.c
@@ -88,17 +88,14 @@ static struct w1_master * w1_alloc_dev(u
dev->groups = 1;
dev->seq = 1;
- 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_NFLOG, dev->dev.bus_id);
- }
+ dev_init_netlink(dev);
err = device_register(&dev->dev);
if (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));
kfree(dev);
dev = NULL;
@@ -107,11 +104,10 @@ static struct w1_master * w1_alloc_dev(u
return dev;
}
-static void w1_free_dev(struct w1_master *dev)
+void w1_free_dev(struct w1_master *dev)
{
device_unregister(&dev->dev);
- if (dev->nls && dev->nls->sk_socket)
- sock_release(dev->nls->sk_socket);
+ dev_fini_netlink(dev);
memset(dev, 0, sizeof(struct w1_master) + sizeof(struct w1_bus_master));
kfree(dev);
}
diff --git a/drivers/w1/w1_netlink.c b/drivers/w1/w1_netlink.c
--- a/drivers/w1/w1_netlink.c
+++ b/drivers/w1/w1_netlink.c
@@ -57,10 +57,36 @@ void w1_netlink_send(struct w1_master *d
nlmsg_failure:
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
#warning Netlink support is disabled. Please compile with NET support enabled.
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
diff --git a/drivers/w1/w1_netlink.h b/drivers/w1/w1_netlink.h
--- a/drivers/w1/w1_netlink.h
+++ b/drivers/w1/w1_netlink.h
@@ -52,6 +52,8 @@ struct w1_netlink_msg
#ifdef __KERNEL__
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 /* __W1_NETLINK_H */
next prev parent reply other threads:[~2005-09-08 22:26 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-09-05 21:44 [GIT PATCH] I2C patches for 2.6.13 Greg KH
2005-09-05 23:45 ` [lm-sensors] " Greg KH
2005-09-06 19:09 ` Jean Delvare
2005-09-06 21:09 ` Jean Delvare
2005-09-08 22:22 ` Greg KH [this message]
2005-09-08 22:22 ` [PATCH] w1: Detouching bug fixed Greg KH
2005-09-08 22:22 ` [PATCH] w1: Fixed 64bit compilation warning Greg KH
2005-09-08 22:22 ` [PATCH] w1: hotplug support Greg KH
2005-09-08 22:22 ` [PATCH] W1: Sync with w1/ds9490 tree Greg KH
2005-09-08 22:22 ` [PATCH] w1: Added add/remove slave callbacks Greg KH
2005-09-08 22:22 ` [PATCH] w1: Added inline functions on top of container_of() Greg KH
2005-09-08 22:22 ` [PATCH] w1: Added w1_reset_select_slave() - Resets the bus and then selects the slave by Greg KH
2005-09-08 22:22 ` [PATCH] w1_ds2433: Added crc16 protection and read caching Greg KH
2005-09-08 22:22 ` [PATCH] lib/crc16: added crc16 algorithm Greg KH
2005-09-08 22:22 ` [PATCH] w1: Decreased debug level Greg KH
2005-09-08 22:22 ` [PATCH] w1: Added DS2433 driver Greg KH
2005-09-08 22:22 ` [PATCH] w1: Added DS2433 driver - family id update Greg KH
2005-09-08 22:22 ` [PATCH] w1: added private family data into w1_slave strucutre Greg KH
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=11262181602327@kroah.com \
--to=gregkh@suse.de \
--cc=greg@kroah.com \
--cc=johnpol@2ka.mipt.ru \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.