From 93f764371c45bc3f1d859026f12ef6255c388a85 Mon Sep 17 00:00:00 2001 From: Peng Li Date: Fri, 11 Jun 2021 11:36:15 +0800 Subject: [PATCH 1/8] net: pc300too: remove redundant blank lines This patch removes some redundant blank lines. Signed-off-by: Peng Li Signed-off-by: Guangbin Huang Signed-off-by: David S. Miller --- drivers/net/wan/pc300too.c | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/drivers/net/wan/pc300too.c b/drivers/net/wan/pc300too.c index 001fd378d417..5ccaec97e3e9 100644 --- a/drivers/net/wan/pc300too.c +++ b/drivers/net/wan/pc300too.c @@ -52,7 +52,6 @@ static unsigned int CLOCK_BASE; #define PC300_CHMEDIA_MASK(port) (0x00000020UL << ((port) * 3)) #define PC300_CTYPE_MASK (0x00000800UL) - enum { PC300_RSV = 1, PC300_X21, PC300_TE }; /* card types */ /* @@ -71,8 +70,6 @@ typedef struct { u32 init_ctrl; /* 50h : EEPROM ctrl, Init Ctrl, etc */ }plx9050; - - typedef struct port_s { struct napi_struct napi; struct net_device *netdev; @@ -90,8 +87,6 @@ typedef struct port_s { u8 chan; /* physical port # - 0 or 1 */ }port_t; - - typedef struct card_s { int type; /* RSV, X21, etc. */ int n_ports; /* 1 or 2 ports */ @@ -107,13 +102,11 @@ typedef struct card_s { port_t ports[2]; }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; @@ -162,8 +155,6 @@ static void pc300_set_iface(port_t *port) } } - - static int pc300_open(struct net_device *dev) { port_t *port = dev_to_port(dev); @@ -177,8 +168,6 @@ static int pc300_open(struct net_device *dev) return 0; } - - static int pc300_close(struct net_device *dev) { sca_close(dev); @@ -186,8 +175,6 @@ static int pc300_close(struct net_device *dev) return 0; } - - static int pc300_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) { const size_t size = sizeof(sync_serial_settings); @@ -214,7 +201,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 && @@ -255,8 +241,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; @@ -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 }, @@ -486,7 +468,6 @@ static const struct pci_device_id pc300_pci_tbl[] = { { 0, } }; - static struct pci_driver pc300_pci_driver = { .name = "PC300", .id_table = pc300_pci_tbl, @@ -494,7 +475,6 @@ static struct pci_driver pc300_pci_driver = { .remove = pc300_pci_remove_one, }; - static int __init pc300_init_module(void) { if (pci_clock_freq < 1000000 || pci_clock_freq > 80000000) { @@ -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); From a657c8b4d50d33954a3f766c8876f31d323d32b9 Mon Sep 17 00:00:00 2001 From: Peng Li Date: Fri, 11 Jun 2021 11:36:16 +0800 Subject: [PATCH 2/8] net: pc300too: add blank line after declarations This patch fixes the checkpatch error about missing a blank line after declarations. Signed-off-by: Peng Li Signed-off-by: Guangbin Huang Signed-off-by: David S. Miller --- drivers/net/wan/pc300too.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/wan/pc300too.c b/drivers/net/wan/pc300too.c index 5ccaec97e3e9..8f592ff798fb 100644 --- a/drivers/net/wan/pc300too.c +++ b/drivers/net/wan/pc300too.c @@ -158,8 +158,8 @@ 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; @@ -426,6 +426,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); From f8864e26d3118ccf91d6a1ae5cdd18f4b56b7704 Mon Sep 17 00:00:00 2001 From: Peng Li Date: Fri, 11 Jun 2021 11:36:17 +0800 Subject: [PATCH 3/8] net: pc300too: fix the code style issue about "foo * bar" Fix the checkpatch error as "foo * bar" and should be "foo *bar". Signed-off-by: Peng Li Signed-off-by: David S. Miller --- drivers/net/wan/pc300too.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wan/pc300too.c b/drivers/net/wan/pc300too.c index 8f592ff798fb..17d5cb8287d4 100644 --- a/drivers/net/wan/pc300too.c +++ b/drivers/net/wan/pc300too.c @@ -110,7 +110,7 @@ typedef struct card_s { 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; From d72f78db55d6daa4542668de1b2cb4f974708a99 Mon Sep 17 00:00:00 2001 From: Peng Li Date: Fri, 11 Jun 2021 11:36:18 +0800 Subject: [PATCH 4/8] net: pc300too: move out assignment in if condition Should not use assignment in if condition. Signed-off-by: Peng Li Signed-off-by: David S. Miller --- drivers/net/wan/pc300too.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/net/wan/pc300too.c b/drivers/net/wan/pc300too.c index 17d5cb8287d4..7d8eae5ea140 100644 --- a/drivers/net/wan/pc300too.c +++ b/drivers/net/wan/pc300too.c @@ -349,12 +349,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; From ae6440483b545176b888bfe74971aa40a5749d46 Mon Sep 17 00:00:00 2001 From: Peng Li Date: Fri, 11 Jun 2021 11:36:19 +0800 Subject: [PATCH 5/8] net: pc300too: remove redundant initialization for statics Should not initialise statics to 0. Signed-off-by: Peng Li Signed-off-by: David S. Miller --- drivers/net/wan/pc300too.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wan/pc300too.c b/drivers/net/wan/pc300too.c index 7d8eae5ea140..56f7d96298a3 100644 --- a/drivers/net/wan/pc300too.c +++ b/drivers/net/wan/pc300too.c @@ -44,7 +44,7 @@ #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 */ From 0cd2135cf83dd183d3fe05658e17b67b5f6cba86 Mon Sep 17 00:00:00 2001 From: Peng Li Date: Fri, 11 Jun 2021 11:36:20 +0800 Subject: [PATCH 6/8] net: pc300too: replace comparison to NULL with "!card->plxbase" According to the chackpatch.pl, comparison to NULL could be written "!card->plxbase". Signed-off-by: Peng Li Signed-off-by: Guangbin Huang Signed-off-by: David S. Miller --- drivers/net/wan/pc300too.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/net/wan/pc300too.c b/drivers/net/wan/pc300too.c index 56f7d96298a3..ecce9992493d 100644 --- a/drivers/net/wan/pc300too.c +++ b/drivers/net/wan/pc300too.c @@ -298,7 +298,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; @@ -322,9 +322,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; From eed00311659fc5aaae7689b46c7740350199477d Mon Sep 17 00:00:00 2001 From: Peng Li Date: Fri, 11 Jun 2021 11:36:21 +0800 Subject: [PATCH 7/8] net: pc300too: add some required spaces Add spaces required before the open parenthesis '('. Add spaces required after that close brace '}'. Signed-off-by: Peng Li Signed-off-by: Guangbin Huang Signed-off-by: David S. Miller --- drivers/net/wan/pc300too.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/wan/pc300too.c b/drivers/net/wan/pc300too.c index ecce9992493d..885dcc5e597e 100644 --- a/drivers/net/wan/pc300too.c +++ b/drivers/net/wan/pc300too.c @@ -68,7 +68,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; @@ -85,7 +85,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. */ @@ -100,7 +100,7 @@ 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)) @@ -117,7 +117,7 @@ static void pc300_set_iface(port_t *port) 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 */ From ef1806a8b9615923c0719548b5fc96a9daa037b1 Mon Sep 17 00:00:00 2001 From: Peng Li Date: Fri, 11 Jun 2021 11:36:22 +0800 Subject: [PATCH 8/8] net: pc300too: fix the comments style issue Networking block comments don't use an empty /* line, use /* Comment... This patch fixes the comments style issues. Signed-off-by: Peng Li Signed-off-by: David S. Miller --- drivers/net/wan/pc300too.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/net/wan/pc300too.c b/drivers/net/wan/pc300too.c index 885dcc5e597e..7b123a771aa6 100644 --- a/drivers/net/wan/pc300too.c +++ b/drivers/net/wan/pc300too.c @@ -54,8 +54,7 @@ static unsigned int CLOCK_BASE; 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 {