aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wan/pci200syn.c
diff options
context:
space:
mode:
authorKrzysztof Hałasa <khc@pm.waw.pl>2008-07-09 17:13:49 -0400
committerKrzysztof Hałasa <khc@pm.waw.pl>2008-11-21 20:49:48 -0500
commit61e0a6a268947f7385282c6841f3e3d64b4c5cb9 (patch)
tree86a9ee7c3eb2028fe1589df5a94091b153fb273a /drivers/net/wan/pci200syn.c
parent967834361a4beb3bbd3069189c192dc6fdeef8a9 (diff)
WAN: Simplify HD64572 drivers.
Signed-off-by: Krzysztof Hałasa <khc@pm.waw.pl>
Diffstat (limited to 'drivers/net/wan/pci200syn.c')
-rw-r--r--drivers/net/wan/pci200syn.c55
1 files changed, 21 insertions, 34 deletions
diff --git a/drivers/net/wan/pci200syn.c b/drivers/net/wan/pci200syn.c
index a16311a79e9a..1104d3a692f7 100644
--- a/drivers/net/wan/pci200syn.c
+++ b/drivers/net/wan/pci200syn.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Goramo PCI200SYN synchronous serial card driver for Linux 2 * Goramo PCI200SYN synchronous serial card driver for Linux
3 * 3 *
4 * Copyright (C) 2002-2003 Krzysztof Halasa <khc@pm.waw.pl> 4 * Copyright (C) 2002-2008 Krzysztof Halasa <khc@pm.waw.pl>
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify it 6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of version 2 of the GNU General Public License 7 * under the terms of version 2 of the GNU General Public License
@@ -63,7 +63,7 @@ typedef struct {
63 63
64typedef struct port_s { 64typedef struct port_s {
65 struct napi_struct napi; 65 struct napi_struct napi;
66 struct net_device *dev; 66 struct net_device *netdev;
67 struct card_s *card; 67 struct card_s *card;
68 spinlock_t lock; /* TX lock */ 68 spinlock_t lock; /* TX lock */
69 sync_serial_settings settings; 69 sync_serial_settings settings;
@@ -74,7 +74,7 @@ typedef struct port_s {
74 u16 txin; /* tx ring buffer 'in' and 'last' pointers */ 74 u16 txin; /* tx ring buffer 'in' and 'last' pointers */
75 u16 txlast; 75 u16 txlast;
76 u8 rxs, txs, tmc; /* SCA registers */ 76 u8 rxs, txs, tmc; /* SCA registers */
77 u8 phy_node; /* physical port # - 0 or 1 */ 77 u8 chan; /* physical port # - 0 or 1 */
78}port_t; 78}port_t;
79 79
80 80
@@ -92,17 +92,6 @@ typedef struct card_s {
92}card_t; 92}card_t;
93 93
94 94
95#define sca_in(reg, card) readb(card->scabase + (reg))
96#define sca_out(value, reg, card) writeb(value, card->scabase + (reg))
97#define sca_inw(reg, card) readw(card->scabase + (reg))
98#define sca_outw(value, reg, card) writew(value, card->scabase + (reg))
99#define sca_inl(reg, card) readl(card->scabase + (reg))
100#define sca_outl(value, reg, card) writel(value, card->scabase + (reg))
101
102#define port_to_card(port) (port->card)
103#define log_node(port) (port->phy_node)
104#define phy_node(port) (port->phy_node)
105#define winbase(card) (card->rambase)
106#define get_port(card, port) (&card->ports[port]) 95#define get_port(card, port) (&card->ports[port])
107#define sca_flush(card) (sca_in(IER0, card)); 96#define sca_flush(card) (sca_in(IER0, card));
108 97
@@ -132,8 +121,8 @@ static void pci200_set_iface(port_t *port)
132 u8 rxs = port->rxs & CLK_BRG_MASK; 121 u8 rxs = port->rxs & CLK_BRG_MASK;
133 u8 txs = port->txs & CLK_BRG_MASK; 122 u8 txs = port->txs & CLK_BRG_MASK;
134 123
135 sca_out(EXS_TES1, (phy_node(port) ? MSCI1_OFFSET : MSCI0_OFFSET) + EXS, 124 sca_out(EXS_TES1, (port->chan ? MSCI1_OFFSET : MSCI0_OFFSET) + EXS,
136 port_to_card(port)); 125 port->card);
137 switch(port->settings.clock_type) { 126 switch(port->settings.clock_type) {
138 case CLOCK_INT: 127 case CLOCK_INT:
139 rxs |= CLK_BRG; /* BRG output */ 128 rxs |= CLK_BRG; /* BRG output */
@@ -175,7 +164,7 @@ static int pci200_open(struct net_device *dev)
175 164
176 sca_open(dev); 165 sca_open(dev);
177 pci200_set_iface(port); 166 pci200_set_iface(port);
178 sca_flush(port_to_card(port)); 167 sca_flush(port->card);
179 return 0; 168 return 0;
180} 169}
181 170
@@ -184,7 +173,7 @@ static int pci200_open(struct net_device *dev)
184static int pci200_close(struct net_device *dev) 173static int pci200_close(struct net_device *dev)
185{ 174{
186 sca_close(dev); 175 sca_close(dev);
187 sca_flush(port_to_card(dev_to_port(dev))); 176 sca_flush(dev_to_port(dev)->card);
188 hdlc_close(dev); 177 hdlc_close(dev);
189 return 0; 178 return 0;
190} 179}
@@ -237,7 +226,7 @@ static int pci200_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
237 226
238 memcpy(&port->settings, &new_line, size); /* Update settings */ 227 memcpy(&port->settings, &new_line, size); /* Update settings */
239 pci200_set_iface(port); 228 pci200_set_iface(port);
240 sca_flush(port_to_card(port)); 229 sca_flush(port->card);
241 return 0; 230 return 0;
242 231
243 default: 232 default:
@@ -253,10 +242,8 @@ static void pci200_pci_remove_one(struct pci_dev *pdev)
253 card_t *card = pci_get_drvdata(pdev); 242 card_t *card = pci_get_drvdata(pdev);
254 243
255 for (i = 0; i < 2; i++) 244 for (i = 0; i < 2; i++)
256 if (card->ports[i].card) { 245 if (card->ports[i].card)
257 struct net_device *dev = port_to_dev(&card->ports[i]); 246 unregister_hdlc_device(card->ports[i].netdev);
258 unregister_hdlc_device(dev);
259 }
260 247
261 if (card->irq) 248 if (card->irq)
262 free_irq(card->irq, card); 249 free_irq(card->irq, card);
@@ -271,10 +258,10 @@ static void pci200_pci_remove_one(struct pci_dev *pdev)
271 pci_release_regions(pdev); 258 pci_release_regions(pdev);
272 pci_disable_device(pdev); 259 pci_disable_device(pdev);
273 pci_set_drvdata(pdev, NULL); 260 pci_set_drvdata(pdev, NULL);
274 if (card->ports[0].dev) 261 if (card->ports[0].netdev)
275 free_netdev(card->ports[0].dev); 262 free_netdev(card->ports[0].netdev);
276 if (card->ports[1].dev) 263 if (card->ports[1].netdev)
277 free_netdev(card->ports[1].dev); 264 free_netdev(card->ports[1].netdev);
278 kfree(card); 265 kfree(card);
279} 266}
280 267
@@ -309,9 +296,9 @@ static int __devinit pci200_pci_init_one(struct pci_dev *pdev,
309 return -ENOBUFS; 296 return -ENOBUFS;
310 } 297 }
311 pci_set_drvdata(pdev, card); 298 pci_set_drvdata(pdev, card);
312 card->ports[0].dev = alloc_hdlcdev(&card->ports[0]); 299 card->ports[0].netdev = alloc_hdlcdev(&card->ports[0]);
313 card->ports[1].dev = alloc_hdlcdev(&card->ports[1]); 300 card->ports[1].netdev = alloc_hdlcdev(&card->ports[1]);
314 if (!card->ports[0].dev || !card->ports[1].dev) { 301 if (!card->ports[0].netdev || !card->ports[1].netdev) {
315 printk(KERN_ERR "pci200syn: unable to allocate memory\n"); 302 printk(KERN_ERR "pci200syn: unable to allocate memory\n");
316 pci200_pci_remove_one(pdev); 303 pci200_pci_remove_one(pdev);
317 return -ENOMEM; 304 return -ENOMEM;
@@ -399,9 +386,9 @@ static int __devinit pci200_pci_init_one(struct pci_dev *pdev,
399 386
400 for (i = 0; i < 2; i++) { 387 for (i = 0; i < 2; i++) {
401 port_t *port = &card->ports[i]; 388 port_t *port = &card->ports[i];
402 struct net_device *dev = port_to_dev(port); 389 struct net_device *dev = port->netdev;
403 hdlc_device *hdlc = dev_to_hdlc(dev); 390 hdlc_device *hdlc = dev_to_hdlc(dev);
404 port->phy_node = i; 391 port->chan = i;
405 392
406 spin_lock_init(&port->lock); 393 spin_lock_init(&port->lock);
407 dev->irq = card->irq; 394 dev->irq = card->irq;
@@ -424,8 +411,8 @@ static int __devinit pci200_pci_init_one(struct pci_dev *pdev,
424 return -ENOBUFS; 411 return -ENOBUFS;
425 } 412 }
426 413
427 printk(KERN_INFO "%s: PCI200SYN node %d\n", 414 printk(KERN_INFO "%s: PCI200SYN channel %d\n",
428 dev->name, port->phy_node); 415 dev->name, port->chan);
429 } 416 }
430 417
431 sca_flush(card); 418 sca_flush(card);