History

switchdev: Remove unused transaction item queue

There are no more in tree users of the switchdev_trans_item_{dequeue,enqueue} or switchdev_trans_item structure in the kernel since commit 00fc0c51e35b ("rocker: Change world_ops API and implementation to be switchdev independant"). Remove this unused code and update the documentation accordingly since.

Florian Fainelli committed 7 years ago

Commit 91cf8ec1 parent 9bfc4453 files · +2 −129Browse files

Showing the changes to net/switchdev/switchdev.c (1 of 3 files). Show all

Unified · Split

net/switchdev/switchdev.c+2−98
@@ -23,78 +23,6 @@ · 22 unmodified lines
2323 #include <linux/rtnetlink.h>
2424 #include <net/switchdev.h>
2525
26−/**
27− * switchdev_trans_item_enqueue - Enqueue data item to transaction queue
28− *
29− * @trans: transaction
30− * @data: pointer to data being queued
31− * @destructor: data destructor
32− * @tritem: transaction item being queued
33− *
34− * Enqeueue data item to transaction queue. tritem is typically placed in
35− * cointainter pointed at by data pointer. Destructor is called on
36− * transaction abort and after successful commit phase in case
37− * the caller did not dequeue the item before.
38− */
39−void switchdev_trans_item_enqueue(struct switchdev_trans *trans,
40− void *data, void (*destructor)(void const *),
41− struct switchdev_trans_item *tritem)
42−{
43− tritem->data = data;
44− tritem->destructor = destructor;
45− list_add_tail(&tritem->list, &trans->item_list);
46−}
47−EXPORT_SYMBOL_GPL(switchdev_trans_item_enqueue);
48−
49−static struct switchdev_trans_item *
50−__switchdev_trans_item_dequeue(struct switchdev_trans *trans)
51−{
52− struct switchdev_trans_item *tritem;
53−
54− if (list_empty(&trans->item_list))
55− return NULL;
56− tritem = list_first_entry(&trans->item_list,
57− struct switchdev_trans_item, list);
58− list_del(&tritem->list);
59− return tritem;
60−}
61−
62−/**
63− * switchdev_trans_item_dequeue - Dequeue data item from transaction queue
64− *
65− * @trans: transaction
66− */
67−void *switchdev_trans_item_dequeue(struct switchdev_trans *trans)
68−{
69− struct switchdev_trans_item *tritem;
70−
71− tritem = __switchdev_trans_item_dequeue(trans);
72− BUG_ON(!tritem);
73− return tritem->data;
74−}
75−EXPORT_SYMBOL_GPL(switchdev_trans_item_dequeue);
76−
77−static void switchdev_trans_init(struct switchdev_trans *trans)
78−{
79− INIT_LIST_HEAD(&trans->item_list);
80−}
81−
82−static void switchdev_trans_items_destroy(struct switchdev_trans *trans)
83−{
84− struct switchdev_trans_item *tritem;
85−
86− while ((tritem = __switchdev_trans_item_dequeue(trans)))
87− tritem->destructor(tritem->data);
88−}
89−
90−static void switchdev_trans_items_warn_destroy(struct net_device *dev,
91− struct switchdev_trans *trans)
92−{
93− WARN(!list_empty(&trans->item_list), "%s: transaction item queue is not empty.\n",
94− dev->name);
95− switchdev_trans_items_destroy(trans);
96−}
97−
9826 static LIST_HEAD(deferred);
9927 static DEFINE_SPINLOCK(deferred_lock);
10028
@@ -208,8 +136,6 @@ static int switchdev_port_attr_set_now(struct net_device *dev, · 107 unmodified lines
208136 struct switchdev_trans trans;
209137 int err;
210138
211− switchdev_trans_init(&trans);
212−
213139 /* Phase I: prepare for attr set. Driver/device should fail
214140 * here if there are going to be issues in the commit phase,
215141 * such as lack of resources or support. The driver/device
@@ -220,17 +146,8 @@ static int switchdev_port_attr_set_now(struct net_device *dev, · 4 unmodified lines
220146 trans.ph_prepare = true;
221147 err = switchdev_port_attr_notify(SWITCHDEV_PORT_ATTR_SET, dev, attr,
222148 &trans);
223− if (err) {
224− /* Prepare phase failed: abort the transaction. Any
225− * resources reserved in the prepare phase are
226− * released.
227− */
228−
229− if (err != -EOPNOTSUPP)
230− switchdev_trans_items_destroy(&trans);
231−
149+ if (err)
232150 return err;
233− }
234151
235152 /* Phase II: commit attr set. This cannot fail as a fault
236153 * of driver/device. If it does, it's a bug in the driver/device
@@ -242,7 +159,6 @@ static int switchdev_port_attr_set_now(struct net_device *dev, · 5 unmodified lines
242159 &trans);
243160 WARN(err, "%s: Commit of attribute (id=%d) failed.\n",
244161 dev->name, attr->id);
245− switchdev_trans_items_warn_destroy(dev, &trans);
246162
247163 return err;
248164 }
@@ -341,8 +257,6 @@ static int switchdev_port_obj_add_now(struct net_device *dev, · 92 unmodified lines
341257
342258 ASSERT_RTNL();
343259
344− switchdev_trans_init(&trans);
345−
346260 /* Phase I: prepare for obj add. Driver/device should fail
347261 * here if there are going to be issues in the commit phase,
348262 * such as lack of resources or support. The driver/device
@@ -353,17 +267,8 @@ static int switchdev_port_obj_add_now(struct net_device *dev, · 4 unmodified lines
353267 trans.ph_prepare = true;
354268 err = switchdev_port_obj_notify(SWITCHDEV_PORT_OBJ_ADD,
355269 dev, obj, &trans, extack);
356− if (err) {
357− /* Prepare phase failed: abort the transaction. Any
358− * resources reserved in the prepare phase are
359− * released.
360− */
361−
362− if (err != -EOPNOTSUPP)
363− switchdev_trans_items_destroy(&trans);
364−
270+ if (err)
365271 return err;
366− }
367272
368273 /* Phase II: commit obj add. This cannot fail as a fault
369274 * of driver/device. If it does, it's a bug in the driver/device
@@ -374,7 +279,6 @@ static int switchdev_port_obj_add_now(struct net_device *dev, · 4 unmodified lines
374279 err = switchdev_port_obj_notify(SWITCHDEV_PORT_OBJ_ADD,
375280 dev, obj, &trans, extack);
376281 WARN(err, "%s: Commit of object (id=%d) failed.\n", dev->name, obj->id);
377− switchdev_trans_items_warn_destroy(dev, &trans);
378282
379283 return err;
380284 }