Re: [PATCH 1/2] Add a matching set of device_ functions for determining mac/phy

From
Jeremy Linton <hidden>
Date
2015-08-13 14:24:23
Also in
linux-arm-kernel
Reply to
Robin Murphy, 2015-08-13
Hello Robin,

On 08/13/2015 06:57 AM, Robin Murphy wrote:
quoted
+static void *device_get_mac_addr(struct device *dev,
+				 const char *name, char *addr,
+				 int alen)
+{
+	int ret = device_property_read_u8_array(dev, name, addr, alen);
+
+	if (ret == 0 && is_valid_ether_addr(addr))
+		return addr;
+	return NULL;
+}
Not sure I understand the logic here - "return the same thing we were
given if we updated it, or null if we didn't". It's only indicating
success/failure (the caller can perfectly well cast its own buffer to a
void * if it needs to), so why wouldn't you just return a normal int
error code?

	No particular reason, other than initially I was trying to keep the function as similar as possible to the one in of_net. AKA copy paste job. I can convert the return types, but I was trying for a simple function rename. That way the users of the of version could be converted with relative ease, and the drivers which invented their own version of these functions could be changed to use this instead. Of course, that plan took a blow, when I added the addr/alen parameters.

	Same thing applies for the other function.


	
Thread (36 messages) 36 messages, 14 authors, last reply 2015-11-02
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help