aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char
diff options
context:
space:
mode:
authorDominik Brodowski <linux@dominikbrodowski.net>2006-03-05 04:45:09 -0500
committerDominik Brodowski <linux@dominikbrodowski.net>2006-03-31 10:15:57 -0500
commitfd238232cd0ff4840ae6946bb338502154096d88 (patch)
treed20e8f5871f7cff9d0867a84f6ba088fbffcbe28 /drivers/char
parenta78f4dd331a4f6a396eb5849656a4a72a70a56d7 (diff)
[PATCH] pcmcia: embed dev_link_t into struct pcmcia_device
Embed dev_link_t into struct pcmcia_device(), as they basically address the same entity. The actual contents of dev_link_t will be cleaned up step by step. This patch includes a bugfix from and signed-off-by Andrew Morton. Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
Diffstat (limited to 'drivers/char')
-rw-r--r--drivers/char/pcmcia/cm4000_cs.c29
-rw-r--r--drivers/char/pcmcia/cm4040_cs.c29
-rw-r--r--drivers/char/pcmcia/synclink_cs.c21
3 files changed, 35 insertions, 44 deletions
diff --git a/drivers/char/pcmcia/cm4000_cs.c b/drivers/char/pcmcia/cm4000_cs.c
index c996ae1375be..3e6d6e0bb6ee 100644
--- a/drivers/char/pcmcia/cm4000_cs.c
+++ b/drivers/char/pcmcia/cm4000_cs.c
@@ -46,7 +46,7 @@
46/* #define ATR_CSUM */ 46/* #define ATR_CSUM */
47 47
48#ifdef PCMCIA_DEBUG 48#ifdef PCMCIA_DEBUG
49#define reader_to_dev(x) (&handle_to_dev(x->link.handle)) 49#define reader_to_dev(x) (&handle_to_dev(x->p_dev->handle))
50static int pc_debug = PCMCIA_DEBUG; 50static int pc_debug = PCMCIA_DEBUG;
51module_param(pc_debug, int, 0600); 51module_param(pc_debug, int, 0600);
52#define DEBUGP(n, rdr, x, args...) do { \ 52#define DEBUGP(n, rdr, x, args...) do { \
@@ -106,7 +106,7 @@ static int major; /* major number we get from the kernel */
106#define REG_STOPBITS(x) (x + 7) 106#define REG_STOPBITS(x) (x + 7)
107 107
108struct cm4000_dev { 108struct cm4000_dev {
109 dev_link_t link; /* pcmcia link */ 109 struct pcmcia_device *p_dev;
110 dev_node_t node; /* OS node (major,minor) */ 110 dev_node_t node; /* OS node (major,minor) */
111 111
112 unsigned char atr[MAX_ATR]; 112 unsigned char atr[MAX_ATR];
@@ -454,7 +454,7 @@ static struct card_fixup card_fixups[] = {
454static void set_cardparameter(struct cm4000_dev *dev) 454static void set_cardparameter(struct cm4000_dev *dev)
455{ 455{
456 int i; 456 int i;
457 ioaddr_t iobase = dev->link.io.BasePort1; 457 ioaddr_t iobase = dev->p_dev->io.BasePort1;
458 u_int8_t stopbits = 0x02; /* ISO default */ 458 u_int8_t stopbits = 0x02; /* ISO default */
459 459
460 DEBUGP(3, dev, "-> set_cardparameter\n"); 460 DEBUGP(3, dev, "-> set_cardparameter\n");
@@ -487,7 +487,7 @@ static int set_protocol(struct cm4000_dev *dev, struct ptsreq *ptsreq)
487 unsigned short num_bytes_read; 487 unsigned short num_bytes_read;
488 unsigned char pts_reply[4]; 488 unsigned char pts_reply[4];
489 ssize_t rc; 489 ssize_t rc;
490 ioaddr_t iobase = dev->link.io.BasePort1; 490 ioaddr_t iobase = dev->p_dev->io.BasePort1;
491 491
492 rc = 0; 492 rc = 0;
493 493
@@ -699,7 +699,7 @@ static void terminate_monitor(struct cm4000_dev *dev)
699static void monitor_card(unsigned long p) 699static void monitor_card(unsigned long p)
700{ 700{
701 struct cm4000_dev *dev = (struct cm4000_dev *) p; 701 struct cm4000_dev *dev = (struct cm4000_dev *) p;
702 ioaddr_t iobase = dev->link.io.BasePort1; 702 ioaddr_t iobase = dev->p_dev->io.BasePort1;
703 unsigned short s; 703 unsigned short s;
704 struct ptsreq ptsreq; 704 struct ptsreq ptsreq;
705 int i, atrc; 705 int i, atrc;
@@ -962,7 +962,7 @@ static ssize_t cmm_read(struct file *filp, __user char *buf, size_t count,
962 loff_t *ppos) 962 loff_t *ppos)
963{ 963{
964 struct cm4000_dev *dev = filp->private_data; 964 struct cm4000_dev *dev = filp->private_data;
965 ioaddr_t iobase = dev->link.io.BasePort1; 965 ioaddr_t iobase = dev->p_dev->io.BasePort1;
966 ssize_t rc; 966 ssize_t rc;
967 int i, j, k; 967 int i, j, k;
968 968
@@ -971,7 +971,7 @@ static ssize_t cmm_read(struct file *filp, __user char *buf, size_t count,
971 if (count == 0) /* according to manpage */ 971 if (count == 0) /* according to manpage */
972 return 0; 972 return 0;
973 973
974 if ((dev->link.state & DEV_PRESENT) == 0 || /* socket removed */ 974 if ((dev->p_dev->state & DEV_PRESENT) == 0 || /* socket removed */
975 test_bit(IS_CMM_ABSENT, &dev->flags)) 975 test_bit(IS_CMM_ABSENT, &dev->flags))
976 return -ENODEV; 976 return -ENODEV;
977 977
@@ -1083,7 +1083,7 @@ static ssize_t cmm_write(struct file *filp, const char __user *buf,
1083 size_t count, loff_t *ppos) 1083 size_t count, loff_t *ppos)
1084{ 1084{
1085 struct cm4000_dev *dev = (struct cm4000_dev *) filp->private_data; 1085 struct cm4000_dev *dev = (struct cm4000_dev *) filp->private_data;
1086 ioaddr_t iobase = dev->link.io.BasePort1; 1086 ioaddr_t iobase = dev->p_dev->io.BasePort1;
1087 unsigned short s; 1087 unsigned short s;
1088 unsigned char tmp; 1088 unsigned char tmp;
1089 unsigned char infolen; 1089 unsigned char infolen;
@@ -1108,7 +1108,7 @@ static ssize_t cmm_write(struct file *filp, const char __user *buf,
1108 1108
1109 sendT0 = dev->proto ? 0 : nr > 5 ? 0x08 : 0; 1109 sendT0 = dev->proto ? 0 : nr > 5 ? 0x08 : 0;
1110 1110
1111 if ((dev->link.state & DEV_PRESENT) == 0 || /* socket removed */ 1111 if ((dev->p_dev->state & DEV_PRESENT) == 0 || /* socket removed */
1112 test_bit(IS_CMM_ABSENT, &dev->flags)) 1112 test_bit(IS_CMM_ABSENT, &dev->flags))
1113 return -ENODEV; 1113 return -ENODEV;
1114 1114
@@ -1440,7 +1440,7 @@ static int cmm_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
1440 unsigned long arg) 1440 unsigned long arg)
1441{ 1441{
1442 struct cm4000_dev *dev = filp->private_data; 1442 struct cm4000_dev *dev = filp->private_data;
1443 ioaddr_t iobase = dev->link.io.BasePort1; 1443 ioaddr_t iobase = dev->p_dev->io.BasePort1;
1444 dev_link_t *link; 1444 dev_link_t *link;
1445 int size; 1445 int size;
1446 int rc; 1446 int rc;
@@ -1844,7 +1844,7 @@ static void cm4000_config(dev_link_t * link, int devno)
1844 dev->node.major = major; 1844 dev->node.major = major;
1845 dev->node.minor = devno; 1845 dev->node.minor = devno;
1846 dev->node.next = NULL; 1846 dev->node.next = NULL;
1847 link->dev = &dev->node; 1847 link->dev_node = &dev->node;
1848 link->state &= ~DEV_CONFIG_PENDING; 1848 link->state &= ~DEV_CONFIG_PENDING;
1849 1849
1850 return; 1850 return;
@@ -1889,8 +1889,8 @@ static void cm4000_release(dev_link_t *link)
1889static int cm4000_attach(struct pcmcia_device *p_dev) 1889static int cm4000_attach(struct pcmcia_device *p_dev)
1890{ 1890{
1891 struct cm4000_dev *dev; 1891 struct cm4000_dev *dev;
1892 dev_link_t *link;
1893 int i; 1892 int i;
1893 dev_link_t *link = dev_to_instance(p_dev);
1894 1894
1895 for (i = 0; i < CM4000_MAX_DEV; i++) 1895 for (i = 0; i < CM4000_MAX_DEV; i++)
1896 if (dev_table[i] == NULL) 1896 if (dev_table[i] == NULL)
@@ -1906,7 +1906,7 @@ static int cm4000_attach(struct pcmcia_device *p_dev)
1906 if (dev == NULL) 1906 if (dev == NULL)
1907 return -ENOMEM; 1907 return -ENOMEM;
1908 1908
1909 link = &dev->link; 1909 dev->p_dev = p_dev;
1910 link->priv = dev; 1910 link->priv = dev;
1911 link->conf.IntType = INT_MEMORY_AND_IO; 1911 link->conf.IntType = INT_MEMORY_AND_IO;
1912 dev_table[i] = link; 1912 dev_table[i] = link;
@@ -1916,9 +1916,6 @@ static int cm4000_attach(struct pcmcia_device *p_dev)
1916 init_waitqueue_head(&dev->atrq); 1916 init_waitqueue_head(&dev->atrq);
1917 init_waitqueue_head(&dev->readq); 1917 init_waitqueue_head(&dev->readq);
1918 1918
1919 link->handle = p_dev;
1920 p_dev->instance = link;
1921
1922 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 1919 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
1923 cm4000_config(link, i); 1920 cm4000_config(link, i);
1924 1921
diff --git a/drivers/char/pcmcia/cm4040_cs.c b/drivers/char/pcmcia/cm4040_cs.c
index 94ecd0342b72..97e32e7f84dc 100644
--- a/drivers/char/pcmcia/cm4040_cs.c
+++ b/drivers/char/pcmcia/cm4040_cs.c
@@ -41,7 +41,7 @@
41 41
42 42
43#ifdef PCMCIA_DEBUG 43#ifdef PCMCIA_DEBUG
44#define reader_to_dev(x) (&handle_to_dev(x->link.handle)) 44#define reader_to_dev(x) (&handle_to_dev(x->p_dev->handle))
45static int pc_debug = PCMCIA_DEBUG; 45static int pc_debug = PCMCIA_DEBUG;
46module_param(pc_debug, int, 0600); 46module_param(pc_debug, int, 0600);
47#define DEBUGP(n, rdr, x, args...) do { \ 47#define DEBUGP(n, rdr, x, args...) do { \
@@ -74,7 +74,7 @@ static struct class *cmx_class;
74#define BS_WRITABLE 0x02 74#define BS_WRITABLE 0x02
75 75
76struct reader_dev { 76struct reader_dev {
77 dev_link_t link; 77 struct pcmcia_device *p_dev;
78 dev_node_t node; 78 dev_node_t node;
79 wait_queue_head_t devq; 79 wait_queue_head_t devq;
80 wait_queue_head_t poll_wait; 80 wait_queue_head_t poll_wait;
@@ -116,7 +116,7 @@ static inline unsigned char xinb(unsigned short port)
116static void cm4040_do_poll(unsigned long dummy) 116static void cm4040_do_poll(unsigned long dummy)
117{ 117{
118 struct reader_dev *dev = (struct reader_dev *) dummy; 118 struct reader_dev *dev = (struct reader_dev *) dummy;
119 unsigned int obs = xinb(dev->link.io.BasePort1 119 unsigned int obs = xinb(dev->p_dev->io.BasePort1
120 + REG_OFFSET_BUFFER_STATUS); 120 + REG_OFFSET_BUFFER_STATUS);
121 121
122 if ((obs & BSR_BULK_IN_FULL)) { 122 if ((obs & BSR_BULK_IN_FULL)) {
@@ -147,7 +147,7 @@ static void cm4040_stop_poll(struct reader_dev *dev)
147static int wait_for_bulk_out_ready(struct reader_dev *dev) 147static int wait_for_bulk_out_ready(struct reader_dev *dev)
148{ 148{
149 int i, rc; 149 int i, rc;
150 int iobase = dev->link.io.BasePort1; 150 int iobase = dev->p_dev->io.BasePort1;
151 151
152 for (i = 0; i < POLL_LOOP_COUNT; i++) { 152 for (i = 0; i < POLL_LOOP_COUNT; i++) {
153 if ((xinb(iobase + REG_OFFSET_BUFFER_STATUS) 153 if ((xinb(iobase + REG_OFFSET_BUFFER_STATUS)
@@ -177,7 +177,7 @@ static int wait_for_bulk_out_ready(struct reader_dev *dev)
177/* Write to Sync Control Register */ 177/* Write to Sync Control Register */
178static int write_sync_reg(unsigned char val, struct reader_dev *dev) 178static int write_sync_reg(unsigned char val, struct reader_dev *dev)
179{ 179{
180 int iobase = dev->link.io.BasePort1; 180 int iobase = dev->p_dev->io.BasePort1;
181 int rc; 181 int rc;
182 182
183 rc = wait_for_bulk_out_ready(dev); 183 rc = wait_for_bulk_out_ready(dev);
@@ -195,7 +195,7 @@ static int write_sync_reg(unsigned char val, struct reader_dev *dev)
195static int wait_for_bulk_in_ready(struct reader_dev *dev) 195static int wait_for_bulk_in_ready(struct reader_dev *dev)
196{ 196{
197 int i, rc; 197 int i, rc;
198 int iobase = dev->link.io.BasePort1; 198 int iobase = dev->p_dev->io.BasePort1;
199 199
200 for (i = 0; i < POLL_LOOP_COUNT; i++) { 200 for (i = 0; i < POLL_LOOP_COUNT; i++) {
201 if ((xinb(iobase + REG_OFFSET_BUFFER_STATUS) 201 if ((xinb(iobase + REG_OFFSET_BUFFER_STATUS)
@@ -225,7 +225,7 @@ static ssize_t cm4040_read(struct file *filp, char __user *buf,
225 size_t count, loff_t *ppos) 225 size_t count, loff_t *ppos)
226{ 226{
227 struct reader_dev *dev = filp->private_data; 227 struct reader_dev *dev = filp->private_data;
228 int iobase = dev->link.io.BasePort1; 228 int iobase = dev->p_dev->io.BasePort1;
229 size_t bytes_to_read; 229 size_t bytes_to_read;
230 unsigned long i; 230 unsigned long i;
231 size_t min_bytes_to_read; 231 size_t min_bytes_to_read;
@@ -246,7 +246,7 @@ static ssize_t cm4040_read(struct file *filp, char __user *buf,
246 return -EAGAIN; 246 return -EAGAIN;
247 } 247 }
248 248
249 if ((dev->link.state & DEV_PRESENT)==0) 249 if ((dev->p_dev->state & DEV_PRESENT)==0)
250 return -ENODEV; 250 return -ENODEV;
251 251
252 for (i = 0; i < 5; i++) { 252 for (i = 0; i < 5; i++) {
@@ -328,7 +328,7 @@ static ssize_t cm4040_write(struct file *filp, const char __user *buf,
328 size_t count, loff_t *ppos) 328 size_t count, loff_t *ppos)
329{ 329{
330 struct reader_dev *dev = filp->private_data; 330 struct reader_dev *dev = filp->private_data;
331 int iobase = dev->link.io.BasePort1; 331 int iobase = dev->p_dev->io.BasePort1;
332 ssize_t rc; 332 ssize_t rc;
333 int i; 333 int i;
334 unsigned int bytes_to_write; 334 unsigned int bytes_to_write;
@@ -351,7 +351,7 @@ static ssize_t cm4040_write(struct file *filp, const char __user *buf,
351 return -EAGAIN; 351 return -EAGAIN;
352 } 352 }
353 353
354 if ((dev->link.state & DEV_PRESENT) == 0) 354 if ((dev->p_dev->state & DEV_PRESENT) == 0)
355 return -ENODEV; 355 return -ENODEV;
356 356
357 bytes_to_write = count; 357 bytes_to_write = count;
@@ -606,7 +606,7 @@ static void reader_config(dev_link_t *link, int devno)
606 dev->node.major = major; 606 dev->node.major = major;
607 dev->node.minor = devno; 607 dev->node.minor = devno;
608 dev->node.next = NULL; 608 dev->node.next = NULL;
609 link->dev = &dev->node; 609 link->dev_node = &dev->node;
610 link->state &= ~DEV_CONFIG_PENDING; 610 link->state &= ~DEV_CONFIG_PENDING;
611 611
612 DEBUGP(2, dev, "device " DEVICE_NAME "%d at 0x%.4x-0x%.4x\n", devno, 612 DEBUGP(2, dev, "device " DEVICE_NAME "%d at 0x%.4x-0x%.4x\n", devno,
@@ -631,8 +631,8 @@ static void reader_release(dev_link_t *link)
631static int reader_attach(struct pcmcia_device *p_dev) 631static int reader_attach(struct pcmcia_device *p_dev)
632{ 632{
633 struct reader_dev *dev; 633 struct reader_dev *dev;
634 dev_link_t *link;
635 int i; 634 int i;
635 dev_link_t *link = dev_to_instance(p_dev);
636 636
637 for (i = 0; i < CM_MAX_DEV; i++) { 637 for (i = 0; i < CM_MAX_DEV; i++) {
638 if (dev_table[i] == NULL) 638 if (dev_table[i] == NULL)
@@ -649,8 +649,8 @@ static int reader_attach(struct pcmcia_device *p_dev)
649 dev->timeout = CCID_DRIVER_MINIMUM_TIMEOUT; 649 dev->timeout = CCID_DRIVER_MINIMUM_TIMEOUT;
650 dev->buffer_status = 0; 650 dev->buffer_status = 0;
651 651
652 link = &dev->link;
653 link->priv = dev; 652 link->priv = dev;
653 dev->p_dev = p_dev;
654 654
655 link->conf.IntType = INT_MEMORY_AND_IO; 655 link->conf.IntType = INT_MEMORY_AND_IO;
656 dev_table[i] = link; 656 dev_table[i] = link;
@@ -662,9 +662,6 @@ static int reader_attach(struct pcmcia_device *p_dev)
662 init_timer(&dev->poll_timer); 662 init_timer(&dev->poll_timer);
663 dev->poll_timer.function = &cm4040_do_poll; 663 dev->poll_timer.function = &cm4040_do_poll;
664 664
665 link->handle = p_dev;
666 p_dev->instance = link;
667
668 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 665 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
669 reader_config(link, i); 666 reader_config(link, i);
670 667
diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
index a6cbd3239921..7b1e055184d1 100644
--- a/drivers/char/pcmcia/synclink_cs.c
+++ b/drivers/char/pcmcia/synclink_cs.c
@@ -228,7 +228,7 @@ typedef struct _mgslpc_info {
228 struct _input_signal_events input_signal_events; 228 struct _input_signal_events input_signal_events;
229 229
230 /* PCMCIA support */ 230 /* PCMCIA support */
231 dev_link_t link; 231 struct pcmcia_device *p_dev;
232 dev_node_t node; 232 dev_node_t node;
233 int stop; 233 int stop;
234 234
@@ -536,11 +536,11 @@ static void ldisc_receive_buf(struct tty_struct *tty,
536static int mgslpc_attach(struct pcmcia_device *p_dev) 536static int mgslpc_attach(struct pcmcia_device *p_dev)
537{ 537{
538 MGSLPC_INFO *info; 538 MGSLPC_INFO *info;
539 dev_link_t *link; 539 dev_link_t *link = dev_to_instance(p_dev);
540 540
541 if (debug_level >= DEBUG_LEVEL_INFO) 541 if (debug_level >= DEBUG_LEVEL_INFO)
542 printk("mgslpc_attach\n"); 542 printk("mgslpc_attach\n");
543 543
544 info = (MGSLPC_INFO *)kmalloc(sizeof(MGSLPC_INFO), GFP_KERNEL); 544 info = (MGSLPC_INFO *)kmalloc(sizeof(MGSLPC_INFO), GFP_KERNEL);
545 if (!info) { 545 if (!info) {
546 printk("Error can't allocate device instance data\n"); 546 printk("Error can't allocate device instance data\n");
@@ -565,22 +565,19 @@ static int mgslpc_attach(struct pcmcia_device *p_dev)
565 info->imrb_value = 0xffff; 565 info->imrb_value = 0xffff;
566 info->pim_value = 0xff; 566 info->pim_value = 0xff;
567 567
568 link = &info->link; 568 info->p_dev = p_dev;
569 link->priv = info; 569 link->priv = info;
570 570
571 /* Initialize the dev_link_t structure */ 571 /* Initialize the dev_link_t structure */
572 572
573 /* Interrupt setup */ 573 /* Interrupt setup */
574 link->irq.Attributes = IRQ_TYPE_EXCLUSIVE; 574 link->irq.Attributes = IRQ_TYPE_EXCLUSIVE;
575 link->irq.IRQInfo1 = IRQ_LEVEL_ID; 575 link->irq.IRQInfo1 = IRQ_LEVEL_ID;
576 link->irq.Handler = NULL; 576 link->irq.Handler = NULL;
577 577
578 link->conf.Attributes = 0; 578 link->conf.Attributes = 0;
579 link->conf.IntType = INT_MEMORY_AND_IO; 579 link->conf.IntType = INT_MEMORY_AND_IO;
580 580
581 link->handle = p_dev;
582 p_dev->instance = link;
583
584 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 581 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
585 mgslpc_config(link); 582 mgslpc_config(link);
586 583
@@ -673,7 +670,7 @@ static void mgslpc_config(dev_link_t *link)
673 /* add to linked list of devices */ 670 /* add to linked list of devices */
674 sprintf(info->node.dev_name, "mgslpc0"); 671 sprintf(info->node.dev_name, "mgslpc0");
675 info->node.major = info->node.minor = 0; 672 info->node.major = info->node.minor = 0;
676 link->dev = &info->node; 673 link->dev_node = &info->node;
677 674
678 printk(KERN_INFO "%s: index 0x%02x:", 675 printk(KERN_INFO "%s: index 0x%02x:",
679 info->node.dev_name, link->conf.ConfigIndex); 676 info->node.dev_name, link->conf.ConfigIndex);
@@ -1259,7 +1256,7 @@ static irqreturn_t mgslpc_isr(int irq, void *dev_id, struct pt_regs * regs)
1259 if (!info) 1256 if (!info)
1260 return IRQ_NONE; 1257 return IRQ_NONE;
1261 1258
1262 if (!(info->link.state & DEV_CONFIG)) 1259 if (!(info->p_dev->state & DEV_CONFIG))
1263 return IRQ_HANDLED; 1260 return IRQ_HANDLED;
1264 1261
1265 spin_lock(&info->lock); 1262 spin_lock(&info->lock);