summaryrefslogtreecommitdiff
path: root/net/can
diff options
context:
space:
mode:
authorMarc Kleine-Budde <mkl@pengutronix.de>2018-10-08 09:02:31 +0200
committerMarc Kleine-Budde <mkl@pengutronix.de>2019-09-04 13:29:14 +0200
commit56be1d52fc0b3f7d50af9f5beec9967c6786563f (patch)
tree42f6d9d6a2b801210be4ccf6c213dd9a6d191861 /net/can
parent564577dfee4e55e33ae64e64a866a212e584d58f (diff)
can: af_can: give variable holding the CAN per device receive lists a sensible name
This patch gives the variables holding the CAN receive filter lists a better name by renaming them from "d" to "dev_rcv_lists". Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Acked-by: Oliver Hartkopp <socketcan@hartkopp.net> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Diffstat (limited to 'net/can')
-rw-r--r--net/can/af_can.c89
1 files changed, 44 insertions, 45 deletions
diff --git a/net/can/af_can.c b/net/can/af_can.c
index 62b3f2d68287..0d51c06a88ac 100644
--- a/net/can/af_can.c
+++ b/net/can/af_can.c
@@ -358,7 +358,7 @@ static unsigned int effhash(canid_t can_id)
* Reduced can_id to have a preprocessed filter compare value.
*/
static struct hlist_head *find_rcv_list(canid_t *can_id, canid_t *mask,
- struct can_dev_rcv_lists *d)
+ struct can_dev_rcv_lists *dev_rcv_lists)
{
canid_t inv = *can_id & CAN_INV_FILTER; /* save flag before masking */
@@ -366,7 +366,7 @@ static struct hlist_head *find_rcv_list(canid_t *can_id, canid_t *mask,
if (*mask & CAN_ERR_FLAG) {
/* clear CAN_ERR_FLAG in filter entry */
*mask &= CAN_ERR_MASK;
- return &d->rx[RX_ERR];
+ return &dev_rcv_lists->rx[RX_ERR];
}
/* with cleared CAN_ERR_FLAG we have a simple mask/value filterpair */
@@ -382,26 +382,26 @@ static struct hlist_head *find_rcv_list(canid_t *can_id, canid_t *mask,
/* inverse can_id/can_mask filter */
if (inv)
- return &d->rx[RX_INV];
+ return &dev_rcv_lists->rx[RX_INV];
/* mask == 0 => no condition testing at receive time */
if (!(*mask))
- return &d->rx[RX_ALL];
+ return &dev_rcv_lists->rx[RX_ALL];
/* extra filterlists for the subscription of a single non-RTR can_id */
if (((*mask & CAN_EFF_RTR_FLAGS) == CAN_EFF_RTR_FLAGS) &&
!(*can_id & CAN_RTR_FLAG)) {
if (*can_id & CAN_EFF_FLAG) {
if (*mask == (CAN_EFF_MASK | CAN_EFF_RTR_FLAGS))
- return &d->rx_eff[effhash(*can_id)];
+ return &dev_rcv_lists->rx_eff[effhash(*can_id)];
} else {
if (*mask == (CAN_SFF_MASK | CAN_EFF_RTR_FLAGS))
- return &d->rx_sff[*can_id];
+ return &dev_rcv_lists->rx_sff[*can_id];
}
}
/* default: filter via can_id/can_mask */
- return &d->rx[RX_FIL];
+ return &dev_rcv_lists->rx[RX_FIL];
}
/**
@@ -440,7 +440,7 @@ int can_rx_register(struct net *net, struct net_device *dev, canid_t can_id,
{
struct receiver *r;
struct hlist_head *rl;
- struct can_dev_rcv_lists *d;
+ struct can_dev_rcv_lists *dev_rcv_lists;
struct can_rcv_lists_stats *rcv_lists_stats = net->can.rcv_lists_stats;
int err = 0;
@@ -458,9 +458,9 @@ int can_rx_register(struct net *net, struct net_device *dev, canid_t can_id,
spin_lock(&net->can.rcvlists_lock);
- d = find_dev_rcv_lists(net, dev);
- if (d) {
- rl = find_rcv_list(&can_id, &mask, d);
+ dev_rcv_lists = find_dev_rcv_lists(net, dev);
+ if (dev_rcv_lists) {
+ rl = find_rcv_list(&can_id, &mask, dev_rcv_lists);
r->can_id = can_id;
r->mask = mask;
@@ -471,7 +471,7 @@ int can_rx_register(struct net *net, struct net_device *dev, canid_t can_id,
r->sk = sk;
hlist_add_head_rcu(&r->list, rl);
- d->entries++;
+ dev_rcv_lists->entries++;
rcv_lists_stats->rcv_entries++;
if (rcv_lists_stats->rcv_entries_max < rcv_lists_stats->rcv_entries)
@@ -516,7 +516,7 @@ void can_rx_unregister(struct net *net, struct net_device *dev, canid_t can_id,
struct receiver *r = NULL;
struct hlist_head *rl;
struct can_rcv_lists_stats *rcv_lists_stats = net->can.rcv_lists_stats;
- struct can_dev_rcv_lists *d;
+ struct can_dev_rcv_lists *dev_rcv_lists;
if (dev && dev->type != ARPHRD_CAN)
return;
@@ -526,20 +526,19 @@ void can_rx_unregister(struct net *net, struct net_device *dev, canid_t can_id,
spin_lock(&net->can.rcvlists_lock);
- d = find_dev_rcv_lists(net, dev);
- if (!d) {
+ dev_rcv_lists = find_dev_rcv_lists(net, dev);
+ if (!dev_rcv_lists) {
pr_err("BUG: receive list not found for dev %s, id %03X, mask %03X\n",
DNAME(dev), can_id, mask);
goto out;
}
- rl = find_rcv_list(&can_id, &mask, d);
+ rl = find_rcv_list(&can_id, &mask, dev_rcv_lists);
/* Search the receiver list for the item to delete. This should
* exist, since no receiver may be unregistered that hasn't
* been registered before.
*/
-
hlist_for_each_entry_rcu(r, rl, list) {
if (r->can_id == can_id && r->mask == mask &&
r->func == func && r->data == data)
@@ -557,14 +556,14 @@ void can_rx_unregister(struct net *net, struct net_device *dev, canid_t can_id,
}
hlist_del_rcu(&r->list);
- d->entries--;
+ dev_rcv_lists->entries--;
if (rcv_lists_stats->rcv_entries > 0)
rcv_lists_stats->rcv_entries--;
/* remove device structure requested by NETDEV_UNREGISTER */
- if (d->remove_on_zero_entries && !d->entries) {
- kfree(d);
+ if (dev_rcv_lists->remove_on_zero_entries && !dev_rcv_lists->entries) {
+ kfree(dev_rcv_lists);
dev->ml_priv = NULL;
}
@@ -586,19 +585,19 @@ static inline void deliver(struct sk_buff *skb, struct receiver *r)
r->matches++;
}
-static int can_rcv_filter(struct can_dev_rcv_lists *d, struct sk_buff *skb)
+static int can_rcv_filter(struct can_dev_rcv_lists *dev_rcv_lists, struct sk_buff *skb)
{
struct receiver *r;
int matches = 0;
struct can_frame *cf = (struct can_frame *)skb->data;
canid_t can_id = cf->can_id;
- if (d->entries == 0)
+ if (dev_rcv_lists->entries == 0)
return 0;
if (can_id & CAN_ERR_FLAG) {
/* check for error message frame entries only */
- hlist_for_each_entry_rcu(r, &d->rx[RX_ERR], list) {
+ hlist_for_each_entry_rcu(r, &dev_rcv_lists->rx[RX_ERR], list) {
if (can_id & r->mask) {
deliver(skb, r);
matches++;
@@ -608,13 +607,13 @@ static int can_rcv_filter(struct can_dev_rcv_lists *d, struct sk_buff *skb)
}
/* check for unfiltered entries */
- hlist_for_each_entry_rcu(r, &d->rx[RX_ALL], list) {
+ hlist_for_each_entry_rcu(r, &dev_rcv_lists->rx[RX_ALL], list) {
deliver(skb, r);
matches++;
}
/* check for can_id/mask entries */
- hlist_for_each_entry_rcu(r, &d->rx[RX_FIL], list) {
+ hlist_for_each_entry_rcu(r, &dev_rcv_lists->rx[RX_FIL], list) {
if ((can_id & r->mask) == r->can_id) {
deliver(skb, r);
matches++;
@@ -622,7 +621,7 @@ static int can_rcv_filter(struct can_dev_rcv_lists *d, struct sk_buff *skb)
}
/* check for inverted can_id/mask entries */
- hlist_for_each_entry_rcu(r, &d->rx[RX_INV], list) {
+ hlist_for_each_entry_rcu(r, &dev_rcv_lists->rx[RX_INV], list) {
if ((can_id & r->mask) != r->can_id) {
deliver(skb, r);
matches++;
@@ -634,7 +633,7 @@ static int can_rcv_filter(struct can_dev_rcv_lists *d, struct sk_buff *skb)
return matches;
if (can_id & CAN_EFF_FLAG) {
- hlist_for_each_entry_rcu(r, &d->rx_eff[effhash(can_id)], list) {
+ hlist_for_each_entry_rcu(r, &dev_rcv_lists->rx_eff[effhash(can_id)], list) {
if (r->can_id == can_id) {
deliver(skb, r);
matches++;
@@ -642,7 +641,7 @@ static int can_rcv_filter(struct can_dev_rcv_lists *d, struct sk_buff *skb)
}
} else {
can_id &= CAN_SFF_MASK;
- hlist_for_each_entry_rcu(r, &d->rx_sff[can_id], list) {
+ hlist_for_each_entry_rcu(r, &dev_rcv_lists->rx_sff[can_id], list) {
deliver(skb, r);
matches++;
}
@@ -653,7 +652,7 @@ static int can_rcv_filter(struct can_dev_rcv_lists *d, struct sk_buff *skb)
static void can_receive(struct sk_buff *skb, struct net_device *dev)
{
- struct can_dev_rcv_lists *d;
+ struct can_dev_rcv_lists *dev_rcv_lists;
struct net *net = dev_net(dev);
struct can_pkg_stats *pkg_stats = net->can.pkg_stats;
int matches;
@@ -672,9 +671,9 @@ static void can_receive(struct sk_buff *skb, struct net_device *dev)
matches = can_rcv_filter(net->can.rx_alldev_list, skb);
/* find receive list for this device */
- d = find_dev_rcv_lists(net, dev);
- if (d)
- matches += can_rcv_filter(d, skb);
+ dev_rcv_lists = find_dev_rcv_lists(net, dev);
+ if (dev_rcv_lists)
+ matches += can_rcv_filter(dev_rcv_lists, skb);
rcu_read_unlock();
@@ -789,7 +788,7 @@ static int can_notifier(struct notifier_block *nb, unsigned long msg,
void *ptr)
{
struct net_device *dev = netdev_notifier_info_to_dev(ptr);
- struct can_dev_rcv_lists *d;
+ struct can_dev_rcv_lists *dev_rcv_lists;
if (dev->type != ARPHRD_CAN)
return NOTIFY_DONE;
@@ -798,23 +797,23 @@ static int can_notifier(struct notifier_block *nb, unsigned long msg,
case NETDEV_REGISTER:
/* create new dev_rcv_lists for this device */
- d = kzalloc(sizeof(*d), GFP_KERNEL);
- if (!d)
+ dev_rcv_lists = kzalloc(sizeof(*dev_rcv_lists), GFP_KERNEL);
+ if (!dev_rcv_lists)
return NOTIFY_DONE;
BUG_ON(dev->ml_priv);
- dev->ml_priv = d;
+ dev->ml_priv = dev_rcv_lists;
break;
case NETDEV_UNREGISTER:
spin_lock(&dev_net(dev)->can.rcvlists_lock);
- d = dev->ml_priv;
- if (d) {
- if (d->entries) {
- d->remove_on_zero_entries = 1;
- } else {
- kfree(d);
+ dev_rcv_lists = dev->ml_priv;
+ if (dev_rcv_lists) {
+ if (dev_rcv_lists->entries)
+ dev_rcv_lists->remove_on_zero_entries = 1;
+ else {
+ kfree(dev_rcv_lists);
dev->ml_priv = NULL;
}
} else {
@@ -880,10 +879,10 @@ static void can_pernet_exit(struct net *net)
rcu_read_lock();
for_each_netdev_rcu(net, dev) {
if (dev->type == ARPHRD_CAN && dev->ml_priv) {
- struct can_dev_rcv_lists *d = dev->ml_priv;
+ struct can_dev_rcv_lists *dev_rcv_lists = dev->ml_priv;
- BUG_ON(d->entries);
- kfree(d);
+ BUG_ON(dev_rcv_lists->entries);
+ kfree(dev_rcv_lists);
dev->ml_priv = NULL;
}
}