Commit 6625a18e authored by Marc Kleine-Budde's avatar Marc Kleine-Budde

can: af_can: give variable holding the CAN receiver and the receiver list a sensible name

This patch gives the variables holding the CAN receiver and the receiver
list a better name by renaming them from "r to "rcv" and "rl" to
"recv_list".
Signed-off-by: default avatarOleksij Rempel <o.rempel@pengutronix.de>
Acked-by: default avatarOliver Hartkopp <socketcan@hartkopp.net>
Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
parent fac78500
...@@ -438,8 +438,8 @@ int can_rx_register(struct net *net, struct net_device *dev, canid_t can_id, ...@@ -438,8 +438,8 @@ int can_rx_register(struct net *net, struct net_device *dev, canid_t can_id,
canid_t mask, void (*func)(struct sk_buff *, void *), canid_t mask, void (*func)(struct sk_buff *, void *),
void *data, char *ident, struct sock *sk) void *data, char *ident, struct sock *sk)
{ {
struct receiver *r; struct receiver *rcv;
struct hlist_head *rl; struct hlist_head *rcv_list;
struct can_dev_rcv_lists *dev_rcv_lists; struct can_dev_rcv_lists *dev_rcv_lists;
struct can_rcv_lists_stats *rcv_lists_stats = net->can.rcv_lists_stats; struct can_rcv_lists_stats *rcv_lists_stats = net->can.rcv_lists_stats;
int err = 0; int err = 0;
...@@ -452,32 +452,32 @@ int can_rx_register(struct net *net, struct net_device *dev, canid_t can_id, ...@@ -452,32 +452,32 @@ int can_rx_register(struct net *net, struct net_device *dev, canid_t can_id,
if (dev && !net_eq(net, dev_net(dev))) if (dev && !net_eq(net, dev_net(dev)))
return -ENODEV; return -ENODEV;
r = kmem_cache_alloc(rcv_cache, GFP_KERNEL); rcv = kmem_cache_alloc(rcv_cache, GFP_KERNEL);
if (!r) if (!rcv)
return -ENOMEM; return -ENOMEM;
spin_lock(&net->can.rcvlists_lock); spin_lock(&net->can.rcvlists_lock);
dev_rcv_lists = can_dev_rcv_lists_find(net, dev); dev_rcv_lists = can_dev_rcv_lists_find(net, dev);
if (dev_rcv_lists) { if (dev_rcv_lists) {
rl = can_rcv_list_find(&can_id, &mask, dev_rcv_lists); rcv_list = can_rcv_list_find(&can_id, &mask, dev_rcv_lists);
r->can_id = can_id; rcv->can_id = can_id;
r->mask = mask; rcv->mask = mask;
r->matches = 0; rcv->matches = 0;
r->func = func; rcv->func = func;
r->data = data; rcv->data = data;
r->ident = ident; rcv->ident = ident;
r->sk = sk; rcv->sk = sk;
hlist_add_head_rcu(&r->list, rl); hlist_add_head_rcu(&rcv->list, rcv_list);
dev_rcv_lists->entries++; dev_rcv_lists->entries++;
rcv_lists_stats->rcv_entries++; rcv_lists_stats->rcv_entries++;
if (rcv_lists_stats->rcv_entries_max < rcv_lists_stats->rcv_entries) if (rcv_lists_stats->rcv_entries_max < rcv_lists_stats->rcv_entries)
rcv_lists_stats->rcv_entries_max = rcv_lists_stats->rcv_entries; rcv_lists_stats->rcv_entries_max = rcv_lists_stats->rcv_entries;
} else { } else {
kmem_cache_free(rcv_cache, r); kmem_cache_free(rcv_cache, rcv);
err = -ENODEV; err = -ENODEV;
} }
...@@ -490,10 +490,10 @@ EXPORT_SYMBOL(can_rx_register); ...@@ -490,10 +490,10 @@ EXPORT_SYMBOL(can_rx_register);
/* can_rx_delete_receiver - rcu callback for single receiver entry removal */ /* can_rx_delete_receiver - rcu callback for single receiver entry removal */
static void can_rx_delete_receiver(struct rcu_head *rp) static void can_rx_delete_receiver(struct rcu_head *rp)
{ {
struct receiver *r = container_of(rp, struct receiver, rcu); struct receiver *rcv = container_of(rp, struct receiver, rcu);
struct sock *sk = r->sk; struct sock *sk = rcv->sk;
kmem_cache_free(rcv_cache, r); kmem_cache_free(rcv_cache, rcv);
if (sk) if (sk)
sock_put(sk); sock_put(sk);
} }
...@@ -513,8 +513,8 @@ void can_rx_unregister(struct net *net, struct net_device *dev, canid_t can_id, ...@@ -513,8 +513,8 @@ void can_rx_unregister(struct net *net, struct net_device *dev, canid_t can_id,
canid_t mask, void (*func)(struct sk_buff *, void *), canid_t mask, void (*func)(struct sk_buff *, void *),
void *data) void *data)
{ {
struct receiver *r = NULL; struct receiver *rcv = NULL;
struct hlist_head *rl; struct hlist_head *rcv_list;
struct can_rcv_lists_stats *rcv_lists_stats = net->can.rcv_lists_stats; struct can_rcv_lists_stats *rcv_lists_stats = net->can.rcv_lists_stats;
struct can_dev_rcv_lists *dev_rcv_lists; struct can_dev_rcv_lists *dev_rcv_lists;
...@@ -533,29 +533,28 @@ void can_rx_unregister(struct net *net, struct net_device *dev, canid_t can_id, ...@@ -533,29 +533,28 @@ void can_rx_unregister(struct net *net, struct net_device *dev, canid_t can_id,
goto out; goto out;
} }
rl = can_rcv_list_find(&can_id, &mask, dev_rcv_lists); rcv_list = can_rcv_list_find(&can_id, &mask, dev_rcv_lists);
/* Search the receiver list for the item to delete. This should /* Search the receiver list for the item to delete. This should
* exist, since no receiver may be unregistered that hasn't * exist, since no receiver may be unregistered that hasn't
* been registered before. * been registered before.
*/ */
hlist_for_each_entry_rcu(r, rl, list) { hlist_for_each_entry_rcu(rcv, rcv_list, list) {
if (r->can_id == can_id && r->mask == mask && if (rcv->can_id == can_id && rcv->mask == mask &&
r->func == func && r->data == data) rcv->func == func && rcv->data == data)
break; break;
} }
/* Check for bugs in CAN protocol implementations using af_can.c: /* Check for bugs in CAN protocol implementations using af_can.c:
* 'r' will be NULL if no matching list item was found for removal. * 'rcv' will be NULL if no matching list item was found for removal.
*/ */
if (!rcv) {
if (!r) {
WARN(1, "BUG: receive list entry not found for dev %s, id %03X, mask %03X\n", WARN(1, "BUG: receive list entry not found for dev %s, id %03X, mask %03X\n",
DNAME(dev), can_id, mask); DNAME(dev), can_id, mask);
goto out; goto out;
} }
hlist_del_rcu(&r->list); hlist_del_rcu(&rcv->list);
dev_rcv_lists->entries--; dev_rcv_lists->entries--;
if (rcv_lists_stats->rcv_entries > 0) if (rcv_lists_stats->rcv_entries > 0)
...@@ -571,23 +570,23 @@ void can_rx_unregister(struct net *net, struct net_device *dev, canid_t can_id, ...@@ -571,23 +570,23 @@ void can_rx_unregister(struct net *net, struct net_device *dev, canid_t can_id,
spin_unlock(&net->can.rcvlists_lock); spin_unlock(&net->can.rcvlists_lock);
/* schedule the receiver item for deletion */ /* schedule the receiver item for deletion */
if (r) { if (rcv) {
if (r->sk) if (rcv->sk)
sock_hold(r->sk); sock_hold(rcv->sk);
call_rcu(&r->rcu, can_rx_delete_receiver); call_rcu(&rcv->rcu, can_rx_delete_receiver);
} }
} }
EXPORT_SYMBOL(can_rx_unregister); EXPORT_SYMBOL(can_rx_unregister);
static inline void deliver(struct sk_buff *skb, struct receiver *r) static inline void deliver(struct sk_buff *skb, struct receiver *rcv)
{ {
r->func(skb, r->data); rcv->func(skb, rcv->data);
r->matches++; rcv->matches++;
} }
static int can_rcv_filter(struct can_dev_rcv_lists *dev_rcv_lists, struct sk_buff *skb) static int can_rcv_filter(struct can_dev_rcv_lists *dev_rcv_lists, struct sk_buff *skb)
{ {
struct receiver *r; struct receiver *rcv;
int matches = 0; int matches = 0;
struct can_frame *cf = (struct can_frame *)skb->data; struct can_frame *cf = (struct can_frame *)skb->data;
canid_t can_id = cf->can_id; canid_t can_id = cf->can_id;
...@@ -597,9 +596,9 @@ static int can_rcv_filter(struct can_dev_rcv_lists *dev_rcv_lists, struct sk_buf ...@@ -597,9 +596,9 @@ static int can_rcv_filter(struct can_dev_rcv_lists *dev_rcv_lists, struct sk_buf
if (can_id & CAN_ERR_FLAG) { if (can_id & CAN_ERR_FLAG) {
/* check for error message frame entries only */ /* check for error message frame entries only */
hlist_for_each_entry_rcu(r, &dev_rcv_lists->rx[RX_ERR], list) { hlist_for_each_entry_rcu(rcv, &dev_rcv_lists->rx[RX_ERR], list) {
if (can_id & r->mask) { if (can_id & rcv->mask) {
deliver(skb, r); deliver(skb, rcv);
matches++; matches++;
} }
} }
...@@ -607,23 +606,23 @@ static int can_rcv_filter(struct can_dev_rcv_lists *dev_rcv_lists, struct sk_buf ...@@ -607,23 +606,23 @@ static int can_rcv_filter(struct can_dev_rcv_lists *dev_rcv_lists, struct sk_buf
} }
/* check for unfiltered entries */ /* check for unfiltered entries */
hlist_for_each_entry_rcu(r, &dev_rcv_lists->rx[RX_ALL], list) { hlist_for_each_entry_rcu(rcv, &dev_rcv_lists->rx[RX_ALL], list) {
deliver(skb, r); deliver(skb, rcv);
matches++; matches++;
} }
/* check for can_id/mask entries */ /* check for can_id/mask entries */
hlist_for_each_entry_rcu(r, &dev_rcv_lists->rx[RX_FIL], list) { hlist_for_each_entry_rcu(rcv, &dev_rcv_lists->rx[RX_FIL], list) {
if ((can_id & r->mask) == r->can_id) { if ((can_id & rcv->mask) == rcv->can_id) {
deliver(skb, r); deliver(skb, rcv);
matches++; matches++;
} }
} }
/* check for inverted can_id/mask entries */ /* check for inverted can_id/mask entries */
hlist_for_each_entry_rcu(r, &dev_rcv_lists->rx[RX_INV], list) { hlist_for_each_entry_rcu(rcv, &dev_rcv_lists->rx[RX_INV], list) {
if ((can_id & r->mask) != r->can_id) { if ((can_id & rcv->mask) != rcv->can_id) {
deliver(skb, r); deliver(skb, rcv);
matches++; matches++;
} }
} }
...@@ -633,16 +632,16 @@ static int can_rcv_filter(struct can_dev_rcv_lists *dev_rcv_lists, struct sk_buf ...@@ -633,16 +632,16 @@ static int can_rcv_filter(struct can_dev_rcv_lists *dev_rcv_lists, struct sk_buf
return matches; return matches;
if (can_id & CAN_EFF_FLAG) { if (can_id & CAN_EFF_FLAG) {
hlist_for_each_entry_rcu(r, &dev_rcv_lists->rx_eff[effhash(can_id)], list) { hlist_for_each_entry_rcu(rcv, &dev_rcv_lists->rx_eff[effhash(can_id)], list) {
if (r->can_id == can_id) { if (rcv->can_id == can_id) {
deliver(skb, r); deliver(skb, rcv);
matches++; matches++;
} }
} }
} else { } else {
can_id &= CAN_SFF_MASK; can_id &= CAN_SFF_MASK;
hlist_for_each_entry_rcu(r, &dev_rcv_lists->rx_sff[can_id], list) { hlist_for_each_entry_rcu(rcv, &dev_rcv_lists->rx_sff[can_id], list) {
deliver(skb, r); deliver(skb, rcv);
matches++; matches++;
} }
} }
......
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