Skip to content

Commit

Permalink
staging: ozwpan: remove debug allocator
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
gregkh committed Mar 3, 2012
1 parent cc55bb0 commit 1ec41a3
Show file tree
Hide file tree
Showing 12 changed files with 51 additions and 201 deletions.
1 change: 0 additions & 1 deletion drivers/staging/ozwpan/Kbuild
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ ozwpan-y := \
ozeltbuf.o \
ozproto.o \
ozcdev.o \
ozalloc.o \
ozurbparanoia.o \
oztrace.o \
ozevent.o
Expand Down
107 changes: 0 additions & 107 deletions drivers/staging/ozwpan/ozalloc.c

This file was deleted.

28 changes: 0 additions & 28 deletions drivers/staging/ozwpan/ozalloc.h

This file was deleted.

11 changes: 4 additions & 7 deletions drivers/staging/ozwpan/ozcdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#include "ozeltbuf.h"
#include "ozpd.h"
#include "ozproto.h"
#include "ozalloc.h"
#include "ozevent.h"
/*------------------------------------------------------------------------------
*/
Expand Down Expand Up @@ -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);
}
}
/*------------------------------------------------------------------------------
Expand Down Expand Up @@ -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]);
Expand Down
1 change: 0 additions & 1 deletion drivers/staging/ozwpan/ozconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#ifndef _OZCONFIG_H
#define _OZCONFIG_H

/* #define WANT_DEBUG_KMALLOC */
/* #define WANT_TRACE */
#ifdef WANT_TRACE
#define WANT_VERBOSE_TRACE
Expand Down
20 changes: 10 additions & 10 deletions drivers/staging/ozwpan/ozeltbuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include "ozeltbuf.h"
#include "ozpd.h"
#include "oztrace.h"
#include "ozalloc.h"
/*------------------------------------------------------------------------------
*/
#define OZ_ELT_INFO_MAGIC_USED 0x35791057
Expand Down Expand Up @@ -48,15 +47,15 @@ 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. */
while (buf->elt_pool) {
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;
}
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}
/*------------------------------------------------------------------------------
Expand Down Expand Up @@ -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);
}
}
19 changes: 9 additions & 10 deletions drivers/staging/ozwpan/ozhcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
#include "ozconfig.h"
#include "ozusbif.h"
#include "oztrace.h"
#include "ozalloc.h"
#include "ozurbparanoia.h"
#include "ozevent.h"
/*------------------------------------------------------------------------------
Expand Down Expand Up @@ -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;
}
/*------------------------------------------------------------------------------
Expand All @@ -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);
}
}
/*------------------------------------------------------------------------------
Expand All @@ -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);
}
}
/*------------------------------------------------------------------------------
Expand All @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 0 additions & 2 deletions drivers/staging/ozwpan/ozmain.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include "ozpd.h"
#include "ozproto.h"
#include "ozcdev.h"
#include "ozalloc.h"
#include "oztrace.h"
#include "ozevent.h"
/*------------------------------------------------------------------------------
Expand Down Expand Up @@ -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();
}
/*------------------------------------------------------------------------------
Expand Down
Loading

0 comments on commit 1ec41a3

Please sign in to comment.