diff options
| author | Marc Kleine-Budde <mkl@pengutronix.de> | 2022-09-06 09:41:15 +0300 |
|---|---|---|
| committer | Marc Kleine-Budde <mkl@pengutronix.de> | 2022-09-06 09:41:15 +0300 |
| commit | bcedce7cf49da06d43bbd0eb47f9f4bcbbb6de12 (patch) | |
| tree | b82ed850922ee21d2c017bb2b1ecce5d2cd51dea /net/can/raw.c | |
| parent | 318d8235bcb8e9b6a42ce4a1190c23e577ed0833 (diff) | |
| parent | 170277c532780392051fee48260896ed280cfbef (diff) | |
| download | linux-bcedce7cf49da06d43bbd0eb47f9f4bcbbb6de12.tar.xz | |
Merge patch series "can: raw: random optimizations"
Ziyang Xuan <william.xuanziyang@huawei.com> says:
Do some small optimizations for can_raw.
Link: https://lore.kernel.org/all/cover.1661584485.git.william.xuanziyang@huawei.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Diffstat (limited to 'net/can/raw.c')
| -rw-r--r-- | net/can/raw.c | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/net/can/raw.c b/net/can/raw.c index d1bd9cc51ebe..e7dfa3584e29 100644 --- a/net/can/raw.c +++ b/net/can/raw.c @@ -136,14 +136,13 @@ static void raw_rcv(struct sk_buff *oskb, void *data) /* eliminate multiple filter matches for the same skb */ if (this_cpu_ptr(ro->uniq)->skb == oskb && this_cpu_ptr(ro->uniq)->skbcnt == can_skb_prv(oskb)->skbcnt) { - if (ro->join_filters) { - this_cpu_inc(ro->uniq->join_rx_count); - /* drop frame until all enabled filters matched */ - if (this_cpu_ptr(ro->uniq)->join_rx_count < ro->count) - return; - } else { + if (!ro->join_filters) + return; + + this_cpu_inc(ro->uniq->join_rx_count); + /* drop frame until all enabled filters matched */ + if (this_cpu_ptr(ro->uniq)->join_rx_count < ro->count) return; - } } else { this_cpu_ptr(ro->uniq)->skb = oskb; this_cpu_ptr(ro->uniq)->skbcnt = can_skb_prv(oskb)->skbcnt; @@ -942,12 +941,20 @@ static __init int raw_module_init(void) pr_info("can: raw protocol\n"); + err = register_netdevice_notifier(&canraw_notifier); + if (err) + return err; + err = can_proto_register(&raw_can_proto); - if (err < 0) + if (err < 0) { pr_err("can: registration of raw protocol failed\n"); - else - register_netdevice_notifier(&canraw_notifier); + goto register_proto_failed; + } + return 0; + +register_proto_failed: + unregister_netdevice_notifier(&canraw_notifier); return err; } |
