Commit 1b19b3f7 authored by David S. Miller's avatar David S. Miller

Merge branch 'wan-cleanups'

Guangbin Huang says:

====================
net: wan: clean up some code style issues

This patchset clean up some code style issues.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 687c87ad 30cbb010
...@@ -32,9 +32,8 @@ ...@@ -32,9 +32,8 @@
#include <asm/io.h> #include <asm/io.h>
#include "hd64570.h" #include "hd64570.h"
static const char *version = "SDL RISCom/N2 driver version: 1.15";
static const char* version = "SDL RISCom/N2 driver version: 1.15"; static const char *devname = "RISCom/N2";
static const char* devname = "RISCom/N2";
#undef DEBUG_PKT #undef DEBUG_PKT
#define DEBUG_RINGS #define DEBUG_RINGS
...@@ -64,11 +63,9 @@ static char *hw; /* pointer to hw=xxx command line string */ ...@@ -64,11 +63,9 @@ static char *hw; /* pointer to hw=xxx command line string */
#define PCR_ENWIN 4 /* Open window */ #define PCR_ENWIN 4 /* Open window */
#define PCR_BUS16 8 /* 16-bit bus */ #define PCR_BUS16 8 /* 16-bit bus */
/* Memory Base Address Register */ /* Memory Base Address Register */
#define N2_BAR 2 #define N2_BAR 2
/* Page Scan Register */ /* Page Scan Register */
#define N2_PSR 4 #define N2_PSR 4
#define WIN16K 0x00 #define WIN16K 0x00
...@@ -78,7 +75,6 @@ static char *hw; /* pointer to hw=xxx command line string */ ...@@ -78,7 +75,6 @@ static char *hw; /* pointer to hw=xxx command line string */
#define PSR_DMAEN 0x80 #define PSR_DMAEN 0x80
#define PSR_PAGEBITS 0x0F #define PSR_PAGEBITS 0x0F
/* Modem Control Reg */ /* Modem Control Reg */
#define N2_MCR 6 #define N2_MCR 6
#define CLOCK_OUT_PORT1 0x80 #define CLOCK_OUT_PORT1 0x80
...@@ -90,7 +86,6 @@ static char *hw; /* pointer to hw=xxx command line string */ ...@@ -90,7 +86,6 @@ static char *hw; /* pointer to hw=xxx command line string */
#define DTR_PORT1 0x02 #define DTR_PORT1 0x02
#define DTR_PORT0 0x01 #define DTR_PORT0 0x01
typedef struct port_s { typedef struct port_s {
struct net_device *dev; struct net_device *dev;
struct card_s *card; struct card_s *card;
...@@ -106,9 +101,7 @@ typedef struct port_s { ...@@ -106,9 +101,7 @@ typedef struct port_s {
u8 rxs, txs, tmc; /* SCA registers */ u8 rxs, txs, tmc; /* SCA registers */
u8 phy_node; /* physical port # - 0 or 1 */ u8 phy_node; /* physical port # - 0 or 1 */
u8 log_node; /* logical port # */ u8 log_node; /* logical port # */
}port_t; } port_t;
typedef struct card_s { typedef struct card_s {
u8 __iomem *winbase; /* ISA window base address */ u8 __iomem *winbase; /* ISA window base address */
...@@ -122,13 +115,11 @@ typedef struct card_s { ...@@ -122,13 +115,11 @@ typedef struct card_s {
port_t ports[2]; port_t ports[2];
struct card_s *next_card; struct card_s *next_card;
}card_t; } card_t;
static card_t *first_card; static card_t *first_card;
static card_t **new_card = &first_card; static card_t **new_card = &first_card;
#define sca_reg(reg, card) (0x8000 | (card)->io | \ #define sca_reg(reg, card) (0x8000 | (card)->io | \
((reg) & 0x0F) | (((reg) & 0xF0) << 6)) ((reg) & 0x0F) | (((reg) & 0xF0) << 6))
#define sca_in(reg, card) inb(sca_reg(reg, card)) #define sca_in(reg, card) inb(sca_reg(reg, card))
...@@ -144,23 +135,20 @@ static card_t **new_card = &first_card; ...@@ -144,23 +135,20 @@ static card_t **new_card = &first_card;
#define get_port(card, port) ((card)->ports[port].valid ? \ #define get_port(card, port) ((card)->ports[port].valid ? \
&(card)->ports[port] : NULL) &(card)->ports[port] : NULL)
static __inline__ u8 sca_get_page(card_t *card) static __inline__ u8 sca_get_page(card_t *card)
{ {
return inb(card->io + N2_PSR) & PSR_PAGEBITS; return inb(card->io + N2_PSR) & PSR_PAGEBITS;
} }
static __inline__ void openwin(card_t *card, u8 page) static __inline__ void openwin(card_t *card, u8 page)
{ {
u8 psr = inb(card->io + N2_PSR); u8 psr = inb(card->io + N2_PSR);
outb((psr & ~PSR_PAGEBITS) | page, card->io + N2_PSR); outb((psr & ~PSR_PAGEBITS) | page, card->io + N2_PSR);
} }
#include "hd64570.c" #include "hd64570.c"
static void n2_set_iface(port_t *port) static void n2_set_iface(port_t *port)
{ {
card_t *card = port->card; card_t *card = port->card;
...@@ -170,7 +158,7 @@ static void n2_set_iface(port_t *port) ...@@ -170,7 +158,7 @@ static void n2_set_iface(port_t *port)
u8 rxs = port->rxs & CLK_BRG_MASK; u8 rxs = port->rxs & CLK_BRG_MASK;
u8 txs = port->txs & CLK_BRG_MASK; u8 txs = port->txs & CLK_BRG_MASK;
switch(port->settings.clock_type) { switch (port->settings.clock_type) {
case CLOCK_INT: case CLOCK_INT:
mcr |= port->phy_node ? CLOCK_OUT_PORT1 : CLOCK_OUT_PORT0; mcr |= port->phy_node ? CLOCK_OUT_PORT1 : CLOCK_OUT_PORT0;
rxs |= CLK_BRG_RX; /* BRG output */ rxs |= CLK_BRG_RX; /* BRG output */
...@@ -203,13 +191,12 @@ static void n2_set_iface(port_t *port) ...@@ -203,13 +191,12 @@ static void n2_set_iface(port_t *port)
sca_set_port(port); sca_set_port(port);
} }
static int n2_open(struct net_device *dev) static int n2_open(struct net_device *dev)
{ {
port_t *port = dev_to_port(dev); port_t *port = dev_to_port(dev);
int io = port->card->io; int io = port->card->io;
u8 mcr = inb(io + N2_MCR) | (port->phy_node ? TX422_PORT1:TX422_PORT0); u8 mcr = inb(io + N2_MCR) |
(port->phy_node ? TX422_PORT1 : TX422_PORT0);
int result; int result;
result = hdlc_open(dev); result = hdlc_open(dev);
...@@ -226,13 +213,12 @@ static int n2_open(struct net_device *dev) ...@@ -226,13 +213,12 @@ static int n2_open(struct net_device *dev)
return 0; return 0;
} }
static int n2_close(struct net_device *dev) static int n2_close(struct net_device *dev)
{ {
port_t *port = dev_to_port(dev); port_t *port = dev_to_port(dev);
int io = port->card->io; int io = port->card->io;
u8 mcr = inb(io+N2_MCR) | (port->phy_node ? TX422_PORT1 : TX422_PORT0); u8 mcr = inb(io + N2_MCR) |
(port->phy_node ? TX422_PORT1 : TX422_PORT0);
sca_close(dev); sca_close(dev);
mcr |= port->phy_node ? DTR_PORT1 : DTR_PORT0; /* set DTR OFF */ mcr |= port->phy_node ? DTR_PORT1 : DTR_PORT0; /* set DTR OFF */
...@@ -241,8 +227,6 @@ static int n2_close(struct net_device *dev) ...@@ -241,8 +227,6 @@ static int n2_close(struct net_device *dev)
return 0; return 0;
} }
static int n2_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) static int n2_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
{ {
const size_t size = sizeof(sync_serial_settings); const size_t size = sizeof(sync_serial_settings);
...@@ -259,7 +243,7 @@ static int n2_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) ...@@ -259,7 +243,7 @@ static int n2_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
if (cmd != SIOCWANDEV) if (cmd != SIOCWANDEV)
return hdlc_ioctl(dev, ifr, cmd); return hdlc_ioctl(dev, ifr, cmd);
switch(ifr->ifr_settings.type) { switch (ifr->ifr_settings.type) {
case IF_GET_IFACE: case IF_GET_IFACE:
ifr->ifr_settings.type = IF_IFACE_SYNC_SERIAL; ifr->ifr_settings.type = IF_IFACE_SYNC_SERIAL;
if (ifr->ifr_settings.size < size) { if (ifr->ifr_settings.size < size) {
...@@ -271,7 +255,7 @@ static int n2_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) ...@@ -271,7 +255,7 @@ static int n2_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
return 0; return 0;
case IF_IFACE_SYNC_SERIAL: case IF_IFACE_SYNC_SERIAL:
if(!capable(CAP_NET_ADMIN)) if (!capable(CAP_NET_ADMIN))
return -EPERM; return -EPERM;
if (copy_from_user(&new_line, line, size)) if (copy_from_user(&new_line, line, size))
...@@ -295,8 +279,6 @@ static int n2_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) ...@@ -295,8 +279,6 @@ static int n2_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
} }
} }
static void n2_destroy_card(card_t *card) static void n2_destroy_card(card_t *card)
{ {
int cnt; int cnt;
...@@ -304,6 +286,7 @@ static void n2_destroy_card(card_t *card) ...@@ -304,6 +286,7 @@ static void n2_destroy_card(card_t *card)
for (cnt = 0; cnt < 2; cnt++) for (cnt = 0; cnt < 2; cnt++)
if (card->ports[cnt].card) { if (card->ports[cnt].card) {
struct net_device *dev = port_to_dev(&card->ports[cnt]); struct net_device *dev = port_to_dev(&card->ports[cnt]);
unregister_hdlc_device(dev); unregister_hdlc_device(dev);
} }
...@@ -354,7 +337,7 @@ static int __init n2_run(unsigned long io, unsigned long irq, ...@@ -354,7 +337,7 @@ static int __init n2_run(unsigned long io, unsigned long irq,
} }
card = kzalloc(sizeof(card_t), GFP_KERNEL); card = kzalloc(sizeof(card_t), GFP_KERNEL);
if (card == NULL) if (!card)
return -ENOBUFS; return -ENOBUFS;
card->ports[0].dev = alloc_hdlcdev(&card->ports[0]); card->ports[0].dev = alloc_hdlcdev(&card->ports[0]);
...@@ -486,11 +469,9 @@ static int __init n2_run(unsigned long io, unsigned long irq, ...@@ -486,11 +469,9 @@ static int __init n2_run(unsigned long io, unsigned long irq,
return 0; return 0;
} }
static int __init n2_init(void) static int __init n2_init(void)
{ {
if (hw==NULL) { if (!hw) {
#ifdef MODULE #ifdef MODULE
pr_info("no card initialized\n"); pr_info("no card initialized\n");
#endif #endif
...@@ -515,7 +496,7 @@ static int __init n2_init(void) ...@@ -515,7 +496,7 @@ static int __init n2_init(void)
if (*hw++ != ',') if (*hw++ != ',')
break; break;
while(1) { while (1) {
if (*hw == '0' && !valid[0]) if (*hw == '0' && !valid[0])
valid[0] = 1; /* Port 0 enabled */ valid[0] = 1; /* Port 0 enabled */
else if (*hw == '1' && !valid[1]) else if (*hw == '1' && !valid[1])
...@@ -533,25 +514,24 @@ static int __init n2_init(void) ...@@ -533,25 +514,24 @@ static int __init n2_init(void)
if (*hw == '\x0') if (*hw == '\x0')
return first_card ? 0 : -EINVAL; return first_card ? 0 : -EINVAL;
}while(*hw++ == ':'); } while (*hw++ == ':');
pr_err("invalid hardware parameters\n"); pr_err("invalid hardware parameters\n");
return first_card ? 0 : -EINVAL; return first_card ? 0 : -EINVAL;
} }
static void __exit n2_cleanup(void) static void __exit n2_cleanup(void)
{ {
card_t *card = first_card; card_t *card = first_card;
while (card) { while (card) {
card_t *ptr = card; card_t *ptr = card;
card = card->next_card; card = card->next_card;
n2_destroy_card(ptr); n2_destroy_card(ptr);
} }
} }
module_init(n2_init); module_init(n2_init);
module_exit(n2_cleanup); module_exit(n2_cleanup);
......
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