Skip to content

Commit 686e846

Browse files
committed
Merge branch 'hdlc-cleanups'
Peng Li says: ==================== net: hdlc: clean up some code style issues This patchset clean up some code style issues. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 00460eb + 1bb5218 commit 686e846

File tree

1 file changed

+23
-40
lines changed

1 file changed

+23
-40
lines changed

drivers/net/wan/hdlc.c

Lines changed: 23 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@
3636
#include <linux/slab.h>
3737
#include <net/net_namespace.h>
3838

39-
40-
static const char* version = "HDLC support module revision 1.22";
39+
static const char *version = "HDLC support module revision 1.22";
4140

4241
#undef DEBUG_LINK
4342

@@ -74,25 +73,24 @@ netdev_tx_t hdlc_start_xmit(struct sk_buff *skb, struct net_device *dev)
7473

7574
return hdlc->xmit(skb, dev); /* call hardware driver directly */
7675
}
76+
EXPORT_SYMBOL(hdlc_start_xmit);
7777

7878
static inline void hdlc_proto_start(struct net_device *dev)
7979
{
8080
hdlc_device *hdlc = dev_to_hdlc(dev);
81+
8182
if (hdlc->proto->start)
8283
hdlc->proto->start(dev);
8384
}
8485

85-
86-
8786
static inline void hdlc_proto_stop(struct net_device *dev)
8887
{
8988
hdlc_device *hdlc = dev_to_hdlc(dev);
89+
9090
if (hdlc->proto->stop)
9191
hdlc->proto->stop(dev);
9292
}
9393

94-
95-
9694
static int hdlc_device_event(struct notifier_block *this, unsigned long event,
9795
void *ptr)
9896
{
@@ -141,8 +139,6 @@ static int hdlc_device_event(struct notifier_block *this, unsigned long event,
141139
return NOTIFY_DONE;
142140
}
143141

144-
145-
146142
/* Must be called by hardware driver when HDLC device is being opened */
147143
int hdlc_open(struct net_device *dev)
148144
{
@@ -152,11 +148,12 @@ int hdlc_open(struct net_device *dev)
152148
hdlc->carrier, hdlc->open);
153149
#endif
154150

155-
if (hdlc->proto == NULL)
151+
if (!hdlc->proto)
156152
return -ENOSYS; /* no protocol attached */
157153

158154
if (hdlc->proto->open) {
159155
int result = hdlc->proto->open(dev);
156+
160157
if (result)
161158
return result;
162159
}
@@ -166,16 +163,16 @@ int hdlc_open(struct net_device *dev)
166163
if (hdlc->carrier) {
167164
netdev_info(dev, "Carrier detected\n");
168165
hdlc_proto_start(dev);
169-
} else
166+
} else {
170167
netdev_info(dev, "No carrier\n");
168+
}
171169

172170
hdlc->open = 1;
173171

174172
spin_unlock_irq(&hdlc->state_lock);
175173
return 0;
176174
}
177-
178-
175+
EXPORT_SYMBOL(hdlc_open);
179176

180177
/* Must be called by hardware driver when HDLC device is being closed */
181178
void hdlc_close(struct net_device *dev)
@@ -197,8 +194,7 @@ void hdlc_close(struct net_device *dev)
197194
if (hdlc->proto->close)
198195
hdlc->proto->close(dev);
199196
}
200-
201-
197+
EXPORT_SYMBOL(hdlc_close);
202198

203199
int hdlc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
204200
{
@@ -217,12 +213,14 @@ int hdlc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
217213
/* Not handled by currently attached protocol (if any) */
218214

219215
while (proto) {
220-
if ((result = proto->ioctl(dev, ifr)) != -EINVAL)
216+
result = proto->ioctl(dev, ifr);
217+
if (result != -EINVAL)
221218
return result;
222219
proto = proto->next;
223220
}
224221
return -EINVAL;
225222
}
223+
EXPORT_SYMBOL(hdlc_ioctl);
226224

227225
static const struct header_ops hdlc_null_ops;
228226

@@ -256,12 +254,14 @@ static void hdlc_setup(struct net_device *dev)
256254
struct net_device *alloc_hdlcdev(void *priv)
257255
{
258256
struct net_device *dev;
257+
259258
dev = alloc_netdev(sizeof(struct hdlc_device), "hdlc%d",
260259
NET_NAME_UNKNOWN, hdlc_setup);
261260
if (dev)
262261
dev_to_hdlc(dev)->priv = priv;
263262
return dev;
264263
}
264+
EXPORT_SYMBOL(alloc_hdlcdev);
265265

