Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f724b584 authored by Joe Perches's avatar Joe Perches Committed by Greg Kroah-Hartman
Browse files

staging: ozwpan: Replace oz_trace with oz_dbg



Introduce new debug macros: oz_dbg, oz_cdev_dbg, oz_pd_dbg
and then replace old oz_trace & oz_trace2 with new macro.

Signed-off-by: default avatarJoe Perches <joe@perches.com>
Signed-off-by: default avatarRupesh Gujare <rupesh.gujare@atmel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 30f1e5a9
Loading
Loading
Loading
Loading
+25 −23
Original line number Diff line number Diff line
@@ -12,6 +12,7 @@
#include <linux/poll.h>
#include <linux/sched.h>
#include "ozconfig.h"
#include "ozdbg.h"
#include "ozprotocol.h"
#include "oztrace.h"
#include "ozappif.h"
@@ -63,7 +64,7 @@ static struct oz_serial_ctx *oz_cdev_claim_ctx(struct oz_pd *pd)
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_dbg(ON, "Dealloc serial context\n");
		kfree(ctx);
	}
}
@@ -72,9 +73,10 @@ static void oz_cdev_release_ctx(struct oz_serial_ctx *ctx)
 */
static int oz_cdev_open(struct inode *inode, struct file *filp)
{
	struct oz_cdev *dev;
	oz_trace("major = %d minor = %d\n", imajor(inode), iminor(inode));
	dev = container_of(inode->i_cdev, struct oz_cdev, cdev);
	struct oz_cdev *dev = container_of(inode->i_cdev, struct oz_cdev, cdev);

	oz_dbg(ON, "major = %d minor = %d\n", imajor(inode), iminor(inode));

	filp->private_data = dev;
	return 0;
}
@@ -249,7 +251,7 @@ static long oz_cdev_ioctl(struct file *filp, unsigned int cmd,
	switch (cmd) {
	case OZ_IOCTL_GET_PD_LIST: {
			struct oz_pd_list list;
			oz_trace("OZ_IOCTL_GET_PD_LIST\n");
			oz_dbg(ON, "OZ_IOCTL_GET_PD_LIST\n");
			memset(&list, 0, sizeof(list));
			list.count = oz_get_pd_list(list.addr, OZ_MAX_PDS);
			if (copy_to_user((void __user *)arg, &list,
@@ -259,7 +261,7 @@ static long oz_cdev_ioctl(struct file *filp, unsigned int cmd,
		break;
	case OZ_IOCTL_SET_ACTIVE_PD: {
			u8 addr[ETH_ALEN];
			oz_trace("OZ_IOCTL_SET_ACTIVE_PD\n");
			oz_dbg(ON, "OZ_IOCTL_SET_ACTIVE_PD\n");
			if (copy_from_user(addr, (void __user *)arg, ETH_ALEN))
				return -EFAULT;
			rc = oz_set_active_pd(addr);
@@ -267,7 +269,7 @@ static long oz_cdev_ioctl(struct file *filp, unsigned int cmd,
		break;
	case OZ_IOCTL_GET_ACTIVE_PD: {
			u8 addr[ETH_ALEN];
			oz_trace("OZ_IOCTL_GET_ACTIVE_PD\n");
			oz_dbg(ON, "OZ_IOCTL_GET_ACTIVE_PD\n");
			spin_lock_bh(&g_cdev.lock);
			memcpy(addr, g_cdev.active_addr, ETH_ALEN);
			spin_unlock_bh(&g_cdev.lock);
@@ -300,7 +302,7 @@ static unsigned int oz_cdev_poll(struct file *filp, poll_table *wait)
{
	unsigned int ret = 0;
	struct oz_cdev *dev = filp->private_data;
	oz_trace("Poll called wait = %p\n", wait);
	oz_dbg(ON, "Poll called wait = %p\n", wait);
	spin_lock_bh(&dev->lock);
	if (dev->active_pd) {
		struct oz_serial_ctx *ctx = oz_cdev_claim_ctx(dev->active_pd);
@@ -337,8 +339,8 @@ int oz_cdev_register(void)
	err = alloc_chrdev_region(&g_cdev.devnum, 0, 1, "ozwpan");
	if (err < 0)
		goto out3;
	oz_trace("Alloc dev number %d:%d\n", MAJOR(g_cdev.devnum),
			MINOR(g_cdev.devnum));
	oz_dbg(ON, "Alloc dev number %d:%d\n",
	       MAJOR(g_cdev.devnum), MINOR(g_cdev.devnum));
	cdev_init(&g_cdev.cdev, &oz_fops);
	g_cdev.cdev.owner = THIS_MODULE;
	g_cdev.cdev.ops = &oz_fops;
@@ -346,18 +348,18 @@ int oz_cdev_register(void)
	init_waitqueue_head(&g_cdev.rdq);
	err = cdev_add(&g_cdev.cdev, g_cdev.devnum, 1);
	if (err < 0) {
		oz_trace("Failed to add cdev\n");
		oz_dbg(ON, "Failed to add cdev\n");
		goto out2;
	}
	g_oz_class = class_create(THIS_MODULE, "ozmo_wpan");
	if (IS_ERR(g_oz_class)) {
		oz_trace("Failed to register ozmo_wpan class\n");
		oz_dbg(ON, "Failed to register ozmo_wpan class\n");
		err = PTR_ERR(g_oz_class);
		goto out1;
	}
	dev = device_create(g_oz_class, NULL, g_cdev.devnum, NULL, "ozwpan");
	if (IS_ERR(dev)) {
		oz_trace("Failed to create sysfs entry for cdev\n");
		oz_dbg(ON, "Failed to create sysfs entry for cdev\n");
		err = PTR_ERR(dev);
		goto out1;
	}
@@ -405,7 +407,7 @@ int oz_cdev_start(struct oz_pd *pd, int resume)
	struct oz_serial_ctx *ctx;
	struct oz_serial_ctx *old_ctx;
	if (resume) {
		oz_trace("Serial service resumed.\n");
		oz_dbg(ON, "Serial service resumed\n");
		return 0;
	}
	ctx = kzalloc(sizeof(struct oz_serial_ctx), GFP_ATOMIC);
@@ -427,10 +429,10 @@ int oz_cdev_start(struct oz_pd *pd, int resume)
		(memcmp(pd->mac_addr, g_cdev.active_addr, ETH_ALEN) == 0)) {
		oz_pd_get(pd);
		g_cdev.active_pd = pd;
		oz_trace("Active PD arrived.\n");
		oz_dbg(ON, "Active PD arrived\n");
	}
	spin_unlock(&g_cdev.lock);
	oz_trace("Serial service started.\n");
	oz_dbg(ON, "Serial service started\n");
	return 0;
}
/*------------------------------------------------------------------------------
@@ -440,7 +442,7 @@ void oz_cdev_stop(struct oz_pd *pd, int pause)
{
	struct oz_serial_ctx *ctx;
	if (pause) {
		oz_trace("Serial service paused.\n");
		oz_dbg(ON, "Serial service paused\n");
		return;
	}
	spin_lock_bh(&pd->app_lock[OZ_APPID_SERIAL-1]);
@@ -457,9 +459,9 @@ void oz_cdev_stop(struct oz_pd *pd, int pause)
	spin_unlock(&g_cdev.lock);
	if (pd) {
		oz_pd_put(pd);
		oz_trace("Active PD departed.\n");
		oz_dbg(ON, "Active PD departed\n");
	}
	oz_trace("Serial service stopped.\n");
	oz_dbg(ON, "Serial service stopped\n");
}
/*------------------------------------------------------------------------------
 * Context: softirq-serialized
@@ -476,7 +478,7 @@ void oz_cdev_rx(struct oz_pd *pd, struct oz_elt *elt)

	ctx = oz_cdev_claim_ctx(pd);
	if (ctx == NULL) {
		oz_trace("Cannot claim serial context.\n");
		oz_dbg(ON, "Cannot claim serial context\n");
		return;
	}

@@ -486,7 +488,7 @@ void oz_cdev_rx(struct oz_pd *pd, struct oz_elt *elt)
	if (app_hdr->elt_seq_num != 0) {
		if (((ctx->rx_seq_num - app_hdr->elt_seq_num) & 0x80) == 0) {
			/* Reject duplicate element. */
			oz_trace("Duplicate element:%02x %02x\n",
			oz_dbg(ON, "Duplicate element:%02x %02x\n",
			       app_hdr->elt_seq_num, ctx->rx_seq_num);
			goto out;
		}
@@ -500,7 +502,7 @@ void oz_cdev_rx(struct oz_pd *pd, struct oz_elt *elt)
	if (space < 0)
		space += OZ_RD_BUF_SZ;
	if (len > space) {
		oz_trace("Not enough space:%d %d\n", len, space);
		oz_dbg(ON, "Not enough space:%d %d\n", len, space);
		len = space;
	}
	ix = ctx->rd_in;
+54 −0
Original line number Diff line number Diff line
/* -----------------------------------------------------------------------------
 * Copyright (c) 2011 Ozmo Inc
 * Released under the GNU General Public License Version 2 (GPLv2).
 * ---------------------------------------------------------------------------*/

#ifndef _OZDBG_H
#define _OZDBG_H

#define OZ_WANT_DBG 0
#define OZ_WANT_VERBOSE_DBG 1

#define OZ_DBG_ON		0x0
#define OZ_DBG_STREAM		0x1
#define OZ_DBG_URB		0x2
#define OZ_DBG_CTRL_DETAIL	0x4
#define OZ_DBG_HUB		0x8
#define OZ_DBG_RX_FRAMES	0x10
#define OZ_DBG_TX_FRAMES	0x20

#define OZ_DEFAULT_DBG_MASK			\
	(					\
	/* OZ_DBG_STREAM | */			\
	/* OZ_DBG_URB | */			\
	/* OZ_DBG_CTRL_DETAIL | */		\
	OZ_DBG_HUB |				\
	/* OZ_DBG_RX_FRAMES | */		\
	/* OZ_DBG_TX_FRAMES | */		\
	0)

extern unsigned int oz_dbg_mask;

#define oz_want_dbg(mask)						\
	((OZ_WANT_DBG && (OZ_DBG_##mask == OZ_DBG_ON)) ||		\
	 (OZ_WANT_VERBOSE_DBG && (OZ_DBG_##mask & oz_dbg_mask)))

#define oz_dbg(mask, fmt, ...)						\
do {									\
	if (oz_want_dbg(mask))						\
		pr_debug(fmt, ##__VA_ARGS__);				\
} while (0)

#define oz_cdev_dbg(cdev, mask, fmt, ...)				\
do {									\
	if (oz_want_dbg(mask))						\
		netdev_dbg((cdev)->dev, fmt, ##__VA_ARGS__);		\
} while (0)

#define oz_pd_dbg(pd, mask, fmt, ...)					\
do {									\
	if (oz_want_dbg(mask))						\
		pr_debug(fmt, ##__VA_ARGS__);				\
} while (0)

#endif /* _OZDBG_H */
+14 −16
Original line number Diff line number Diff line
@@ -7,10 +7,12 @@
#include <linux/module.h>
#include <linux/netdevice.h>
#include "ozconfig.h"
#include "ozdbg.h"
#include "ozprotocol.h"
#include "ozeltbuf.h"
#include "ozpd.h"
#include "oztrace.h"

/*------------------------------------------------------------------------------
 */
#define OZ_ELT_INFO_MAGIC_USED	0x35791057
@@ -72,8 +74,8 @@ struct oz_elt_info *oz_elt_info_alloc(struct oz_elt_buf *buf)
		buf->free_elts--;
		spin_unlock_bh(&buf->lock);
		if (ei->magic != OZ_ELT_INFO_MAGIC_FREE) {
			oz_trace("oz_elt_info_alloc: ei with bad magic: 0x%x\n",
				ei->magic);
			oz_dbg(ON, "%s: ei with bad magic: 0x%x\n",
			       __func__, ei->magic);
		}
	} else {
		spin_unlock_bh(&buf->lock);
@@ -104,9 +106,8 @@ void oz_elt_info_free(struct oz_elt_buf *buf, struct oz_elt_info *ei)
			buf->elt_pool = &ei->link;
			ei->magic = OZ_ELT_INFO_MAGIC_FREE;
		} else {
			oz_trace("oz_elt_info_free: bad magic ei: %p"
				" magic: 0x%x\n",
				ei, ei->magic);
			oz_dbg(ON, "%s: bad magic ei: %p magic: 0x%x\n",
			       __func__, ei, ei->magic);
		}
	}
}
@@ -132,7 +133,7 @@ int oz_elt_stream_create(struct oz_elt_buf *buf, u8 id, int max_buf_count)
{
	struct oz_elt_stream *st;

	oz_trace("oz_elt_stream_create(0x%x)\n", id);
	oz_dbg(ON, "%s: (0x%x)\n", __func__, id);

	st = kzalloc(sizeof(struct oz_elt_stream), GFP_ATOMIC | __GFP_ZERO);
	if (st == NULL)
@@ -152,7 +153,7 @@ int oz_elt_stream_delete(struct oz_elt_buf *buf, u8 id)
{
	struct list_head *e;
	struct oz_elt_stream *st = NULL;
	oz_trace("oz_elt_stream_delete(0x%x)\n", id);
	oz_dbg(ON, "%s: (0x%x)\n", __func__, id);
	spin_lock_bh(&buf->lock);
	e = buf->stream_list.next;
	while (e != &buf->stream_list) {
@@ -175,9 +176,8 @@ int oz_elt_stream_delete(struct oz_elt_buf *buf, u8 id)
		list_del_init(&ei->link);
		list_del_init(&ei->link_order);
		st->buf_count -= ei->length;
		oz_trace2(OZ_TRACE_STREAM, "Stream down: %d  %d %d\n",
			st->buf_count,
			ei->length, atomic_read(&st->ref_count));
		oz_dbg(STREAM, "Stream down: %d %d %d\n",
		       st->buf_count, ei->length, atomic_read(&st->ref_count));
		oz_elt_stream_put(st);
		oz_elt_info_free(buf, ei);
	}
@@ -196,7 +196,7 @@ void oz_elt_stream_get(struct oz_elt_stream *st)
void oz_elt_stream_put(struct oz_elt_stream *st)
{
	if (atomic_dec_and_test(&st->ref_count)) {
		oz_trace("Stream destroyed\n");
		oz_dbg(ON, "Stream destroyed\n");
		kfree(st);
	}
}
@@ -242,8 +242,7 @@ int oz_queue_elt_info(struct oz_elt_buf *buf, u8 isoc, u8 id,
		st->buf_count += ei->length;
		/* Add to list in stream. */
		list_add_tail(&ei->link, &st->elt_list);
		oz_trace2(OZ_TRACE_STREAM, "Stream up: %d  %d\n",
			st->buf_count, ei->length);
		oz_dbg(STREAM, "Stream up: %d %d\n", st->buf_count, ei->length);
		/* Check if we have too much buffered for this stream. If so
		 * start dropping elements until we are back in bounds.
		 */
@@ -293,8 +292,7 @@ int oz_select_elts_for_tx(struct oz_elt_buf *buf, u8 isoc, unsigned *len,
			list_del(&ei->link_order);
			if (ei->stream) {
				ei->stream->buf_count -= ei->length;
				oz_trace2(OZ_TRACE_STREAM,
					"Stream down: %d  %d\n",
				oz_dbg(STREAM, "Stream down: %d %d\n",
				       ei->stream->buf_count, ei->length);
				oz_elt_stream_put(ei->stream);
				ei->stream = NULL;
+130 −131

File changed.

Preview size limit exceeded, changes collapsed.

+30 −31
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@
#include <linux/sched.h>
#include <linux/netdevice.h>
#include <linux/errno.h>
#include "ozdbg.h"
#include "ozconfig.h"
#include "ozprotocol.h"
#include "ozeltbuf.h"
@@ -123,16 +124,16 @@ void oz_pd_set_state(struct oz_pd *pd, unsigned state)
#ifdef WANT_TRACE
	switch (state) {
	case OZ_PD_S_IDLE:
		oz_trace("PD State: OZ_PD_S_IDLE\n");
		oz_pd_dbg(pd, ON, "PD State: OZ_PD_S_IDLE\n");
		break;
	case OZ_PD_S_CONNECTED:
		oz_trace("PD State: OZ_PD_S_CONNECTED\n");
		oz_pd_dbg(pd, ON, "PD State: OZ_PD_S_CONNECTED\n");
		break;
	case OZ_PD_S_STOPPED:
		oz_trace("PD State: OZ_PD_S_STOPPED\n");
		oz_pd_dbg(pd, ON, "PD State: OZ_PD_S_STOPPED\n");
		break;
	case OZ_PD_S_SLEEP:
		oz_trace("PD State: OZ_PD_S_SLEEP\n");
		oz_pd_dbg(pd, ON, "PD State: OZ_PD_S_SLEEP\n");
		break;
	}
#endif /* WANT_TRACE */
@@ -189,7 +190,7 @@ void oz_pd_destroy(struct oz_pd *pd)
	struct oz_tx_frame *f;
	struct oz_isoc_stream *st;
	struct oz_farewell *fwell;
	oz_trace("Destroying PD\n");
	oz_pd_dbg(pd, ON, "Destroying PD\n");
	/* Delete any streams.
	 */
	e = pd->stream_list.next;
@@ -235,12 +236,13 @@ int oz_services_start(struct oz_pd *pd, u16 apps, int resume)
{
	const struct oz_app_if *ai;
	int rc = 0;
	oz_trace("oz_services_start(0x%x) resume(%d)\n", apps, resume);
	oz_pd_dbg(pd, ON, "%s: (0x%x) resume(%d)\n", __func__, apps, resume);
	for (ai = g_app_if; ai < &g_app_if[OZ_APPID_MAX]; ai++) {
		if (apps & (1<<ai->app_id)) {
			if (ai->start(pd, resume)) {
				rc = -1;
				oz_trace("Unabled to start service %d\n",
				oz_pd_dbg(pd, ON,
					  "Unable to start service %d\n",
					  ai->app_id);
				break;
			}
@@ -259,7 +261,7 @@ int oz_services_start(struct oz_pd *pd, u16 apps, int resume)
void oz_services_stop(struct oz_pd *pd, u16 apps, int pause)
{
	const struct oz_app_if *ai;
	oz_trace("oz_stop_services(0x%x) pause(%d)\n", apps, pause);
	oz_pd_dbg(pd, ON, "%s: (0x%x) pause(%d)\n", __func__, apps, pause);
	for (ai = g_app_if; ai < &g_app_if[OZ_APPID_MAX]; ai++) {
		if (apps & (1<<ai->app_id)) {
			oz_polling_lock_bh();
@@ -301,7 +303,7 @@ void oz_pd_heartbeat(struct oz_pd *pd, u16 apps)
void oz_pd_stop(struct oz_pd *pd)
{
	u16 stop_apps = 0;
	oz_trace("oz_pd_stop() State = 0x%x\n", pd->state);
	oz_dbg(ON, "oz_pd_stop() State = 0x%x\n", pd->state);
	oz_pd_indicate_farewells(pd);
	oz_polling_lock_bh();
	stop_apps = pd->total_apps;
@@ -314,7 +316,7 @@ void oz_pd_stop(struct oz_pd *pd)
	/* Remove from PD list.*/
	list_del(&pd->link);
	oz_polling_unlock_bh();
	oz_trace("pd ref count = %d\n", atomic_read(&pd->ref_count));
	oz_dbg(ON, "pd ref count = %d\n", atomic_read(&pd->ref_count));
	oz_timer_delete(pd, 0);
	oz_pd_put(pd);
}
@@ -333,7 +335,7 @@ int oz_pd_sleep(struct oz_pd *pd)
	if (pd->keep_alive_j && pd->session_id) {
		oz_pd_set_state(pd, OZ_PD_S_SLEEP);
		pd->pulse_time_j = jiffies + pd->keep_alive_j;
		oz_trace("Sleep Now %lu until %lu\n",
		oz_dbg(ON, "Sleep Now %lu until %lu\n",
		       jiffies, pd->pulse_time_j);
	} else {
		do_stop = 1;
@@ -384,7 +386,7 @@ static void oz_tx_isoc_free(struct oz_pd *pd, struct oz_tx_frame *f)
	} else {
		kfree(f);
	}
	oz_trace2(OZ_TRACE_TX_FRAMES, "Releasing ISOC Frame isoc_nb= %d\n",
	oz_dbg(TX_FRAMES, "Releasing ISOC Frame isoc_nb= %d\n",
	       pd->nb_queued_isoc_frames);
}
/*------------------------------------------------------------------------------
@@ -540,18 +542,16 @@ static int oz_send_next_queued_frame(struct oz_pd *pd, int more_data)
		if ((int)atomic_read(&g_submitted_isoc) <
							OZ_MAX_SUBMITTED_ISOC) {
			if (dev_queue_xmit(skb) < 0) {
				oz_trace2(OZ_TRACE_TX_FRAMES,
						"Dropping ISOC Frame\n");
				oz_dbg(TX_FRAMES, "Dropping ISOC Frame\n");
				return -1;
			}
			atomic_inc(&g_submitted_isoc);
			oz_trace2(OZ_TRACE_TX_FRAMES,
					"Sending ISOC Frame, nb_isoc= %d\n",
			oz_dbg(TX_FRAMES, "Sending ISOC Frame, nb_isoc= %d\n",
			       pd->nb_queued_isoc_frames);
			return 0;
		} else {
			kfree_skb(skb);
			oz_trace2(OZ_TRACE_TX_FRAMES, "Dropping ISOC Frame>\n");
			oz_dbg(TX_FRAMES, "Dropping ISOC Frame>\n");
			return -1;
		}
	}
@@ -561,7 +561,7 @@ static int oz_send_next_queued_frame(struct oz_pd *pd, int more_data)
	spin_unlock(&pd->tx_frame_lock);
	if (more_data)
		oz_set_more_bit(skb);
	oz_trace2(OZ_TRACE_TX_FRAMES, "TX frame PN=0x%x\n", f->hdr.pkt_num);
	oz_dbg(TX_FRAMES, "TX frame PN=0x%x\n", f->hdr.pkt_num);
	if (skb) {
		if (dev_queue_xmit(skb) < 0)
			return -1;
@@ -627,7 +627,7 @@ static int oz_send_isoc_frame(struct oz_pd *pd)
		return 0;
	skb = alloc_skb(total_size + OZ_ALLOCATED_SPACE(dev), GFP_ATOMIC);
	if (skb == NULL) {
		oz_trace("Cannot alloc skb\n");
		oz_dbg(ON, "Cannot alloc skb\n");
		oz_elt_info_free_chain(&pd->elt_buff, &list);
		return -1;
	}
@@ -675,7 +675,7 @@ void oz_retire_tx_frames(struct oz_pd *pd, u8 lpn)
		diff = (lpn - (pkt_num & OZ_LAST_PN_MASK)) & OZ_LAST_PN_MASK;
		if ((diff > OZ_LAST_PN_HALF_CYCLE) || (pkt_num == 0))
			break;
		oz_trace2(OZ_TRACE_TX_FRAMES, "Releasing pkt_num= %u, nb= %d\n",
		oz_dbg(TX_FRAMES, "Releasing pkt_num= %u, nb= %d\n",
		       pkt_num, pd->nb_queued_frames);
		if (first == NULL)
			first = e;
@@ -835,8 +835,7 @@ int oz_send_isoc_unit(struct oz_pd *pd, u8 ep_num, const u8 *data, int len)
			struct oz_tx_frame *isoc_unit = NULL;
			int nb = pd->nb_queued_isoc_frames;
			if (nb >= pd->isoc_latency) {
				oz_trace2(OZ_TRACE_TX_FRAMES,
						"Dropping ISOC Unit nb= %d\n",
				oz_dbg(TX_FRAMES, "Dropping ISOC Unit nb= %d\n",
				       nb);
				goto out;
			}
@@ -849,7 +848,7 @@ int oz_send_isoc_unit(struct oz_pd *pd, u8 ep_num, const u8 *data, int len)
			list_add_tail(&isoc_unit->link, &pd->tx_queue);
			pd->nb_queued_isoc_frames++;
			spin_unlock_bh(&pd->tx_frame_lock);
			oz_trace2(OZ_TRACE_TX_FRAMES,
			oz_dbg(TX_FRAMES,
			       "Added ISOC Frame to Tx Queue isoc_nb= %d, nb= %d\n",
			       pd->nb_queued_isoc_frames, pd->nb_queued_frames);
			return 0;
Loading