[CFT] 1/2 Overhaul PCMCIA debugging
Russell King
rmk+pcmcia at arm.linux.org.uk
Sat Feb 21 21:20:13 GMT 2004
Hi,
The attached patch overhauls (and fixes) PCMCIA debugging:
- introduce cs_debug_level() so we don't have to export pc_debug
from cs.c.
- use socket->dev.class_id rather than the address of socket as an
identifier.
- use module_param() for pc_debug variable - this now means that
socket drivers can be built in, and debugging enabled via:
pcmcia_core.pc_debug=n
ds.pc_debug=n
sa11xx_core.pc_debug=n
tcic.pc_debug=n
etc
- pc_debug from modules works as expected
- make PCMCIA core errors reflect the same format as the debugging
messages, and use cs_err() to report them.
The patch is rather large, so I've split it in two. First, the core
changes, then the socket drivers. Even so, the two are a little
unseparable because au1000 uses the PCMCIA core debugging macros. ;(
diff -urpN orig/drivers/pcmcia/bulkmem.c linux/drivers/pcmcia/bulkmem.c
--- orig/drivers/pcmcia/bulkmem.c Wed Feb 18 22:34:34 2004
+++ linux/drivers/pcmcia/bulkmem.c Sat Feb 21 19:21:45 2004
@@ -48,6 +48,8 @@
#include <pcmcia/cistpl.h>
#include "cs_internal.h"
+static void retry_erase_list(erase_busy_t *list, u_int cause);
+
/*======================================================================
This function handles submitting an MTD request, and retrying
@@ -108,18 +110,18 @@ static int do_mtd_request(memory_handle_
======================================================================*/
-static void insert_queue(erase_busy_t *head, erase_busy_t *entry)
+static void insert_queue(struct pcmcia_socket *s, erase_busy_t *head, erase_busy_t *entry)
{
- DEBUG(2, "cs: adding 0x%p to queue 0x%p\n", entry, head);
+ cs_dbg(s, 2, "adding 0x%p to queue 0x%p\n", entry, head);
entry->next = head;
entry->prev = head->prev;
head->prev->next = entry;
head->prev = entry;
}
-static void remove_queue(erase_busy_t *entry)
+static void remove_queue(struct pcmcia_socket *s, erase_busy_t *entry)
{
- DEBUG(2, "cs: unqueueing 0x%p\n", entry);
+ cs_dbg(s, 2, "unqueueing 0x%p\n", entry);
entry->next->prev = entry->prev;
entry->prev->next = entry->next;
}
@@ -132,34 +134,35 @@ static void retry_erase(erase_busy_t *bu
struct pcmcia_socket *s;
int ret;
- DEBUG(2, "cs: trying erase request 0x%p...\n", busy);
+ mtd = erase->Handle->mtd;
+ s = SOCKET(mtd);
+
+ cs_dbg(s, 2, "trying erase request 0x%p...\n", busy);
if (busy->next)
- remove_queue(busy);
+ remove_queue(s, busy);
req.Function = MTD_REQ_ERASE | cause;
req.TransferLength = erase->Size;
req.DestCardOffset = erase->Offset + erase->Handle->info.CardOffset;
req.MediaID = erase->Handle->MediaID;
- mtd = erase->Handle->mtd;
- s = SOCKET(mtd);
mtd->event_callback_args.mtdrequest = &req;
ret = EVENT(mtd, CS_EVENT_MTD_REQUEST, CS_EVENT_PRI_LOW);
if (ret == CS_BUSY) {
- DEBUG(2, " Status = %d, requeueing.\n", req.Status);
+ cs_dbg(s, 2, " Status = %d, requeueing.\n", req.Status);
switch (req.Status) {
case MTD_WAITREQ:
case MTD_WAITPOWER:
- insert_queue(&mtd->erase_busy, busy);
+ insert_queue(s, &mtd->erase_busy, busy);
break;
case MTD_WAITTIMER:
case MTD_WAITRDY:
if (req.Status == MTD_WAITRDY)
- insert_queue(&s->erase_busy, busy);
+ insert_queue(s, &s->erase_busy, busy);
mod_timer(&busy->timeout, jiffies + req.Timeout*HZ/1000);
break;
}
} else {
/* update erase queue status */
- DEBUG(2, " Ret = %d\n", ret);
+ cs_dbg(s, 2, " Ret = %d\n", ret);
switch (ret) {
case CS_SUCCESS:
erase->State = ERASE_PASSED; break;
@@ -183,11 +186,11 @@ static void retry_erase(erase_busy_t *bu
}
} /* retry_erase */
-void retry_erase_list(erase_busy_t *list, u_int cause)
+static void retry_erase_list(erase_busy_t *list, u_int cause)
{
erase_busy_t tmp = *list;
- DEBUG(2, "cs: rescanning erase queue list 0x%p\n", list);
+ cs_dbg(SOCKET(list->client), 2, "rescanning erase queue list 0x%p\n", list);
if (list->next == list)
return;
/* First, truncate the original list */
@@ -204,8 +207,9 @@ void retry_erase_list(erase_busy_t *list
static void handle_erase_timeout(u_long arg)
{
- DEBUG(0, "cs: erase timeout for entry 0x%lx\n", arg);
- retry_erase((erase_busy_t *)arg, MTD_REQ_TIMEOUT);
+ erase_busy_t *busy = (erase_busy_t *)arg;
+ cs_dbg(SOCKET(busy->client), 0, "erase timeout for entry 0x%lx\n", arg);
+ retry_erase(busy, MTD_REQ_TIMEOUT);
}
static void setup_erase_request(client_handle_t handle, eraseq_entry_t *erase)
@@ -333,8 +337,8 @@ static void setup_regions(client_handle_
cistpl_device_geo_t geo;
memory_handle_t r;
- DEBUG(1, "cs: setup_regions(0x%p, %d, 0x%p)\n",
- handle, attr, list);
+ cs_dbg(SOCKET(handle), 1, "setup_regions(0x%p, %d, 0x%p)\n",
+ handle, attr, list);
code = (attr) ? CISTPL_DEVICE_A : CISTPL_DEVICE;
if (read_tuple(handle, code, &device) != CS_SUCCESS)
@@ -342,17 +346,13 @@ static void setup_regions(client_handle_
code = (attr) ? CISTPL_JEDEC_A : CISTPL_JEDEC_C;
has_jedec = (read_tuple(handle, code, &jedec) == CS_SUCCESS);
if (has_jedec && (device.ndev != jedec.nid)) {
-#ifdef PCMCIA_DEBUG
- printk(KERN_DEBUG "cs: Device info does not match JEDEC info.\n");
-#endif
+ cs_dbg(SOCKET(handle), 0, "Device info does not match JEDEC info.\n");
has_jedec = 0;
}
code = (attr) ? CISTPL_DEVICE_GEO_A : CISTPL_DEVICE_GEO;
has_geo = (read_tuple(handle, code, &geo) == CS_SUCCESS);
if (has_geo && (device.ndev != geo.ngeo)) {
-#ifdef PCMCIA_DEBUG
- printk(KERN_DEBUG "cs: Device info does not match geometry tuple.\n");
-#endif
+ cs_dbg(SOCKET(handle), 0, "Device info does not match geometry tuple.\n");
has_geo = 0;
}
@@ -458,7 +458,7 @@ int pcmcia_register_mtd(client_handle_t
list = s->a_region;
else
list = s->c_region;
- DEBUG(1, "cs: register_mtd(0x%p, '%s', 0x%x)\n",
+ cs_dbg(s, 1, "register_mtd(0x%p, '%s', 0x%x)\n",
handle, handle->dev_info, reg->Offset);
while (list) {
if (list->info.CardOffset == reg->Offset) break;
@@ -548,8 +548,8 @@ int pcmcia_open_memory(client_handle_t *
}
if (region && region->mtd) {
*mh = region;
- DEBUG(1, "cs: open_memory(0x%p, 0x%x) = 0x%p\n",
- handle, open->Offset, region);
+ cs_dbg(s, 1, "open_memory(0x%p, 0x%x) = 0x%p\n",
+ handle, open->Offset, region);
return CS_SUCCESS;
} else
return CS_BAD_OFFSET;
@@ -565,7 +565,7 @@ int pcmcia_open_memory(client_handle_t *
int pcmcia_close_memory(memory_handle_t handle)
{
- DEBUG(1, "cs: close_memory(0x%p)\n", handle);
+ cs_dbg(SOCKET(handle->mtd), 1, "cs: close_memory(0x%p)\n", handle);
if (CHECK_REGION(handle))
return CS_BAD_HANDLE;
return CS_SUCCESS;
diff -urpN orig/drivers/pcmcia/cardbus.c linux/drivers/pcmcia/cardbus.c
--- orig/drivers/pcmcia/cardbus.c Sun Sep 28 09:54:57 2003
+++ linux/drivers/pcmcia/cardbus.c Sat Feb 21 21:10:36 2004
@@ -58,10 +58,6 @@
#include <pcmcia/cistpl.h>
#include "cs_internal.h"
-#ifdef PCMCIA_DEBUG
-static int pc_debug = PCMCIA_DEBUG;
-#endif
-
/*====================================================================*/
#define FIND_FIRST_BIT(n) ((n) - ((n) & ((n)-1)))
@@ -119,7 +115,7 @@ static u_int xlate_rom_addr(u_char * b,
static void cb_release_cis_mem(struct pcmcia_socket * s)
{
if (s->cb_cis_virt) {
- DEBUG(1, "cs: cb_release_cis_mem()\n");
+ cs_dbg(s, 1, "cb_release_cis_mem()\n");
iounmap(s->cb_cis_virt);
s->cb_cis_virt = NULL;
s->cb_cis_res = 0;
@@ -160,7 +156,7 @@ int read_cb_mem(struct pcmcia_socket * s
struct pci_dev *dev;
struct resource *res;
- DEBUG(3, "cs: read_cb_mem(%d, %#x, %u)\n", space, addr, len);
+ cs_dbg(s, 3, "read_cb_mem(%d, %#x, %u)\n", space, addr, len);
dev = pci_find_slot(s->cb_dev->subordinate->number, 0);
if (!dev)
diff -urpN orig/drivers/pcmcia/cistpl.c linux/drivers/pcmcia/cistpl.c
--- orig/drivers/pcmcia/cistpl.c Fri Jan 9 22:39:36 2004
+++ linux/drivers/pcmcia/cistpl.c Sat Feb 21 19:21:45 2004
@@ -143,7 +143,7 @@ int read_cis_mem(struct pcmcia_socket *s
{
u_char *sys, *end, *buf = ptr;
- DEBUG(3, "cs: read_cis_mem(%d, %#x, %u)\n", attr, addr, len);
+ cs_dbg(s, 3, "read_cis_mem(%d, %#x, %u)\n", attr, addr, len);
if (attr & IS_INDIRECT) {
/* Indirect accesses use a bunch of special registers at fixed
@@ -195,7 +195,7 @@ int read_cis_mem(struct pcmcia_socket *s
addr = 0;
}
}
- DEBUG(3, "cs: %#2.2x %#2.2x %#2.2x %#2.2x ...\n",
+ cs_dbg(s, 3, " %#2.2x %#2.2x %#2.2x %#2.2x ...\n",
*(u_char *)(ptr+0), *(u_char *)(ptr+1),
*(u_char *)(ptr+2), *(u_char *)(ptr+3));
return 0;
@@ -206,7 +206,7 @@ void write_cis_mem(struct pcmcia_socket
{
u_char *sys, *end, *buf = ptr;
- DEBUG(3, "cs: write_cis_mem(%d, %#x, %u)\n", attr, addr, len);
+ cs_dbg(s, 3, "write_cis_mem(%d, %#x, %u)\n", attr, addr, len);
if (attr & IS_INDIRECT) {
/* Indirect accesses use a bunch of special registers at fixed
@@ -578,8 +578,7 @@ int pcmcia_get_next_tuple(client_handle_
ofs += link[1] + 2;
}
if (i == MAX_TUPLES) {
- DEBUG(1, "cs: overrun in pcmcia_get_next_tuple for socket %d\n",
- handle->Socket);
+ cs_dbg(s, 1, "cs: overrun in pcmcia_get_next_tuple\n");
return CS_NO_MORE_ITEMS;
}
diff -urpN orig/drivers/pcmcia/cs.c linux/drivers/pcmcia/cs.c
--- orig/drivers/pcmcia/cs.c Thu Feb 19 14:33:40 2004
+++ linux/drivers/pcmcia/cs.c Sat Feb 21 21:10:50 2004
@@ -32,6 +32,7 @@
======================================================================*/
#include <linux/module.h>
+#include <linux/moduleparam.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/config.h>
@@ -110,12 +111,17 @@ INT_MODULE_PARM(cis_speed, 300); /* ns
/* Access speed for IO windows */
INT_MODULE_PARM(io_speed, 0); /* ns */
-#ifdef PCMCIA_DEBUG
-INT_MODULE_PARM(pc_debug, PCMCIA_DEBUG);
-static const char *version =
-"cs.c 1.279 2001/10/13 00:08:28 (David Hinds)";
+#ifdef DEBUG
+static int pc_debug;
+
+module_param(pc_debug, int, 0644);
+
+int cs_debug_level(int level)
+{
+ return pc_debug > level;
+}
#endif
-
+
/*====================================================================*/
socket_state_t dead_socket = {
@@ -306,7 +312,7 @@ int pcmcia_register_socket(struct pcmcia
if (!socket || !socket->ops || !socket->dev.dev)
return -EINVAL;
- DEBUG(0, "cs: pcmcia_register_socket(0x%p)\n", socket->ops);
+ cs_dbg(socket, 0, "pcmcia_register_socket(0x%p)\n", socket->ops);
/* try to obtain a socket number [yes, it gets ugly if we
* register more than 2^sizeof(unsigned int) pcmcia
@@ -377,7 +383,7 @@ void pcmcia_unregister_socket(struct pcm
if (!socket)
return;
- DEBUG(0, "cs: pcmcia_unregister_socket(0x%p)\n", socket->ops);
+ cs_dbg(socket, 0, "pcmcia_unregister_socket(0x%p)\n", socket->ops);
if (socket->thread) {
init_completion(&socket->thread_done);
@@ -443,7 +449,7 @@ static void shutdown_socket(struct pcmci
{
client_t **c;
- DEBUG(1, "cs: shutdown_socket(%p)\n", s);
+ cs_dbg(s, 1, "shutdown_socket\n");
/* Blank out the socket state */
s->state &= SOCKET_PRESENT|SOCKET_INUSE;
@@ -499,8 +505,8 @@ static int send_event(struct pcmcia_sock
{
client_t *client = s->clients;
int ret;
- DEBUG(1, "cs: send_event(sock %d, event %d, pri %d)\n",
- s->sock, event, priority);
+ cs_dbg(s, 1, "send_event(event %d, pri %d)\n",
+ event, priority);
ret = 0;
if (s->state & SOCKET_CARDBUS)
return 0;
@@ -516,26 +522,14 @@ static int send_event(struct pcmcia_sock
return ret;
} /* send_event */
-static void pcmcia_error(struct pcmcia_socket *skt, const char *fmt, ...)
-{
- static char buf[128];
- va_list ap;
- int len;
-
- va_start(ap, fmt);
- len = vsnprintf(buf, sizeof(buf), fmt, ap);
- va_end(ap);
- buf[len] = '\0';
-
- printk(KERN_ERR "PCMCIA: socket %p: %s", skt, buf);
-}
-
#define cs_to_timeout(cs) (((cs) * HZ + 99) / 100)
static void socket_remove_drivers(struct pcmcia_socket *skt)
{
client_t *client;
+ cs_dbg(skt, 4, "remove_drivers\n");
+
send_event(skt, CS_EVENT_CARD_REMOVAL, CS_EVENT_PRI_HIGH);
for (client = skt->clients; client; client = client->next)
@@ -545,6 +539,8 @@ static void socket_remove_drivers(struct
static void socket_shutdown(struct pcmcia_socket *skt)
{
+ cs_dbg(skt, 4, "shutdown\n");
+
socket_remove_drivers(skt);
set_current_state(TASK_UNINTERRUPTIBLE);
schedule_timeout(cs_to_timeout(shutdown_delay));
@@ -556,6 +552,8 @@ static int socket_reset(struct pcmcia_so
{
int status, i;
+ cs_dbg(skt, 4, "reset\n");
+
skt->socket.flags |= SS_OUTPUT_ENA | SS_RESET;
skt->ops->set_socket(skt, &skt->socket);
udelay((long)reset_time);
@@ -578,7 +576,7 @@ static int socket_reset(struct pcmcia_so
schedule_timeout(cs_to_timeout(unreset_check));
}
- pcmcia_error(skt, "time out after reset.\n");
+ cs_err(skt, "time out after reset.\n");
return CS_GENERAL_FAILURE;
}
@@ -586,6 +584,8 @@ static int socket_setup(struct pcmcia_so
{
int status, i;
+ cs_dbg(skt, 4, "setup\n");
+
skt->ops->get_status(skt, &status);
if (!(status & SS_DETECT))
return CS_NO_CARD;
@@ -606,14 +606,14 @@ static int socket_setup(struct pcmcia_so
}
if (status & SS_PENDING) {
- pcmcia_error(skt, "voltage interrogation timed out.\n");
+ cs_err(skt, "voltage interrogation timed out.\n");
return CS_GENERAL_FAILURE;
}
if (status & SS_CARDBUS) {
skt->state |= SOCKET_CARDBUS;
#ifndef CONFIG_CARDBUS
- pcmcia_error(skt, "cardbus cards are not supported.\n");
+ cs_err(skt, "cardbus cards are not supported.\n");
return CS_BAD_TYPE;
#endif
}
@@ -626,7 +626,7 @@ static int socket_setup(struct pcmcia_so
else if (!(status & SS_XVCARD))
skt->socket.Vcc = skt->socket.Vpp = 50;
else {
- pcmcia_error(skt, "unsupported voltage key.\n");
+ cs_err(skt, "unsupported voltage key.\n");
return CS_BAD_TYPE;
}
skt->socket.flags = 0;
@@ -640,7 +640,7 @@ static int socket_setup(struct pcmcia_so
skt->ops->get_status(skt, &status);
if (!(status & SS_POWERON)) {
- pcmcia_error(skt, "unable to apply power.\n");
+ cs_err(skt, "unable to apply power.\n");
return CS_BAD_TYPE;
}
@@ -655,6 +655,8 @@ static int socket_insert(struct pcmcia_s
{
int ret;
+ cs_dbg(skt, 4, "insert\n");
+
if (!cs_socket_get(skt))
return CS_NO_CARD;
@@ -667,6 +669,8 @@ static int socket_insert(struct pcmcia_s
skt->state |= SOCKET_CARDBUS_CONFIG;
}
#endif
+ cs_dbg(skt, 4, "insert done\n");
+
send_event(skt, CS_EVENT_CARD_INSERTION, CS_EVENT_PRI_LOW);
} else {
socket_shutdown(skt);
@@ -832,6 +836,7 @@ static int pccardd(void *__skt)
*/
void pcmcia_parse_events(struct pcmcia_socket *s, u_int events)
{
+ cs_dbg(s, 4, "parse_events: events %08x\n", events);
if (s->thread) {
spin_lock(&s->thread_lock);
s->thread_events |= events;
@@ -857,15 +862,15 @@ static int alloc_io_space(struct pcmcia_
align = (*base) ? (lines ? 1<<lines : 0) : 1;
if (align && (align < num)) {
if (*base) {
- DEBUG(0, "odd IO request: num %04x align %04x\n",
- num, align);
+ cs_dbg(s, 0, "odd IO request: num %04x align %04x\n",
+ num, align);
align = 0;
} else
while (align && (align < num)) align <<= 1;
}
if (*base & ~(align-1)) {
- DEBUG(0, "odd IO request: base %04x align %04x\n",
- *base, align);
+ cs_dbg(s, 0, "odd IO request: base %04x align %04x\n",
+ *base, align);
align = 0;
}
if ((s->features & SS_CAP_STATIC_MAP) && s->io_offset) {
@@ -1010,8 +1015,8 @@ int pcmcia_bind_device(bind_req_t *req)
init_waitqueue_head(&client->mtd_req);
client->next = s->clients;
s->clients = client;
- DEBUG(1, "cs: bind_device(): client 0x%p, sock %p, dev %s\n",
- client, client->Socket, client->dev_info);
+ cs_dbg(s, 1, "bind_device(): client 0x%p, dev %s\n",
+ client, client->dev_info);
return CS_SUCCESS;
} /* bind_device */
@@ -1046,8 +1051,8 @@ int pcmcia_bind_mtd(mtd_bind_t *req)
return CS_BAD_OFFSET;
strlcpy(region->dev_info, (char *)req->dev_info, DEV_NAME_LEN);
- DEBUG(1, "cs: bind_mtd(): attr 0x%x, offset 0x%x, dev %s\n",
- req->Attributes, req->CardOffset, (char *)req->dev_info);
+ cs_dbg(s, 1, "bind_mtd(): attr 0x%x, offset 0x%x, dev %s\n",
+ req->Attributes, req->CardOffset, (char *)req->dev_info);
return CS_SUCCESS;
} /* bind_mtd */
@@ -1061,9 +1066,12 @@ int pcmcia_deregister_client(client_hand
u_long flags;
int i;
- DEBUG(1, "cs: deregister_client(%p)\n", handle);
if (CHECK_HANDLE(handle))
return CS_BAD_HANDLE;
+
+ s = SOCKET(handle);
+ cs_dbg(s, 1, "deregister_client(%p)\n", handle);
+
if (handle->state &
(CLIENT_IRQ_REQ|CLIENT_IO_REQ|CLIENT_CONFIG_LOCKED))
return CS_IN_USE;
@@ -1072,7 +1080,6 @@ int pcmcia_deregister_client(client_hand
return CS_IN_USE;
/* Disconnect all MTD links */
- s = SOCKET(handle);
if (handle->mtd_count) {
for (region = s->a_region; region; region = region->info.next)
if (region->mtd == handle) region->mtd = NULL;
@@ -1543,8 +1550,8 @@ int pcmcia_register_client(client_handle
memset(s->config, 0, sizeof(config_t) * s->functions);
}
- DEBUG(1, "cs: register_client(): client 0x%p, sock %p, dev %s\n",
- client, client->Socket, client->dev_info);
+ cs_dbg(s, 1, "register_client(): client 0x%p, dev %s\n",
+ client, client->dev_info);
if (client->EventMask & CS_EVENT_REGISTRATION_COMPLETE)
EVENT(client, CS_EVENT_REGISTRATION_COMPLETE, CS_EVENT_PRI_LOW);
@@ -2077,8 +2084,8 @@ int pcmcia_reset_card(client_handle_t ha
if (CHECK_HANDLE(handle))
return CS_BAD_HANDLE;
- DEBUG(1, "cs: resetting socket %p\n", handle->Socket);
skt = SOCKET(handle);
+ cs_dbg(skt, 1, "resetting socket\n");
down(&skt->skt_sem);
do {
@@ -2126,8 +2133,8 @@ int pcmcia_suspend_card(client_handle_t
if (CHECK_HANDLE(handle))
return CS_BAD_HANDLE;
- DEBUG(1, "cs: suspending socket %p\n", handle->Socket);
skt = SOCKET(handle);
+ cs_dbg(skt, 1, "suspending socket\n");
down(&skt->skt_sem);
do {
@@ -2153,8 +2160,8 @@ int pcmcia_resume_card(client_handle_t h
if (CHECK_HANDLE(handle))
return CS_BAD_HANDLE;
- DEBUG(1, "cs: waking up socket %p\n", handle->Socket);
skt = SOCKET(handle);
+ cs_dbg(skt, 1, "waking up socket\n");
down(&skt->skt_sem);
do {
@@ -2186,8 +2193,8 @@ int pcmcia_eject_card(client_handle_t ha
if (CHECK_HANDLE(handle))
return CS_BAD_HANDLE;
- DEBUG(1, "cs: user eject request on socket %p\n", handle->Socket);
skt = SOCKET(handle);
+ cs_dbg(skt, 1, "user eject request\n");
down(&skt->skt_sem);
do {
@@ -2215,8 +2222,8 @@ int pcmcia_insert_card(client_handle_t h
if (CHECK_HANDLE(handle))
return CS_BAD_HANDLE;
- DEBUG(1, "cs: user insert request on socket %p\n", handle->Socket);
skt = SOCKET(handle);
+ cs_dbg(skt, 1, "user insert request\n");
down(&skt->skt_sem);
do {
@@ -2360,7 +2367,6 @@ static int __init init_pcmcia_cs(void)
{
printk(KERN_INFO "%s\n", release);
printk(KERN_INFO " %s\n", options);
- DEBUG(0, "%s\n", version);
class_register(&pcmcia_socket_class);
return 0;
diff -urpN orig/drivers/pcmcia/cs_internal.h linux/drivers/pcmcia/cs_internal.h
--- orig/drivers/pcmcia/cs_internal.h Sun Sep 28 09:54:57 2003
+++ linux/drivers/pcmcia/cs_internal.h Sat Feb 21 19:21:45 2004
@@ -167,7 +167,6 @@ int replace_cis(client_handle_t handle,
int read_tuple(client_handle_t handle, cisdata_t code, void *parse);
/* In bulkmem.c */
-void retry_erase_list(struct erase_busy_t *list, u_int cause);
int get_first_region(client_handle_t handle, region_info_t *rgn);
int get_next_region(client_handle_t handle, region_info_t *rgn);
int register_mtd(client_handle_t handle, mtd_reg_t *reg);
@@ -195,10 +194,19 @@ extern struct rw_semaphore pcmcia_socket
extern struct list_head pcmcia_socket_list;
#ifdef PCMCIA_DEBUG
-extern int pc_debug;
-#define DEBUG(n, args...) do { if (pc_debug>(n)) printk(KERN_DEBUG args); } while (0)
+extern int cs_debug_level(int);
+
+#define cs_dbg(skt, lvl, fmt, arg...) do { \
+ if (cs_debug_level(lvl)) \
+ printk(KERN_DEBUG "cs: %s: " fmt, \
+ (skt)->dev.class_id, ## arg); \
+} while (0)
+
#else
-#define DEBUG(n, args...) do { } while (0)
+#define cs_dbg(skt, lvl, fmt, arg...) do { } while (0)
#endif
+#define cs_err(skt, fmt, arg...) \
+ printk(KERN_ERR "cs: %s: " fmt, (skt)->dev.class_id, ## arg)
+
#endif /* _LINUX_CS_INTERNAL_H */
diff -urpN orig/drivers/pcmcia/ds.c linux/drivers/pcmcia/ds.c
--- orig/drivers/pcmcia/ds.c Thu Feb 5 15:26:01 2004
+++ linux/drivers/pcmcia/ds.c Sat Feb 21 21:11:00 2004
@@ -33,6 +33,7 @@
#include <linux/config.h>
#include <linux/module.h>
+#include <linux/moduleparam.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/major.h>
@@ -69,13 +70,17 @@ MODULE_AUTHOR("David Hinds <dahinds at user
MODULE_DESCRIPTION("PCMCIA Driver Services");
MODULE_LICENSE("Dual MPL/GPL");
-#define INT_MODULE_PARM(n, v) static int n = v; MODULE_PARM(n, "i")
+#ifdef DEBUG
+static int pc_debug;
-#ifdef PCMCIA_DEBUG
-INT_MODULE_PARM(pc_debug, PCMCIA_DEBUG);
-#define DEBUG(n, args...) if (pc_debug>(n)) printk(KERN_DEBUG args)
+module_param(pc_debug, int, 0644);
+
+#define debug(lvl, fmt, arg...) do { \
+ if (pc_debug > (lvl)) \
+ printk(KERN_DEBUG "ds: " fmt, ## arg); \
+} while (0)
#else
-#define DEBUG(n, args...)
+#define debug(lvl, fmt, arg...) do { } while (0)
#endif
/*====================================================================*/
@@ -277,7 +282,7 @@ static int ds_event(event_t event, int p
{
struct pcmcia_bus_socket *s;
- DEBUG(1, "ds: ds_event(0x%06x, %d, 0x%p)\n",
+ debug(1, "ds_event(0x%06x, %d, 0x%p)\n",
event, priority, args->client_handle);
s = args->client_data;
@@ -353,7 +358,7 @@ static int bind_request(struct pcmcia_bu
if (!s)
return -EINVAL;
- DEBUG(2, "bind_request(%d, '%s')\n", s->parent->sock,
+ debug(2, "bind_request(%d, '%s')\n", s->parent->sock,
(char *)bind_info->dev_info);
driver = get_pcmcia_driver(&bind_info->dev_info);
if (!driver)
@@ -484,7 +489,7 @@ static int unbind_request(struct pcmcia_
{
socket_bind_t **b, *c;
- DEBUG(2, "unbind_request(%d, '%s')\n", s->parent->sock,
+ debug(2, "unbind_request(%d, '%s')\n", s->parent->sock,
(char *)bind_info->dev_info);
for (b = &s->bind; *b; b = &(*b)->next)
if ((strcmp((char *)(*b)->driver->drv.name,
@@ -518,7 +523,7 @@ static int ds_open(struct inode *inode,
struct pcmcia_bus_socket *s;
user_info_t *user;
- DEBUG(0, "ds_open(socket %d)\n", i);
+ debug(0, "ds_open(socket %d)\n", i);
s = pcmcia_get_bus_socket(i);
if (!s)
@@ -552,7 +557,7 @@ static int ds_release(struct inode *inod
struct pcmcia_bus_socket *s;
user_info_t *user, **link;
- DEBUG(0, "ds_release(socket %d)\n", iminor(inode));
+ debug(0, "ds_release(socket %d)\n", iminor(inode));
user = file->private_data;
if (CHECK_USER(user))
@@ -588,7 +593,7 @@ static ssize_t ds_read(struct file *file
user_info_t *user;
int ret;
- DEBUG(2, "ds_read(socket %d)\n", iminor(inode));
+ debug(2, "ds_read(socket %d)\n", iminor(file->f_dentry->d_inode));
if (count < 4)
return -EINVAL;
@@ -616,7 +621,7 @@ static ssize_t ds_write(struct file *fil
struct pcmcia_bus_socket *s;
user_info_t *user;
- DEBUG(2, "ds_write(socket %d)\n", iminor(inode));
+ debug(2, "ds_write(socket %d)\n", iminor(file->f_dentry->d_inode));
if (count != 4)
return -EINVAL;
@@ -650,7 +655,7 @@ static u_int ds_poll(struct file *file,
struct pcmcia_bus_socket *s;
user_info_t *user;
- DEBUG(2, "ds_poll(socket %d)\n", iminor(inode));
+ debug(2, "ds_poll(socket %d)\n", iminor(file->f_dentry->d_inode));
user = file->private_data;
if (CHECK_USER(user))
@@ -677,7 +682,7 @@ static int ds_ioctl(struct inode * inode
ds_ioctl_arg_t buf;
user_info_t *user;
- DEBUG(2, "ds_ioctl(socket %d, %#x, %#lx)\n", iminor(inode), cmd, arg);
+ debug(2, "ds_ioctl(socket %d, %#x, %#lx)\n", iminor(inode), cmd, arg);
user = file->private_data;
if (CHECK_USER(user))
@@ -697,14 +702,14 @@ static int ds_ioctl(struct inode * inode
if (cmd & IOC_IN) {
err = verify_area(VERIFY_READ, (char *)arg, size);
if (err) {
- DEBUG(3, "ds_ioctl(): verify_read = %d\n", err);
+ debug(3, "ds_ioctl(): verify_read = %d\n", err);
return err;
}
}
if (cmd & IOC_OUT) {
err = verify_area(VERIFY_WRITE, (char *)arg, size);
if (err) {
- DEBUG(3, "ds_ioctl(): verify_write = %d\n", err);
+ debug(3, "ds_ioctl(): verify_write = %d\n", err);
return err;
}
}
@@ -806,7 +811,7 @@ static int ds_ioctl(struct inode * inode
}
if ((err == 0) && (ret != CS_SUCCESS)) {
- DEBUG(2, "ds_ioctl: ret = %d\n", ret);
+ debug(2, "ds_ioctl: ret = %d\n", ret);
switch (ret) {
case CS_BAD_SOCKET: case CS_NO_CARD:
err = -ENODEV; break;
--
Russell King
Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/
maintainer of: 2.6 PCMCIA - http://pcmcia.arm.linux.org.uk/
2.6 Serial core
More information about the linux-pcmcia
mailing list