driverdev-devel.linuxdriverproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1] staging: fieldbus: Use %pM format specifier for MAC addresses
@ 2020-07-30 15:27 Andy Shevchenko
  2020-07-30 17:34 ` kernel test robot
  2020-07-31  1:32 ` Sven Van Asbroeck
  0 siblings, 2 replies; 3+ messages in thread
From: Andy Shevchenko @ 2020-07-30 15:27 UTC (permalink / raw)
  To: Sven Van Asbroeck, devel, Greg Kroah-Hartman; +Cc: Andy Shevchenko

Convert to %pM instead of using custom code.

While here, replace one time use structure by buffer on stack.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/staging/fieldbus/anybuss/hms-profinet.c | 14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/fieldbus/anybuss/hms-profinet.c b/drivers/staging/fieldbus/anybuss/hms-profinet.c
index 31c43a0a5776..505480fb281d 100644
--- a/drivers/staging/fieldbus/anybuss/hms-profinet.c
+++ b/drivers/staging/fieldbus/anybuss/hms-profinet.c
@@ -26,10 +26,6 @@
  * exactly as advertised.
  */
 
-struct msg_mac_addr {
-	u8 addr[6];
-};
-
 struct profi_priv {
 	struct fieldbus_dev fbdev;
 	struct anybuss_client *client;
@@ -59,17 +55,13 @@ static int profi_id_get(struct fieldbus_dev *fbdev, char *buf,
 			size_t max_size)
 {
 	struct profi_priv *priv = container_of(fbdev, struct profi_priv, fbdev);
-	struct msg_mac_addr response;
+	u8 mac[ETH_ALEN];
 	int ret;
 
-	ret = anybuss_recv_msg(priv->client, 0x0010, &response,
-			       sizeof(response));
+	ret = anybuss_recv_msg(priv->client, 0x0010, &mac, sizeof(mac));
 	if (ret < 0)
 		return ret;
-	return snprintf(buf, max_size, "%02X:%02X:%02X:%02X:%02X:%02X\n",
-		response.addr[0], response.addr[1],
-		response.addr[2], response.addr[3],
-		response.addr[4], response.addr[5]);
+	return snprintf(buf, max_size, "%pM\n", mac);
 }
 
 static bool profi_enable_get(struct fieldbus_dev *fbdev)
-- 
2.27.0

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-07-31  1:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-30 15:27 [PATCH v1] staging: fieldbus: Use %pM format specifier for MAC addresses Andy Shevchenko
2020-07-30 17:34 ` kernel test robot
2020-07-31  1:32 ` Sven Van Asbroeck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).