From: Peng Li <[email protected]>
This patchset clean up some code style issues.
Peng Li (7):
net: hdlc: remove redundant blank lines
net: hdlc: add blank line after declarations
net: hdlc: fix an code style issue about "foo* bar"
net: hdlc: fix an code style issue about EXPORT_SYMBOL(foo)
net: hdlc: replace comparison to NULL with "!param"
net: hdlc: move out assignment in if condition
net: hdlc: add braces {} to all arms of the statement
drivers/net/wan/hdlc.c | 63 ++++++++++++++++++--------------------------------
1 file changed, 23 insertions(+), 40 deletions(-)
--
2.8.1
From: Peng Li <[email protected]>
This patch fixes the checkpatch error about missing a blank line
after declarations.
Signed-off-by: Peng Li <[email protected]>
Signed-off-by: Guangbin Huang <[email protected]>
---
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 0883302..6199a70 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)
--
2.8.1
From: Peng Li <[email protected]>
According to the chackpatch.pl, comparison to NULL could
be written "!param".
Signed-off-by: Peng Li <[email protected]>
Signed-off-by: Guangbin Huang <[email protected]>
---
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 13388ba..fefc732 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;
}
--
2.8.1
From: Peng Li <[email protected]>
This patch removes some redundant blank lines.
Signed-off-by: Peng Li <[email protected]>
Signed-off-by: Guangbin Huang <[email protected]>
---
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 1bdd3df..0883302 100644
--- a/drivers/net/wan/hdlc.c
+++ b/drivers/net/wan/hdlc.c
@@ -36,7 +36,6 @@
#include <linux/slab.h>
#include <net/net_namespace.h>
-
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 @@ static int hdlc_device_event(struct notifier_block *this, unsigned long event,
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 <[email protected]>");
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);
--
2.8.1
From: Peng Li <[email protected]>
Fix the checkpatch error as "foo* bar" and should be "foo *bar".
Signed-off-by: Peng Li <[email protected]>
Signed-off-by: Guangbin Huang <[email protected]>
---
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 6199a70..3cdb641 100644
--- a/drivers/net/wan/hdlc.c
+++ b/drivers/net/wan/hdlc.c
@@ -36,7 +36,7 @@
#include <linux/slab.h>
#include <net/net_namespace.h>
-static const char* version = "HDLC support module revision 1.22";
+static const char *version = "HDLC support module revision 1.22";
#undef DEBUG_LINK
--
2.8.1
From: Peng Li <[email protected]>
Braces {} should be used on all arms of this statement.
Signed-off-by: Peng Li <[email protected]>
Signed-off-by: Guangbin Huang <[email protected]>
---
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 f48d70e..dd6312b 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;
--
2.8.1
From: Peng Li <[email protected]>
According to the chackpatch.pl,
EXPORT_SYMBOL(foo); should immediately follow its function/variable.
Signed-off-by: Peng Li <[email protected]>
Signed-off-by: Guangbin Huang <[email protected]>
---
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 3cdb641..13388ba 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 <[email protected]>");
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,
--
2.8.1
From: Peng Li <[email protected]>
Should not use assignment in if condition.
Signed-off-by: Peng Li <[email protected]>
Signed-off-by: Guangbin Huang <[email protected]>
---
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 fefc732..f48d70e 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;
--
2.8.1
Hello:
This series was applied to netdev/net-next.git (refs/heads/master):
On Tue, 1 Jun 2021 21:23:15 +0800 you wrote:
> From: Peng Li <[email protected]>
>
> This patchset clean up some code style issues.
>
> Peng Li (7):
> net: hdlc: remove redundant blank lines
> net: hdlc: add blank line after declarations
> net: hdlc: fix an code style issue about "foo* bar"
> net: hdlc: fix an code style issue about EXPORT_SYMBOL(foo)
> net: hdlc: replace comparison to NULL with "!param"
> net: hdlc: move out assignment in if condition
> net: hdlc: add braces {} to all arms of the statement
>
> [...]
Here is the summary with links:
- [net-next,1/7] net: hdlc: remove redundant blank lines
https://git.kernel.org/netdev/net-next/c/30cd458be244
- [net-next,2/7] net: hdlc: add blank line after declarations
https://git.kernel.org/netdev/net-next/c/04cc04f07bb2
- [net-next,3/7] net: hdlc: fix an code style issue about "foo* bar"
https://git.kernel.org/netdev/net-next/c/68fd73925bce
- [net-next,4/7] net: hdlc: fix an code style issue about EXPORT_SYMBOL(foo)
https://git.kernel.org/netdev/net-next/c/01506939cc84
- [net-next,5/7] net: hdlc: replace comparison to NULL with "!param"
https://git.kernel.org/netdev/net-next/c/387847f295c8
- [net-next,6/7] net: hdlc: move out assignment in if condition
https://git.kernel.org/netdev/net-next/c/e50eb6c3578c
- [net-next,7/7] net: hdlc: add braces {} to all arms of the statement
https://git.kernel.org/netdev/net-next/c/1bb521825265
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html