]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
staging: ozwpan: remove debug allocator
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 3 Mar 2012 00:51:09 +0000 (16:51 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 3 Mar 2012 00:51:09 +0000 (16:51 -0800)
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>
12 files changed:
drivers/staging/ozwpan/Kbuild
drivers/staging/ozwpan/ozalloc.c [deleted file]
drivers/staging/ozwpan/ozalloc.h [deleted file]
drivers/staging/ozwpan/ozcdev.c
drivers/staging/ozwpan/ozconfig.h
drivers/staging/ozwpan/ozeltbuf.c
drivers/staging/ozwpan/ozhcd.c
drivers/staging/ozwpan/ozmain.c
drivers/staging/ozwpan/ozpd.c
drivers/staging/ozwpan/ozproto.c
drivers/staging/ozwpan/ozusbsvc.c
drivers/staging/ozwpan/ozusbsvc1.c

index e655e0005ffd734ae1c69b5e65511b2aa05ff88e..6cc84cb3f0a6dfb2e27ebb336ba694b68fcc61f1 100644 (file)
@@ -12,7 +12,6 @@ ozwpan-y := \
        ozeltbuf.o \
        ozproto.o \
        ozcdev.o \
-       ozalloc.o \
        ozurbparanoia.o \
        oztrace.o \
        ozevent.o
diff --git a/drivers/staging/ozwpan/ozalloc.c b/drivers/staging/ozwpan/ozalloc.c
deleted file mode 100644 (file)
index fe3cd40..0000000
+++ /dev/null
@@ -1,107 +0,0 @@
-/* -----------------------------------------------------------------------------
- * Copyright (c) 2011 Ozmo Inc
- * Released under the GNU General Public License Version 2 (GPLv2).
- * This file contains debug allocation and free functions. These are turned on
- * by the configuration switch WANT_DEBUG_KMALLOC. This flags should be turned
- * off in the release version but facilitate memory leak and corruption during
- * development.
- * -----------------------------------------------------------------------------
- */
-#include <linux/module.h>
-#include "ozconfig.h"
-#include "ozalloc.h"
-#include "oztrace.h"
-#ifdef WANT_DEBUG_KMALLOC
-/*------------------------------------------------------------------------------
- */
-#define MAGIC_1        0x12848796
-#define MAGIC_2        0x87465920
-#define MAGIC_3        0x80288264
-/*------------------------------------------------------------------------------
- */
-struct oz_alloc_hdr {
-       int size;
-       int line;
-       unsigned magic;
-       struct list_head link;
-};
-/*------------------------------------------------------------------------------
- */
-static unsigned long g_total_alloc_size;
-static int g_alloc_count;
-static DEFINE_SPINLOCK(g_alloc_lock);
-static LIST_HEAD(g_alloc_list);
-/*------------------------------------------------------------------------------
- * Context: any
- */
-void *oz_alloc_debug(size_t size, gfp_t flags, int line)
-{
-       struct oz_alloc_hdr *hdr = (struct oz_alloc_hdr *)
-               kmalloc(size + sizeof(struct oz_alloc_hdr) +
-                       sizeof(unsigned), flags);
-       if (hdr) {
-               unsigned long irq_state;
-               hdr->size = size;
-               hdr->line = line;
-               hdr->magic = MAGIC_1;
-               *(unsigned *)(((u8 *)(hdr + 1)) + size) = MAGIC_2;
-               spin_lock_irqsave(&g_alloc_lock, irq_state);
-               g_total_alloc_size += size;
-               g_alloc_count++;
-               list_add_tail(&hdr->link, &g_alloc_list);
-               spin_unlock_irqrestore(&g_alloc_lock, irq_state);
-               return hdr + 1;
-       }
-       return 0;
-}
-/*------------------------------------------------------------------------------
- * Context: any
- */
-void oz_free_debug(void *p)
-{
-       if (p) {
-               struct oz_alloc_hdr *hdr = (struct oz_alloc_hdr *)
-                       (((unsigned char *)p) - sizeof(struct oz_alloc_hdr));
-               if (hdr->magic == MAGIC_1) {
-                       unsigned long irq_state;
-                       if (*(unsigned *)(((u8 *)(hdr + 1)) + hdr->size)
-                               != MAGIC_2) {
-                               oz_trace("oz_free_debug: Corrupted beyond"
-                                       " %p size %d\n", hdr+1, hdr->size);
-                               return;
-                       }
-                       spin_lock_irqsave(&g_alloc_lock, irq_state);
-                       g_total_alloc_size -= hdr->size;
-                       g_alloc_count--;
-                       list_del(&hdr->link);
-                       spin_unlock_irqrestore(&g_alloc_lock, irq_state);
-                       hdr->magic = MAGIC_3;
-                       kfree(hdr);
-               } else {
-                       oz_trace("oz_free_debug: Invalid magic number %u\n",
-                               hdr->magic);
-               }
-       }
-}
-/*------------------------------------------------------------------------------
- * Context: process
- */
-void oz_trace_leaks(void)
-{
-#ifdef WANT_TRACE
-       struct list_head *e;
-       oz_trace("Total alloc size:%ld  Alloc count:%d\n",
-                       g_total_alloc_size, g_alloc_count);
-       if (g_alloc_count)
-               oz_trace("Trace of leaks.\n");
-       else
-               oz_trace("No memory leaks.\n");
-       list_for_each(e, &g_alloc_list) {
-               struct oz_alloc_hdr *hdr =
-                       container_of(e, struct oz_alloc_hdr, link);
-               oz_trace("LEAK size %d line %d\n", hdr->size, hdr->line);
-       }
-#endif /* #ifdef WANT_TRACE */
-}
-#endif /* #ifdef WANT_DEBUG_KMALLOC */
-
diff --git a/drivers/staging/ozwpan/ozalloc.h b/drivers/staging/ozwpan/ozalloc.h
deleted file mode 100644 (file)
index 11a7a16..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-/* -----------------------------------------------------------------------------
- * Copyright (c) 2011 Ozmo Inc
- * Released under the GNU General Public License Version 2 (GPLv2).
- * -----------------------------------------------------------------------------
- */
-#ifndef _OZALLOC_H
-#define _OZALLOC_H
-
-#include <linux/slab.h>
-
-#ifdef WANT_DEBUG_KMALLOC
-
-void *oz_alloc_debug(size_t size, gfp_t flags, int line);
-void oz_free_debug(void *p);
-void oz_trace_leaks(void);
-#define oz_alloc(__s, __f)     oz_alloc_debug(__s, __f, __LINE__)
-#define oz_free                        oz_free_debug
-
-#else
-
-
-#define oz_alloc       kmalloc
-#define oz_free                kfree
-#define oz_trace_leaks()
-
-#endif /* #ifdef WANT_DEBUG_KMALLOC */
-
-#endif /* _OZALLOC_H */
index 912c964cb5528124ac6e63d67b472a6442ab437d..1c380d6879639a90b0d5d3b251538342888eebda 100644 (file)
@@ -17,7 +17,6 @@
 #include "ozeltbuf.h"
 #include "ozpd.h"
 #include "ozproto.h"
-#include "ozalloc.h"
 #include "ozevent.h"
 /*------------------------------------------------------------------------------
  */
@@ -66,7 +65,7 @@ static void oz_cdev_release_ctx(struct oz_serial_ctx *ctx)
 {
        if (atomic_dec_and_test(&ctx->ref_count)) {
                oz_trace("Dealloc serial context.\n");
-               oz_free(ctx);
+               kfree(ctx);
        }
 }
 /*------------------------------------------------------------------------------
@@ -400,18 +399,16 @@ int oz_cdev_start(struct oz_pd *pd, int resume)
                oz_trace("Serial service resumed.\n");
                return 0;
        }
-       ctx = (struct oz_serial_ctx *)
-               oz_alloc(sizeof(struct oz_serial_ctx), GFP_ATOMIC);
+       ctx = kzalloc(sizeof(struct oz_serial_ctx), GFP_ATOMIC);
        if (ctx == 0)
-               return -1;
-       memset(ctx, 0, sizeof(struct oz_serial_ctx));
+               return -ENOMEM;
        atomic_set(&ctx->ref_count, 1);
        ctx->tx_seq_num = 1;
        spin_lock_bh(&pd->app_lock[OZ_APPID_SERIAL-1]);
        old_ctx = pd->app_ctx[OZ_APPID_SERIAL-1];
        if (old_ctx) {
                spin_unlock_bh(&pd->app_lock[OZ_APPID_SERIAL-1]);
-               oz_free(ctx);
+               kfree(ctx);
        } else {
                pd->app_ctx[OZ_APPID_SERIAL-1] = ctx;
                spin_unlock_bh(&pd->app_lock[OZ_APPID_SERIAL-1]);
index a8c97265c5f69b0f6b7c646dcd8c91c01627fc6c..43e6373a009c7e05c193dbd05e6bf5874eaadf88 100644 (file)
@@ -5,7 +5,6 @@
 #ifndef _OZCONFIG_H
 #define _OZCONFIG_H
 
-/* #define WANT_DEBUG_KMALLOC */
 /* #define WANT_TRACE */
 #ifdef WANT_TRACE
 #define WANT_VERBOSE_TRACE
index 1c96c0033d769b3fc803dbf10c9462e7175affa0..988f522475d92429e54fd7e6ddc434d5f77c694e 100644 (file)
@@ -11,7 +11,6 @@
 #include "ozeltbuf.h"
 #include "ozpd.h"
 #include "oztrace.h"
-#include "ozalloc.h"
 /*------------------------------------------------------------------------------
  */
 #define OZ_ELT_INFO_MAGIC_USED 0x35791057
@@ -48,7 +47,7 @@ void oz_elt_buf_term(struct oz_elt_buf *buf)
                        struct oz_elt_info *ei =
                                container_of(e, struct oz_elt_info, link_order);
                        e = e->next;
-                       oz_free(ei);
+                       kfree(ei);
                }
        }
        /* Free any elelment in the pool. */
@@ -56,7 +55,7 @@ void oz_elt_buf_term(struct oz_elt_buf *buf)
                struct oz_elt_info *ei =
                        container_of(buf->elt_pool, struct oz_elt_info, link);
                buf->elt_pool = buf->elt_pool->next;
-               oz_free(ei);
+               kfree(ei);
        }
        buf->free_elts = 0;
 }
@@ -78,7 +77,7 @@ struct oz_elt_info *oz_elt_info_alloc(struct oz_elt_buf *buf)
                }
        } else {
                spin_unlock_bh(&buf->lock);
-               ei = oz_alloc(sizeof(struct oz_elt_info), GFP_ATOMIC);
+               ei = kmalloc(sizeof(struct oz_elt_info), GFP_ATOMIC);
        }
        if (ei) {
                ei->flags = 0;
@@ -131,12 +130,13 @@ void oz_elt_info_free_chain(struct oz_elt_buf *buf, struct list_head *list)
  */
 int oz_elt_stream_create(struct oz_elt_buf *buf, u8 id, int max_buf_count)
 {
-       struct oz_elt_stream *st =
-               oz_alloc(sizeof(struct oz_elt_stream), GFP_ATOMIC | __GFP_ZERO);
+       struct oz_elt_stream *st;
+
        oz_trace("oz_elt_stream_create(0x%x)\n", id);
+
+       st = kzalloc(sizeof(struct oz_elt_stream), GFP_ATOMIC | __GFP_ZERO);
        if (st == 0)
-               return -1;
-       memset(st, 0, sizeof(struct oz_elt_stream));
+               return -ENOMEM;
        atomic_set(&st->ref_count, 1);
        st->id = id;
        st->max_buf_count = max_buf_count;
@@ -197,7 +197,7 @@ void oz_elt_stream_put(struct oz_elt_stream *st)
 {
        if (atomic_dec_and_test(&st->ref_count)) {
                oz_trace("Stream destroyed\n");
-               oz_free(st);
+               kfree(st);
        }
 }
 /*------------------------------------------------------------------------------
@@ -334,6 +334,6 @@ void oz_trim_elt_pool(struct oz_elt_buf *buf)
                struct oz_elt_info *ei =
                        container_of(free, struct oz_elt_info, link);
                free = free->next;
-               oz_free(ei);
+               kfree(ei);
        }
 }
index 775dfe9c7b85305e1aff3863fdc5865e9fa7051d..750b14eb505e1356b9b07cc4a57685065f7cc7db 100644 (file)
@@ -34,7 +34,6 @@
 #include "ozconfig.h"
 #include "ozusbif.h"
 #include "oztrace.h"
-#include "ozalloc.h"
 #include "ozurbparanoia.h"
 #include "ozevent.h"
 /*------------------------------------------------------------------------------
@@ -259,7 +258,7 @@ static struct oz_urb_link *oz_alloc_urb_link(void)
        }
        spin_unlock_irqrestore(&g_link_lock, irq_state);
        if (urbl == 0)
-               urbl = oz_alloc(sizeof(struct oz_urb_link), GFP_ATOMIC);
+               urbl = kmalloc(sizeof(struct oz_urb_link), GFP_ATOMIC);
        return urbl;
 }
 /*------------------------------------------------------------------------------
@@ -280,7 +279,7 @@ static void oz_free_urb_link(struct oz_urb_link *urbl)
                }
                spin_unlock_irqrestore(&g_link_lock, irq_state);
                if (urbl)
-                       oz_free(urbl);
+                       kfree(urbl);
        }
 }
 /*------------------------------------------------------------------------------
@@ -300,7 +299,7 @@ static void oz_empty_link_pool(void)
                struct oz_urb_link *urbl =
                        container_of(e, struct oz_urb_link, link);
                e = e->next;
-               oz_free(urbl);
+               kfree(urbl);
        }
 }
 /*------------------------------------------------------------------------------
@@ -311,9 +310,8 @@ static void oz_empty_link_pool(void)
 static struct oz_endpoint *oz_ep_alloc(gfp_t mem_flags, int buffer_size)
 {
        struct oz_endpoint *ep =
-               oz_alloc(sizeof(struct oz_endpoint)+buffer_size, mem_flags);
+               kzalloc(sizeof(struct oz_endpoint)+buffer_size, mem_flags);
        if (ep) {
-               memset(ep, 0, sizeof(*ep));
                INIT_LIST_HEAD(&ep->urb_list);
                INIT_LIST_HEAD(&ep->link);
                ep->credit = -1;
@@ -414,7 +412,7 @@ static void oz_ep_free(struct oz_port *port, struct oz_endpoint *ep)
                spin_unlock_bh(&ozhcd->hcd_lock);
        }
        oz_trace("Freeing endpoint memory\n");
-       oz_free(ep);
+       kfree(ep);
 }
 /*------------------------------------------------------------------------------
  * Context: softirq
@@ -1280,8 +1278,9 @@ static int oz_build_endpoints_for_config(struct usb_hcd *hcd,
        int i;
        int num_iface = config->desc.bNumInterfaces;
        if (num_iface) {
-               struct oz_interface *iface = (struct oz_interface *)
-                       oz_alloc(num_iface*sizeof(struct oz_interface),
+               struct oz_interface *iface;
+
+               iface = kmalloc(num_iface*sizeof(struct oz_interface),
                                mem_flags | __GFP_ZERO);
                if (!iface)
                        return -ENOMEM;
@@ -1316,7 +1315,7 @@ static void oz_clean_endpoints_for_config(struct usb_hcd *hcd,
        spin_lock_bh(&ozhcd->hcd_lock);
        if (port->iface) {
                oz_trace("Freeing interfaces object.\n");
-               oz_free(port->iface);
+               kfree(port->iface);
                port->iface = 0;
        }
        port->num_iface = 0;
index d34242b6e9e3e7c18ae716a070800134cc32f601..aaf2ccc0bcfbdd3f45dc29bf251f26f53e8a3c4a 100644 (file)
@@ -14,7 +14,6 @@
 #include "ozpd.h"
 #include "ozproto.h"
 #include "ozcdev.h"
-#include "ozalloc.h"
 #include "oztrace.h"
 #include "ozevent.h"
 /*------------------------------------------------------------------------------
@@ -44,7 +43,6 @@ static void __exit ozwpan_exit(void)
        oz_protocol_term();
        oz_apps_term();
        oz_cdev_deregister();
-       oz_trace_leaks();
        oz_event_term();
 }
 /*------------------------------------------------------------------------------
index e3381add51a46fe39172172761821260ca44c219..2b45d3d1800c13bc1a6341a9b5c5d2c8f4048086 100644 (file)
@@ -15,7 +15,6 @@
 #include "ozpd.h"
 #include "ozproto.h"
 #include "oztrace.h"
-#include "ozalloc.h"
 #include "ozevent.h"
 #include "ozcdev.h"
 #include "ozusbsvc.h"
@@ -162,10 +161,9 @@ void oz_pd_put(struct oz_pd *pd)
  */
 struct oz_pd *oz_pd_alloc(u8 *mac_addr)
 {
-       struct oz_pd *pd = oz_alloc(sizeof(struct oz_pd), GFP_ATOMIC);
+       struct oz_pd *pd = kzalloc(sizeof(struct oz_pd), GFP_ATOMIC);
        if (pd) {
                int i;
-               memset(pd, 0, sizeof(struct oz_pd));
                atomic_set(&pd->ref_count, 2);
                for (i = 0; i < OZ_APPID_MAX; i++)
                        spin_lock_init(&pd->app_lock[i]);
@@ -174,7 +172,7 @@ struct oz_pd *oz_pd_alloc(u8 *mac_addr)
                pd->max_tx_size = OZ_MAX_TX_SIZE;
                memcpy(pd->mac_addr, mac_addr, ETH_ALEN);
                if (0 != oz_elt_buf_init(&pd->elt_buff)) {
-                       oz_free(pd);
+                       kfree(pd);
                        pd = 0;
                }
                spin_lock_init(&pd->tx_frame_lock);
@@ -219,18 +217,18 @@ void oz_pd_destroy(struct oz_pd *pd)
        while (e != &pd->farewell_list) {
                fwell = container_of(e, struct oz_farewell, link);
                e = e->next;
-               oz_free(fwell);
+               kfree(fwell);
        }
        /* Deallocate all frames in tx pool.
         */
        while (pd->tx_pool) {
                e = pd->tx_pool;
                pd->tx_pool = e->next;
-               oz_free(container_of(e, struct oz_tx_frame, link));
+               kfree(container_of(e, struct oz_tx_frame, link));
        }
        if (pd->net_dev)
                dev_put(pd->net_dev);
-       oz_free(pd);
+       kfree(pd);
 }
 /*------------------------------------------------------------------------------
  * Context: softirq-serialized
@@ -366,7 +364,7 @@ static struct oz_tx_frame *oz_tx_frame_alloc(struct oz_pd *pd)
        }
        spin_unlock_bh(&pd->tx_frame_lock);
        if (f == 0)
-               f = oz_alloc(sizeof(struct oz_tx_frame), GFP_ATOMIC);
+               f = kmalloc(sizeof(struct oz_tx_frame), GFP_ATOMIC);
        if (f) {
                f->total_size = sizeof(struct oz_hdr);
                INIT_LIST_HEAD(&f->link);
@@ -386,11 +384,11 @@ static void oz_tx_frame_free(struct oz_pd *pd, struct oz_tx_frame *f)
                pd->tx_pool_count++;
                f = 0;
        } else {
-               oz_free(f);
+               kfree(f);
        }
        spin_unlock_bh(&pd->tx_frame_lock);
        if (f)
-               oz_free(f);
+               kfree(f);
 }
 /*------------------------------------------------------------------------------
  * Context: softirq
@@ -649,10 +647,9 @@ static struct oz_isoc_stream *pd_stream_find(struct oz_pd *pd, u8 ep_num)
 int oz_isoc_stream_create(struct oz_pd *pd, u8 ep_num)
 {
        struct oz_isoc_stream *st =
-               oz_alloc(sizeof(struct oz_isoc_stream), GFP_ATOMIC);
+               kzalloc(sizeof(struct oz_isoc_stream), GFP_ATOMIC);
        if (!st)
-               return -1;
-       memset(st, 0, sizeof(struct oz_isoc_stream));
+               return -ENOMEM;
        st->ep_num = ep_num;
        spin_lock_bh(&pd->stream_lock);
        if (!pd_stream_find(pd, ep_num)) {
@@ -661,7 +658,7 @@ int oz_isoc_stream_create(struct oz_pd *pd, u8 ep_num)
        }
        spin_unlock_bh(&pd->stream_lock);
        if (st)
-               oz_free(st);
+               kfree(st);
        return 0;
 }
 /*------------------------------------------------------------------------------
@@ -671,7 +668,7 @@ static void oz_isoc_stream_free(struct oz_isoc_stream *st)
 {
        if (st->skb)
                kfree_skb(st->skb);
-       oz_free(st);
+       kfree(st);
 }
 /*------------------------------------------------------------------------------
  * Context: softirq
@@ -830,6 +827,6 @@ void oz_pd_indicate_farewells(struct oz_pd *pd)
                oz_polling_unlock_bh();
                if (ai->farewell)
                        ai->farewell(pd, f->ep_num, f->report, f->len);
-               oz_free(f);
+               kfree(f);
        }
 }
index 44f3926d4f0896707844bb00242f36a7ccd4e4f2..ad857eeabbb75c7b3f21efe465b1245996b9649a 100644 (file)
@@ -19,7 +19,6 @@
 #include "oztrace.h"
 #include "ozappif.h"
 #include "ozevent.h"
-#include "ozalloc.h"
 #include <asm/unaligned.h>
 #include <linux/uaccess.h>
 #include <net/psnap.h>
@@ -300,7 +299,7 @@ static void oz_add_farewell(struct oz_pd *pd, u8 ep_num, u8 index,
        struct oz_farewell *f;
        struct oz_farewell *f2;
        int found = 0;
-       f = oz_alloc(sizeof(struct oz_farewell) + len - 1, GFP_ATOMIC);
+       f = kmalloc(sizeof(struct oz_farewell) + len - 1, GFP_ATOMIC);
        if (!f)
                return;
        f->ep_num = ep_num;
@@ -318,7 +317,7 @@ static void oz_add_farewell(struct oz_pd *pd, u8 ep_num, u8 index,
        list_add_tail(&f->link, &pd->farewell_list);
        spin_unlock(&g_polling_lock);
        if (found)
-               oz_free(f2);
+               kfree(f2);
 }
 /*------------------------------------------------------------------------------
  * Context: softirq-serialized
@@ -458,7 +457,7 @@ void oz_protocol_term(void)
                dev_remove_pack(&b->ptype);
                if (b->ptype.dev)
                        dev_put(b->ptype.dev);
-               oz_free(b);
+               kfree(b);
                spin_lock_bh(&g_binding_lock);
        }
        spin_unlock_bh(&g_binding_lock);
@@ -482,7 +481,7 @@ void oz_protocol_term(void)
        while (chain) {
                struct oz_timer *t = container_of(chain, struct oz_timer, link);
                chain = chain->next;
-               oz_free(t);
+               kfree(t);
        }
        oz_trace("Protocol stopped\n");
 }
@@ -557,7 +556,7 @@ static void oz_protocol_timer(unsigned long arg)
                spin_unlock_bh(&g_polling_lock);
                oz_pd_put(pd);
                if (t)
-                       oz_free(t);
+                       kfree(t);
                t = t2;
        } while (t);
        g_timer_state = OZ_TIMER_IDLE;
@@ -623,7 +622,7 @@ void oz_timer_add(struct oz_pd *pd, int type, unsigned long due_time,
                        g_timer_pool = g_timer_pool->next;
                        g_timer_pool_count--;
                } else {
-                       t = oz_alloc(sizeof(struct oz_timer), GFP_ATOMIC);
+                       t = kmalloc(sizeof(struct oz_timer), GFP_ATOMIC);
                }
                if (t) {
                        t->pd = pd;
@@ -699,7 +698,7 @@ void oz_timer_delete(struct oz_pd *pd, int type)
        while (chain) {
                t = container_of(chain, struct oz_timer, link);
                chain = chain->next;
-               oz_free(t);
+               kfree(t);
        }
 }
 /*------------------------------------------------------------------------------
@@ -796,7 +795,8 @@ static int oz_pkt_recv(struct sk_buff *skb, struct net_device *dev,
 void oz_binding_add(char *net_dev)
 {
        struct oz_binding *binding;
-       binding = oz_alloc(sizeof(struct oz_binding), GFP_ATOMIC);
+
+       binding = kmalloc(sizeof(struct oz_binding), GFP_ATOMIC);
        if (binding) {
                binding->ptype.type = __constant_htons(OZ_ETHERTYPE);
                binding->ptype.func = oz_pkt_recv;
@@ -807,7 +807,7 @@ void oz_binding_add(char *net_dev)
                                dev_get_by_name(&init_net, net_dev);
                        if (binding->ptype.dev == 0) {
                                oz_trace("Netdev %s not found\n", net_dev);
-                               oz_free(binding);
+                               kfree(binding);
                                binding = 0;
                        }
                } else {
@@ -889,7 +889,7 @@ void oz_binding_remove(char *net_dev)
                        dev_put(binding->ptype.dev);
                        pd_stop_all_for_device(binding->ptype.dev);
                }
-               oz_free(binding);
+               kfree(binding);
        }
 }
 /*------------------------------------------------------------------------------
index 1da98f6ecbe9218a6e0d230713ce9a9ccb2d40e5..9e74f960238466743747a9ae5446071fd102fc22 100644 (file)
@@ -26,7 +26,6 @@
 #include "ozusbif.h"
 #include "ozhcd.h"
 #include "oztrace.h"
-#include "ozalloc.h"
 #include "ozusbsvc.h"
 #include "ozevent.h"
 /*------------------------------------------------------------------------------
@@ -65,11 +64,9 @@ int oz_usb_start(struct oz_pd *pd, int resume)
        /* Create a USB context in case we need one. If we find the PD already
         * has a USB context then we will destroy it.
         */
-       usb_ctx = (struct oz_usb_ctx *)
-               oz_alloc(sizeof(struct oz_usb_ctx), GFP_ATOMIC);
+       usb_ctx = kzalloc(sizeof(struct oz_usb_ctx), GFP_ATOMIC);
        if (usb_ctx == 0)
-               return -1;
-       memset(usb_ctx, 0, sizeof(struct oz_usb_ctx));
+               return -ENOMEM;
        atomic_set(&usb_ctx->ref_count, 1);
        usb_ctx->pd = pd;
        usb_ctx->stopped = 0;
@@ -85,7 +82,7 @@ int oz_usb_start(struct oz_pd *pd, int resume)
        spin_unlock_bh(&pd->app_lock[OZ_APPID_USB-1]);
        if (old_ctx) {
                oz_trace("Already have USB context.\n");
-               oz_free(usb_ctx);
+               kfree(usb_ctx);
                usb_ctx = old_ctx;
        } else if (usb_ctx) {
                /* Take a reference to the PD. This will be released when
@@ -170,7 +167,7 @@ void oz_usb_put(void *hpd)
        if (atomic_dec_and_test(&usb_ctx->ref_count)) {
                oz_trace("Dealloc USB context.\n");
                oz_pd_put(usb_ctx->pd);
-               oz_free(usb_ctx);
+               kfree(usb_ctx);
        }
 }
 /*------------------------------------------------------------------------------
index 3982194cd0eec7726e801d3fc135d4b59aa19c9e..66bd576bb5e9d297d47a972eb3639ec4a27752b2 100644 (file)
@@ -21,7 +21,6 @@
 #include "ozusbif.h"
 #include "ozhcd.h"
 #include "oztrace.h"
-#include "ozalloc.h"
 #include "ozusbsvc.h"
 #include "ozevent.h"
 /*------------------------------------------------------------------------------