From: Rupesh Gujare <rupesh.gujare@atmel.com>
To: <devel@linuxdriverproject.org>
Cc: <linux-usb@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<gregkh@linuxfoundation.org>
Subject: [PATCH 1/6] staging: ozwpan: Use kernel list function for managing interface list.
Date: Thu, 1 Aug 2013 18:40:00 +0100 [thread overview]
Message-ID: <1375378806-17948-2-git-send-email-rupesh.gujare@atmel.com> (raw)
In-Reply-To: <1375378806-17948-1-git-send-email-rupesh.gujare@atmel.com>
Managing interface list, is easier if we use kernel list_* API
than managing it on our own.
Signed-off-by: Rupesh Gujare <rupesh.gujare@atmel.com>
---
drivers/staging/ozwpan/ozproto.c | 29 +++++++++++++----------------
1 file changed, 13 insertions(+), 16 deletions(-)
diff --git a/drivers/staging/ozwpan/ozproto.c b/drivers/staging/ozwpan/ozproto.c
index ed22729..500800f 100644
--- a/drivers/staging/ozwpan/ozproto.c
+++ b/drivers/staging/ozwpan/ozproto.c
@@ -37,7 +37,7 @@
struct oz_binding {
struct packet_type ptype;
char name[OZ_MAX_BINDING_LEN];
- struct oz_binding *next;
+ struct list_head link;
};
/*------------------------------------------------------------------------------
@@ -45,7 +45,7 @@ struct oz_binding {
*/
static DEFINE_SPINLOCK(g_polling_lock);
static LIST_HEAD(g_pd_list);
-static struct oz_binding *g_binding ;
+static LIST_HEAD(g_binding);
static DEFINE_SPINLOCK(g_binding_lock);
static struct sk_buff_head g_rx_queue;
static u8 g_session_id;
@@ -437,12 +437,13 @@ done:
*/
void oz_protocol_term(void)
{
+ struct oz_binding *b, *t;
+
/* Walk the list of bindings and remove each one.
*/
spin_lock_bh(&g_binding_lock);
- while (g_binding) {
- struct oz_binding *b = g_binding;
- g_binding = b->next;
+ list_for_each_entry_safe(b, t, &g_binding, link) {
+ list_del(&b->link);
spin_unlock_bh(&g_binding_lock);
dev_remove_pack(&b->ptype);
if (b->ptype.dev)
@@ -660,8 +661,7 @@ void oz_binding_add(char *net_dev)
if (binding) {
dev_add_pack(&binding->ptype);
spin_lock_bh(&g_binding_lock);
- binding->next = g_binding;
- g_binding = binding;
+ list_add_tail(&binding->link, &g_binding);
spin_unlock_bh(&g_binding_lock);
}
}
@@ -710,28 +710,25 @@ static void pd_stop_all_for_device(struct net_device *net_dev)
void oz_binding_remove(char *net_dev)
{
struct oz_binding *binding;
- struct oz_binding **link;
+ int found = 0;
+
oz_dbg(ON, "Removing binding: %s\n", net_dev);
spin_lock_bh(&g_binding_lock);
- binding = g_binding;
- link = &g_binding;
- while (binding) {
+ list_for_each_entry(binding, &g_binding, link) {
if (compare_binding_name(binding->name, net_dev)) {
oz_dbg(ON, "Binding '%s' found\n", net_dev);
- *link = binding->next;
+ found = 1;
break;
- } else {
- link = &binding;
- binding = binding->next;
}
}
spin_unlock_bh(&g_binding_lock);
- if (binding) {
+ if (found) {
dev_remove_pack(&binding->ptype);
if (binding->ptype.dev) {
dev_put(binding->ptype.dev);
pd_stop_all_for_device(binding->ptype.dev);
}
+ list_del(&binding->link);
kfree(binding);
}
}
--
1.7.9.5
next prev parent reply other threads:[~2013-08-01 17:41 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-01 17:39 [PATCH 0/6] staging: ozwpan: Use Kernel API & Bug fixes Rupesh Gujare
2013-08-01 17:40 ` Rupesh Gujare [this message]
2013-08-01 17:40 ` [PATCH 2/6] staging: ozwpan: Mark string as const Rupesh Gujare
2013-08-01 18:17 ` Joe Perches
2013-08-01 17:40 ` [PATCH 3/6] staging: ozwpan: Use kernel strncmp function Rupesh Gujare
2013-08-01 17:40 ` [PATCH 4/6] staging: ozwpan: Drop oldest ISOC frame instead of dropping latest Rupesh Gujare
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=1375378806-17948-2-git-send-email-rupesh.gujare@atmel.com \
--to=rupesh.gujare@atmel.com \
--cc=devel@linuxdriverproject.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®