Skip to content

Commit

Permalink
Merge branch 'pc300too'
Browse files Browse the repository at this point in the history
Peng Li says:

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

This patchset clean up some code style issues.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
David S. Miller committed Jun 11, 2021
2 parents 51a1ebc + ef1806a commit d41783b
Showing 1 changed file with 15 additions and 37 deletions.
52 changes: 15 additions & 37 deletions drivers/net/wan/pc300too.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,17 @@
#define MAX_TX_BUFFERS 10

static int pci_clock_freq = 33000000;
static int use_crystal_clock = 0;
static int use_crystal_clock;
static unsigned int CLOCK_BASE;

/* Masks to access the init_ctrl PLX register */
#define PC300_CLKSEL_MASK (0x00000004UL)
#define PC300_CHMEDIA_MASK(port) (0x00000020UL << ((port) * 3))
#define PC300_CTYPE_MASK (0x00000800UL)


enum { PC300_RSV = 1, PC300_X21, PC300_TE }; /* card types */

/*
* PLX PCI9050-1 local configuration and shared runtime registers.
/* PLX PCI9050-1 local configuration and shared runtime registers.
* This structure can be used to access 9050 registers (memory mapped).
*/
typedef struct {
Expand All @@ -69,9 +67,7 @@ typedef struct {
u32 cs_base[4]; /* 3C-48h : Chip Select Base Addrs */
u32 intr_ctrl_stat; /* 4Ch : Interrupt Control/Status */
u32 init_ctrl; /* 50h : EEPROM ctrl, Init Ctrl, etc */
}plx9050;


} plx9050;

typedef struct port_s {
struct napi_struct napi;
Expand All @@ -88,9 +84,7 @@ typedef struct port_s {
u16 txlast;
u8 rxs, txs, tmc; /* SCA registers */
u8 chan; /* physical port # - 0 or 1 */
}port_t;


} port_t;

typedef struct card_s {
int type; /* RSV, X21, etc. */
Expand All @@ -105,26 +99,24 @@ typedef struct card_s {
u8 irq; /* interrupt request level */

port_t ports[2];
}card_t;

} card_t;

#define get_port(card, port) ((port) < (card)->n_ports ? \
(&(card)->ports[port]) : (NULL))

#include "hd64572.c"


static void pc300_set_iface(port_t *port)
{
card_t *card = port->card;
u32 __iomem * init_ctrl = &card->plxbase->init_ctrl;
u32 __iomem *init_ctrl = &card->plxbase->init_ctrl;
u16 msci = get_msci(port);
u8 rxs = port->rxs & CLK_BRG_MASK;
u8 txs = port->txs & CLK_BRG_MASK;

sca_out(EXS_TES1, (port->chan ? MSCI1_OFFSET : MSCI0_OFFSET) + EXS,
port->card);
switch(port->settings.clock_type) {
switch (port->settings.clock_type) {
case CLOCK_INT:
rxs |= CLK_BRG; /* BRG output */
txs |= CLK_PIN_OUT | CLK_TX_RXCLK; /* RX clock */
Expand Down Expand Up @@ -162,13 +154,11 @@ static void pc300_set_iface(port_t *port)
}
}



static int pc300_open(struct net_device *dev)
{
port_t *port = dev_to_port(dev);

int result = hdlc_open(dev);

if (result)
return result;

Expand All @@ -177,17 +167,13 @@ static int pc300_open(struct net_device *dev)
return 0;
}



static int pc300_close(struct net_device *dev)
{
sca_close(dev);
hdlc_close(dev);
return 0;
}



static int pc300_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
{
const size_t size = sizeof(sync_serial_settings);
Expand All @@ -214,7 +200,6 @@ static int pc300_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
if (copy_to_user(line, &port->settings, size))
return -EFAULT;
return 0;

}

if (port->card->type == PC300_X21 &&
Expand Down Expand Up @@ -255,8 +240,6 @@ static int pc300_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
return 0;
}



static void pc300_pci_remove_one(struct pci_dev *pdev)
{
int i;
Expand Down Expand Up @@ -314,7 +297,7 @@ static int pc300_pci_init_one(struct pci_dev *pdev,
}

card = kzalloc(sizeof(card_t), GFP_KERNEL);
if (card == NULL) {
if (!card) {
pci_release_regions(pdev);
pci_disable_device(pdev);
return -ENOBUFS;
Expand All @@ -338,9 +321,7 @@ static int pc300_pci_init_one(struct pci_dev *pdev,
ramphys = pci_resource_start(pdev, 3) & PCI_BASE_ADDRESS_MEM_MASK;
card->rambase = pci_ioremap_bar(pdev, 3);

if (card->plxbase == NULL ||
card->scabase == NULL ||
card->rambase == NULL) {
if (!card->plxbase || !card->scabase || !card->rambase) {
pr_err("ioremap() failed\n");
pc300_pci_remove_one(pdev);
return -ENOMEM;
Expand All @@ -365,12 +346,14 @@ static int pc300_pci_init_one(struct pci_dev *pdev,
else
card->n_ports = 2;

for (i = 0; i < card->n_ports; i++)
if (!(card->ports[i].netdev = alloc_hdlcdev(&card->ports[i]))) {
for (i = 0; i < card->n_ports; i++) {
card->ports[i].netdev = alloc_hdlcdev(&card->ports[i]);
if (!card->ports[i].netdev) {
pr_err("unable to allocate memory\n");
pc300_pci_remove_one(pdev);
return -ENOMEM;
}
}

/* Reset PLX */
p = &card->plxbase->init_ctrl;
Expand Down Expand Up @@ -442,6 +425,7 @@ static int pc300_pci_init_one(struct pci_dev *pdev,
port_t *port = &card->ports[i];
struct net_device *dev = port->netdev;
hdlc_device *hdlc = dev_to_hdlc(dev);

port->chan = i;

spin_lock_init(&port->lock);
Expand Down Expand Up @@ -472,8 +456,6 @@ static int pc300_pci_init_one(struct pci_dev *pdev,
return 0;
}



static const struct pci_device_id pc300_pci_tbl[] = {
{ PCI_VENDOR_ID_CYCLADES, PCI_DEVICE_ID_PC300_RX_1, PCI_ANY_ID,
PCI_ANY_ID, 0, 0, 0 },
Expand All @@ -486,15 +468,13 @@ static const struct pci_device_id pc300_pci_tbl[] = {
{ 0, }
};


static struct pci_driver pc300_pci_driver = {
.name = "PC300",
.id_table = pc300_pci_tbl,
.probe = pc300_pci_init_one,
.remove = pc300_pci_remove_one,
};


static int __init pc300_init_module(void)
{
if (pci_clock_freq < 1000000 || pci_clock_freq > 80000000) {
Expand All @@ -511,8 +491,6 @@ static int __init pc300_init_module(void)
return pci_register_driver(&pc300_pci_driver);
}



static void __exit pc300_cleanup_module(void)
{
pci_unregister_driver(&pc300_pci_driver);
Expand Down

0 comments on commit d41783b

Please sign in to comment.