o wan/cycx: further cleanups

. remove whitespaces
. use tabs instead of sequences of 8 spaces
. remove the wrappers for write{b,w} & friends
. align case entries with corresponding switch statement
parent 706245bb
......@@ -6,7 +6,7 @@
*
* Author: Arnaldo Carvalho de Melo <acme@conectiva.com.br>
*
* Copyright: (c) 1998-2000 Arnaldo Carvalho de Melo
* Copyright: (c) 1998-2003 Arnaldo Carvalho de Melo
*
* Based on sdladrv.c by Gene Kozin <genek@compuserve.com>
*
......@@ -66,12 +66,6 @@ MODULE_AUTHOR("Arnaldo Carvalho de Melo");
MODULE_DESCRIPTION("Cyclom 2x Sync Card Driver");
MODULE_LICENSE("GPL");
/* Function Prototypes */
/* Module entry points. These are called by the OS and must be public. */
int init_module(void);
void cleanup_module(void);
/* Hardware-specific functions */
static int load_cyc2x(cycxhw_t *hw, struct cycx_firmware *cfm, u32 len);
static void cycx_bootcfg(cycxhw_t *hw);
......@@ -86,27 +80,19 @@ static u16 checksum(u8 *buf, u32 len);
#define wait_cyc(addr) cycx_exec(addr + CMD_OFFSET)
#define cyc2x_readb(b) readb(b)
#define cyc2x_readw(b) readw(b)
#define cyc2x_writeb(b, addr) writeb(b, addr)
#define cyc2x_writew(w, addr) writew(w, addr)
#define cyc2x_memcpy_toio(addr, buf, len) memcpy_toio((addr), buf, len)
#define cyc2x_memcpy_fromio(buf, addr, len) memcpy_fromio(buf, (addr), len)
/* Global Data */
/* private data */
static char modname[] = "cycx_drv";
static char fullname[] = "Cyclom 2X Support Module";
static char copyright[] = "(c) 1998-2000 Arnaldo Carvalho de Melo "
static char copyright[] = "(c) 1998-2003 Arnaldo Carvalho de Melo "
"<acme@conectiva.com.br>";
/* Hardware configuration options.
* These are arrays of configuration options used by verification routines.
* The first element of each array is its size (i.e. number of options).
*/
static u32 cyc2x_dpmbase_options[] =
{
static u32 cyc2x_dpmbase_options[] = {
20,
0xA0000, 0xA4000, 0xA8000, 0xAC000, 0xB0000, 0xB4000, 0xB8000,
0xBC000, 0xC0000, 0xC4000, 0xC8000, 0xCC000, 0xD0000, 0xD4000,
......@@ -204,14 +190,14 @@ int cycx_down(cycxhw_t *hw)
EXPORT_SYMBOL(cycx_inten);
void cycx_inten(cycxhw_t *hw)
{
cyc2x_writeb(0, hw->dpmbase);
writeb(0, hw->dpmbase);
}
/* Generate an interrupt to adapter's CPU. */
EXPORT_SYMBOL(cycx_intr);
void cycx_intr(cycxhw_t *hw)
{
cyc2x_writew(0, hw->dpmbase + GEN_CYCX_INTR);
writew(0, hw->dpmbase + GEN_CYCX_INTR);
}
/* Execute Adapter Command.
......@@ -223,7 +209,7 @@ int cycx_exec(u32 addr)
u16 i = 0;
/* wait till addr content is zeroed */
while (cyc2x_readw(addr)) {
while (readw(addr)) {
udelay(1000);
if (++i > 50)
......@@ -239,9 +225,9 @@ EXPORT_SYMBOL(cycx_peek);
int cycx_peek(cycxhw_t *hw, u32 addr, void *buf, u32 len)
{
if (len == 1)
*(u8*)buf = cyc2x_readb(hw->dpmbase + addr);
*(u8*)buf = readb(hw->dpmbase + addr);
else
cyc2x_memcpy_fromio(buf, hw->dpmbase + addr, len);
memcpy_fromio(buf, hw->dpmbase + addr, len);
return 0;
}
......@@ -252,9 +238,9 @@ EXPORT_SYMBOL(cycx_poke);
int cycx_poke(cycxhw_t *hw, u32 addr, void *buf, u32 len)
{
if (len == 1)
cyc2x_writeb(*(u8*)buf, hw->dpmbase + addr);
writeb(*(u8*)buf, hw->dpmbase + addr);
else
cyc2x_memcpy_toio(hw->dpmbase + addr, buf, len);
memcpy_toio(hw->dpmbase + addr, buf, len);
return 0;
}
......@@ -269,10 +255,10 @@ static int memory_exists(u32 addr)
int tries = 0;
for (; tries < 3 ; tries++) {
cyc2x_writew(TEST_PATTERN, addr + 0x10);
writew(TEST_PATTERN, addr + 0x10);
if (cyc2x_readw(addr + 0x10) == TEST_PATTERN)
if (cyc2x_readw(addr + 0x10) == TEST_PATTERN)
if (readw(addr + 0x10) == TEST_PATTERN)
if (readw(addr + 0x10) == TEST_PATTERN)
return 1;
delay_cycx(1);
......@@ -289,7 +275,7 @@ static void reset_load(u32 addr, u8 *buffer, u32 cnt)
for (i = 0 ; i < cnt ; i++) {
/* for (j = 0 ; j < 50 ; j++); Delay - FIXME busy waiting... */
cyc2x_writeb(*buffer++, pt_code++);
writeb(*buffer++, pt_code++);
}
}
......@@ -298,8 +284,8 @@ static void reset_load(u32 addr, u8 *buffer, u32 cnt)
* o wait for reset code to copy it to right portion of memory */
static int buffer_load(u32 addr, u8 *buffer, u32 cnt)
{
cyc2x_memcpy_toio(addr + DATA_OFFSET, buffer, cnt);
cyc2x_writew(GEN_BOOT_DAT, addr + CMD_OFFSET);
memcpy_toio(addr + DATA_OFFSET, buffer, cnt);
writew(GEN_BOOT_DAT, addr + CMD_OFFSET);
return wait_cyc(addr);
}
......@@ -308,14 +294,14 @@ static int buffer_load(u32 addr, u8 *buffer, u32 cnt)
static void cycx_start(u32 addr)
{
/* put in 0x30 offset the jump instruction to the code entry point */
cyc2x_writeb(0xea, addr + 0x30);
cyc2x_writeb(0x00, addr + 0x31);
cyc2x_writeb(0xc4, addr + 0x32);
cyc2x_writeb(0x00, addr + 0x33);
cyc2x_writeb(0x00, addr + 0x34);
writeb(0xea, addr + 0x30);
writeb(0x00, addr + 0x31);
writeb(0xc4, addr + 0x32);
writeb(0x00, addr + 0x33);
writeb(0x00, addr + 0x34);
/* cmd to start executing code */
cyc2x_writew(GEN_START, addr + CMD_OFFSET);
writew(GEN_START, addr + CMD_OFFSET);
}
/* Load and boot reset code. */
......@@ -323,15 +309,15 @@ static void cycx_reset_boot(u32 addr, u8 *code, u32 len)
{
u32 pt_start = addr + START_OFFSET;
cyc2x_writeb(0xea, pt_start++); /* jmp to f000:3f00 */
cyc2x_writeb(0x00, pt_start++);
cyc2x_writeb(0xfc, pt_start++);
cyc2x_writeb(0x00, pt_start++);
cyc2x_writeb(0xf0, pt_start);
writeb(0xea, pt_start++); /* jmp to f000:3f00 */
writeb(0x00, pt_start++);
writeb(0xfc, pt_start++);
writeb(0x00, pt_start++);
writeb(0xf0, pt_start);
reset_load(addr, code, len);
/* 80186 was in hold, go */
cyc2x_writeb(0, addr + START_CPU);
writeb(0, addr + START_CPU);
delay_cycx(1);
}
......@@ -342,15 +328,15 @@ static int cycx_data_boot(u32 addr, u8 *code, u32 len)
u32 i;
/* boot buffer lenght */
cyc2x_writew(CFM_LOAD_BUFSZ, pt_boot_cmd + sizeof(u16));
cyc2x_writew(GEN_DEFPAR, pt_boot_cmd);
writew(CFM_LOAD_BUFSZ, pt_boot_cmd + sizeof(u16));
writew(GEN_DEFPAR, pt_boot_cmd);
if (wait_cyc(addr) < 0)
return -1;
cyc2x_writew(0, pt_boot_cmd + sizeof(u16));
cyc2x_writew(0x4000, pt_boot_cmd + 2 * sizeof(u16));
cyc2x_writew(GEN_SET_SEG, pt_boot_cmd);
writew(0, pt_boot_cmd + sizeof(u16));
writew(0x4000, pt_boot_cmd + 2 * sizeof(u16));
writew(GEN_SET_SEG, pt_boot_cmd);
if (wait_cyc(addr) < 0)
return -1;
......@@ -373,21 +359,22 @@ static int cycx_code_boot(u32 addr, u8 *code, u32 len)
u32 i;
/* boot buffer lenght */
cyc2x_writew(CFM_LOAD_BUFSZ, pt_boot_cmd + sizeof(u16));
cyc2x_writew(GEN_DEFPAR, pt_boot_cmd);
writew(CFM_LOAD_BUFSZ, pt_boot_cmd + sizeof(u16));
writew(GEN_DEFPAR, pt_boot_cmd);
if (wait_cyc(addr) < 0)
return -1;
cyc2x_writew(0x0000, pt_boot_cmd + sizeof(u16));
cyc2x_writew(0xc400, pt_boot_cmd + 2 * sizeof(u16));
cyc2x_writew(GEN_SET_SEG, pt_boot_cmd);
writew(0x0000, pt_boot_cmd + sizeof(u16));
writew(0xc400, pt_boot_cmd + 2 * sizeof(u16));
writew(GEN_SET_SEG, pt_boot_cmd);
if (wait_cyc(addr) < 0)
return -1;
for (i = 0 ; i < len ; i += CFM_LOAD_BUFSZ)
if (buffer_load(addr, code + i,MIN(CFM_LOAD_BUFSZ,(len - i)))) {
if (buffer_load(addr, code + i,
MIN(CFM_LOAD_BUFSZ, (len - i)))) {
printk(KERN_ERR "%s: Error !!\n", modname);
return -1;
}
......@@ -478,11 +465,11 @@ static int load_cyc2x(cycxhw_t *hw, struct cycx_firmware *cfm, u32 len)
/* Load reset.bin */
cycx_reset_boot(hw->dpmbase, reset_image, img_hdr->reset_size);
/* reset is waiting for boot */
cyc2x_writew(GEN_POWER_ON, pt_cycld);
writew(GEN_POWER_ON, pt_cycld);
delay_cycx(1);
for (j = 0 ; j < 3 ; j++)
if (!cyc2x_readw(pt_cycld))
if (!readw(pt_cycld))
goto reset_loaded;
else
delay_cycx(1);
......@@ -530,7 +517,7 @@ static int load_cyc2x(cycxhw_t *hw, struct cycx_firmware *cfm, u32 len)
static void cycx_bootcfg(cycxhw_t *hw)
{
/* use fixed buffers */
cyc2x_writeb(FIXED_BUFFERS, hw->dpmbase + CONF_OFFSET);
writeb(FIXED_BUFFERS, hw->dpmbase + CONF_OFFSET);
}
/* Detect Cyclom 2x adapter.
......@@ -563,9 +550,9 @@ static int get_option_index(u32 *optlist, u32 optval)
/* Reset adapter's CPU. */
static int reset_cyc2x(u32 addr)
{
cyc2x_writeb(0, addr + RST_ENABLE);
writeb(0, addr + RST_ENABLE);
delay_cycx(2);
cyc2x_writeb(0, addr + RST_DISABLE);
writeb(0, addr + RST_DISABLE);
delay_cycx(2);
return memory_exists(addr);
......@@ -575,7 +562,7 @@ static int reset_cyc2x(u32 addr)
static void delay_cycx(int sec)
{
set_current_state(TASK_INTERRUPTIBLE);
schedule_timeout(sec*HZ);
schedule_timeout(sec * HZ);
}
/* Calculate 16-bit CRC using CCITT polynomial. */
......
......@@ -3,7 +3,7 @@
*
* Author: Arnaldo Carvalho de Melo <acme@conectiva.com.br>
*
* Copyright: (c) 1998-2001 Arnaldo Carvalho de Melo
* Copyright: (c) 1998-2003 Arnaldo Carvalho de Melo
*
* Based on sdlamain.c by Gene Kozin <genek@compuserve.com> &
* Jaspreet Singh <jaspreet@sangoma.com>
......@@ -75,7 +75,7 @@ static int shutdown(struct wan_device *wandev);
static int ioctl(struct wan_device *wandev, unsigned cmd, unsigned long arg);
/* Miscellaneous functions */
static irqreturn_t cycx_isr (int irq, void *dev_id, struct pt_regs *regs);
static irqreturn_t cycx_isr(int irq, void *dev_id, struct pt_regs *regs);
/* Global Data
* Note: All data must be explicitly initialized!!!
......@@ -103,7 +103,7 @@ static struct cycx_device *card_array; /* adapter data space */
* < 0 error.
* Context: process
*/
int __init cyclomx_init (void)
int __init cyclomx_init(void)
{
int cnt, err = -ENOMEM;
......@@ -156,7 +156,7 @@ out: return err;
* o unregister all adapters from the WAN router
* o release all remaining system resources
*/
static void __exit cyclomx_cleanup (void)
static void __exit cyclomx_cleanup(void)
{
int i = 0;
......@@ -316,7 +316,7 @@ static int ioctl(struct wan_device *wandev, unsigned cmd, unsigned long arg)
* o acknowledge Cyclom 2X hardware interrupt.
* o call protocol-specific interrupt service routine, if any.
*/
static irqreturn_t cycx_isr (int irq, void *dev_id, struct pt_regs *regs)
static irqreturn_t cycx_isr(int irq, void *dev_id, struct pt_regs *regs)
{
struct cycx_device *card = (struct cycx_device *)dev_id;
......@@ -348,12 +348,10 @@ void cyclomx_set_state(struct cycx_device *card, int state)
case WAN_CONNECTED:
string_state = "connected!";
break;
case WAN_DISCONNECTED:
string_state = "disconnected!";
break;
}
printk(KERN_INFO "%s: link %s\n", card->devname, string_state);
card->wandev.state = state;
}
......
......@@ -3,7 +3,7 @@
*
* Author: Arnaldo Carvalho de Melo <acme@conectiva.com.br>
*
* Copyright: (c) 1998-2001 Arnaldo Carvalho de Melo
* Copyright: (c) 1998-2003 Arnaldo Carvalho de Melo
*
* Based on sdla_x25.c by Gene Kozin <genek@compuserve.com>
*
......@@ -129,15 +129,15 @@ static int update(struct wan_device *wandev),
del_if(struct wan_device *wandev, struct net_device *dev);
/* Network device interface */
static int if_init (struct net_device *dev),
if_open (struct net_device *dev),
if_close (struct net_device *dev),
if_header (struct sk_buff *skb, struct net_device *dev,
static int if_init(struct net_device *dev),
if_open(struct net_device *dev),
if_close(struct net_device *dev),
if_header(struct sk_buff *skb, struct net_device *dev,
u16 type, void *daddr, void *saddr, unsigned len),
if_rebuild_hdr (struct sk_buff *skb),
if_send (struct sk_buff *skb, struct net_device *dev);
if_rebuild_hdr(struct sk_buff *skb),
if_send(struct sk_buff *skb, struct net_device *dev);
static struct net_device_stats * if_stats (struct net_device *dev);
static struct net_device_stats *if_stats(struct net_device *dev);
/* Interrupt handlers */
static void cyx_isr(struct cycx_device *card),
......@@ -160,23 +160,23 @@ static int x25_configure(struct cycx_device *card, TX25Config *conf),
x25_disconnect_response(struct cycx_device *card, u8 link, u8 lcn);
/* channel functions */
static int chan_connect (struct net_device *dev),
chan_send (struct net_device *dev, struct sk_buff *skb);
static int chan_connect(struct net_device *dev),
chan_send(struct net_device *dev, struct sk_buff *skb);
static void chan_disconnect (struct net_device *dev),
static void chan_disconnect(struct net_device *dev),
chan_x25_send_event(struct net_device *dev, u8 event);
/* Miscellaneous functions */
static void set_chan_state (struct net_device *dev, u8 state),
chan_timer (unsigned long d);
static void set_chan_state(struct net_device *dev, u8 state),
chan_timer(unsigned long d);
static void nibble_to_byte (u8 *s, u8 *d, u8 len, u8 nibble),
reset_timer (struct net_device *dev);
static void nibble_to_byte(u8 *s, u8 *d, u8 len, u8 nibble),
reset_timer(struct net_device *dev);
static u8 bps_to_speed_code (u32 bps);
static u8 log2 (u32 n);
static u8 bps_to_speed_code(u32 bps);
static u8 log2(u32 n);
static unsigned dec_to_uint (u8 *str, int len);
static unsigned dec_to_uint(u8 *str, int len);
static struct net_device *get_dev_by_lcn(struct wan_device *wandev, s16 lcn);
static struct net_device *get_dev_by_dte_addr(struct wan_device *wandev,
......@@ -354,7 +354,8 @@ static int new_if(struct wan_device *wandev, struct net_device *dev,
int err = 0;
if (!conf->name[0] || strlen(conf->name) > WAN_IFNAME_SZ) {
printk(KERN_INFO "%s: invalid interface name!\n",card->devname);
printk(KERN_INFO "%s: invalid interface name!\n",
card->devname);
return -EINVAL;
}
......@@ -539,7 +540,7 @@ static int if_close(struct net_device *dev)
* set skb->protocol to 0 and discard packet later.
*
* Return: media header length. */
static int if_header (struct sk_buff *skb, struct net_device *dev,
static int if_header(struct sk_buff *skb, struct net_device *dev,
u16 type, void *daddr, void *saddr, unsigned len)
{
skb->protocol = type;
......@@ -550,7 +551,7 @@ static int if_header (struct sk_buff *skb, struct net_device *dev,
/* * Re-build media header.
* Return: 1 physical address resolved.
* 0 physical address not resolved */
static int if_rebuild_hdr (struct sk_buff *skb)
static int if_rebuild_hdr(struct sk_buff *skb)
{
return 1;
}
......@@ -570,7 +571,7 @@ static int if_rebuild_hdr (struct sk_buff *skb)
* bottom half" (with interrupts enabled).
* 2. Setting tbusy flag will inhibit further transmit requests from the
* protocol stack and can be used for flow control with protocol layer. */
static int if_send (struct sk_buff *skb, struct net_device *dev)
static int if_send(struct sk_buff *skb, struct net_device *dev)
{
x25_channel_t *chan = dev->priv;
struct cycx_device *card = chan->card;
......@@ -644,7 +645,7 @@ static int if_send (struct sk_buff *skb, struct net_device *dev)
/* Get Ethernet-style interface statistics.
* Return a pointer to struct net_device_stats */
static struct net_device_stats *if_stats (struct net_device *dev)
static struct net_device_stats *if_stats(struct net_device *dev)
{
x25_channel_t *chan = dev->priv;
......@@ -1049,7 +1050,7 @@ static int x25_configure(struct cycx_device *card, TX25Config *conf)
TX25Config conf[2];
} x25_cmd_conf;
memset (&x25_cmd_conf, 0, sizeof(x25_cmd_conf));
memset(&x25_cmd_conf, 0, sizeof(x25_cmd_conf));
x25_cmd_conf.nlinks = 2;
x25_cmd_conf.conf[0] = *conf;
/* FIXME: we need to find a way in the wanrouter framework
......@@ -1293,7 +1294,7 @@ static struct net_device *get_dev_by_dte_addr(struct wan_device *wandev,
* Return: 0 connected
* >0 connection in progress
* <0 failure */
static int chan_connect (struct net_device *dev)
static int chan_connect(struct net_device *dev)
{
x25_channel_t *chan = dev->priv;
struct cycx_device *card = chan->card;
......@@ -1318,7 +1319,7 @@ static int chan_connect (struct net_device *dev)
/* Disconnect logical channel.
* o if SVC then clear X.25 call */
static void chan_disconnect (struct net_device *dev)
static void chan_disconnect(struct net_device *dev)
{
x25_channel_t *chan = dev->priv;
......@@ -1330,7 +1331,7 @@ static void chan_disconnect (struct net_device *dev)
}
/* Called by kernel timer */
static void chan_timer (unsigned long d)
static void chan_timer(unsigned long d)
{
struct net_device *dev = (struct net_device *)d;
x25_channel_t *chan = dev->priv;
......@@ -1343,7 +1344,7 @@ static void chan_timer (unsigned long d)
}
/* Set logical channel state. */
static void set_chan_state (struct net_device *dev, u8 state)
static void set_chan_state(struct net_device *dev, u8 state)
{
x25_channel_t *chan = dev->priv;
struct cycx_device *card = chan->card;
......@@ -1367,15 +1368,12 @@ static void set_chan_state (struct net_device *dev, u8 state)
chan_x25_send_event(dev, 1);
break;
case WAN_CONNECTING:
string_state = "connecting...";
break;
case WAN_DISCONNECTING:
string_state = "disconnecting...";
break;
case WAN_DISCONNECTED:
string_state = "disconnected!";
......@@ -1391,7 +1389,7 @@ static void set_chan_state (struct net_device *dev, u8 state)
break;
}
printk (KERN_INFO "%s: interface %s %s\n", card->devname,
printk(KERN_INFO "%s: interface %s %s\n", card->devname,
dev->name, string_state);
chan->state = state;
}
......@@ -1412,7 +1410,7 @@ static void set_chan_state (struct net_device *dev, u8 state)
* the packet into 'complete sequence' using M-bit.
* 2. When transmission is complete, an event notification should be issued
* to the router. */
static int chan_send (struct net_device *dev, struct sk_buff *skb)
static int chan_send(struct net_device *dev, struct sk_buff *skb)
{
x25_channel_t *chan = dev->priv;
struct cycx_device *card = chan->card;
......@@ -1463,7 +1461,7 @@ static void chan_x25_send_event(struct net_device *dev, u8 event)
}
/* Convert line speed in bps to a number used by cyclom 2x code. */
static u8 bps_to_speed_code (u32 bps)
static u8 bps_to_speed_code(u32 bps)
{
u8 number = 0; /* defaults to the lowest (1200) speed ;> */
......@@ -1480,7 +1478,7 @@ static u8 bps_to_speed_code (u32 bps)
}
/* log base 2 */
static u8 log2 (u32 n)
static u8 log2(u32 n)
{
u8 log = 0;
......@@ -1497,7 +1495,7 @@ static u8 log2 (u32 n)
/* Convert decimal string to unsigned integer.
* If len != 0 then only 'len' characters of the string are converted. */
static unsigned dec_to_uint (u8 *str, int len)
static unsigned dec_to_uint(u8 *str, int len)
{
unsigned val = 0;
......
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