Commit dac81152 authored by David S. Miller's avatar David S. Miller

Merge branch 'lapbther-cleanups'

Peng Li says:

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

This patchset clean up some code style issues.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 4724acc4 63a2bb15
...@@ -44,7 +44,8 @@ ...@@ -44,7 +44,8 @@
static const u8 bcast_addr[6] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; static const u8 bcast_addr[6] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
/* If this number is made larger, check that the temporary string buffer /* If this number is made larger, check that the temporary string buffer
* in lapbeth_new_device is large enough to store the probe device name.*/ * in lapbeth_new_device is large enough to store the probe device name.
*/
#define MAXLAPBDEV 100 #define MAXLAPBDEV 100
struct lapbethdev { struct lapbethdev {
...@@ -64,8 +65,7 @@ static void lapbeth_disconnected(struct net_device *dev, int reason); ...@@ -64,8 +65,7 @@ static void lapbeth_disconnected(struct net_device *dev, int reason);
/* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */
/* /* Get the LAPB device for the ethernet device
* Get the LAPB device for the ethernet device
*/ */
static struct lapbethdev *lapbeth_get_x25_dev(struct net_device *dev) static struct lapbethdev *lapbeth_get_x25_dev(struct net_device *dev)
{ {
...@@ -105,10 +105,10 @@ static int lapbeth_napi_poll(struct napi_struct *napi, int budget) ...@@ -105,10 +105,10 @@ static int lapbeth_napi_poll(struct napi_struct *napi, int budget)
return processed; return processed;
} }
/* /* Receive a LAPB frame via an ethernet interface.
* Receive a LAPB frame via an ethernet interface.
*/ */
static int lapbeth_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *ptype, struct net_device *orig_dev) static int lapbeth_rcv(struct sk_buff *skb, struct net_device *dev,
struct packet_type *ptype, struct net_device *orig_dev)
{ {
int len, err; int len, err;
struct lapbethdev *lapbeth; struct lapbethdev *lapbeth;
...@@ -116,7 +116,8 @@ static int lapbeth_rcv(struct sk_buff *skb, struct net_device *dev, struct packe ...@@ -116,7 +116,8 @@ static int lapbeth_rcv(struct sk_buff *skb, struct net_device *dev, struct packe
if (dev_net(dev) != &init_net) if (dev_net(dev) != &init_net)
goto drop; goto drop;
if ((skb = skb_share_check(skb, GFP_ATOMIC)) == NULL) skb = skb_share_check(skb, GFP_ATOMIC);
if (!skb)
return NET_RX_DROP; return NET_RX_DROP;
if (!pskb_may_pull(skb, 2)) if (!pskb_may_pull(skb, 2))
...@@ -137,7 +138,8 @@ static int lapbeth_rcv(struct sk_buff *skb, struct net_device *dev, struct packe ...@@ -137,7 +138,8 @@ static int lapbeth_rcv(struct sk_buff *skb, struct net_device *dev, struct packe
skb_pull(skb, 2); /* Remove the length bytes */ skb_pull(skb, 2); /* Remove the length bytes */
skb_trim(skb, len); /* Set the length of the data */ skb_trim(skb, len); /* Set the length of the data */
if ((err = lapb_data_received(lapbeth->axdev, skb)) != LAPB_OK) { err = lapb_data_received(lapbeth->axdev, skb);
if (err != LAPB_OK) {
printk(KERN_DEBUG "lapbether: lapb_data_received err - %d\n", err); printk(KERN_DEBUG "lapbether: lapb_data_received err - %d\n", err);
goto drop_unlock; goto drop_unlock;
} }
...@@ -177,8 +179,7 @@ static int lapbeth_data_indication(struct net_device *dev, struct sk_buff *skb) ...@@ -177,8 +179,7 @@ static int lapbeth_data_indication(struct net_device *dev, struct sk_buff *skb)
return NET_RX_SUCCESS; return NET_RX_SUCCESS;
} }
/* /* Send a LAPB frame via an ethernet interface
* Send a LAPB frame via an ethernet interface
*/ */
static netdev_tx_t lapbeth_xmit(struct sk_buff *skb, static netdev_tx_t lapbeth_xmit(struct sk_buff *skb,
struct net_device *dev) struct net_device *dev)
...@@ -219,7 +220,8 @@ static netdev_tx_t lapbeth_xmit(struct sk_buff *skb, ...@@ -219,7 +220,8 @@ static netdev_tx_t lapbeth_xmit(struct sk_buff *skb,
skb_pull(skb, 1); skb_pull(skb, 1);
if ((err = lapb_data_request(dev, skb)) != LAPB_OK) { err = lapb_data_request(dev, skb);
if (err != LAPB_OK) {
pr_err("lapb_data_request error - %d\n", err); pr_err("lapb_data_request error - %d\n", err);
goto drop; goto drop;
} }
...@@ -263,10 +265,8 @@ static void lapbeth_connected(struct net_device *dev, int reason) ...@@ -263,10 +265,8 @@ static void lapbeth_connected(struct net_device *dev, int reason)
unsigned char *ptr; unsigned char *ptr;
struct sk_buff *skb = __dev_alloc_skb(1, GFP_ATOMIC | __GFP_NOMEMALLOC); struct sk_buff *skb = __dev_alloc_skb(1, GFP_ATOMIC | __GFP_NOMEMALLOC);
if (!skb) { if (!skb)
pr_err("out of memory\n");
return; return;
}
ptr = skb_put(skb, 1); ptr = skb_put(skb, 1);
*ptr = X25_IFACE_CONNECT; *ptr = X25_IFACE_CONNECT;
...@@ -283,10 +283,8 @@ static void lapbeth_disconnected(struct net_device *dev, int reason) ...@@ -283,10 +283,8 @@ static void lapbeth_disconnected(struct net_device *dev, int reason)
unsigned char *ptr; unsigned char *ptr;
struct sk_buff *skb = __dev_alloc_skb(1, GFP_ATOMIC | __GFP_NOMEMALLOC); struct sk_buff *skb = __dev_alloc_skb(1, GFP_ATOMIC | __GFP_NOMEMALLOC);
if (!skb) { if (!skb)
pr_err("out of memory\n");
return; return;
}
ptr = skb_put(skb, 1); ptr = skb_put(skb, 1);
*ptr = X25_IFACE_DISCONNECT; *ptr = X25_IFACE_DISCONNECT;
...@@ -297,17 +295,16 @@ static void lapbeth_disconnected(struct net_device *dev, int reason) ...@@ -297,17 +295,16 @@ static void lapbeth_disconnected(struct net_device *dev, int reason)
napi_schedule(&lapbeth->napi); napi_schedule(&lapbeth->napi);
} }
/* /* Set AX.25 callsign
* Set AX.25 callsign
*/ */
static int lapbeth_set_mac_address(struct net_device *dev, void *addr) static int lapbeth_set_mac_address(struct net_device *dev, void *addr)
{ {
struct sockaddr *sa = addr; struct sockaddr *sa = addr;
memcpy(dev->dev_addr, sa->sa_data, dev->addr_len); memcpy(dev->dev_addr, sa->sa_data, dev->addr_len);
return 0; return 0;
} }
static const struct lapb_register_struct lapbeth_callbacks = { static const struct lapb_register_struct lapbeth_callbacks = {
.connect_confirmation = lapbeth_connected, .connect_confirmation = lapbeth_connected,
.connect_indication = lapbeth_connected, .connect_indication = lapbeth_connected,
...@@ -317,8 +314,7 @@ static const struct lapb_register_struct lapbeth_callbacks = { ...@@ -317,8 +314,7 @@ static const struct lapb_register_struct lapbeth_callbacks = {
.data_transmit = lapbeth_data_transmit, .data_transmit = lapbeth_data_transmit,
}; };
/* /* open/close a device
* open/close a device
*/ */
static int lapbeth_open(struct net_device *dev) static int lapbeth_open(struct net_device *dev)
{ {
...@@ -327,7 +323,8 @@ static int lapbeth_open(struct net_device *dev) ...@@ -327,7 +323,8 @@ static int lapbeth_open(struct net_device *dev)
napi_enable(&lapbeth->napi); napi_enable(&lapbeth->napi);
if ((err = lapb_register(dev, &lapbeth_callbacks)) != LAPB_OK) { err = lapb_register(dev, &lapbeth_callbacks);
if (err != LAPB_OK) {
pr_err("lapb_register error: %d\n", err); pr_err("lapb_register error: %d\n", err);
return -ENODEV; return -ENODEV;
} }
...@@ -348,7 +345,8 @@ static int lapbeth_close(struct net_device *dev) ...@@ -348,7 +345,8 @@ static int lapbeth_close(struct net_device *dev)
lapbeth->up = false; lapbeth->up = false;
spin_unlock_bh(&lapbeth->up_lock); spin_unlock_bh(&lapbeth->up_lock);
if ((err = lapb_unregister(dev)) != LAPB_OK) err = lapb_unregister(dev);
if (err != LAPB_OK)
pr_err("lapb_unregister error: %d\n", err); pr_err("lapb_unregister error: %d\n", err);
napi_disable(&lapbeth->napi); napi_disable(&lapbeth->napi);
...@@ -375,8 +373,7 @@ static void lapbeth_setup(struct net_device *dev) ...@@ -375,8 +373,7 @@ static void lapbeth_setup(struct net_device *dev)
dev->addr_len = 0; dev->addr_len = 0;
} }
/* /* Setup a new device.
* Setup a new device.
*/ */
static int lapbeth_new_device(struct net_device *dev) static int lapbeth_new_device(struct net_device *dev)
{ {
...@@ -427,8 +424,7 @@ static int lapbeth_new_device(struct net_device *dev) ...@@ -427,8 +424,7 @@ static int lapbeth_new_device(struct net_device *dev)
goto out; goto out;
} }
/* /* Free a lapb network device.
* Free a lapb network device.
*/ */
static void lapbeth_free_device(struct lapbethdev *lapbeth) static void lapbeth_free_device(struct lapbethdev *lapbeth)
{ {
...@@ -437,8 +433,7 @@ static void lapbeth_free_device(struct lapbethdev *lapbeth) ...@@ -437,8 +433,7 @@ static void lapbeth_free_device(struct lapbethdev *lapbeth)
unregister_netdevice(lapbeth->axdev); unregister_netdevice(lapbeth->axdev);
} }
/* /* Handle device status changes.
* Handle device status changes.
* *
* Called from notifier with RTNL held. * Called from notifier with RTNL held.
*/ */
...@@ -457,7 +452,7 @@ static int lapbeth_device_event(struct notifier_block *this, ...@@ -457,7 +452,7 @@ static int lapbeth_device_event(struct notifier_block *this,
switch (event) { switch (event) {
case NETDEV_UP: case NETDEV_UP:
/* New ethernet device -> new LAPB interface */ /* New ethernet device -> new LAPB interface */
if (lapbeth_get_x25_dev(dev) == NULL) if (!lapbeth_get_x25_dev(dev))
lapbeth_new_device(dev); lapbeth_new_device(dev);
break; break;
case NETDEV_GOING_DOWN: case NETDEV_GOING_DOWN:
......
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