Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 169109
b: refs/heads/master
c: cbf624f
h: refs/heads/master
i:
  169107: bc7a015
v: v3
  • Loading branch information
Dominik Brodowski committed Nov 9, 2009
1 parent eec2a69 commit 63eec99
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 108 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 9ac3e58ceff0b7b8b981c09c38a28742270eea12
refs/heads/master: cbf624f0e18c4a05219855663a3e5f9fe8f2d876
71 changes: 27 additions & 44 deletions trunk/drivers/char/pcmcia/cm4000_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
* All rights reserved. Licensed under dual BSD/GPL license.
*/

/* #define PCMCIA_DEBUG 6 */

#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/slab.h>
Expand All @@ -47,18 +45,17 @@

/* #define ATR_CSUM */

#ifdef PCMCIA_DEBUG
#define reader_to_dev(x) (&handle_to_dev(x->p_dev))
static int pc_debug = PCMCIA_DEBUG;
module_param(pc_debug, int, 0600);
#define DEBUGP(n, rdr, x, args...) do { \
if (pc_debug >= (n)) \
dev_printk(KERN_DEBUG, reader_to_dev(rdr), "%s:" x, \
__func__ , ## args); \

/* n (debug level) is ignored */
/* additional debug output may be enabled by re-compiling with
* CM4000_DEBUG set */
/* #define CM4000_DEBUG */
#define DEBUGP(n, rdr, x, args...) do { \
dev_dbg(reader_to_dev(rdr), "%s:" x, \
__func__ , ## args); \
} while (0)
#else
#define DEBUGP(n, rdr, x, args...)
#endif

static char *version = "cm4000_cs.c v2.4.0gm6 - All bugs added by Harald Welte";

#define T_1SEC (HZ)
Expand Down Expand Up @@ -174,23 +171,21 @@ static unsigned char fi_di_table[10][14] = {
/* 9 */ {0x09,0x19,0x29,0x39,0x49,0x59,0x69,0x11,0x11,0x99,0xA9,0xB9,0xC9,0xD9}
};

#ifndef PCMCIA_DEBUG
#ifndef CM4000_DEBUG
#define xoutb outb
#define xinb inb
#else
static inline void xoutb(unsigned char val, unsigned short port)
{
if (pc_debug >= 7)
printk(KERN_DEBUG "outb(val=%.2x,port=%.4x)\n", val, port);
pr_debug("outb(val=%.2x,port=%.4x)\n", val, port);
outb(val, port);
}
static inline unsigned char xinb(unsigned short port)
{
unsigned char val;

val = inb(port);
if (pc_debug >= 7)
printk(KERN_DEBUG "%.2x=inb(%.4x)\n", val, port);
pr_debug("%.2x=inb(%.4x)\n", val, port);

return val;
}
Expand Down Expand Up @@ -514,12 +509,10 @@ static int set_protocol(struct cm4000_dev *dev, struct ptsreq *ptsreq)
for (i = 0; i < 4; i++) {
xoutb(i, REG_BUF_ADDR(iobase));
xoutb(dev->pts[i], REG_BUF_DATA(iobase)); /* buf data */
#ifdef PCMCIA_DEBUG
if (pc_debug >= 5)
printk("0x%.2x ", dev->pts[i]);
#ifdef CM4000_DEBUG
pr_debug("0x%.2x ", dev->pts[i]);
}
if (pc_debug >= 5)
printk("\n");
pr_debug("\n");
#else
}
#endif
Expand Down Expand Up @@ -579,14 +572,13 @@ static int set_protocol(struct cm4000_dev *dev, struct ptsreq *ptsreq)
pts_reply[i] = inb(REG_BUF_DATA(iobase));
}

#ifdef PCMCIA_DEBUG
#ifdef CM4000_DEBUG
DEBUGP(2, dev, "PTSreply: ");
for (i = 0; i < num_bytes_read; i++) {
if (pc_debug >= 5)
printk("0x%.2x ", pts_reply[i]);
pr_debug("0x%.2x ", pts_reply[i]);
}
printk("\n");
#endif /* PCMCIA_DEBUG */
pr_debug("\n");
#endif /* CM4000_DEBUG */

DEBUGP(5, dev, "Clear Tactive in Flags1\n");
xoutb(0x20, REG_FLAGS1(iobase));
Expand Down Expand Up @@ -655,7 +647,7 @@ static void terminate_monitor(struct cm4000_dev *dev)

DEBUGP(5, dev, "Delete timer\n");
del_timer_sync(&dev->timer);
#ifdef PCMCIA_DEBUG
#ifdef CM4000_DEBUG
dev->monitor_running = 0;
#endif

