aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/pcmcia/pcnet_cs.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2009-12-05 12:42:59 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2009-12-05 12:42:59 -0500
commitd9b2c4d0b03c721808c0d259e43a27f1e80205bc (patch)
treef17a4166f62ee14faa1401a6cbd353a4ab8c77cb /drivers/net/pcmcia/pcnet_cs.c
parent27d16d08717faeaa8afd1b736a096dbaab90f08e (diff)
parent5fa9167a1bf5f5a4b7282f5e7ac56a4a5a1fa044 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/brodo/pcmcia-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/brodo/pcmcia-2.6: (50 commits) pcmcia: rework the irq_req_t typedef pcmcia: remove deprecated handle_to_dev() macro pcmcia: pcmcia_request_window() doesn't need a pointer to a pointer pcmcia: remove unused "window_t" typedef pcmcia: move some window-related code to pcmcia_ioctl.c pcmcia: Change window_handle_t logic to unsigned long pcmcia: Pass struct pcmcia_socket to pcmcia_get_mem_page() pcmcia: Pass struct pcmcia_device to pcmcia_map_mem_page() pcmcia: Pass struct pcmcia_device to pcmcia_release_window() drivers/pcmcia: remove unnecessary kzalloc pcmcia: correct handling for Zoomed Video registers in topic.h pcmcia: fix printk formats pcmcia: autoload module pcmcia pcmcia/staging: update comedi drivers PCMCIA: stop duplicating pci_irq in soc_pcmcia_socket PCMCIA: ss: allow PCI IRQs > 255 PCMCIA: soc_common: remove 'dev' member from soc_pcmcia_socket PCMCIA: soc_common: constify soc_pcmcia_socket ops member PCMCIA: sa1111: remove duplicated initializers PCMCIA: sa1111: wrap soc_pcmcia_socket to contain sa1111 specific data ...
Diffstat (limited to 'drivers/net/pcmcia/pcnet_cs.c')
-rw-r--r--drivers/net/pcmcia/pcnet_cs.c80
1 files changed, 31 insertions, 49 deletions
diff --git a/drivers/net/pcmcia/pcnet_cs.c b/drivers/net/pcmcia/pcnet_cs.c
index 94c9ad2746bc..cbe462ed221f 100644
--- a/drivers/net/pcmcia/pcnet_cs.c
+++ b/drivers/net/pcmcia/pcnet_cs.c
@@ -71,15 +71,6 @@
71 71
72static const char *if_names[] = { "auto", "10baseT", "10base2"}; 72static const char *if_names[] = { "auto", "10baseT", "10base2"};
73 73
74#ifdef PCMCIA_DEBUG
75static int pc_debug = PCMCIA_DEBUG;
76module_param(pc_debug, int, 0);
77#define DEBUG(n, args...) if (pc_debug>(n)) printk(KERN_DEBUG args)
78static char *version =
79"pcnet_cs.c 1.153 2003/11/09 18:53:09 (David Hinds)";
80#else
81#define DEBUG(n, args...)
82#endif
83 74
84/*====================================================================*/ 75/*====================================================================*/
85 76
@@ -265,7 +256,7 @@ static int pcnet_probe(struct pcmcia_device *link)
265 pcnet_dev_t *info; 256 pcnet_dev_t *info;
266 struct net_device *dev; 257 struct net_device *dev;
267 258
268 DEBUG(0, "pcnet_attach()\n"); 259 dev_dbg(&link->dev, "pcnet_attach()\n");
269 260
270 /* Create new ethernet device */ 261 /* Create new ethernet device */
271 dev = __alloc_ei_netdev(sizeof(pcnet_dev_t)); 262 dev = __alloc_ei_netdev(sizeof(pcnet_dev_t));
@@ -275,7 +266,6 @@ static int pcnet_probe(struct pcmcia_device *link)
275 link->priv = dev; 266 link->priv = dev;
276 267
277 link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING; 268 link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING;
278 link->irq.IRQInfo1 = IRQ_LEVEL_ID;
279 link->conf.Attributes = CONF_ENABLE_IRQ; 269 link->conf.Attributes = CONF_ENABLE_IRQ;
280 link->conf.IntType = INT_MEMORY_AND_IO; 270 link->conf.IntType = INT_MEMORY_AND_IO;
281 271
@@ -297,7 +287,7 @@ static void pcnet_detach(struct pcmcia_device *link)
297{ 287{
298 struct net_device *dev = link->priv; 288 struct net_device *dev = link->priv;
299 289
300 DEBUG(0, "pcnet_detach(0x%p)\n", link); 290 dev_dbg(&link->dev, "pcnet_detach\n");
301 291
302 if (link->dev_node) 292 if (link->dev_node)
303 unregister_netdev(dev); 293 unregister_netdev(dev);
@@ -326,17 +316,15 @@ static hw_info_t *get_hwinfo(struct pcmcia_device *link)
326 req.Attributes = WIN_DATA_WIDTH_8|WIN_MEMORY_TYPE_AM|WIN_ENABLE; 316 req.Attributes = WIN_DATA_WIDTH_8|WIN_MEMORY_TYPE_AM|WIN_ENABLE;
327 req.Base = 0; req.Size = 0; 317 req.Base = 0; req.Size = 0;
328 req.AccessSpeed = 0; 318 req.AccessSpeed = 0;
329 i = pcmcia_request_window(&link, &req, &link->win); 319 i = pcmcia_request_window(link, &req, &link->win);
330 if (i != 0) { 320 if (i != 0)
331 cs_error(link, RequestWindow, i);
332 return NULL; 321 return NULL;
333 }
334 322
335 virt = ioremap(req.Base, req.Size); 323 virt = ioremap(req.Base, req.Size);
336 mem.Page = 0; 324 mem.Page = 0;
337 for (i = 0; i < NR_INFO; i++) { 325 for (i = 0; i < NR_INFO; i++) {
338 mem.CardOffset = hw_info[i].offset & ~(req.Size-1); 326 mem.CardOffset = hw_info[i].offset & ~(req.Size-1);
339 pcmcia_map_mem_page(link->win, &mem); 327 pcmcia_map_mem_page(link, link->win, &mem);
340 base = &virt[hw_info[i].offset & (req.Size-1)]; 328 base = &virt[hw_info[i].offset & (req.Size-1)];
341 if ((readb(base+0) == hw_info[i].a0) && 329 if ((readb(base+0) == hw_info[i].a0) &&
342 (readb(base+2) == hw_info[i].a1) && 330 (readb(base+2) == hw_info[i].a1) &&
@@ -348,9 +336,7 @@ static hw_info_t *get_hwinfo(struct pcmcia_device *link)
348 } 336 }
349 337
350 iounmap(virt); 338 iounmap(virt);
351 j = pcmcia_release_window(link->win); 339 j = pcmcia_release_window(link, link->win);
352 if (j != 0)
353 cs_error(link, ReleaseWindow, j);
354 return (i < NR_INFO) ? hw_info+i : NULL; 340 return (i < NR_INFO) ? hw_info+i : NULL;
355} /* get_hwinfo */ 341} /* get_hwinfo */
356 342
@@ -495,9 +481,6 @@ static hw_info_t *get_hwired(struct pcmcia_device *link)
495 481
496======================================================================*/ 482======================================================================*/
497 483
498#define CS_CHECK(fn, ret) \
499do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
500
501static int try_io_port(struct pcmcia_device *link) 484static int try_io_port(struct pcmcia_device *link)
502{ 485{
503 int j, ret; 486 int j, ret;
@@ -567,19 +550,19 @@ static int pcnet_config(struct pcmcia_device *link)
567{ 550{
568 struct net_device *dev = link->priv; 551 struct net_device *dev = link->priv;
569 pcnet_dev_t *info = PRIV(dev); 552 pcnet_dev_t *info = PRIV(dev);
570 int last_ret, last_fn, start_pg, stop_pg, cm_offset; 553 int ret, start_pg, stop_pg, cm_offset;
571 int has_shmem = 0; 554 int has_shmem = 0;
572 hw_info_t *local_hw_info; 555 hw_info_t *local_hw_info;
573 556
574 DEBUG(0, "pcnet_config(0x%p)\n", link); 557 dev_dbg(&link->dev, "pcnet_config\n");
575 558
576 last_ret = pcmcia_loop_config(link, pcnet_confcheck, &has_shmem); 559 ret = pcmcia_loop_config(link, pcnet_confcheck, &has_shmem);
577 if (last_ret) { 560 if (ret)
578 cs_error(link, RequestIO, last_ret);
579 goto failed; 561 goto failed;
580 }
581 562
582 CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); 563 ret = pcmcia_request_irq(link, &link->irq);
564 if (ret)
565 goto failed;
583 566
584 if (link->io.NumPorts2 == 8) { 567 if (link->io.NumPorts2 == 8) {
585 link->conf.Attributes |= CONF_ENABLE_SPKR; 568 link->conf.Attributes |= CONF_ENABLE_SPKR;
@@ -589,7 +572,9 @@ static int pcnet_config(struct pcmcia_device *link)
589 (link->card_id == PRODID_IBM_HOME_AND_AWAY)) 572 (link->card_id == PRODID_IBM_HOME_AND_AWAY))
590 link->conf.ConfigIndex |= 0x10; 573 link->conf.ConfigIndex |= 0x10;
591 574
592 CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf)); 575 ret = pcmcia_request_configuration(link, &link->conf);
576 if (ret)
577 goto failed;
593 dev->irq = link->irq.AssignedIRQ; 578 dev->irq = link->irq.AssignedIRQ;
594 dev->base_addr = link->io.BasePort1; 579 dev->base_addr = link->io.BasePort1;
595 if (info->flags & HAS_MISC_REG) { 580 if (info->flags & HAS_MISC_REG) {
@@ -660,7 +645,7 @@ static int pcnet_config(struct pcmcia_device *link)
660 mii_phy_probe(dev); 645 mii_phy_probe(dev);
661 646
662 link->dev_node = &info->node; 647 link->dev_node = &info->node;
663 SET_NETDEV_DEV(dev, &handle_to_dev(link)); 648 SET_NETDEV_DEV(dev, &link->dev);
664 649
665 if (register_netdev(dev) != 0) { 650 if (register_netdev(dev) != 0) {
666 printk(KERN_NOTICE "pcnet_cs: register_netdev() failed\n"); 651 printk(KERN_NOTICE "pcnet_cs: register_netdev() failed\n");
@@ -687,8 +672,6 @@ static int pcnet_config(struct pcmcia_device *link)
687 printk(" hw_addr %pM\n", dev->dev_addr); 672 printk(" hw_addr %pM\n", dev->dev_addr);
688 return 0; 673 return 0;
689 674
690cs_failed:
691 cs_error(link, last_fn, last_ret);
692failed: 675failed:
693 pcnet_release(link); 676 pcnet_release(link);
694 return -ENODEV; 677 return -ENODEV;
@@ -706,7 +689,7 @@ static void pcnet_release(struct pcmcia_device *link)
706{ 689{
707 pcnet_dev_t *info = PRIV(link->priv); 690 pcnet_dev_t *info = PRIV(link->priv);
708 691
709 DEBUG(0, "pcnet_release(0x%p)\n", link); 692 dev_dbg(&link->dev, "pcnet_release\n");
710 693
711 if (info->flags & USE_SHMEM) 694 if (info->flags & USE_SHMEM)
712 iounmap(info->base); 695 iounmap(info->base);
@@ -960,7 +943,7 @@ static void mii_phy_probe(struct net_device *dev)
960 phyid = tmp << 16; 943 phyid = tmp << 16;
961 phyid |= mdio_read(mii_addr, i, MII_PHYID_REG2); 944 phyid |= mdio_read(mii_addr, i, MII_PHYID_REG2);
962 phyid &= MII_PHYID_REV_MASK; 945 phyid &= MII_PHYID_REV_MASK;
963 DEBUG(0, "%s: MII at %d is 0x%08x\n", dev->name, i, phyid); 946 pr_debug("%s: MII at %d is 0x%08x\n", dev->name, i, phyid);
964 if (phyid == AM79C9XX_HOME_PHY) { 947 if (phyid == AM79C9XX_HOME_PHY) {
965 info->pna_phy = i; 948 info->pna_phy = i;
966 } else if (phyid != AM79C9XX_ETH_PHY) { 949 } else if (phyid != AM79C9XX_ETH_PHY) {
@@ -976,7 +959,7 @@ static int pcnet_open(struct net_device *dev)
976 struct pcmcia_device *link = info->p_dev; 959 struct pcmcia_device *link = info->p_dev;
977 unsigned int nic_base = dev->base_addr; 960 unsigned int nic_base = dev->base_addr;
978 961
979 DEBUG(2, "pcnet_open('%s')\n", dev->name); 962 dev_dbg(&link->dev, "pcnet_open('%s')\n", dev->name);
980 963
981 if (!pcmcia_dev_present(link)) 964 if (!pcmcia_dev_present(link))
982 return -ENODEV; 965 return -ENODEV;
@@ -1008,7 +991,7 @@ static int pcnet_close(struct net_device *dev)
1008 pcnet_dev_t *info = PRIV(dev); 991 pcnet_dev_t *info = PRIV(dev);
1009 struct pcmcia_device *link = info->p_dev; 992 struct pcmcia_device *link = info->p_dev;
1010 993
1011 DEBUG(2, "pcnet_close('%s')\n", dev->name); 994 dev_dbg(&link->dev, "pcnet_close('%s')\n", dev->name);
1012 995
1013 ei_close(dev); 996 ei_close(dev);
1014 free_irq(dev->irq, dev); 997 free_irq(dev->irq, dev);
@@ -1251,10 +1234,8 @@ static void dma_block_input(struct net_device *dev, int count,
1251 int xfer_count = count; 1234 int xfer_count = count;
1252 char *buf = skb->data; 1235 char *buf = skb->data;
1253 1236
1254#ifdef PCMCIA_DEBUG
1255 if ((ei_debug > 4) && (count != 4)) 1237 if ((ei_debug > 4) && (count != 4))
1256 printk(KERN_DEBUG "%s: [bi=%d]\n", dev->name, count+4); 1238 pr_debug("%s: [bi=%d]\n", dev->name, count+4);
1257#endif
1258 if (ei_status.dmaing) { 1239 if (ei_status.dmaing) {
1259 printk(KERN_NOTICE "%s: DMAing conflict in dma_block_input." 1240 printk(KERN_NOTICE "%s: DMAing conflict in dma_block_input."
1260 "[DMAstat:%1x][irqlock:%1x]\n", 1241 "[DMAstat:%1x][irqlock:%1x]\n",
@@ -1495,7 +1476,7 @@ static int setup_shmem_window(struct pcmcia_device *link, int start_pg,
1495 pcnet_dev_t *info = PRIV(dev); 1476 pcnet_dev_t *info = PRIV(dev);
1496 win_req_t req; 1477 win_req_t req;
1497 memreq_t mem; 1478 memreq_t mem;
1498 int i, window_size, offset, last_ret, last_fn; 1479 int i, window_size, offset, ret;
1499 1480
1500 window_size = (stop_pg - start_pg) << 8; 1481 window_size = (stop_pg - start_pg) << 8;
1501 if (window_size > 32 * 1024) 1482 if (window_size > 32 * 1024)
@@ -1509,13 +1490,17 @@ static int setup_shmem_window(struct pcmcia_device *link, int start_pg,
1509 req.Attributes |= WIN_USE_WAIT; 1490 req.Attributes |= WIN_USE_WAIT;
1510 req.Base = 0; req.Size = window_size; 1491 req.Base = 0; req.Size = window_size;
1511 req.AccessSpeed = mem_speed; 1492 req.AccessSpeed = mem_speed;
1512 CS_CHECK(RequestWindow, pcmcia_request_window(&link, &req, &link->win)); 1493 ret = pcmcia_request_window(link, &req, &link->win);
1494 if (ret)
1495 goto failed;
1513 1496
1514 mem.CardOffset = (start_pg << 8) + cm_offset; 1497 mem.CardOffset = (start_pg << 8) + cm_offset;
1515 offset = mem.CardOffset % window_size; 1498 offset = mem.CardOffset % window_size;
1516 mem.CardOffset -= offset; 1499 mem.CardOffset -= offset;
1517 mem.Page = 0; 1500 mem.Page = 0;
1518 CS_CHECK(MapMemPage, pcmcia_map_mem_page(link->win, &mem)); 1501 ret = pcmcia_map_mem_page(link, link->win, &mem);
1502 if (ret)
1503 goto failed;
1519 1504
1520 /* Try scribbling on the buffer */ 1505 /* Try scribbling on the buffer */
1521 info->base = ioremap(req.Base, window_size); 1506 info->base = ioremap(req.Base, window_size);
@@ -1527,8 +1512,8 @@ static int setup_shmem_window(struct pcmcia_device *link, int start_pg,
1527 pcnet_reset_8390(dev); 1512 pcnet_reset_8390(dev);
1528 if (i != (TX_PAGES<<8)) { 1513 if (i != (TX_PAGES<<8)) {
1529 iounmap(info->base); 1514 iounmap(info->base);
1530 pcmcia_release_window(link->win); 1515 pcmcia_release_window(link, link->win);
1531 info->base = NULL; link->win = NULL; 1516 info->base = NULL; link->win = 0;
1532 goto failed; 1517 goto failed;
1533 } 1518 }
1534 1519
@@ -1549,8 +1534,6 @@ static int setup_shmem_window(struct pcmcia_device *link, int start_pg,
1549 info->flags |= USE_SHMEM; 1534 info->flags |= USE_SHMEM;
1550 return 0; 1535 return 0;
1551 1536
1552cs_failed:
1553 cs_error(link, last_fn, last_ret);
1554failed: 1537failed:
1555 return 1; 1538 return 1;
1556} 1539}
@@ -1788,7 +1771,6 @@ static int __init init_pcnet_cs(void)
1788 1771
1789static void __exit exit_pcnet_cs(void) 1772static void __exit exit_pcnet_cs(void)
1790{ 1773{
1791 DEBUG(0, "pcnet_cs: unloading\n");
1792 pcmcia_unregister_driver(&pcnet_driver); 1774 pcmcia_unregister_driver(&pcnet_driver);
1793} 1775}
1794 1776