Commit 0a5519df authored by Alexander Viro's avatar Alexander Viro Committed by Stephen Hemminger

[wan hdlc] kill embedded struct in various drivers

Killed embedded hdlc in hd6457x.c derivatives (same as wanxl in previous
patch)
parent 9f361f7a
...@@ -54,7 +54,7 @@ static char *hw; /* pointer to hw=xxx command line string */ ...@@ -54,7 +54,7 @@ static char *hw; /* pointer to hw=xxx command line string */
typedef struct card_s { typedef struct card_s {
hdlc_device hdlc; /* HDLC device struct - must be first */ struct net_device *dev;
spinlock_t lock; /* TX lock */ spinlock_t lock; /* TX lock */
u8 *win0base; /* ISA window base address */ u8 *win0base; /* ISA window base address */
u32 phy_winbase; /* ISA physical base address */ u32 phy_winbase; /* ISA physical base address */
...@@ -287,6 +287,8 @@ static void c101_destroy_card(card_t *card) ...@@ -287,6 +287,8 @@ static void c101_destroy_card(card_t *card)
release_mem_region(card->phy_winbase, C101_MAPPED_RAM_SIZE); release_mem_region(card->phy_winbase, C101_MAPPED_RAM_SIZE);
} }
free_hdlcdev(card->dev);
kfree(card); kfree(card);
} }
...@@ -316,6 +318,13 @@ static int __init c101_run(unsigned long irq, unsigned long winbase) ...@@ -316,6 +318,13 @@ static int __init c101_run(unsigned long irq, unsigned long winbase)
} }
memset(card, 0, sizeof(card_t)); memset(card, 0, sizeof(card_t));
card->dev = alloc_hdlcdev(card);
if (!card->dev) {
printk(KERN_ERR "c101: unable to allocate memory\n");
kfree(card);
return -ENOBUFS;
}
if (request_irq(irq, sca_intr, 0, devname, card)) { if (request_irq(irq, sca_intr, 0, devname, card)) {
printk(KERN_ERR "c101: could not allocate IRQ\n"); printk(KERN_ERR "c101: could not allocate IRQ\n");
c101_destroy_card(card); c101_destroy_card(card);
...@@ -370,6 +379,8 @@ static int __init c101_run(unsigned long irq, unsigned long winbase) ...@@ -370,6 +379,8 @@ static int __init c101_run(unsigned long irq, unsigned long winbase)
return result; return result;
} }
/* XXX: are we OK with having that done when card is already up? */
sca_init_sync_port(card); /* Set up C101 memory */ sca_init_sync_port(card); /* Set up C101 memory */
hdlc_set_carrier(!(sca_in(MSCI1_OFFSET + ST3, card) & ST3_DCD), dev); hdlc_set_carrier(!(sca_in(MSCI1_OFFSET + ST3, card) & ST3_DCD), dev);
......
...@@ -75,7 +75,7 @@ ...@@ -75,7 +75,7 @@
static inline struct net_device *port_to_dev(port_t *port) static inline struct net_device *port_to_dev(port_t *port)
{ {
return hdlc_to_dev(&port->hdlc); return port->dev;
} }
static inline int sca_intr_status(card_t *card) static inline int sca_intr_status(card_t *card)
...@@ -117,7 +117,7 @@ static inline int sca_intr_status(card_t *card) ...@@ -117,7 +117,7 @@ static inline int sca_intr_status(card_t *card)
static inline port_t* dev_to_port(struct net_device *dev) static inline port_t* dev_to_port(struct net_device *dev)
{ {
return (port_t *)(dev_to_hdlc(dev)); return dev_to_hdlc(dev)->priv;
} }
static inline u16 next_desc(port_t *port, u16 desc, int transmit) static inline u16 next_desc(port_t *port, u16 desc, int transmit)
......
...@@ -92,7 +92,7 @@ static char *hw = NULL; /* pointer to hw=xxx command line string */ ...@@ -92,7 +92,7 @@ static char *hw = NULL; /* pointer to hw=xxx command line string */
typedef struct port_s { typedef struct port_s {
hdlc_device hdlc; /* HDLC device struct - must be first */ struct net_device *dev;
struct card_s *card; struct card_s *card;
spinlock_t lock; /* TX lock */ spinlock_t lock; /* TX lock */
sync_serial_settings settings; sync_serial_settings settings;
...@@ -324,6 +324,10 @@ static void n2_destroy_card(card_t *card) ...@@ -324,6 +324,10 @@ static void n2_destroy_card(card_t *card)
if (card->io) if (card->io)
release_region(card->io, N2_IOPORTS); release_region(card->io, N2_IOPORTS);
if (card->ports[0].dev)
free_hdlcdev(card->ports[0].dev);
if (card->ports[1].dev)
free_hdlcdev(card->ports[1].dev);
kfree(card); kfree(card);
} }
...@@ -358,6 +362,14 @@ static int __init n2_run(unsigned long io, unsigned long irq, ...@@ -358,6 +362,14 @@ static int __init n2_run(unsigned long io, unsigned long irq,
} }
memset(card, 0, sizeof(card_t)); memset(card, 0, sizeof(card_t));
card->ports[0].dev = alloc_hdlcdev(&card->ports[0]);
card->ports[1].dev = alloc_hdlcdev(&card->ports[1]);
if (!card->ports[0].dev || !card->ports[1].dev) {
printk(KERN_ERR "n2: unable to allocate memory\n");
n2_destroy_card(card);
return -ENOMEM;
}
if (!request_region(io, N2_IOPORTS, devname)) { if (!request_region(io, N2_IOPORTS, devname)) {
printk(KERN_ERR "n2: I/O port region in use\n"); printk(KERN_ERR "n2: I/O port region in use\n");
n2_destroy_card(card); n2_destroy_card(card);
...@@ -458,14 +470,15 @@ static int __init n2_run(unsigned long io, unsigned long irq, ...@@ -458,14 +470,15 @@ static int __init n2_run(unsigned long io, unsigned long irq,
hdlc->attach = sca_attach; hdlc->attach = sca_attach;
hdlc->xmit = sca_xmit; hdlc->xmit = sca_xmit;
port->settings.clock_type = CLOCK_EXT; port->settings.clock_type = CLOCK_EXT;
port->card = card;
if (register_hdlc_device(dev)) { if (register_hdlc_device(dev)) {
printk(KERN_WARNING "n2: unable to register hdlc " printk(KERN_WARNING "n2: unable to register hdlc "
"device\n"); "device\n");
port->card = NULL;
n2_destroy_card(card); n2_destroy_card(card);
return -ENOBUFS; return -ENOBUFS;
} }
port->card = card;
sca_init_sync_port(port); /* Set up SCA memory */ sca_init_sync_port(port); /* Set up SCA memory */
printk(KERN_INFO "%s: RISCom/N2 node %d\n", printk(KERN_INFO "%s: RISCom/N2 node %d\n",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment