summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-03-02 19:51:09 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-03-02 19:51:09 -0500
commit1ec41a31fb695682cab7fc7c1f6ced84d188b6f9 (patch)
tree03d080d0f0202afef3b8b445c1f817b832ddb8d5
parentcc55bb03ea17fcbeffb5ae3ec68ea1f8673bc0c8 (diff)
staging: ozwpan: remove debug allocator
The kernel already has a debug allocator, no need to have one unique to a single driver. So delete it, replace with kfree, kmalloc, and, in a few places that need it, kzalloc(). Cc: Chris Kelly <ckelly@ozmodevices.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/staging/ozwpan/Kbuild1
-rw-r--r--drivers/staging/ozwpan/ozalloc.c107
-rw-r--r--drivers/staging/ozwpan/ozalloc.h28
-rw-r--r--drivers/staging/ozwpan/ozcdev.c11
-rw-r--r--drivers/staging/ozwpan/ozconfig.h1
-rw-r--r--drivers/staging/ozwpan/ozeltbuf.c20
-rw-r--r--drivers/staging/ozwpan/ozhcd.c19
-rw-r--r--drivers/staging/ozwpan/ozmain.c2
-rw-r--r--drivers/staging/ozwpan/ozpd.c29
-rw-r--r--drivers/staging/ozwpan/ozproto.c22
-rw-r--r--drivers/staging/ozwpan/ozusbsvc.c11
-rw-r--r--drivers/staging/ozwpan/ozusbsvc1.c1
12 files changed, 51 insertions, 201 deletions
diff --git a/drivers/staging/ozwpan/Kbuild b/drivers/staging/ozwpan/Kbuild
index e655e0005ffd..6cc84cb3f0a6 100644
--- a/drivers/staging/ozwpan/Kbuild
+++ b/drivers/staging/ozwpan/Kbuild
@@ -12,7 +12,6 @@ ozwpan-y := \
12 ozeltbuf.o \ 12 ozeltbuf.o \
13 ozproto.o \ 13 ozproto.o \
14 ozcdev.o \ 14 ozcdev.o \
15 ozalloc.o \
16 ozurbparanoia.o \ 15 ozurbparanoia.o \
17 oztrace.o \ 16 oztrace.o \
18 ozevent.o 17 ozevent.o
diff --git a/drivers/staging/ozwpan/ozalloc.c b/drivers/staging/ozwpan/ozalloc.c
deleted file mode 100644
index fe3cd406e4fa..000000000000
--- a/drivers/staging/ozwpan/ozalloc.c
+++ /dev/null
@@ -1,107 +0,0 @@
1/* -----------------------------------------------------------------------------
2 * Copyright (c) 2011 Ozmo Inc
3 * Released under the GNU General Public License Version 2 (GPLv2).
4 * This file contains debug allocation and free functions. These are turned on
5 * by the configuration switch WANT_DEBUG_KMALLOC. This flags should be turned
6 * off in the release version but facilitate memory leak and corruption during
7 * development.
8 * -----------------------------------------------------------------------------
9 */
10#include <linux/module.h>
11#include "ozconfig.h"
12#include "ozalloc.h"
13#include "oztrace.h"
14#ifdef WANT_DEBUG_KMALLOC
15/*------------------------------------------------------------------------------
16 */
17#define MAGIC_1 0x12848796
18#define MAGIC_2 0x87465920
19#define MAGIC_3 0x80288264
20/*------------------------------------------------------------------------------
21 */
22struct oz_alloc_hdr {
23 int size;
24 int line;
25 unsigned magic;
26 struct list_head link;
27};
28/*------------------------------------------------------------------------------
29 */
30static unsigned long g_total_alloc_size;
31static int g_alloc_count;
32static DEFINE_SPINLOCK(g_alloc_lock);
33static LIST_HEAD(g_alloc_list);
34/*------------------------------------------------------------------------------
35 * Context: any
36 */
37void *oz_alloc_debug(size_t size, gfp_t flags, int line)
38{
39 struct oz_alloc_hdr *hdr = (struct oz_alloc_hdr *)
40 kmalloc(size + sizeof(struct oz_alloc_hdr) +
41 sizeof(unsigned), flags);
42 if (hdr) {
43 unsigned long irq_state;
44 hdr->size = size;
45 hdr->line = line;
46 hdr->magic = MAGIC_1;
47 *(unsigned *)(((u8 *)(hdr + 1)) + size) = MAGIC_2;
48 spin_lock_irqsave(&g_alloc_lock, irq_state);
49 g_total_alloc_size += size;
50 g_alloc_count++;
51 list_add_tail(&hdr->link, &g_alloc_list);
52 spin_unlock_irqrestore(&g_alloc_lock, irq_state);
53 return hdr + 1;
54 }
55 return 0;
56}
57/*------------------------------------------------------------------------------
58 * Context: any
59 */
60void oz_free_debug(void *p)
61{
62 if (p) {
63 struct oz_alloc_hdr *hdr = (struct oz_alloc_hdr *)
64 (((unsigned char *)p) - sizeof(struct oz_alloc_hdr));
65 if (hdr->magic == MAGIC_1) {
66 unsigned long irq_state;
67 if (*(unsigned *)(((u8 *)(hdr + 1)) + hdr->size)
68 != MAGIC_2) {
69 oz_trace("oz_free_debug: Corrupted beyond"
70 " %p size %d\n", hdr+1, hdr->size);
71 return;
72 }
73 spin_lock_irqsave(&g_alloc_lock, irq_state);
74 g_total_alloc_size -= hdr->size;
75 g_alloc_count--;
76 list_del(&hdr->link);
77 spin_unlock_irqrestore(&g_alloc_lock, irq_state);
78 hdr->magic = MAGIC_3;
79 kfree(hdr);
80 } else {
81 oz_trace("oz_free_debug: Invalid magic number %u\n",
82 hdr->magic);
83 }
84 }
85}
86/*------------------------------------------------------------------------------
87 * Context: process
88 */
89void oz_trace_leaks(void)
90{
91#ifdef WANT_TRACE
92 struct list_head *e;
93 oz_trace("Total alloc size:%ld Alloc count:%d\n",
94 g_total_alloc_size, g_alloc_count);
95 if (g_alloc_count)
96 oz_trace("Trace of leaks.\n");
97 else
98 oz_trace("No memory leaks.\n");
99 list_for_each(e, &g_alloc_list) {
100 struct oz_alloc_hdr *hdr =
101 container_of(e, struct oz_alloc_hdr, link);
102 oz_trace("LEAK size %d line %d\n", hdr->size, hdr->line);
103 }
104#endif /* #ifdef WANT_TRACE */
105}
106#endif /* #ifdef WANT_DEBUG_KMALLOC */
107
diff --git a/drivers/staging/ozwpan/ozalloc.h b/drivers/staging/ozwpan/ozalloc.h
deleted file mode 100644
index 11a7a1642880..000000000000
--- a/drivers/staging/ozwpan/ozalloc.h
+++ /dev/null
@@ -1,28 +0,0 @@
1/* -----------------------------------------------------------------------------
2 * Copyright (c) 2011 Ozmo Inc
3 * Released under the GNU General Public License Version 2 (GPLv2).
4 * -----------------------------------------------------------------------------
5 */
6#ifndef _OZALLOC_H
7#define _OZALLOC_H
8
9#include <linux/slab.h>
10
11#ifdef WANT_DEBUG_KMALLOC
12
13void *oz_alloc_debug(size_t size, gfp_t flags, int line);
14void oz_free_debug(void *p);
15void oz_trace_leaks(void);
16#define oz_alloc(__s, __f) oz_alloc_debug(__s, __f, __LINE__)
17#define oz_free oz_free_debug
18
19#else
20
21
22#define oz_alloc kmalloc
23#define oz_free kfree
24#define oz_trace_leaks()
25
26#endif /* #ifdef WANT_DEBUG_KMALLOC */
27
28#endif /* _OZALLOC_H */
diff --git a/drivers/staging/ozwpan/ozcdev.c b/drivers/staging/ozwpan/ozcdev.c
index 912c964cb552..1c380d687963 100644
--- a/drivers/staging/ozwpan/ozcdev.c
+++ b/drivers/staging/ozwpan/ozcdev.c
@@ -17,7 +17,6 @@
17#include "ozeltbuf.h" 17#include "ozeltbuf.h"
18#include "ozpd.h" 18#include "ozpd.h"
19#include "ozproto.h" 19#include "ozproto.h"
20#include "ozalloc.h"
21#include "ozevent.h" 20#include "ozevent.h"
22/*------------------------------------------------------------------------------ 21/*------------------------------------------------------------------------------
23 */ 22 */
@@ -66,7 +65,7 @@ static void oz_cdev_release_ctx(struct oz_serial_ctx *ctx)
66{ 65{
67 if (atomic_dec_and_test(&ctx->ref_count)) { 66 if (atomic_dec_and_test(&ctx->ref_count)) {
68 oz_trace("Dealloc serial context.\n"); 67 oz_trace("Dealloc serial context.\n");
69 oz_free(ctx); 68 kfree(ctx);
70 } 69 }
71} 70}
72/*------------------------------------------------------------------------------ 71/*------------------------------------------------------------------------------
@@ -400,18 +399,16 @@ int oz_cdev_start(struct oz_pd *pd, int resume)
400 oz_trace("Serial service resumed.\n"); 399 oz_trace("Serial service resumed.\n");
401 return 0; 400 return 0;
402 } 401 }
403 ctx = (struct oz_serial_ctx *) 402 ctx = kzalloc(sizeof(struct oz_serial_ctx), GFP_ATOMIC);
404 oz_alloc(sizeof(struct oz_serial_ctx), GFP_ATOMIC);
405 if (ctx == 0) 403 if (ctx == 0)
406 return -1; 404 return -ENOMEM;
407 memset(ctx, 0, sizeof(struct oz_serial_ctx));
408 atomic_set(&ctx->ref_count, 1); 405 atomic_set(&ctx->ref_count, 1);
409 ctx->tx_seq_num = 1; 406 ctx->tx_seq_num = 1;
410 spin_lock_bh(&pd->app_lock[OZ_APPID_SERIAL-1]); 407 spin_lock_bh(&pd->app_lock[OZ_APPID_SERIAL-1]);
411 old_ctx = pd->app_ctx[OZ_APPID_SERIAL-1]; 408 old_ctx = pd->app_ctx[OZ_APPID_SERIAL-1];
412 if (old_ctx) { 409 if (old_ctx) {
413 spin_unlock_bh(&pd->app_lock[OZ_APPID_SERIAL-1]); 410 spin_unlock_bh(&pd->app_lock[OZ_APPID_SERIAL-1]);
414 oz_free(ctx); 411 kfree(ctx);
415 } else { 412 } else {
416 pd->app_ctx[OZ_APPID_SERIAL-1] = ctx; 413 pd->app_ctx[OZ_APPID_SERIAL-1] = ctx;
417 spin_unlock_bh(&pd->app_lock[OZ_APPID_SERIAL-1]); 414 spin_unlock_bh(&pd->app_lock[OZ_APPID_SERIAL-1]);
diff --git a/drivers/staging/ozwpan/ozconfig.h b/drivers/staging/ozwpan/ozconfig.h
index a8c97265c5f6..43e6373a009c 100644
--- a/drivers/staging/ozwpan/ozconfig.h
+++ b/drivers/staging/ozwpan/ozconfig.h
@@ -5,7 +5,6 @@
5#ifndef _OZCONFIG_H 5#ifndef _OZCONFIG_H
6#define _OZCONFIG_H 6#define _OZCONFIG_H
7 7
8/* #define WANT_DEBUG_KMALLOC */
9/* #define WANT_TRACE */ 8/* #define WANT_TRACE */
10#ifdef WANT_TRACE 9#ifdef WANT_TRACE
11#define WANT_VERBOSE_TRACE 10#define WANT_VERBOSE_TRACE
diff --git a/drivers/staging/ozwpan/ozeltbuf.c b/drivers/staging/ozwpan/ozeltbuf.c
index 1c96c0033d76..988f522475d9 100644
--- a/drivers/staging/ozwpan/ozeltbuf.c
+++ b/drivers/staging/ozwpan/ozeltbuf.c
@@ -11,7 +11,6 @@
11#include "ozeltbuf.h" 11#include "ozeltbuf.h"
12#include "ozpd.h" 12#include "ozpd.h"
13#include "oztrace.h" 13#include "oztrace.h"
14#include "ozalloc.h"
15/*------------------------------------------------------------------------------ 14/*------------------------------------------------------------------------------
16 */ 15 */
17#define OZ_ELT_INFO_MAGIC_USED 0x35791057 16#define OZ_ELT_INFO_MAGIC_USED 0x35791057
@@ -48,7 +47,7 @@ void oz_elt_buf_term(struct oz_elt_buf *buf)
48 struct oz_elt_info *ei = 47 struct oz_elt_info *ei =
49 container_of(e, struct oz_elt_info, link_order); 48 container_of(e, struct oz_elt_info, link_order);
50 e = e->next; 49 e = e->next;
51 oz_free(ei); 50 kfree(ei);
52 } 51 }
53 } 52 }
54 /* Free any elelment in the pool. */ 53 /* Free any elelment in the pool. */
@@ -56,7 +55,7 @@ void oz_elt_buf_term(struct oz_elt_buf *buf)
56 struct oz_elt_info *ei = 55 struct oz_elt_info *ei =
57 container_of(buf->elt_pool, struct oz_elt_info, link); 56 container_of(buf->elt_pool, struct oz_elt_info, link);
58 buf->elt_pool = buf->elt_pool->next; 57 buf->elt_pool = buf->elt_pool->next;
59 oz_free(ei); 58 kfree(ei);
60 } 59 }
61 buf->free_elts = 0; 60 buf->free_elts = 0;
62} 61}
@@ -78,7 +77,7 @@ struct oz_elt_info *oz_elt_info_alloc(struct oz_elt_buf *buf)
78 } 77 }
79 } else { 78 } else {
80 spin_unlock_bh(&buf->lock); 79 spin_unlock_bh(&buf->lock);
81 ei = oz_alloc(sizeof(struct oz_elt_info), GFP_ATOMIC); 80 ei = kmalloc(sizeof(struct oz_elt_info), GFP_ATOMIC);
82 } 81 }
83 if (ei) { 82 if (ei) {
84 ei->flags = 0; 83 ei->flags = 0;
@@ -131,12 +130,13 @@ void oz_elt_info_free_chain(struct oz_elt_buf *buf, struct list_head *list)
131 */ 130 */
132int oz_elt_stream_create(struct oz_elt_buf *buf, u8 id, int max_buf_count) 131int oz_elt_stream_create(struct oz_elt_buf *buf, u8 id, int max_buf_count)
133{ 132{
134 struct oz_elt_stream *st = 133 struct oz_elt_stream *st;
135 oz_alloc(sizeof(struct oz_elt_stream), GFP_ATOMIC | __GFP_ZERO); 134
136 oz_trace("oz_elt_stream_create(0x%x)\n", id); 135 oz_trace("oz_elt_stream_create(0x%x)\n", id);
136
137 st = kzalloc(sizeof(struct oz_elt_stream), GFP_ATOMIC | __GFP_ZERO);
137 if (st == 0) 138 if (st == 0)
138 return -1; 139 return -ENOMEM;
139 memset(st, 0, sizeof(struct oz_elt_stream));
140 atomic_set(&st->ref_count, 1); 140 atomic_set(&st->ref_count, 1);
141 st->id = id; 141 st->id = id;
142 st->max_buf_count = max_buf_count; 142 st->max_buf_count = max_buf_count;
@@ -197,7 +197,7 @@ void oz_elt_stream_put(struct oz_elt_stream *st)
197{ 197{
198 if (atomic_dec_and_test(&st->ref_count)) { 198 if (atomic_dec_and_test(&st->ref_count)) {
199 oz_trace("Stream destroyed\n"); 199 oz_trace("Stream destroyed\n");
200 oz_free(st); 200 kfree(st);
201 } 201 }
202} 202}
203/*------------------------------------------------------------------------------ 203/*------------------------------------------------------------------------------
@@ -334,6 +334,6 @@ void oz_trim_elt_pool(struct oz_elt_buf *buf)
334 struct oz_elt_info *ei = 334 struct oz_elt_info *ei =
335 container_of(free, struct oz_elt_info, link); 335 container_of(free, struct oz_elt_info, link);
336 free = free->next; 336 free = free->next;
337 oz_free(ei); 337 kfree(ei);
338 } 338 }
339} 339}
diff --git a/drivers/staging/ozwpan/ozhcd.c b/drivers/staging/ozwpan/ozhcd.c
index 775dfe9c7b85..750b14eb505e 100644
--- a/drivers/staging/ozwpan/ozhcd.c
+++ b/drivers/staging/ozwpan/ozhcd.c
@@ -34,7 +34,6 @@
34#include "ozconfig.h" 34#include "ozconfig.h"
35#include "ozusbif.h" 35#include "ozusbif.h"
36#include "oztrace.h" 36#include "oztrace.h"
37#include "ozalloc.h"
38#include "ozurbparanoia.h" 37#include "ozurbparanoia.h"
39#include "ozevent.h" 38#include "ozevent.h"
40/*------------------------------------------------------------------------------ 39/*------------------------------------------------------------------------------
@@ -259,7 +258,7 @@ static struct oz_urb_link *oz_alloc_urb_link(void)
259 } 258 }
260 spin_unlock_irqrestore(&g_link_lock, irq_state); 259 spin_unlock_irqrestore(&g_link_lock, irq_state);
261 if (urbl == 0) 260 if (urbl == 0)
262 urbl = oz_alloc(sizeof(struct oz_urb_link), GFP_ATOMIC); 261 urbl = kmalloc(sizeof(struct oz_urb_link), GFP_ATOMIC);
263 return urbl; 262 return urbl;
264} 263}
265/*------------------------------------------------------------------------------ 264/*------------------------------------------------------------------------------
@@ -280,7 +279,7 @@ static void oz_free_urb_link(struct oz_urb_link *urbl)
280 } 279 }
281 spin_unlock_irqrestore(&g_link_lock, irq_state); 280 spin_unlock_irqrestore(&g_link_lock, irq_state);
282 if (urbl) 281 if (urbl)
283 oz_free(urbl); 282 kfree(urbl);
284 } 283 }
285} 284}
286/*------------------------------------------------------------------------------ 285/*------------------------------------------------------------------------------
@@ -300,7 +299,7 @@ static void oz_empty_link_pool(void)
300 struct oz_urb_link *urbl = 299 struct oz_urb_link *urbl =
301 container_of(e, struct oz_urb_link, link); 300 container_of(e, struct oz_urb_link, link);
302 e = e->next; 301 e = e->next;
303 oz_free(urbl); 302 kfree(urbl);
304 } 303 }
305} 304}
306/*------------------------------------------------------------------------------ 305/*------------------------------------------------------------------------------
@@ -311,9 +310,8 @@ static void oz_empty_link_pool(void)
311static struct oz_endpoint *oz_ep_alloc(gfp_t mem_flags, int buffer_size) 310static struct oz_endpoint *oz_ep_alloc(gfp_t mem_flags, int buffer_size)
312{ 311{
313 struct oz_endpoint *ep = 312 struct oz_endpoint *ep =
314 oz_alloc(sizeof(struct oz_endpoint)+buffer_size, mem_flags); 313 kzalloc(sizeof(struct oz_endpoint)+buffer_size, mem_flags);
315 if (ep) { 314 if (ep) {
316 memset(ep, 0, sizeof(*ep));
317 INIT_LIST_HEAD(&ep->urb_list); 315 INIT_LIST_HEAD(&ep->urb_list);
318 INIT_LIST_HEAD(&ep->link); 316 INIT_LIST_HEAD(&ep->link);
319 ep->credit = -1; 317 ep->credit = -1;
@@ -414,7 +412,7 @@ static void oz_ep_free(struct oz_port *port, struct oz_endpoint *ep)
414 spin_unlock_bh(&ozhcd->hcd_lock); 412 spin_unlock_bh(&ozhcd->hcd_lock);
415 } 413 }
416 oz_trace("Freeing endpoint memory\n"); 414 oz_trace("Freeing endpoint memory\n");
417 oz_free(ep); 415 kfree(ep);
418} 416}
419/*------------------------------------------------------------------------------ 417/*------------------------------------------------------------------------------
420 * Context: softirq 418 * Context: softirq
@@ -1280,8 +1278,9 @@ static int oz_build_endpoints_for_config(struct usb_hcd *hcd,
1280 int i; 1278 int i;
1281 int num_iface = config->desc.bNumInterfaces; 1279 int num_iface = config->desc.bNumInterfaces;
1282 if (num_iface) { 1280 if (num_iface) {
1283 struct oz_interface *iface = (struct oz_interface *) 1281 struct oz_interface *iface;
1284 oz_alloc(num_iface*sizeof(struct oz_interface), 1282
1283 iface = kmalloc(num_iface*sizeof(struct oz_interface),
1285 mem_flags | __GFP_ZERO); 1284 mem_flags | __GFP_ZERO);
1286 if (!iface) 1285 if (!iface)
1287 return -ENOMEM; 1286 return -ENOMEM;
@@ -1316,7 +1315,7 @@ static void oz_clean_endpoints_for_config(struct usb_hcd *hcd,
1316 spin_lock_bh(&ozhcd->hcd_lock); 1315 spin_lock_bh(&ozhcd->hcd_lock);
1317 if (port->iface) { 1316 if (port->iface) {
1318 oz_trace("Freeing interfaces object.\n"); 1317 oz_trace("Freeing interfaces object.\n");
1319 oz_free(port->iface); 1318 kfree(port->iface);
1320 port->iface = 0; 1319 port->iface = 0;
1321 } 1320 }
1322 port->num_iface = 0; 1321 port->num_iface = 0;
diff --git a/drivers/staging/ozwpan/ozmain.c b/drivers/staging/ozwpan/ozmain.c
index d34242b6e9e3..aaf2ccc0bcfb 100644
--- a/drivers/staging/ozwpan/ozmain.c
+++ b/drivers/staging/ozwpan/ozmain.c
@@ -14,7 +14,6 @@
14#include "ozpd.h" 14#include "ozpd.h"
15#include "ozproto.h" 15#include "ozproto.h"
16#include "ozcdev.h" 16#include "ozcdev.h"
17#include "ozalloc.h"
18#include "oztrace.h" 17#include "oztrace.h"
19#include "ozevent.h" 18#include "ozevent.h"
20/*------------------------------------------------------------------------------ 19/*------------------------------------------------------------------------------
@@ -44,7 +43,6 @@ static void __exit ozwpan_exit(void)
44 oz_protocol_term(); 43 oz_protocol_term();
45 oz_apps_term(); 44 oz_apps_term();
46 oz_cdev_deregister(); 45 oz_cdev_deregister();
47 oz_trace_leaks();
48 oz_event_term(); 46 oz_event_term();
49} 47}
50/*------------------------------------------------------------------------------ 48/*------------------------------------------------------------------------------
diff --git a/drivers/staging/ozwpan/ozpd.c b/drivers/staging/ozwpan/ozpd.c
index e3381add51a4..2b45d3d1800c 100644
--- a/drivers/staging/ozwpan/ozpd.c
+++ b/drivers/staging/ozwpan/ozpd.c
@@ -15,7 +15,6 @@
15#include "ozpd.h" 15#include "ozpd.h"
16#include "ozproto.h" 16#include "ozproto.h"
17#include "oztrace.h" 17#include "oztrace.h"
18#include "ozalloc.h"
19#include "ozevent.h" 18#include "ozevent.h"
20#include "ozcdev.h" 19#include "ozcdev.h"
21#include "ozusbsvc.h" 20#include "ozusbsvc.h"
@@ -162,10 +161,9 @@ void oz_pd_put(struct oz_pd *pd)
162 */ 161 */
163struct oz_pd *oz_pd_alloc(u8 *mac_addr) 162struct oz_pd *oz_pd_alloc(u8 *mac_addr)
164{ 163{
165 struct oz_pd *pd = oz_alloc(sizeof(struct oz_pd), GFP_ATOMIC); 164 struct oz_pd *pd = kzalloc(sizeof(struct oz_pd), GFP_ATOMIC);
166 if (pd) { 165 if (pd) {
167 int i; 166 int i;
168 memset(pd, 0, sizeof(struct oz_pd));
169 atomic_set(&pd->ref_count, 2); 167 atomic_set(&pd->ref_count, 2);
170 for (i = 0; i < OZ_APPID_MAX; i++) 168 for (i = 0; i < OZ_APPID_MAX; i++)
171 spin_lock_init(&pd->app_lock[i]); 169 spin_lock_init(&pd->app_lock[i]);
@@ -174,7 +172,7 @@ struct oz_pd *oz_pd_alloc(u8 *mac_addr)
174 pd->max_tx_size = OZ_MAX_TX_SIZE; 172 pd->max_tx_size = OZ_MAX_TX_SIZE;
175 memcpy(pd->mac_addr, mac_addr, ETH_ALEN); 173 memcpy(pd->mac_addr, mac_addr, ETH_ALEN);
176 if (0 != oz_elt_buf_init(&pd->elt_buff)) { 174 if (0 != oz_elt_buf_init(&pd->elt_buff)) {
177 oz_free(pd); 175 kfree(pd);
178 pd = 0; 176 pd = 0;
179 } 177 }
180 spin_lock_init(&pd->tx_frame_lock); 178 spin_lock_init(&pd->tx_frame_lock);
@@ -219,18 +217,18 @@ void oz_pd_destroy(struct oz_pd *pd)
219 while (e != &pd->farewell_list) { 217 while (e != &pd->farewell_list) {
220 fwell = container_of(e, struct oz_farewell, link); 218 fwell = container_of(e, struct oz_farewell, link);
221 e = e->next; 219 e = e->next;
222 oz_free(fwell); 220 kfree(fwell);
223 } 221 }
224 /* Deallocate all frames in tx pool. 222 /* Deallocate all frames in tx pool.
225 */ 223 */
226 while (pd->tx_pool) { 224 while (pd->tx_pool) {
227 e = pd->tx_pool; 225 e = pd->tx_pool;
228 pd->tx_pool = e->next; 226 pd->tx_pool = e->next;
229 oz_free(container_of(e, struct oz_tx_frame, link)); 227 kfree(container_of(e, struct oz_tx_frame, link));
230 } 228 }
231 if (pd->net_dev) 229 if (pd->net_dev)
232 dev_put(pd->net_dev); 230 dev_put(pd->net_dev);
233 oz_free(pd); 231 kfree(pd);
234} 232}
235/*------------------------------------------------------------------------------ 233/*------------------------------------------------------------------------------
236 * Context: softirq-serialized 234 * Context: softirq-serialized
@@ -366,7 +364,7 @@ static struct oz_tx_frame *oz_tx_frame_alloc(struct oz_pd *pd)
366 } 364 }
367 spin_unlock_bh(&pd->tx_frame_lock); 365 spin_unlock_bh(&pd->tx_frame_lock);
368 if (f == 0) 366 if (f == 0)
369 f = oz_alloc(sizeof(struct oz_tx_frame), GFP_ATOMIC); 367 f = kmalloc(sizeof(struct oz_tx_frame), GFP_ATOMIC);
370 if (f) { 368 if (f) {
371 f->total_size = sizeof(struct oz_hdr); 369 f->total_size = sizeof(struct oz_hdr);
372 INIT_LIST_HEAD(&f->link); 370 INIT_LIST_HEAD(&f->link);
@@ -386,11 +384,11 @@ static void oz_tx_frame_free(struct oz_pd *pd, struct oz_tx_frame *f)
386 pd->tx_pool_count++; 384 pd->tx_pool_count++;
387 f = 0; 385 f = 0;
388 } else { 386 } else {
389 oz_free(f); 387 kfree(f);
390 } 388 }
391 spin_unlock_bh(&pd->tx_frame_lock); 389 spin_unlock_bh(&pd->tx_frame_lock);
392 if (f) 390 if (f)
393 oz_free(f); 391 kfree(f);
394} 392}
395/*------------------------------------------------------------------------------ 393/*------------------------------------------------------------------------------
396 * Context: softirq 394 * Context: softirq
@@ -649,10 +647,9 @@ static struct oz_isoc_stream *pd_stream_find(struct oz_pd *pd, u8 ep_num)
649int oz_isoc_stream_create(struct oz_pd *pd, u8 ep_num) 647int oz_isoc_stream_create(struct oz_pd *pd, u8 ep_num)
650{ 648{
651 struct oz_isoc_stream *st = 649 struct oz_isoc_stream *st =
652 oz_alloc(sizeof(struct oz_isoc_stream), GFP_ATOMIC); 650 kzalloc(sizeof(struct oz_isoc_stream), GFP_ATOMIC);
653 if (!st) 651 if (!st)
654 return -1; 652 return -ENOMEM;
655 memset(st, 0, sizeof(struct oz_isoc_stream));
656 st->ep_num = ep_num; 653 st->ep_num = ep_num;
657 spin_lock_bh(&pd->stream_lock); 654 spin_lock_bh(&pd->stream_lock);
658 if (!pd_stream_find(pd, ep_num)) { 655 if (!pd_stream_find(pd, ep_num)) {
@@ -661,7 +658,7 @@ int oz_isoc_stream_create(struct oz_pd *pd, u8 ep_num)
661 } 658 }
662 spin_unlock_bh(&pd->stream_lock); 659 spin_unlock_bh(&pd->stream_lock);
663 if (st) 660 if (st)
664 oz_free(st); 661 kfree(st);
665 return 0; 662 return 0;
666} 663}
667/*------------------------------------------------------------------------------ 664/*------------------------------------------------------------------------------
@@ -671,7 +668,7 @@ static void oz_isoc_stream_free(struct oz_isoc_stream *st)
671{ 668{
672 if (st->skb) 669 if (st->skb)
673 kfree_skb(st->skb); 670 kfree_skb(st->skb);
674 oz_free(st); 671 kfree(st);
675} 672}
676/*------------------------------------------------------------------------------ 673/*------------------------------------------------------------------------------
677 * Context: softirq 674 * Context: softirq
@@ -830,6 +827,6 @@ void oz_pd_indicate_farewells(struct oz_pd *pd)
830 oz_polling_unlock_bh(); 827 oz_polling_unlock_bh();
831 if (ai->farewell) 828 if (ai->farewell)
832 ai->farewell(pd, f->ep_num, f->report, f->len); 829 ai->farewell(pd, f->ep_num, f->report, f->len);
833 oz_free(f); 830 kfree(f);
834 } 831 }
835} 832}
diff --git a/drivers/staging/ozwpan/ozproto.c b/drivers/staging/ozwpan/ozproto.c
index 44f3926d4f08..ad857eeabbb7 100644
--- a/drivers/staging/ozwpan/ozproto.c
+++ b/drivers/staging/ozwpan/ozproto.c
@@ -19,7 +19,6 @@
19#include "oztrace.h" 19#include "oztrace.h"
20#include "ozappif.h" 20#include "ozappif.h"
21#include "ozevent.h" 21#include "ozevent.h"
22#include "ozalloc.h"
23#include <asm/unaligned.h> 22#include <asm/unaligned.h>
24#include <linux/uaccess.h> 23#include <linux/uaccess.h>
25#include <net/psnap.h> 24#include <net/psnap.h>
@@ -300,7 +299,7 @@ static void oz_add_farewell(struct oz_pd *pd, u8 ep_num, u8 index,
300 struct oz_farewell *f; 299 struct oz_farewell *f;
301 struct oz_farewell *f2; 300 struct oz_farewell *f2;
302 int found = 0; 301 int found = 0;
303 f = oz_alloc(sizeof(struct oz_farewell) + len - 1, GFP_ATOMIC); 302 f = kmalloc(sizeof(struct oz_farewell) + len - 1, GFP_ATOMIC);
304 if (!f) 303 if (!f)
305 return; 304 return;
306 f->ep_num = ep_num; 305 f->ep_num = ep_num;
@@ -318,7 +317,7 @@ static void oz_add_farewell(struct oz_pd *pd, u8 ep_num, u8 index,
318 list_add_tail(&f->link, &pd->farewell_list); 317 list_add_tail(&f->link, &pd->farewell_list);
319 spin_unlock(&g_polling_lock); 318 spin_unlock(&g_polling_lock);
320 if (found) 319 if (found)
321 oz_free(f2); 320 kfree(f2);
322} 321}
323/*------------------------------------------------------------------------------ 322/*------------------------------------------------------------------------------
324 * Context: softirq-serialized 323 * Context: softirq-serialized
@@ -458,7 +457,7 @@ void oz_protocol_term(void)
458 dev_remove_pack(&b->ptype); 457 dev_remove_pack(&b->ptype);
459 if (b->ptype.dev) 458 if (b->ptype.dev)
460 dev_put(b->ptype.dev); 459 dev_put(b->ptype.dev);
461 oz_free(b); 460 kfree(b);
462 spin_lock_bh(&g_binding_lock); 461 spin_lock_bh(&g_binding_lock);
463 } 462 }
464 spin_unlock_bh(&g_binding_lock); 463 spin_unlock_bh(&g_binding_lock);
@@ -482,7 +481,7 @@ void oz_protocol_term(void)
482 while (chain) { 481 while (chain) {
483 struct oz_timer *t = container_of(chain, struct oz_timer, link); 482 struct oz_timer *t = container_of(chain, struct oz_timer, link);
484 chain = chain->next; 483 chain = chain->next;
485 oz_free(t); 484 kfree(t);
486 } 485 }
487 oz_trace("Protocol stopped\n"); 486 oz_trace("Protocol stopped\n");
488} 487}
@@ -557,7 +556,7 @@ static void oz_protocol_timer(unsigned long arg)
557 spin_unlock_bh(&g_polling_lock); 556 spin_unlock_bh(&g_polling_lock);
558 oz_pd_put(pd); 557 oz_pd_put(pd);
559 if (t) 558 if (t)
560 oz_free(t); 559 kfree(t);
561 t = t2; 560 t = t2;
562 } while (t); 561 } while (t);
563 g_timer_state = OZ_TIMER_IDLE; 562 g_timer_state = OZ_TIMER_IDLE;
@@ -623,7 +622,7 @@ void oz_timer_add(struct oz_pd *pd, int type, unsigned long due_time,
623 g_timer_pool = g_timer_pool->next; 622 g_timer_pool = g_timer_pool->next;
624 g_timer_pool_count--; 623 g_timer_pool_count--;
625 } else { 624 } else {
626 t = oz_alloc(sizeof(struct oz_timer), GFP_ATOMIC); 625 t = kmalloc(sizeof(struct oz_timer), GFP_ATOMIC);
627 } 626 }
628 if (t) { 627 if (t) {
629 t->pd = pd; 628 t->pd = pd;
@@ -699,7 +698,7 @@ void oz_timer_delete(struct oz_pd *pd, int type)
699 while (chain) { 698 while (chain) {
700 t = container_of(chain, struct oz_timer, link); 699 t = container_of(chain, struct oz_timer, link);
701 chain = chain->next; 700 chain = chain->next;
702 oz_free(t); 701 kfree(t);
703 } 702 }
704} 703}
705/*------------------------------------------------------------------------------ 704/*------------------------------------------------------------------------------
@@ -796,7 +795,8 @@ static int oz_pkt_recv(struct sk_buff *skb, struct net_device *dev,
796void oz_binding_add(char *net_dev) 795void oz_binding_add(char *net_dev)
797{ 796{
798 struct oz_binding *binding; 797 struct oz_binding *binding;
799 binding = oz_alloc(sizeof(struct oz_binding), GFP_ATOMIC); 798
799 binding = kmalloc(sizeof(struct oz_binding), GFP_ATOMIC);
800 if (binding) { 800 if (binding) {
801 binding->ptype.type = __constant_htons(OZ_ETHERTYPE); 801 binding->ptype.type = __constant_htons(OZ_ETHERTYPE);
802 binding->ptype.func = oz_pkt_recv; 802 binding->ptype.func = oz_pkt_recv;
@@ -807,7 +807,7 @@ void oz_binding_add(char *net_dev)
807 dev_get_by_name(&init_net, net_dev); 807 dev_get_by_name(&init_net, net_dev);
808 if (binding->ptype.dev == 0) { 808 if (binding->ptype.dev == 0) {
809 oz_trace("Netdev %s not found\n", net_dev); 809 oz_trace("Netdev %s not found\n", net_dev);
810 oz_free(binding); 810 kfree(binding);
811 binding = 0; 811 binding = 0;
812 } 812 }
813 } else { 813 } else {
@@ -889,7 +889,7 @@ void oz_binding_remove(char *net_dev)
889 dev_put(binding->ptype.dev); 889 dev_put(binding->ptype.dev);
890 pd_stop_all_for_device(binding->ptype.dev); 890 pd_stop_all_for_device(binding->ptype.dev);
891 } 891 }
892 oz_free(binding); 892 kfree(binding);
893 } 893 }
894} 894}
895/*------------------------------------------------------------------------------ 895/*------------------------------------------------------------------------------
diff --git a/drivers/staging/ozwpan/ozusbsvc.c b/drivers/staging/ozwpan/ozusbsvc.c
index 1da98f6ecbe9..9e74f9602384 100644
--- a/drivers/staging/ozwpan/ozusbsvc.c
+++ b/drivers/staging/ozwpan/ozusbsvc.c
@@ -26,7 +26,6 @@
26#include "ozusbif.h" 26#include "ozusbif.h"
27#include "ozhcd.h" 27#include "ozhcd.h"
28#include "oztrace.h" 28#include "oztrace.h"
29#include "ozalloc.h"
30#include "ozusbsvc.h" 29#include "ozusbsvc.h"
31#include "ozevent.h" 30#include "ozevent.h"
32/*------------------------------------------------------------------------------ 31/*------------------------------------------------------------------------------
@@ -65,11 +64,9 @@ int oz_usb_start(struct oz_pd *pd, int resume)
65 /* Create a USB context in case we need one. If we find the PD already 64 /* Create a USB context in case we need one. If we find the PD already
66 * has a USB context then we will destroy it. 65 * has a USB context then we will destroy it.
67 */ 66 */
68 usb_ctx = (struct oz_usb_ctx *) 67 usb_ctx = kzalloc(sizeof(struct oz_usb_ctx), GFP_ATOMIC);
69 oz_alloc(sizeof(struct oz_usb_ctx), GFP_ATOMIC);
70 if (usb_ctx == 0) 68 if (usb_ctx == 0)
71 return -1; 69 return -ENOMEM;
72 memset(usb_ctx, 0, sizeof(struct oz_usb_ctx));
73 atomic_set(&usb_ctx->ref_count, 1); 70 atomic_set(&usb_ctx->ref_count, 1);
74 usb_ctx->pd = pd; 71 usb_ctx->pd = pd;
75 usb_ctx->stopped = 0; 72 usb_ctx->stopped = 0;
@@ -85,7 +82,7 @@ int oz_usb_start(struct oz_pd *pd, int resume)
85 spin_unlock_bh(&pd->app_lock[OZ_APPID_USB-1]); 82 spin_unlock_bh(&pd->app_lock[OZ_APPID_USB-1]);
86 if (old_ctx) { 83 if (old_ctx) {
87 oz_trace("Already have USB context.\n"); 84 oz_trace("Already have USB context.\n");
88 oz_free(usb_ctx); 85 kfree(usb_ctx);
89 usb_ctx = old_ctx; 86 usb_ctx = old_ctx;
90 } else if (usb_ctx) { 87 } else if (usb_ctx) {
91 /* Take a reference to the PD. This will be released when 88 /* Take a reference to the PD. This will be released when
@@ -170,7 +167,7 @@ void oz_usb_put(void *hpd)
170 if (atomic_dec_and_test(&usb_ctx->ref_count)) { 167 if (atomic_dec_and_test(&usb_ctx->ref_count)) {
171 oz_trace("Dealloc USB context.\n"); 168 oz_trace("Dealloc USB context.\n");
172 oz_pd_put(usb_ctx->pd); 169 oz_pd_put(usb_ctx->pd);
173 oz_free(usb_ctx); 170 kfree(usb_ctx);
174 } 171 }
175} 172}
176/*------------------------------------------------------------------------------ 173/*------------------------------------------------------------------------------
diff --git a/drivers/staging/ozwpan/ozusbsvc1.c b/drivers/staging/ozwpan/ozusbsvc1.c
index 3982194cd0ee..66bd576bb5e9 100644
--- a/drivers/staging/ozwpan/ozusbsvc1.c
+++ b/drivers/staging/ozwpan/ozusbsvc1.c
@@ -21,7 +21,6 @@
21#include "ozusbif.h" 21#include "ozusbif.h"
22#include "ozhcd.h" 22#include "ozhcd.h"
23#include "oztrace.h" 23#include "oztrace.h"
24#include "ozalloc.h"
25#include "ozusbsvc.h" 24#include "ozusbsvc.h"
26#include "ozevent.h" 25#include "ozevent.h"
27/*------------------------------------------------------------------------------ 26/*------------------------------------------------------------------------------