From 30cd458be244a929e929512fa63bbcf45225e752 Mon Sep 17 00:00:00 2001 From: Peng Li Date: Tue, 1 Jun 2021 21:23:16 +0800 Subject: net: hdlc: 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/hdlc.c | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/drivers/net/wan/hdlc.c b/drivers/net/wan/hdlc.c index 1bdd3df0867a..08833023b116 100644 --- a/drivers/net/wan/hdlc.c +++ b/drivers/net/wan/hdlc.c @@ -36,7 +36,6 @@ #include #include - static const char* version = "HDLC support module revision 1.22"; #undef DEBUG_LINK @@ -82,8 +81,6 @@ static inline void hdlc_proto_start(struct net_device *dev) hdlc->proto->start(dev); } - - static inline void hdlc_proto_stop(struct net_device *dev) { hdlc_device *hdlc = dev_to_hdlc(dev); @@ -91,8 +88,6 @@ static inline void hdlc_proto_stop(struct net_device *dev) hdlc->proto->stop(dev); } - - static int hdlc_device_event(struct notifier_block *this, unsigned long event, void *ptr) { @@ -141,8 +136,6 @@ carrier_exit: return NOTIFY_DONE; } - - /* Must be called by hardware driver when HDLC device is being opened */ int hdlc_open(struct net_device *dev) { @@ -175,8 +168,6 @@ int hdlc_open(struct net_device *dev) return 0; } - - /* Must be called by hardware driver when HDLC device is being closed */ void hdlc_close(struct net_device *dev) { @@ -198,8 +189,6 @@ void hdlc_close(struct net_device *dev) hdlc->proto->close(dev); } - - int hdlc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) { struct hdlc_proto *proto = first_proto; @@ -271,8 +260,6 @@ void unregister_hdlc_device(struct net_device *dev) rtnl_unlock(); } - - int attach_hdlc_protocol(struct net_device *dev, struct hdlc_proto *proto, size_t size) { @@ -297,7 +284,6 @@ int attach_hdlc_protocol(struct net_device *dev, struct hdlc_proto *proto, return 0; } - int detach_hdlc_protocol(struct net_device *dev) { hdlc_device *hdlc = dev_to_hdlc(dev); @@ -323,7 +309,6 @@ int detach_hdlc_protocol(struct net_device *dev) return 0; } - void register_hdlc_protocol(struct hdlc_proto *proto) { rtnl_lock(); @@ -332,7 +317,6 @@ void register_hdlc_protocol(struct hdlc_proto *proto) rtnl_unlock(); } - void unregister_hdlc_protocol(struct hdlc_proto *proto) { struct hdlc_proto **p; @@ -347,8 +331,6 @@ void unregister_hdlc_protocol(struct hdlc_proto *proto) rtnl_unlock(); } - - MODULE_AUTHOR("Krzysztof Halasa "); MODULE_DESCRIPTION("HDLC support module"); MODULE_LICENSE("GPL v2"); @@ -369,12 +351,10 @@ static struct packet_type hdlc_packet_type __read_mostly = { .func = hdlc_rcv, }; - static struct notifier_block hdlc_notifier = { .notifier_call = hdlc_device_event, }; - static int __init hdlc_module_init(void) { int result; @@ -386,14 +366,11 @@ static int __init hdlc_module_init(void) return 0; } - - static void __exit hdlc_module_exit(void) { dev_remove_pack(&hdlc_packet_type); unregister_netdevice_notifier(&hdlc_notifier); } - module_init(hdlc_module_init); module_exit(hdlc_module_exit); -- cgit v1.2.3 From 04cc04f07bb25e5555b27f0d6069599f0da23cad Mon Sep 17 00:00:00 2001 From: Peng Li Date: Tue, 1 Jun 2021 21:23:17 +0800 Subject: net: hdlc: 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/hdlc.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/wan/hdlc.c b/drivers/net/wan/hdlc.c index 08833023b116..6199a705d3df 100644 --- a/drivers/net/wan/hdlc.c +++ b/drivers/net/wan/hdlc.c @@ -77,6 +77,7 @@ netdev_tx_t hdlc_start_xmit(struct sk_buff *skb, struct net_device *dev) static inline void hdlc_proto_start(struct net_device *dev) { hdlc_device *hdlc = dev_to_hdlc(dev); + if (hdlc->proto->start) hdlc->proto->start(dev); } @@ -84,6 +85,7 @@ static inline void hdlc_proto_start(struct net_device *dev) static inline void hdlc_proto_stop(struct net_device *dev) { hdlc_device *hdlc = dev_to_hdlc(dev); + if (hdlc->proto->stop) hdlc->proto->stop(dev); } @@ -150,6 +152,7 @@ int hdlc_open(struct net_device *dev) if (hdlc->proto->open) { int result = hdlc->proto->open(dev); + if (result) return result; } @@ -245,6 +248,7 @@ static void hdlc_setup(struct net_device *dev) struct net_device *alloc_hdlcdev(void *priv) { struct net_device *dev; + dev = alloc_netdev(sizeof(struct hdlc_device), "hdlc%d", NET_NAME_UNKNOWN, hdlc_setup); if (dev) -- cgit v1.2.3 From 68fd73925bce2d81e7144caf16519e6b7e80b6a1 Mon Sep 17 00:00:00 2001 From: Peng Li Date: Tue, 1 Jun 2021 21:23:18 +0800 Subject: net: hdlc: fix an 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: Guangbin Huang Signed-off-by: David S. Miller --- drivers/net/wan/hdlc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wan/hdlc.c b/drivers/net/wan/hdlc.c index 6199a705d3df..3cdb6417ffdb 100644 --- a/drivers/net/wan/hdlc.c +++ b/drivers/net/wan/hdlc.c @@ -36,7 +36,7 @@ #include #include -static const char* version = "HDLC support module revision 1.22"; +static const char *version = "HDLC support module revision 1.22"; #undef DEBUG_LINK -- cgit v1.2.3 From 01506939cc8466635fb05711a79f8eb2b5df1ff3 Mon Sep 17 00:00:00 2001 From: Peng Li Date: Tue, 1 Jun 2021 21:23:19 +0800 Subject: net: hdlc: fix an code style issue about EXPORT_SYMBOL(foo) According to the chackpatch.pl, EXPORT_SYMBOL(foo); should immediately follow its function/variable. Signed-off-by: Peng Li Signed-off-by: Guangbin Huang Signed-off-by: David S. Miller --- drivers/net/wan/hdlc.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/drivers/net/wan/hdlc.c b/drivers/net/wan/hdlc.c index 3cdb6417ffdb..13388bad88a3 100644 --- a/drivers/net/wan/hdlc.c +++ b/drivers/net/wan/hdlc.c @@ -73,6 +73,7 @@ netdev_tx_t hdlc_start_xmit(struct sk_buff *skb, struct net_device *dev) return hdlc->xmit(skb, dev); /* call hardware driver directly */ } +EXPORT_SYMBOL(hdlc_start_xmit); static inline void hdlc_proto_start(struct net_device *dev) { @@ -170,6 +171,7 @@ int hdlc_open(struct net_device *dev) spin_unlock_irq(&hdlc->state_lock); return 0; } +EXPORT_SYMBOL(hdlc_open); /* Must be called by hardware driver when HDLC device is being closed */ void hdlc_close(struct net_device *dev) @@ -191,6 +193,7 @@ void hdlc_close(struct net_device *dev) if (hdlc->proto->close) hdlc->proto->close(dev); } +EXPORT_SYMBOL(hdlc_close); int hdlc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) { @@ -215,6 +218,7 @@ int hdlc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) } return -EINVAL; } +EXPORT_SYMBOL(hdlc_ioctl); static const struct header_ops hdlc_null_ops; @@ -255,6 +259,7 @@ struct net_device *alloc_hdlcdev(void *priv) dev_to_hdlc(dev)->priv = priv; return dev; } +EXPORT_SYMBOL(alloc_hdlcdev); void unregister_hdlc_device(struct net_device *dev) { @@ -263,6 +268,7 @@ void unregister_hdlc_device(struct net_device *dev) unregister_netdevice(dev); rtnl_unlock(); } +EXPORT_SYMBOL(unregister_hdlc_device); int attach_hdlc_protocol(struct net_device *dev, struct hdlc_proto *proto, size_t size) @@ -287,6 +293,7 @@ int attach_hdlc_protocol(struct net_device *dev, struct hdlc_proto *proto, return 0; } +EXPORT_SYMBOL(attach_hdlc_protocol); int detach_hdlc_protocol(struct net_device *dev) { @@ -312,6 +319,7 @@ int detach_hdlc_protocol(struct net_device *dev) return 0; } +EXPORT_SYMBOL(detach_hdlc_protocol); void register_hdlc_protocol(struct hdlc_proto *proto) { @@ -320,6 +328,7 @@ void register_hdlc_protocol(struct hdlc_proto *proto) first_proto = proto; rtnl_unlock(); } +EXPORT_SYMBOL(register_hdlc_protocol); void unregister_hdlc_protocol(struct hdlc_proto *proto) { @@ -334,22 +343,12 @@ void unregister_hdlc_protocol(struct hdlc_proto *proto) *p = proto->next; rtnl_unlock(); } +EXPORT_SYMBOL(unregister_hdlc_protocol); MODULE_AUTHOR("Krzysztof Halasa "); MODULE_DESCRIPTION("HDLC support module"); MODULE_LICENSE("GPL v2"); -EXPORT_SYMBOL(hdlc_start_xmit); -EXPORT_SYMBOL(hdlc_open); -EXPORT_SYMBOL(hdlc_close); -EXPORT_SYMBOL(hdlc_ioctl); -EXPORT_SYMBOL(alloc_hdlcdev); -EXPORT_SYMBOL(unregister_hdlc_device); -EXPORT_SYMBOL(register_hdlc_protocol); -EXPORT_SYMBOL(unregister_hdlc_protocol); -EXPORT_SYMBOL(attach_hdlc_protocol); -EXPORT_SYMBOL(detach_hdlc_protocol); - static struct packet_type hdlc_packet_type __read_mostly = { .type = cpu_to_be16(ETH_P_HDLC), .func = hdlc_rcv, -- cgit v1.2.3 From 387847f295c86fe72693178ed1eab000154f98ff Mon Sep 17 00:00:00 2001 From: Peng Li Date: Tue, 1 Jun 2021 21:23:20 +0800 Subject: net: hdlc: replace comparison to NULL with "!param" According to the chackpatch.pl, comparison to NULL could be written "!param". Signed-off-by: Peng Li Signed-off-by: Guangbin Huang Signed-off-by: David S. Miller --- drivers/net/wan/hdlc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/wan/hdlc.c b/drivers/net/wan/hdlc.c index 13388bad88a3..fefc7321c0c4 100644 --- a/drivers/net/wan/hdlc.c +++ b/drivers/net/wan/hdlc.c @@ -148,7 +148,7 @@ int hdlc_open(struct net_device *dev) hdlc->carrier, hdlc->open); #endif - if (hdlc->proto == NULL) + if (!hdlc->proto) return -ENOSYS; /* no protocol attached */ if (hdlc->proto->open) { @@ -284,7 +284,7 @@ int attach_hdlc_protocol(struct net_device *dev, struct hdlc_proto *proto, if (size) { dev_to_hdlc(dev)->state = kmalloc(size, GFP_KERNEL); - if (dev_to_hdlc(dev)->state == NULL) { + if (!dev_to_hdlc(dev)->state) { module_put(proto->module); return -ENOBUFS; } -- cgit v1.2.3 From e50eb6c3578c6bd7c43c30bfa40a882f0815a2d2 Mon Sep 17 00:00:00 2001 From: Peng Li Date: Tue, 1 Jun 2021 21:23:21 +0800 Subject: net: hdlc: move out assignment in if condition Should not use assignment in if condition. Signed-off-by: Peng Li Signed-off-by: Guangbin Huang Signed-off-by: David S. Miller --- drivers/net/wan/hdlc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/net/wan/hdlc.c b/drivers/net/wan/hdlc.c index fefc7321c0c4..f48d70e7f3ba 100644 --- a/drivers/net/wan/hdlc.c +++ b/drivers/net/wan/hdlc.c @@ -212,7 +212,8 @@ int hdlc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) /* Not handled by currently attached protocol (if any) */ while (proto) { - if ((result = proto->ioctl(dev, ifr)) != -EINVAL) + result = proto->ioctl(dev, ifr); + if (result != -EINVAL) return result; proto = proto->next; } @@ -363,7 +364,8 @@ static int __init hdlc_module_init(void) int result; pr_info("%s\n", version); - if ((result = register_netdevice_notifier(&hdlc_notifier)) != 0) + result = register_netdevice_notifier(&hdlc_notifier); + if (result) return result; dev_add_pack(&hdlc_packet_type); return 0; -- cgit v1.2.3 From 1bb52182526552e31367ea521cf36d37ebb26966 Mon Sep 17 00:00:00 2001 From: Peng Li Date: Tue, 1 Jun 2021 21:23:22 +0800 Subject: net: hdlc: add braces {} to all arms of the statement Braces {} should be used on all arms of this statement. Signed-off-by: Peng Li Signed-off-by: Guangbin Huang Signed-off-by: David S. Miller --- drivers/net/wan/hdlc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/wan/hdlc.c b/drivers/net/wan/hdlc.c index f48d70e7f3ba..dd6312b69861 100644 --- a/drivers/net/wan/hdlc.c +++ b/drivers/net/wan/hdlc.c @@ -163,8 +163,9 @@ int hdlc_open(struct net_device *dev) if (hdlc->carrier) { netdev_info(dev, "Carrier detected\n"); hdlc_proto_start(dev); - } else + } else { netdev_info(dev, "No carrier\n"); + } hdlc->open = 1; -- cgit v1.2.3