Thread (24 messages) 24 messages, 4 authors, 2021-09-29

Re: [PATCH net-next v1 3/5] devlink: Allow set specific ops callbacks dynamically

From: Leon Romanovsky <leon@kernel.org>
Date: 2021-09-29 12:58:36
Also in: intel-wired-lan, linux-omap, linux-rdma, linux-staging, lkml

On Wed, Sep 29, 2021 at 02:25:00PM +0200, Greg Kroah-Hartman wrote:
On Wed, Sep 29, 2021 at 03:00:44PM +0300, Leon Romanovsky wrote:
quoted
+void devlink_set_ops(struct devlink *devlink, struct devlink_ops *ops)
+{
+	struct devlink_ops *dev_ops = devlink->ops;
+
+	WARN_ON(!devlink_reload_actions_valid(ops));
+
+#define SET_DEVICE_OP(ptr, op, name)                                           \
+	do {                                                                   \
+		if ((op)->name)                                                \
+			if (!((ptr)->name))                                    \
+				(ptr)->name = (op)->name;                      \
+	} while (0)
+
+	/* Keep sorted */
+	SET_DEVICE_OP(dev_ops, ops, reload_actions);
+	SET_DEVICE_OP(dev_ops, ops, reload_down);
+	SET_DEVICE_OP(dev_ops, ops, reload_limits);
+	SET_DEVICE_OP(dev_ops, ops, reload_up);
Keep sorted in what order?  And why?
Sorted by name.

It simplifies future addition of new commands and removes useless fraction
where place new line.

Thanks
thanks,

greg k-h
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help