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

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

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

On Wed, Sep 29, 2021 at 01:38:23PM +0300, Dan Carpenter wrote:
On Wed, Sep 29, 2021 at 01:16:37PM +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, name)                                               \
+	do {                                                                   \
+		if (ops->name)                                                 \
Could you make "ops" a parameter of the macro instead of hard coding it?
Sure
regards,
dan carpenter
quoted
+			if (!((ptr)->name))				       \
+				(ptr)->name = ops->name;                       \
+	} while (0)
+
+	/* Keep sorted */
+	SET_DEVICE_OP(dev_ops, reload_actions);
+	SET_DEVICE_OP(dev_ops, reload_down);
+	SET_DEVICE_OP(dev_ops, reload_limits);
+	SET_DEVICE_OP(dev_ops, reload_up);
+
+#undef SET_DEVICE_OP
+}
+EXPORT_SYMBOL_GPL(devlink_set_ops);
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help