Thread (29 messages) flat view 29 messages, 4 authors, 2017-09-19

RE: [PATCH net-next 05/12] net: dsa: b53: Use a macro to define I/O operations

From: David Laight <hidden>
Date: 2017-09-19 16:14:33

quoted
quoted
quoted
+#define b53_build_op(type, op_size, val_type)	\
+static inline int b53_##type##op_size(struct b53_device *dev, u8
page,		\
quoted
quoted
+				      u8 reg, val_type val)			\
+{										\
+	int ret;								\
+										\
+	mutex_lock(&dev->reg_mutex);						\
+	ret = dev->ops->type##op_size(dev, page, reg, val);			\
+	mutex_unlock(&dev->reg_mutex);						\
+										\
+	return ret;								\
 }
Why separate the 'type' and 'op_size' arguments since they
are always pasted together?
For read/write48, the value type is u64.
The way I read David's comment is that instead of calling the macro with read, 48, just combine that
in a single argument: read48. I don't have a preference about that and can respin eventually.
Indeed, factoring in the type is harder because reads want 'u64 *' not 'u64'.
While that could be factored, it would take more source lines and make
things very obfuscated.

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