aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/uwb/uwbd.c
diff options
context:
space:
mode:
authorDavid Vrabel <david.vrabel@csr.com>2008-12-22 13:22:50 -0500
committerDavid Vrabel <david.vrabel@csr.com>2008-12-22 13:22:50 -0500
commitbce83697c5fe84a7a5d38c96fbbe43b4bc028c3e (patch)
treeb8e920af66f5b4de509e95a7295cedbe42878dd6 /drivers/uwb/uwbd.c
parent02f11ee181baa562df23e105ba930902f0d0b1bf (diff)
uwb: use dev_dbg() for debug messages
Instead of the home-grown d_fnstart(), d_fnend() and d_printf() macros, use dev_dbg() or remove the message entirely. Signed-off-by: David Vrabel <david.vrabel@csr.com>
Diffstat (limited to 'drivers/uwb/uwbd.c')
-rw-r--r--drivers/uwb/uwbd.c74
1 files changed, 30 insertions, 44 deletions
diff --git a/drivers/uwb/uwbd.c b/drivers/uwb/uwbd.c
index ec42ce92dbce..57bd6bfef37e 100644
--- a/drivers/uwb/uwbd.c
+++ b/drivers/uwb/uwbd.c
@@ -68,17 +68,13 @@
68 * 68 *
69 * Handler functions are called normally uwbd_evt_handle_*(). 69 * Handler functions are called normally uwbd_evt_handle_*().
70 */ 70 */
71
72#include <linux/kthread.h> 71#include <linux/kthread.h>
73#include <linux/module.h> 72#include <linux/module.h>
74#include <linux/freezer.h> 73#include <linux/freezer.h>
75#include "uwb-internal.h"
76
77#define D_LOCAL 1
78#include <linux/uwb/debug.h>
79 74
75#include "uwb-internal.h"
80 76
81/** 77/*
82 * UWBD Event handler function signature 78 * UWBD Event handler function signature
83 * 79 *
84 * Return !0 if the event needs not to be freed (ie the handler 80 * Return !0 if the event needs not to be freed (ie the handler
@@ -101,9 +97,8 @@ struct uwbd_event {
101 const char *name; 97 const char *name;
102}; 98};
103 99
104/** Table of handlers for and properties of the UWBD Radio Control Events */ 100/* Table of handlers for and properties of the UWBD Radio Control Events */
105static 101static struct uwbd_event uwbd_urc_events[] = {
106struct uwbd_event uwbd_events[] = {
107 [UWB_RC_EVT_IE_RCV] = { 102 [UWB_RC_EVT_IE_RCV] = {
108 .handler = uwbd_evt_handle_rc_ie_rcv, 103 .handler = uwbd_evt_handle_rc_ie_rcv,
109 .name = "IE_RECEIVED" 104 .name = "IE_RECEIVED"
@@ -146,23 +141,15 @@ struct uwbd_evt_type_handler {
146 size_t size; 141 size_t size;
147}; 142};
148 143
149#define UWBD_EVT_TYPE_HANDLER(n,a) { \ 144/* Table of handlers for each UWBD Event type. */
150 .name = (n), \ 145static struct uwbd_evt_type_handler uwbd_urc_evt_type_handlers[] = {
151 .uwbd_events = (a), \ 146 [UWB_RC_CET_GENERAL] = {
152 .size = sizeof(a)/sizeof((a)[0]) \ 147 .name = "URC",
153} 148 .uwbd_events = uwbd_urc_events,
154 149 .size = ARRAY_SIZE(uwbd_urc_events),
155 150 },
156/** Table of handlers for each UWBD Event type. */
157static
158struct uwbd_evt_type_handler uwbd_evt_type_handlers[] = {
159 [UWB_RC_CET_GENERAL] = UWBD_EVT_TYPE_HANDLER("RC", uwbd_events)
160}; 151};
161 152
162static const
163size_t uwbd_evt_type_handlers_len =
164 sizeof(uwbd_evt_type_handlers) / sizeof(uwbd_evt_type_handlers[0]);
165
166static const struct uwbd_event uwbd_message_handlers[] = { 153static const struct uwbd_event uwbd_message_handlers[] = {
167 [UWB_EVT_MSG_RESET] = { 154 [UWB_EVT_MSG_RESET] = {
168 .handler = uwbd_msg_handle_reset, 155 .handler = uwbd_msg_handle_reset,
@@ -170,7 +157,7 @@ static const struct uwbd_event uwbd_message_handlers[] = {
170 }, 157 },
171}; 158};
172 159
173/** 160/*
174 * Handle an URC event passed to the UWB Daemon 161 * Handle an URC event passed to the UWB Daemon
175 * 162 *
176 * @evt: the event to handle 163 * @evt: the event to handle
@@ -190,6 +177,7 @@ static const struct uwbd_event uwbd_message_handlers[] = {
190static 177static
191int uwbd_event_handle_urc(struct uwb_event *evt) 178int uwbd_event_handle_urc(struct uwb_event *evt)
192{ 179{
180 int result = -EINVAL;
193 struct uwbd_evt_type_handler *type_table; 181 struct uwbd_evt_type_handler *type_table;
194 uwbd_evt_handler_f handler; 182 uwbd_evt_handler_f handler;
195 u8 type, context; 183 u8 type, context;
@@ -199,26 +187,24 @@ int uwbd_event_handle_urc(struct uwb_event *evt)
199 event = le16_to_cpu(evt->notif.rceb->wEvent); 187 event = le16_to_cpu(evt->notif.rceb->wEvent);
200 context = evt->notif.rceb->bEventContext; 188 context = evt->notif.rceb->bEventContext;
201 189
202 if (type > uwbd_evt_type_handlers_len) { 190 if (type > ARRAY_SIZE(uwbd_urc_evt_type_handlers))
203 printk(KERN_ERR "UWBD: event type %u: unknown (too high)\n", type); 191 goto out;
204 return -EINVAL; 192 type_table = &uwbd_urc_evt_type_handlers[type];
205 } 193 if (type_table->uwbd_events == NULL)
206 type_table = &uwbd_evt_type_handlers[type]; 194 goto out;
207 if (type_table->uwbd_events == NULL) { 195 if (event > type_table->size)
208 printk(KERN_ERR "UWBD: event type %u: unknown\n", type); 196 goto out;
209 return -EINVAL;
210 }
211 if (event > type_table->size) {
212 printk(KERN_ERR "UWBD: event %s[%u]: unknown (too high)\n",
213 type_table->name, event);
214 return -EINVAL;
215 }
216 handler = type_table->uwbd_events[event].handler; 197 handler = type_table->uwbd_events[event].handler;
217 if (handler == NULL) { 198 if (handler == NULL)
218 printk(KERN_ERR "UWBD: event %s[%u]: unknown\n", type_table->name, event); 199 goto out;
219 return -EINVAL; 200
220 } 201 result = (*handler)(evt);
221 return (*handler)(evt); 202out:
203 if (result < 0)
204 dev_err(&evt->rc->uwb_dev.dev,
205 "UWBD: event 0x%02x/%04x/%02x, handling failed: %d\n",
206 type, event, context, result);
207 return result;
222} 208}
223 209
224static void uwbd_event_handle_message(struct uwb_event *evt) 210static void uwbd_event_handle_message(struct uwb_event *evt)