266266
void unregister_hdlc_device(struct net_device *dev)
267267
{
@@ -270,8 +270,7 @@ void unregister_hdlc_device(struct net_device *dev)
270270
unregister_netdevice(dev);
271271
rtnl_unlock();
272272
}
273-
274-
273+
EXPORT_SYMBOL(unregister_hdlc_device);
275274

276275
int attach_hdlc_protocol(struct net_device *dev, struct hdlc_proto *proto,
277276
size_t size)
@@ -287,7 +286,7 @@ int attach_hdlc_protocol(struct net_device *dev, struct hdlc_proto *proto,
287286

288287
if (size) {
289288
dev_to_hdlc(dev)->state = kmalloc(size, GFP_KERNEL);
290-
if (dev_to_hdlc(dev)->state == NULL) {
289+
if (!dev_to_hdlc(dev)->state) {
291290
module_put(proto->module);
292291
return -ENOBUFS;
293292
}
@@ -296,7 +295,7 @@ int attach_hdlc_protocol(struct net_device *dev, struct hdlc_proto *proto,
296295

297296
return 0;
298297
}
299-
298+
EXPORT_SYMBOL(attach_hdlc_protocol);
300299

301300
int detach_hdlc_protocol(struct net_device *dev)
302301
{
@@ -322,7 +321,7 @@ int detach_hdlc_protocol(struct net_device *dev)
322321

323322
return 0;
324323
}
325-
324+
EXPORT_SYMBOL(detach_hdlc_protocol);
326325

327326
void register_hdlc_protocol(struct hdlc_proto *proto)
328327
{
@@ -331,7 +330,7 @@ void register_hdlc_protocol(struct hdlc_proto *proto)
331330
first_proto = proto;
332331
rtnl_unlock();
333332
}
334-
333+
EXPORT_SYMBOL(register_hdlc_protocol);
335334

336335
void unregister_hdlc_protocol(struct hdlc_proto *proto)
337336
{
@@ -346,54 +345,38 @@ void unregister_hdlc_protocol(struct hdlc_proto *proto)
346345
*p = proto->next;
347346
rtnl_unlock();
348347
}
349-
350-
348+
EXPORT_SYMBOL(unregister_hdlc_protocol);
351349

352350
MODULE_AUTHOR("Krzysztof Halasa <[email protected]>");
353351
MODULE_DESCRIPTION("HDLC support module");
354352
MODULE_LICENSE("GPL v2");
355353

356-
EXPORT_SYMBOL(hdlc_start_xmit);
357-
EXPORT_SYMBOL(hdlc_open);
358-
EXPORT_SYMBOL(hdlc_close);
359-
EXPORT_SYMBOL(hdlc_ioctl);
360-
EXPORT_SYMBOL(alloc_hdlcdev);
361-
EXPORT_SYMBOL(unregister_hdlc_device);
362-
EXPORT_SYMBOL(register_hdlc_protocol);
363-
EXPORT_SYMBOL(unregister_hdlc_protocol);
364-
EXPORT_SYMBOL(attach_hdlc_protocol);
365-
EXPORT_SYMBOL(detach_hdlc_protocol);
366-
367354
static struct packet_type hdlc_packet_type __read_mostly = {
368355
.type = cpu_to_be16(ETH_P_HDLC),
369356
.func = hdlc_rcv,
370357
};
371358

372-
373359
static struct notifier_block hdlc_notifier = {
374360
.notifier_call = hdlc_device_event,
375361
};
376362

377-
378363
static int __init hdlc_module_init(void)
379364
{
380365
int result;
381366

382367
pr_info("%s\n", version);
383-
if ((result = register_netdevice_notifier(&hdlc_notifier)) != 0)
368+
result = register_netdevice_notifier(&hdlc_notifier);
369+
if (result)
384370
return result;
385371
dev_add_pack(&hdlc_packet_type);
386372
return 0;
387373
}
388374

389-
390-
391375
static void __exit hdlc_module_exit(void)
392376
{
393377
dev_remove_pack(&hdlc_packet_type);
394378
unregister_netdevice_notifier(&hdlc_notifier);
395379
}
396380

397-
398381
module_init(hdlc_module_init);
399382
module_exit(hdlc_module_exit);

0 commit comments

Comments
 (0)