Expand Down Expand Up @@ -898,7 +890,7 @@ static void monitor_card(unsigned long p)
DEBUGP(4, dev, "ATR checksum (0x%.2x, should "
"be zero) failed\n", dev->atr_csum);
}
#ifdef PCMCIA_DEBUG
#ifdef CM4000_DEBUG
else if (test_bit(IS_BAD_LENGTH, &dev->flags)) {
DEBUGP(4, dev, "ATR length error\n");
} else {
Expand Down Expand Up @@ -1415,17 +1407,17 @@ static long cmm_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
int size;
int rc;
void __user *argp = (void __user *)arg;
#ifdef PCMCIA_DEBUG
#ifdef CM4000_DEBUG
char *ioctl_names[CM_IOC_MAXNR + 1] = {
[_IOC_NR(CM_IOCGSTATUS)] "CM_IOCGSTATUS",
[_IOC_NR(CM_IOCGATR)] "CM_IOCGATR",
[_IOC_NR(CM_IOCARDOFF)] "CM_IOCARDOFF",
[_IOC_NR(CM_IOCSPTS)] "CM_IOCSPTS",
[_IOC_NR(CM_IOSDBGLVL)] "CM4000_DBGLVL",
};
#endif
DEBUGP(3, dev, "cmm_ioctl(device=%d.%d) %s\n", imajor(inode),
iminor(inode), ioctl_names[_IOC_NR(cmd)]);
#endif

lock_kernel();
rc = -ENODEV;
Expand Down Expand Up @@ -1523,7 +1515,7 @@ static long cmm_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
}
case CM_IOCARDOFF:

#ifdef PCMCIA_DEBUG
#ifdef CM4000_DEBUG
DEBUGP(4, dev, "... in CM_IOCARDOFF\n");
if (dev->flags0 & 0x01) {
DEBUGP(4, dev, " Card inserted\n");
Expand Down Expand Up @@ -1625,18 +1617,9 @@ static long cmm_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)

}
break;
#ifdef PCMCIA_DEBUG
case CM_IOSDBGLVL: /* set debug log level */
{
int old_pc_debug = 0;

old_pc_debug = pc_debug;
if (copy_from_user(&pc_debug, argp, sizeof(int)))
rc = -EFAULT;
else if (old_pc_debug != pc_debug)
DEBUGP(0, dev, "Changed debug log level "
"to %i\n", pc_debug);
}
#ifdef CM4000_DEBUG
case CM_IOSDBGLVL:
rc = -ENOTTY;
break;
#endif
default:
Expand Down
42 changes: 17 additions & 25 deletions trunk/drivers/char/pcmcia/cm4040_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
* All rights reserved, Dual BSD/GPL Licensed.
*/

/* #define PCMCIA_DEBUG 6 */

#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/slab.h>
Expand All @@ -41,18 +39,16 @@
#include "cm4040_cs.h"


#ifdef PCMCIA_DEBUG
#define reader_to_dev(x) (&handle_to_dev(x->p_dev))
static int pc_debug = PCMCIA_DEBUG;
module_param(pc_debug, int, 0600);
#define DEBUGP(n, rdr, x, args...) do { \
if (pc_debug >= (n)) \
dev_printk(KERN_DEBUG, reader_to_dev(rdr), "%s:" x, \
__func__ , ##args); \

/* n (debug level) is ignored */
/* additional debug output may be enabled by re-compiling with
* CM4040_DEBUG set */
/* #define CM4040_DEBUG */
#define DEBUGP(n, rdr, x, args...) do { \
dev_dbg(reader_to_dev(rdr), "%s:" x, \
__func__ , ## args); \
} while (0)
#else
#define DEBUGP(n, rdr, x, args...)
#endif

static char *version =
"OMNIKEY CardMan 4040 v1.1.0gm5 - All bugs added by Harald Welte";
Expand Down Expand Up @@ -90,14 +86,13 @@ struct reader_dev {

static struct pcmcia_device *dev_table[CM_MAX_DEV];

#ifndef PCMCIA_DEBUG
#ifndef CM4040_DEBUG
#define xoutb outb
#define xinb inb
#else
static inline void xoutb(unsigned char val, unsigned short port)
{
if (pc_debug >= 7)
printk(KERN_DEBUG "outb(val=%.2x,port=%.4x)\n", val, port);
pr_debug("outb(val=%.2x,port=%.4x)\n", val, port);
outb(val, port);
}

Expand All @@ -106,8 +101,7 @@ static inline unsigned char xinb(unsigned short port)
unsigned char val;

val = inb(port);
if (pc_debug >= 7)
printk(KERN_DEBUG "%.2x=inb(%.4x)\n", val, port);
pr_debug("%.2x=inb(%.4x)\n", val, port);
return val;
}
#endif
Expand Down Expand Up @@ -260,11 +254,10 @@ static ssize_t cm4040_read(struct file *filp, char __user *buf,
return -EIO;
}
dev->r_buf[i] = xinb(iobase + REG_OFFSET_BULK_IN);
#ifdef PCMCIA_DEBUG
if (pc_debug >= 6)
printk(KERN_DEBUG "%lu:%2x ", i, dev->r_buf[i]);
#ifdef CM4040_DEBUG
pr_debug("%lu:%2x ", i, dev->r_buf[i]);
}
printk("\n");
pr_debug("\n");
#else
}
#endif
Expand All @@ -288,11 +281,10 @@ static ssize_t cm4040_read(struct file *filp, char __user *buf,
return -EIO;
}
dev->r_buf[i+5] = xinb(iobase + REG_OFFSET_BULK_IN);
#ifdef PCMCIA_DEBUG
if (pc_debug >= 6)
printk(KERN_DEBUG "%lu:%2x ", i, dev->r_buf[i]);
#ifdef CM4040_DEBUG
pr_debug("%lu:%2x ", i, dev->r_buf[i]);
}
printk("\n");
pr_debug("\n");
#else
}
#endif
Expand Down
34 changes: 8 additions & 26 deletions trunk/drivers/char/pcmcia/ipwireless/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,7 @@ static void signalled_reboot_work(struct work_struct *work_reboot)
struct ipw_dev *ipw = container_of(work_reboot, struct ipw_dev,
work_reboot);
struct pcmcia_device *link = ipw->link;
int ret = pcmcia_reset_card(link->socket);

if (ret != 0)
cs_error(link, ResetCard, ret);
pcmcia_reset_card(link->socket);
}

static void signalled_reboot_callback(void *callback_data)
Expand Down Expand Up @@ -122,21 +119,17 @@ static int ipwireless_probe(struct pcmcia_device *p_dev,
ret = pcmcia_request_window(&p_dev, &ipw->request_common_memory,
&ipw->handle_common_memory);

if (ret != 0) {
cs_error(p_dev, RequestWindow, ret);
if (ret != 0)
goto exit1;
}

memreq_common_memory.CardOffset = cfg->mem.win[0].card_addr;
memreq_common_memory.Page = 0;

ret = pcmcia_map_mem_page(ipw->handle_common_memory,
&memreq_common_memory);

if (ret != 0) {
cs_error(p_dev, MapMemPage, ret);
if (ret != 0)
goto exit2;
}

ipw->is_v2_card = cfg->mem.win[0].len == 0x100;

Expand All @@ -155,21 +148,17 @@ static int ipwireless_probe(struct pcmcia_device *p_dev,
ret = pcmcia_request_window(&p_dev, &ipw->request_attr_memory,
&ipw->handle_attr_memory);

if (ret != 0) {
cs_error(p_dev, RequestWindow, ret);
if (ret != 0)
goto exit2;
}

memreq_attr_memory.CardOffset = 0;
memreq_attr_memory.Page = 0;

ret = pcmcia_map_mem_page(ipw->handle_attr_memory,
&memreq_attr_memory);

if (ret != 0) {
cs_error(p_dev, MapMemPage, ret);
if (ret != 0)
goto exit3;
}

ipw->attr_memory = ioremap(ipw->request_attr_memory.Base,
ipw->request_attr_memory.Size);
Expand Down Expand Up @@ -202,10 +191,8 @@ static int config_ipwireless(struct ipw_dev *ipw)
ipw->is_v2_card = 0;

ret = pcmcia_loop_config(link, ipwireless_probe, ipw);
if (ret != 0) {
cs_error(link, RequestIO, ret);
if (ret != 0)
return ret;
}

link->conf.Attributes = CONF_ENABLE_IRQ;
link->conf.IntType = INT_MEMORY_AND_IO;
Expand All @@ -223,10 +210,8 @@ static int config_ipwireless(struct ipw_dev *ipw)

ret = pcmcia_request_irq(link, &link->irq);

if (ret != 0) {
cs_error(link, RequestIRQ, ret);
if (ret != 0)
goto exit;
}

printk(KERN_INFO IPWIRELESS_PCCARD_NAME ": Card type %s\n",
ipw->is_v2_card ? "V2/V3" : "V1");
Expand Down Expand Up @@ -263,10 +248,8 @@ static int config_ipwireless(struct ipw_dev *ipw)
*/
ret = pcmcia_request_configuration(link, &link->conf);

if (ret != 0) {
cs_error(link, RequestConfiguration, ret);
if (ret != 0)
goto exit;
}

link->dev_node = &ipw->nodes[0];

Expand Down Expand Up @@ -347,7 +330,6 @@ static int ipwireless_attach(struct pcmcia_device *link)
ret = config_ipwireless(ipw);

if (ret != 0) {
cs_error(link, RegisterClient, ret);
ipwireless_detach(link);
return ret;
}
Expand Down
Loading

0 comments on commit 63eec99

Please sign in to comment.